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
372f18411005908b2da8bcfc3b88e8b1b89f4d79
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/OvmfPkg/XenPvBlkDxe/BlockIo.h
a05f27c813812031736aba600996027926cf0669
[ "MIT", "BSD-2-Clause", "LicenseRef-scancode-generic-cla", "Apache-2.0", "OpenSSL" ]
permissive
google/google-ctf
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
df02323eaf945d15e124801c74abaadca2749dc7
refs/heads/master
2023-08-31T14:30:27.548081
2023-08-29T13:04:20
2023-08-29T13:04:20
131,317,137
4,136
607
Apache-2.0
2023-08-30T22:17:02
2018-04-27T15:56:03
Go
UTF-8
C
false
false
4,288
h
BlockIo.h
/** @file BlockIo function declaration for Xen PV block driver. Copyright (C) 2014, Citrix Ltd. 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. **/ /** Read BufferSize bytes from Lba into Buffer. @param This Indicates a pointer to the calling context. @param MediaId Id of the media, changes every time the media is replaced. @param Lba The starting Logical Block Address to read from @param BufferSize Size of Buffer, must be a multiple of device block size. @param Buffer A pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer. @retval EFI_SUCCESS The data was read correctly from the device. @retval EFI_DEVICE_ERROR The device reported an error while performing the read. @retval EFI_NO_MEDIA There is no media in the device. @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device. @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device. @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, or the buffer is not on proper alignment. **/ EFI_STATUS EFIAPI XenPvBlkDxeBlockIoReadBlocks ( IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer ); /** Write BufferSize bytes from Lba into Buffer. @param This Indicates a pointer to the calling context. @param MediaId The media ID that the write request is for. @param Lba The starting logical block address to be written. The caller is responsible for writing to only legitimate locations. @param BufferSize Size of Buffer, must be a multiple of device block size. @param Buffer A pointer to the source buffer for the data. @retval EFI_SUCCESS The data was written correctly to the device. @retval EFI_WRITE_PROTECTED The device can not be written to. @retval EFI_DEVICE_ERROR The device reported an error while performing the write. @retval EFI_NO_MEDIA There is no media in the device. @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device. @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, or the buffer is not on proper alignment. **/ EFI_STATUS EFIAPI XenPvBlkDxeBlockIoWriteBlocks ( IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer ); /** Flush the Block Device. @param This Indicates a pointer to the calling context. @retval EFI_SUCCESS All outstanding data was written to the device @retval EFI_DEVICE_ERROR The device reported an error while writting back the data @retval EFI_NO_MEDIA There is no media in the device. **/ EFI_STATUS EFIAPI XenPvBlkDxeBlockIoFlushBlocks ( IN EFI_BLOCK_IO_PROTOCOL *This ); /** Reset the block device hardware. @param[in] This Indicates a pointer to the calling context. @param[in] ExtendedVerification Not used. @retval EFI_SUCCESS The device was reset. **/ EFI_STATUS EFIAPI XenPvBlkDxeBlockIoReset ( IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification ); extern EFI_BLOCK_IO_MEDIA gXenPvBlkDxeBlockIoMedia; extern EFI_BLOCK_IO_PROTOCOL gXenPvBlkDxeBlockIo;
33db2f8d8c4fb7d3f754071beb910b7ecdad6e73
e683a0b8dbb87c7ceb99e0d06896174a559d2c67
/Tools/utils/malloc.h
73f26f24778f0bd011a6a8f382b07a92ab3b6b3f
[ "Apache-2.0" ]
permissive
bluewaysw/pcgeos
f093d79567d977d992f47065056d14d5a04b9f14
c6ae4c8e77b54b9ff654c3916f2191f8b1a1b65d
refs/heads/master
2023-08-31T00:17:54.481175
2023-08-29T19:00:49
2023-08-29T19:00:49
157,968,410
603
88
Apache-2.0
2023-09-13T07:44:06
2018-11-17T09:09:55
Assembly
UTF-8
C
false
false
2,320
h
malloc.h
/* @(#)malloc.h 1.4 89/06/25 SMI; from include/malloc.h 1.5 */ /* $Id: malloc.h,v 1.4 96/05/20 18:56:44 dbaumann Exp $ */ #ifndef __malloc_h #define __malloc_h #include <stddef.h> /* * Constants defining mallopt operations */ #define M_MXFAST 1 /* set size of 'small blocks' */ #define M_NLBLKS 2 /* set num of small blocks in holding block */ #define M_GRAIN 3 /* set rounding factor for small blocks */ #define M_KEEP 4 /* (nop) retain contents of freed blocks */ /* * malloc information structure */ struct mallinfo { int arena; /* total space in arena */ int ordblks; /* number of ordinary blocks */ int smblks; /* number of small blocks */ int hblks; /* number of holding blocks */ int hblkhd; /* space in holding block headers */ int usmblks; /* space in small blocks in use */ int fsmblks; /* space in free small blocks */ int uordblks; /* space in ordinary blocks in use */ int fordblks; /* space in free ordinary blocks */ int keepcost; /* cost of enabling keep option */ int mxfast; /* max size of small blocks */ int nlblks; /* number of small blocks in a holding block */ int grain; /* small block rounding factor */ int uordbytes; /* space (including overhead) allocated in ord. blks */ int allocated; /* number of ordinary blocks allocated */ int treeoverhead; /* bytes used in maintaining the free tree */ }; #if defined(__HIGHC__) || defined(__BORLANDC__) || defined(__WATCOMC__) typedef char *malloc_t; #else typedef void *malloc_t; #endif extern malloc_t calloc(size_t, size_t); extern void free(malloc_t); extern malloc_t malloc(size_t size); extern malloc_t realloc(malloc_t, size_t); #define realloc_tagged(p,s) realloc((p), (s)) extern int mallopt(); extern struct mallinfo mallinfo(); extern malloc_t malloc_tagged(size_t nbytes, unsigned tag); extern malloc_t calloc_tagged(size_t elsize, unsigned nel, unsigned tag); extern unsigned malloc_tag(malloc_t ptr); extern void malloc_settag(malloc_t ptr, unsigned tag); #ifndef __HIGHC__ extern unsigned malloc_size(malloc_t ptr); #endif typedef void malloc_printstats_callback(void *, const char *, ...); extern int malloc_printstats(malloc_printstats_callback *printFunc, void *data); extern int shrinkheap(void); #endif /* !__malloc_h */
daf3dc57c797d94e965dabfa01f322cf75fec1c0
2b7ab9f36c5370de17f07dfba601eff48f6279c0
/bsodSurvivor/tests/ExternalDll/DllMain.h
90c8cc77ec0585acdf71b5a6d50e0b7e629e2945
[ "LLVM-exception", "NCSA", "Apache-2.0" ]
permissive
ykfre/BsodSurvivor
135956c0e09f731b23566b37376a2e10f0500550
ca21967f5552966853285e5cea630970fc5e3556
refs/heads/master
2023-04-28T03:51:30.115441
2023-04-20T22:42:18
2023-04-20T22:42:18
325,870,912
180
26
null
2021-03-14T00:27:04
2020-12-31T20:45:09
C++
UTF-8
C
false
false
50
h
DllMain.h
#pragma once const int EXTERNAL_FUNC_RESULT = 1;
5f181788ee19b07422f11402319a44ce2ff0c0d9
2c73a693c2b3c162eae2ab94f649d8c4494878ba
/lua/src/bget.c
d5c9dd5bb65412e389cc0ec82bb16df663be6ce9
[ "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
57,730
c
bget.c
/* B G E T Buffer allocator Designed and implemented in April of 1972 by John Walker, based on the Case Algol OPRO$ algorithm implemented in 1966. Reimplemented in 1975 by John Walker for the Interdata 70. Reimplemented in 1977 by John Walker for the Marinchip 9900. Reimplemented in 1982 by Duff Kurland for the Intel 8080. Portable C version implemented in September of 1990 by an older, wiser instance of the original implementor. Souped up and/or weighed down slightly shortly thereafter by Greg Lutz. AMIX edition, including the new compaction call-back option, prepared by John Walker in July of 1992. Bug in built-in test program fixed, ANSI compiler warnings eradicated, buffer pool validator implemented, and guaranteed repeatable test added by John Walker in October of 1995. This program is in the public domain. 1. This is the book of the generations of Adam. In the day that God created man, in the likeness of God made he him; 2. Male and female created he them; and blessed them, and called their name Adam, in the day when they were created. 3. And Adam lived an hundred and thirty years, and begat a son in his own likeness, and after his image; and called his name Seth: 4. And the days of Adam after he had begotten Seth were eight hundred years: and he begat sons and daughters: 5. And all the days that Adam lived were nine hundred and thirty years: and he died. 6. And Seth lived an hundred and five years, and begat Enos: 7. And Seth lived after he begat Enos eight hundred and seven years, and begat sons and daughters: 8. And all the days of Seth were nine hundred and twelve years: and he died. 9. And Enos lived ninety years, and begat Cainan: 10. And Enos lived after he begat Cainan eight hundred and fifteen years, and begat sons and daughters: 11. And all the days of Enos were nine hundred and five years: and he died. 12. And Cainan lived seventy years and begat Mahalaleel: 13. And Cainan lived after he begat Mahalaleel eight hundred and forty years, and begat sons and daughters: 14. And all the days of Cainan were nine hundred and ten years: and he died. 15. And Mahalaleel lived sixty and five years, and begat Jared: 16. And Mahalaleel lived after he begat Jared eight hundred and thirty years, and begat sons and daughters: 17. And all the days of Mahalaleel were eight hundred ninety and five years: and he died. 18. And Jared lived an hundred sixty and two years, and he begat Enoch: 19. And Jared lived after he begat Enoch eight hundred years, and begat sons and daughters: 20. And all the days of Jared were nine hundred sixty and two years: and he died. 21. And Enoch lived sixty and five years, and begat Methuselah: 22. And Enoch walked with God after he begat Methuselah three hundred years, and begat sons and daughters: 23. And all the days of Enoch were three hundred sixty and five years: 24. And Enoch walked with God: and he was not; for God took him. 25. And Methuselah lived an hundred eighty and seven years, and begat Lamech. 26. And Methuselah lived after he begat Lamech seven hundred eighty and two years, and begat sons and daughters: 27. And all the days of Methuselah were nine hundred sixty and nine years: and he died. 28. And Lamech lived an hundred eighty and two years, and begat a son: 29. And he called his name Noah, saying, This same shall comfort us concerning our work and toil of our hands, because of the ground which the LORD hath cursed. 30. And Lamech lived after he begat Noah five hundred ninety and five years, and begat sons and daughters: 31. And all the days of Lamech were seven hundred seventy and seven years: and he died. 32. And Noah was five hundred years old: and Noah begat Shem, Ham, and Japheth. And buffers begat buffers, and links begat links, and buffer pools begat links to chains of buffer pools containing buffers, and lo the buffers and links and pools of buffers and pools of links to chains of pools of buffers were fruitful and they multiplied and the Operating System looked down upon them and said that it was Good. INTRODUCTION ============ BGET is a comprehensive memory allocation package which is easily configured to the needs of an application. BGET is efficient in both the time needed to allocate and release buffers and in the memory overhead required for buffer pool management. It automatically consolidates contiguous space to minimise fragmentation. BGET is configured by compile-time definitions, Major options include: * A built-in test program to exercise BGET and demonstrate how the various functions are used. * Allocation by either the "first fit" or "best fit" method. * Wiping buffers at release time to catch code which references previously released storage. * Built-in routines to dump individual buffers or the entire buffer pool. * Retrieval of allocation and pool size statistics. * Quantisation of buffer sizes to a power of two to satisfy hardware alignment constraints. * Automatic pool compaction, growth, and shrinkage by means of call-backs to user defined functions. Applications of BGET can range from storage management in ROM-based embedded programs to providing the framework upon which a multitasking system incorporating garbage collection is constructed. BGET incorporates extensive internal consistency checking using the <assert.h> mechanism; all these checks can be turned off by compiling with NDEBUG defined, yielding a version of BGET with minimal size and maximum speed. The basic algorithm underlying BGET has withstood the test of time; more than 25 years have passed since the first implementation of this code. And yet, it is substantially more efficient than the native allocation schemes of many operating systems: the Macintosh and Microsoft Windows to name two, on which programs have obtained substantial speed-ups by layering BGET as an application level memory manager atop the underlying system's. BGET has been implemented on the largest mainframes and the lowest of microprocessors. It has served as the core for multitasking operating systems, multi-thread applications, embedded software in data network switching processors, and a host of C programs. And while it has accreted flexibility and additional options over the years, it remains fast, memory efficient, portable, and easy to integrate into your program. BGET IMPLEMENTATION ASSUMPTIONS =============================== BGET is written in as portable a dialect of C as possible. The only fundamental assumption about the underlying hardware architecture is that memory is allocated is a linear array which can be addressed as a vector of C "char" objects. On segmented address space architectures, this generally means that BGET should be used to allocate storage within a single segment (although some compilers simulate linear address spaces on segmented architectures). On segmented architectures, then, BGET buffer pools may not be larger than a segment, but since BGET allows any number of separate buffer pools, there is no limit on the total storage which can be managed, only on the largest individual object which can be allocated. Machines with a linear address architecture, such as the VAX, 680x0, Sparc, MIPS, or the Intel 80386 and above in native mode, may use BGET without restriction. GETTING STARTED WITH BGET ========================= Although BGET can be configured in a multitude of fashions, there are three basic ways of working with BGET. The functions mentioned below are documented in the following section. Please excuse the forward references which are made in the interest of providing a roadmap to guide you to the BGET functions you're likely to need. Embedded Applications --------------------- Embedded applications typically have a fixed area of memory dedicated to buffer allocation (often in a separate RAM address space distinct from the ROM that contains the executable code). To use BGET in such an environment, simply call bpool() with the start address and length of the buffer pool area in RAM, then allocate buffers with bget() and release them with brel(). Embedded applications with very limited RAM but abundant CPU speed may benefit by configuring BGET for BestFit allocation (which is usually not worth it in other environments). Malloc() Emulation ------------------ If the C library malloc() function is too slow, not present in your development environment (for example, an a native Windows or Macintosh program), or otherwise unsuitable, you can replace it with BGET. Initially define a buffer pool of an appropriate size with bpool()--usually obtained by making a call to the operating system's low-level memory allocator. Then allocate buffers with bget(), bgetz(), and bgetr() (the last two permit the allocation of buffers initialised to zero and [inefficient] re-allocation of existing buffers for compatibility with C library functions). Release buffers by calling brel(). If a buffer allocation request fails, obtain more storage from the underlying operating system, add it to the buffer pool by another call to bpool(), and continue execution. Automatic Storage Management ---------------------------- You can use BGET as your application's native memory manager and implement automatic storage pool expansion, contraction, and optionally application-specific memory compaction by compiling BGET with the BECtl variable defined, then calling bectl() and supplying functions for storage compaction, acquisition, and release, as well as a standard pool expansion increment. All of these functions are optional (although it doesn't make much sense to provide a release function without an acquisition function, does it?). Once the call-back functions have been defined with bectl(), you simply use bget() and brel() to allocate and release storage as before. You can supply an initial buffer pool with bpool() or rely on automatic allocation to acquire the entire pool. When a call on bget() cannot be satisfied, BGET first checks if a compaction function has been supplied. If so, it is called (with the space required to satisfy the allocation request and a sequence number to allow the compaction routine to be called successively without looping). If the compaction function is able to free any storage (it needn't know whether the storage it freed was adequate) it should return a nonzero value, whereupon BGET will retry the allocation request and, if it fails again, call the compaction function again with the next-higher sequence number. If the compaction function returns zero, indicating failure to free space, or no compaction function is defined, BGET next tests whether a non-NULL allocation function was supplied to bectl(). If so, that function is called with an argument indicating how many bytes of additional space are required. This will be the standard pool expansion increment supplied in the call to bectl() unless the original bget() call requested a buffer larger than this; buffers larger than the standard pool block can be managed "off the books" by BGET in this mode. If the allocation function succeeds in obtaining the storage, it returns a pointer to the new block and BGET expands the buffer pool; if it fails, the allocation request fails and returns NULL to the caller. If a non-NULL release function is supplied, expansion blocks which become totally empty are released to the global free pool by passing their addresses to the release function. Equipped with appropriate allocation, release, and compaction functions, BGET can be used as part of very sophisticated memory management strategies, including garbage collection. (Note, however, that BGET is *not* a garbage collector by itself, and that developing such a system requires much additional logic and careful design of the application's memory allocation strategy.) BGET FUNCTION DESCRIPTIONS ========================== Functions implemented in this file (some are enabled by certain of the optional settings below): void bpool(void *buffer, bufsize len); Create a buffer pool of <len> bytes, using the storage starting at <buffer>. You can call bpool() subsequently to contribute additional storage to the overall buffer pool. void *bget(bufsize size); Allocate a buffer of <size> bytes. The address of the buffer is returned, or NULL if insufficient memory was available to allocate the buffer. void *bgetz(bufsize size); Allocate a buffer of <size> bytes and clear it to all zeroes. The address of the buffer is returned, or NULL if insufficient memory was available to allocate the buffer. void *bgetr(void *buffer, bufsize newsize); Reallocate a buffer previously allocated by bget(), changing its size to <newsize> and preserving all existing data. NULL is returned if insufficient memory is available to reallocate the buffer, in which case the original buffer remains intact. void brel(void *buf); Return the buffer <buf>, previously allocated by bget(), to the free space pool. void bectl(int (*compact)(bufsize sizereq, int sequence), void *(*acquire)(bufsize size), void (*release)(void *buf), bufsize pool_incr); Expansion control: specify functions through which the package may compact storage (or take other appropriate action) when an allocation request fails, and optionally automatically acquire storage for expansion blocks when necessary, and release such blocks when they become empty. If <compact> is non-NULL, whenever a buffer allocation request fails, the <compact> function will be called with arguments specifying the number of bytes (total buffer size, including header overhead) required to satisfy the allocation request, and a sequence number indicating the number of consecutive calls on <compact> attempting to satisfy this allocation request. The sequence number is 1 for the first call on <compact> for a given allocation request, and increments on subsequent calls, permitting the <compact> function to take increasingly dire measures in an attempt to free up storage. If the <compact> function returns a nonzero value, the allocation attempt is re-tried. If <compact> returns 0 (as it must if it isn't able to release any space or add storage to the buffer pool), the allocation request fails, which can trigger automatic pool expansion if the <acquire> argument is non-NULL. At the time the <compact> function is called, the state of the buffer allocator is identical to that at the moment the allocation request was made; consequently, the <compact> function may call brel(), bpool(), bstats(), and/or directly manipulate the buffer pool in any manner which would be valid were the application in control. This does not, however, relieve the <compact> function of the need to ensure that whatever actions it takes do not change things underneath the application that made the allocation request. For example, a <compact> function that released a buffer in the process of being reallocated with bgetr() would lead to disaster. Implementing a safe and effective <compact> mechanism requires careful design of an application's memory architecture, and cannot generally be easily retrofitted into existing code. If <acquire> is non-NULL, that function will be called whenever an allocation request fails. If the <acquire> function succeeds in allocating the requested space and returns a pointer to the new area, allocation will proceed using the expanded buffer pool. If <acquire> cannot obtain the requested space, it should return NULL and the entire allocation process will fail. <pool_incr> specifies the normal expansion block size. Providing an <acquire> function will cause subsequent bget() requests for buffers too large to be managed in the linked-block scheme (in other words, larger than <pool_incr> minus the buffer overhead) to be satisfied directly by calls to the <acquire> function. Automatic release of empty pool blocks will occur only if all pool blocks in the system are the size given by <pool_incr>. void bstats(bufsize *curalloc, bufsize *totfree, bufsize *maxfree, unsigned long *nget, unsigned long *nrel); The amount of space currently allocated is stored into the variable pointed to by <curalloc>. The total free space (sum of all free blocks in the pool) is stored into the variable pointed to by <totfree>, and the size of the largest single block in the free space pool is stored into the variable pointed to by <maxfree>. The variables pointed to by <nget> and <nrel> are filled, respectively, with the number of successful (non-NULL return) bget() calls and the number of brel() calls. void bstatse(bufsize *pool_incr, unsigned long *npool, unsigned long *npget, unsigned long *nprel, unsigned long *ndget, unsigned long *ndrel); Extended statistics: The expansion block size will be stored into the variable pointed to by <pool_incr>, or the negative thereof if automatic expansion block releases are disabled. The number of currently active pool blocks will be stored into the variable pointed to by <npool>. The variables pointed to by <npget> and <nprel> will be filled with, respectively, the number of expansion block acquisitions and releases which have occurred. The variables pointed to by <ndget> and <ndrel> will be filled with the number of bget() and brel() calls, respectively, managed through blocks directly allocated by the acquisition and release functions. void bufdump(void *buf); The buffer pointed to by <buf> is dumped on standard output. void bpoold(void *pool, int dumpalloc, int dumpfree); All buffers in the buffer pool <pool>, previously initialised by a call on bpool(), are listed in ascending memory address order. If <dumpalloc> is nonzero, the contents of allocated buffers are dumped; if <dumpfree> is nonzero, the contents of free blocks are dumped. int bpoolv(void *pool); The named buffer pool, previously initialised by a call on bpool(), is validated for bad pointers, overwritten data, etc. If compiled with NDEBUG not defined, any error generates an assertion failure. Otherwise 1 is returned if the pool is valid, 0 if an error is found. BGET CONFIGURATION ================== */ #if 0 #define TestProg 20000 /* Generate built-in test program if defined. The value specifies how many buffer allocation attempts the test program should make. */ #endif #define SizeQuant 8 /* Buffer allocation size quantum: all buffers allocated are a multiple of this size. This MUST be a power of two. */ #if 0 #define BufDump 1 /* Define this symbol to enable the bpoold() function which dumps the buffers in a buffer pool. */ #endif #if 0 #define BufValid 1 /* Define this symbol to enable the bpoolv() function for validating a buffer pool. */ #endif #if 0 #define DumpData 1 /* Define this symbol to enable the bufdump() function which allows dumping the contents of an allocated or free buffer. */ #endif #if 1 #define BufStats 1 /* Define this symbol to enable the bstats() function which calculates the total free space in the buffer pool, the largest available buffer, and the total space currently allocated. */ #endif #if 0 #define FreeWipe 1 /* Wipe free buffers to a guaranteed pattern of garbage to trip up miscreants who attempt to use pointers into released buffers. */ #endif #if 1 #define BestFit 1 /* Use a best fit algorithm when searching for space for an allocation request. This uses memory more efficiently, but allocation will be much slower. */ #endif #if 0 #define BECtl 1 /* Define this symbol to enable the bectl() function for automatic pool space control. */ #endif #include <stdio.h> #ifdef lint #define NDEBUG /* Exits in asserts confuse lint */ /* LINTLIBRARY */ /* Don't complain about def, no ref */ extern char *sprintf(); /* Sun includes don't define sprintf */ #endif //#include <assert.h> #include <string.h> #ifdef BufDump /* BufDump implies DumpData */ #ifndef DumpData #define DumpData 1 #endif #endif #ifdef DumpData #include <ctype.h> #endif /* Declare the interface, including the requested buffer size type, bufsize. */ #include "bget.h" #define MemSize int /* Type for size arguments to memxxx() functions such as memcmp(). */ /* Queue links */ struct qlinks { struct bfhead *flink; /* Forward link */ struct bfhead *blink; /* Backward link */ }; /* Header in allocated and free buffers */ struct bhead { bufsize prevfree; /* Relative link back to previous free buffer in memory or 0 if previous buffer is allocated. */ bufsize bsize; /* Buffer size: positive if free, negative if allocated. */ }; #define BH(p) ((struct bhead *) (p)) /* Header in directly allocated buffers (by acqfcn) */ struct bdhead { bufsize tsize; /* Total size, including overhead */ struct bhead bh; /* Common header */ }; #define BDH(p) ((struct bdhead *) (p)) /* Header in free buffers */ struct bfhead { struct bhead bh; /* Common allocated/free header */ struct qlinks ql; /* Links on free list */ }; #define BFH(p) ((struct bfhead *) (p)) static struct bfhead freelist = { /* List of free buffers */ {0, 0}, {&freelist, &freelist} }; #ifdef BufStats static bufsize totalloc = 0; /* Total space currently allocated */ static bufsize maxalloc = 0; static unsigned long numget = 0, numrel = 0; /* Number of bget() and brel() calls */ #ifdef BECtl static long numpblk = 0; /* Number of pool blocks */ static unsigned long numpget = 0, numprel = 0; /* Number of block gets and rels */ static unsigned long numdget = 0, numdrel = 0; /* Number of direct gets and rels */ #endif /* BECtl */ #endif /* BufStats */ #ifdef BECtl /* Automatic expansion block management functions */ static int (*compfcn) _((bufsize sizereq, int sequence)) = NULL; static void *(*acqfcn) _((bufsize size)) = NULL; static void (*relfcn) _((void *buf)) = NULL; static bufsize exp_incr = 0; /* Expansion block size */ static bufsize pool_len = 0; /* 0: no bpool calls have been made -1: not all pool blocks are the same size >0: (common) block size for all bpool calls made so far */ #endif /* Minimum allocation quantum: */ #define QLSize (sizeof(struct qlinks)) #define SizeQ ((SizeQuant > QLSize) ? SizeQuant : QLSize) #define V (void) /* To denote unwanted returned values */ /* End sentinel: value placed in bsize field of dummy block delimiting end of pool block. The most negative number which will fit in a bufsize, defined in a way that the compiler will accept. */ #define ESent ((bufsize) (-(((1L << (sizeof(bufsize) * 8 - 2)) - 1) * 2) - 2)) #define _assert_(x) /* BGET -- Allocate a buffer. */ void *bget(bufsize requested_size) { bufsize size = requested_size; struct bfhead *b; #ifdef BestFit struct bfhead *best; #endif void *buf; #ifdef BECtl int compactseq = 0; #endif _assert_(size >= 0); if (!size) { return NULL; } if (size < (bufsize)SizeQ) { /* Need at least room for the */ size = SizeQ; /* queue links. */ } #ifdef SizeQuant #if SizeQuant > 1 size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1)); #endif #endif size += sizeof(struct bhead); /* Add overhead in allocated buffer to size required. */ #ifdef BECtl /* If a compact function was provided in the call to bectl(), wrap a loop around the allocation process to allow compaction to intervene in case we don't find a suitable buffer in the chain. */ while (1) { #endif b = freelist.ql.flink; #ifdef BestFit best = &freelist; #endif /* Scan the free list searching for the first buffer big enough to hold the requested size buffer. */ #ifdef BestFit while (b != &freelist) { if (b->bh.bsize >= size) { if ((best == &freelist) || (b->bh.bsize < best->bh.bsize)) { best = b; } } b = b->ql.flink; /* Link to next buffer */ } b = best; #endif /* BestFit */ while (b != &freelist) { if ((bufsize) b->bh.bsize >= size) { /* Buffer is big enough to satisfy the request. Allocate it to the caller. We must decide whether the buffer is large enough to split into the part given to the caller and a free buffer that remains on the free list, or whether the entire buffer should be removed from the free list and given to the caller in its entirety. We only split the buffer if enough room remains for a header plus the minimum quantum of allocation. */ if ((b->bh.bsize - size) > (bufsize)(SizeQ + (sizeof(struct bhead)))) { struct bhead *ba, *bn; ba = BH(((char *) b) + (b->bh.bsize - size)); bn = BH(((char *) ba) + size); _assert_(bn->prevfree == b->bh.bsize); /* Subtract size from length of free block. */ b->bh.bsize -= size; /* Link allocated buffer to the previous free buffer. */ ba->prevfree = b->bh.bsize; /* Plug negative size into user buffer. */ ba->bsize = -(bufsize) size; /* Mark buffer after this one not preceded by free block. */ bn->prevfree = 0; #ifdef BufStats totalloc += size; if (totalloc > maxalloc) { maxalloc = totalloc; } numget++; /* Increment number of bget() calls */ #endif buf = (void *) ((((char *) ba) + sizeof(struct bhead))); return buf; } else { struct bhead *ba; ba = BH(((char *) b) + b->bh.bsize); _assert_(ba->prevfree == b->bh.bsize); /* The buffer isn't big enough to split. Give the whole shebang to the caller and remove it from the free list. */ _assert_(b->ql.blink->ql.flink == b); _assert_(b->ql.flink->ql.blink == b); b->ql.blink->ql.flink = b->ql.flink; b->ql.flink->ql.blink = b->ql.blink; #ifdef BufStats totalloc += b->bh.bsize; if (totalloc > maxalloc) { maxalloc = totalloc; } numget++; /* Increment number of bget() calls */ #endif /* Negate size to mark buffer allocated. */ b->bh.bsize = -(b->bh.bsize); /* Zero the back pointer in the next buffer in memory to indicate that this buffer is allocated. */ ba->prevfree = 0; /* Give user buffer starting at queue links. */ buf = (void *) &(b->ql); return buf; } } b = b->ql.flink; /* Link to next buffer */ } #ifdef BECtl /* We failed to find a buffer. If there's a compact function defined, notify it of the size requested. If it returns TRUE, try the allocation again. */ if ((compfcn == NULL) || (!(*compfcn)(size, ++compactseq))) { break; } } /* No buffer available with requested size free. */ /* Don't give up yet -- look in the reserve supply. */ if (acqfcn != NULL) { if (size > exp_incr - sizeof(struct bhead)) { /* Request is too large to fit in a single expansion block. Try to satisy it by a direct buffer acquisition. */ struct bdhead *bdh; size += sizeof(struct bdhead) - sizeof(struct bhead); if ((bdh = BDH((*acqfcn)((bufsize) size))) != NULL) { /* Mark the buffer special by setting the size field of its header to zero. */ bdh->bh.bsize = 0; bdh->bh.prevfree = 0; bdh->tsize = size; #ifdef BufStats totalloc += size; numget++; /* Increment number of bget() calls */ numdget++; /* Direct bget() call count */ #endif buf = (void *) (bdh + 1); return buf; } } else { /* Try to obtain a new expansion block */ void *newpool; if ((newpool = (*acqfcn)((bufsize) exp_incr)) != NULL) { bpool(newpool, exp_incr); buf = bget(requested_size); /* This can't, I say, can't get into a loop. */ return buf; } } } /* Still no buffer available */ #endif /* BECtl */ return NULL; } /* BGETZ -- Allocate a buffer and clear its contents to zero. We clear the entire contents of the buffer to zero, not just the region requested by the caller. */ void *bgetz(bufsize size) { char *buf = (char *) bget(size); if (buf != NULL) { struct bhead *b; bufsize rsize; b = BH(buf - sizeof(struct bhead)); rsize = -(b->bsize); if (rsize == 0) { struct bdhead *bd; bd = BDH(buf - sizeof(struct bdhead)); rsize = bd->tsize - sizeof(struct bdhead); } else { rsize -= sizeof(struct bhead); } _assert_(rsize >= size); memset(buf, 0, (MemSize) rsize); } return ((void *) buf); } /* BGETR -- Reallocate a buffer. This is a minimal implementation, simply in terms of brel() and bget(). It could be enhanced to allow the buffer to grow into adjacent free blocks and to avoid moving data unnecessarily. */ void *bgetr(void *buf, bufsize size) { void *nbuf; bufsize osize; /* Old size of buffer */ struct bhead *b; if ((nbuf = bget(size)) == NULL) { /* Acquire new buffer */ return NULL; } if (buf == NULL) { return nbuf; } b = BH(((char *) buf) - sizeof(struct bhead)); osize = -b->bsize; #ifdef BECtl if (osize == 0) { /* Buffer acquired directly through acqfcn. */ struct bdhead *bd; bd = BDH(((char *) buf) - sizeof(struct bdhead)); osize = bd->tsize - sizeof(struct bdhead); } else #endif osize -= sizeof(struct bhead); _assert_(osize > 0); V memcpy((char *) nbuf, (char *) buf, /* Copy the data */ (MemSize) ((size < osize) ? size : osize)); brel(buf); return nbuf; } /* BREL -- Release a buffer. */ void brel(void *buf) { struct bfhead *b, *bn; b = BFH(((char *) buf) - sizeof(struct bhead)); #ifdef BufStats numrel++; /* Increment number of brel() calls */ #endif _assert_(buf != NULL); if (!buf) { return; } #ifdef BECtl if (b->bh.bsize == 0) { /* Directly-acquired buffer? */ struct bdhead *bdh; bdh = BDH(((char *) buf) - sizeof(struct bdhead)); _assert_(b->bh.prevfree == 0); #ifdef BufStats totalloc -= bdh->tsize; _assert_(totalloc >= 0); numdrel++; /* Number of direct releases */ #endif /* BufStats */ #ifdef FreeWipe V memset((char *) buf, 0x55, (MemSize) (bdh->tsize - sizeof(struct bdhead))); #endif /* FreeWipe */ _assert_(relfcn != NULL); (*relfcn)((void *) bdh); /* Release it directly. */ return; } #endif /* BECtl */ /* Buffer size must be negative, indicating that the buffer is allocated. */ if (b->bh.bsize >= 0) { bn = NULL; } _assert_(b->bh.bsize < 0); /* Back pointer in next buffer must be zero, indicating the same thing: */ _assert_(BH((char *) b - b->bh.bsize)->prevfree == 0); #ifdef BufStats totalloc += b->bh.bsize; _assert_(totalloc >= 0); #endif /* If the back link is nonzero, the previous buffer is free. */ if (b->bh.prevfree != 0) { /* The previous buffer is free. Consolidate this buffer with it by adding the length of this buffer to the previous free buffer. Note that we subtract the size in the buffer being released, since it's negative to indicate that the buffer is allocated. */ register bufsize size = b->bh.bsize; /* Make the previous buffer the one we're working on. */ _assert_(BH((char *) b - b->bh.prevfree)->bsize == b->bh.prevfree); b = BFH(((char *) b) - b->bh.prevfree); b->bh.bsize -= size; } else { /* The previous buffer isn't allocated. Insert this buffer on the free list as an isolated free block. */ _assert_(freelist.ql.blink->ql.flink == &freelist); _assert_(freelist.ql.flink->ql.blink == &freelist); b->ql.flink = &freelist; b->ql.blink = freelist.ql.blink; freelist.ql.blink = b; b->ql.blink->ql.flink = b; b->bh.bsize = -b->bh.bsize; } /* Now we look at the next buffer in memory, located by advancing from the start of this buffer by its size, to see if that buffer is free. If it is, we combine this buffer with the next one in memory, dechaining the second buffer from the free list. */ bn = BFH(((char *) b) + b->bh.bsize); if (bn->bh.bsize > 0) { /* The buffer is free. Remove it from the free list and add its size to that of our buffer. */ _assert_(BH((char *) bn + bn->bh.bsize)->prevfree == bn->bh.bsize); _assert_(bn->ql.blink->ql.flink == bn); _assert_(bn->ql.flink->ql.blink == bn); bn->ql.blink->ql.flink = bn->ql.flink; bn->ql.flink->ql.blink = bn->ql.blink; b->bh.bsize += bn->bh.bsize; /* Finally, advance to the buffer that follows the newly consolidated free block. We must set its backpointer to the head of the consolidated free block. We know the next block must be an allocated block because the process of recombination guarantees that two free blocks will never be contiguous in memory. */ bn = BFH(((char *) b) + b->bh.bsize); } #ifdef FreeWipe V memset(((char *) b) + sizeof(struct bfhead), 0x55, (MemSize) (b->bh.bsize - sizeof(struct bfhead))); #endif _assert_(bn->bh.bsize < 0); /* The next buffer is allocated. Set the backpointer in it to point to this buffer; the previous free buffer in memory. */ bn->bh.prevfree = b->bh.bsize; #ifdef BECtl /* If a block-release function is defined, and this free buffer constitutes the entire block, release it. Note that pool_len is defined in such a way that the test will fail unless all pool blocks are the same size. */ if (relfcn != NULL && ((bufsize) b->bh.bsize) == (pool_len - sizeof(struct bhead))) { _assert_(b->bh.prevfree == 0); _assert_(BH((char *) b + b->bh.bsize)->bsize == ESent); _assert_(BH((char *) b + b->bh.bsize)->prevfree == b->bh.bsize); /* Unlink the buffer from the free list */ b->ql.blink->ql.flink = b->ql.flink; b->ql.flink->ql.blink = b->ql.blink; (*relfcn)(b); #ifdef BufStats numprel++; /* Nr of expansion block releases */ numpblk--; /* Total number of blocks */ _assert_(numpblk == numpget - numprel); #endif /* BufStats */ } #endif /* BECtl */ } #ifdef BECtl /* BECTL -- Establish automatic pool expansion control */ void bectl(int (*compact) _((bufsize sizereq, int sequence)), void *(*acquire) _((bufsize size)), void (*release) _((void *buf)), bufsize pool_incr) { compfcn = compact; acqfcn = acquire; relfcn = release; exp_incr = pool_incr; } #endif /* BPOOL -- Add a region of memory to the buffer pool. */ void bpool(void *buf, bufsize len) { struct bfhead *b = BFH(buf); struct bhead *bn; #ifdef SizeQuant len &= ~(SizeQuant - 1); #endif #ifdef BECtl if (pool_len == 0) { pool_len = len; } else if (len != pool_len) { pool_len = -1; } #ifdef BufStats numpget++; /* Number of block acquisitions */ numpblk++; /* Number of blocks total */ _assert_(numpblk == numpget - numprel); #endif /* BufStats */ #endif /* BECtl */ /* Since the block is initially occupied by a single free buffer, it had better not be (much) larger than the largest buffer whose size we can store in bhead.bsize. */ _assert_(len - sizeof(struct bhead) <= -((bufsize) ESent + 1)); /* Clear the backpointer at the start of the block to indicate that there is no free block prior to this one. That blocks recombination when the first block in memory is released. */ b->bh.prevfree = 0; /* Chain the new block to the free list. */ _assert_(freelist.ql.blink->ql.flink == &freelist); _assert_(freelist.ql.flink->ql.blink == &freelist); b->ql.flink = &freelist; b->ql.blink = freelist.ql.blink; freelist.ql.blink = b; b->ql.blink->ql.flink = b; /* Create a dummy allocated buffer at the end of the pool. This dummy buffer is seen when a buffer at the end of the pool is released and blocks recombination of the last buffer with the dummy buffer at the end. The length in the dummy buffer is set to the largest negative number to denote the end of the pool for diagnostic routines (this specific value is not counted on by the actual allocation and release functions). */ len -= sizeof(struct bhead); b->bh.bsize = (bufsize) len; #ifdef FreeWipe V memset(((char *) b) + sizeof(struct bfhead), 0x55, (MemSize) (len - sizeof(struct bfhead))); #endif bn = BH(((char *) b) + len); bn->prevfree = (bufsize) len; /* Definition of ESent assumes two's complement! */ _assert_((~0) == -1); bn->bsize = ESent; } #ifdef BufStats /* BSTATS -- Return buffer allocation free space statistics. */ void bstats(bufsize *curalloc, bufsize *totfree, bufsize *maxfree, unsigned long *nget, unsigned long *nrel) { struct bfhead *b = freelist.ql.flink; *nget = numget; *nrel = numrel; *curalloc = totalloc; *totfree = 0; *maxfree = -1; while (b != &freelist) { _assert_(b->bh.bsize > 0); *totfree += b->bh.bsize; if (b->bh.bsize > *maxfree) { *maxfree = b->bh.bsize; } b = b->ql.flink; /* Link to next buffer */ } } bufsize bstatsmaxget(void) { return maxalloc; } #ifdef BECtl /* BSTATSE -- Return extended statistics */ void bstatse(bufsize *pool_incr, long *npool, unsigned long *npget, unsigned long *nprel, unsigned long * ndget, unsigned long *ndrel) { *pool_incr = (pool_len < 0) ? -exp_incr : exp_incr; *npool = numpblk; *npget = numpget; *nprel = numprel; *ndget = numdget; *ndrel = numdrel; } #endif /* BECtl */ #endif /* BufStats */ #ifdef DumpData /* BUFDUMP -- Dump the data in a buffer. This is called with the user data pointer, and backs up to the buffer header. It will dump either a free block or an allocated one. */ void bufdump(buf) void *buf; { struct bfhead *b; unsigned char *bdump; bufsize bdlen; b = BFH(((char *) buf) - sizeof(struct bhead)); _assert_(b->bh.bsize != 0); if (b->bh.bsize < 0) { bdump = (unsigned char *) buf; bdlen = (-b->bh.bsize) - sizeof(struct bhead); } else { bdump = (unsigned char *) (((char *) b) + sizeof(struct bfhead)); bdlen = b->bh.bsize - sizeof(struct bfhead); } while (bdlen > 0) { int i, dupes = 0; bufsize l = bdlen; char bhex[50], bascii[20]; if (l > 16) { l = 16; } for (i = 0; i < l; i++) { V sprintf(bhex + i * 3, "%02X ", bdump[i]); bascii[i] = isprint(bdump[i]) ? bdump[i] : ' '; } bascii[i] = 0; V printf("%-48s %s\n", bhex, bascii); bdump += l; bdlen -= l; while ((bdlen > 16) && (memcmp((char *) (bdump - 16), (char *) bdump, 16) == 0)) { dupes++; bdump += 16; bdlen -= 16; } if (dupes > 1) { V printf( " (%d lines [%d bytes] identical to above line skipped)\n", dupes, dupes * 16); } else if (dupes == 1) { bdump -= 16; bdlen += 16; } } } #endif #ifdef BufDump /* BPOOLD -- Dump a buffer pool. The buffer headers are always listed. If DUMPALLOC is nonzero, the contents of allocated buffers are dumped. If DUMPFREE is nonzero, free blocks are dumped as well. If FreeWipe checking is enabled, free blocks which have been clobbered will always be dumped. */ void bpoold(void *buf, int dumpalloc, int dumpfree) { struct bfhead *b = BFH(buf); while (b->bh.bsize != ESent) { bufsize bs = b->bh.bsize; if (bs < 0) { bs = -bs; V printf("Allocated buffer: size %6ld bytes.\n", (unsigned long) bs); if (dumpalloc) { bufdump((void *) (((char *) b) + sizeof(struct bhead))); } } else { char *lerr = ""; _assert_(bs > 0); if ((b->ql.blink->ql.flink != b) || (b->ql.flink->ql.blink != b)) { lerr = " (Bad free list links)"; } V printf("Free block: size %6ld bytes.%s\n", (unsigned long) bs, lerr); #ifdef FreeWipe lerr = ((char *) b) + sizeof(struct bfhead); if ((bs > sizeof(struct bfhead)) && ((*lerr != 0x55) || (memcmp(lerr, lerr + 1, (MemSize) (bs - (sizeof(struct bfhead) + 1))) != 0))) { V printf( "(Contents of above free block have been overstored.)\n"); bufdump((void *) (((char *) b) + sizeof(struct bhead))); } else #endif if (dumpfree) { bufdump((void *) (((char *) b) + sizeof(struct bhead))); } } b = BFH(((char *) b) + bs); } } #endif /* BufDump */ #ifdef BufValid /* BPOOLV -- Validate a buffer pool. If NDEBUG isn't defined, any error generates an assertion failure. */ int bpoolv(void *buf) { struct bfhead *b = BFH(buf); while (b->bh.bsize != ESent) { bufsize bs = b->bh.bsize; if (bs < 0) { bs = -bs; } else { char *lerr = ""; _assert_(bs > 0); if (bs <= 0) { return 0; } if ((b->ql.blink->ql.flink != b) || (b->ql.flink->ql.blink != b)) { V printf("Free block: size %6ld bytes. (Bad free list links)\n", (unsigned long) bs); _assert_(0); return 0; } #ifdef FreeWipe lerr = ((char *) b) + sizeof(struct bfhead); if ((bs > sizeof(struct bfhead)) && ((*lerr != 0x55) || (memcmp(lerr, lerr + 1, (MemSize) (bs - (sizeof(struct bfhead) + 1))) != 0))) { V printf( "(Contents of above free block have been overstored.)\n"); bufdump((void *) (((char *) b) + sizeof(struct bhead))); _assert_(0); return 0; } #endif } b = BFH(((char *) b) + bs); } return 1; } #endif /* BufValid */ /***********************\ * * * Built-in test program * * * \***********************/ #ifdef TestProg #define Repeatable 1 /* Repeatable pseudorandom sequence */ /* If Repeatable is not defined, a time-seeded pseudorandom sequence is generated, exercising BGET with a different pattern of calls on each run. */ #define OUR_RAND /* Use our own built-in version of rand() to guarantee the test is 100% repeatable. */ #ifdef BECtl #define PoolSize 300000 /* Test buffer pool size */ #else #define PoolSize 50000 /* Test buffer pool size */ #endif #define ExpIncr 32768 /* Test expansion block size */ #define CompactTries 10 /* Maximum tries at compacting */ #define dumpAlloc 0 /* Dump allocated buffers ? */ #define dumpFree 0 /* Dump free buffers ? */ #ifndef Repeatable extern unsigned long time(); #endif extern char *malloc(); extern int free _((char *)); static char *bchain = NULL; /* Our private buffer chain */ static char *bp = NULL; /* Our initial buffer pool */ #include <math.h> #ifdef OUR_RAND static unsigned long int next = 1; /* Return next random integer */ int rand() { next = next * 1103515245L + 12345; return (unsigned int) (next / 65536L) % 32768L; } /* Set seed for random generator */ void srand(unsigned int seed) { next = seed; } #endif /* STATS -- Edit statistics returned by bstats() or bstatse(). */ static void stats(char *when) { bufsize cural, totfree, maxfree; unsigned long nget, nfree; #ifdef BECtl bufsize pincr; long totblocks; unsigned npget, nprel, ndget, ndrel; #endif bstats(&cural, &totfree, &maxfree, &nget, &nfree); V printf( "%s: %ld gets, %ld releases. %ld in use, %ld free, largest = %ld\n", when, nget, nfree, (unsigned long) cural, (unsigned long) totfree, (unsigned long) maxfree); #ifdef BECtl bstatse(&pincr, &totblocks, &npget, &nprel, &ndget, &ndrel); V printf( " Blocks: size = %ld, %ld (%ld bytes) in use, %ld gets, %ld frees\n", (long)pincr, totblocks, pincr * totblocks, npget, nprel); V printf(" %ld direct gets, %ld direct frees\n", ndget, ndrel); #endif /* BECtl */ } #ifdef BECtl static int protect = 0; /* Disable compaction during bgetr() */ /* BCOMPACT -- Compaction call-back function. */ static int bcompact(bufsize bsize, int seq) { #ifdef CompactTries char *bc = bchain; int i = rand() & 0x3; #ifdef COMPACTRACE V printf("Compaction requested. %ld bytes needed, sequence %d.\n", (long) bsize, seq); #endif if (protect || (seq > CompactTries)) { #ifdef COMPACTRACE V printf("Compaction gave up.\n"); #endif return 0; } /* Based on a random cast, release a random buffer in the list of allocated buffers. */ while (i > 0 && bc != NULL) { bc = *((char **) bc); i--; } if (bc != NULL) { char *fb; fb = *((char **) bc); if (fb != NULL) { *((char **) bc) = *((char **) fb); brel((void *) fb); return 1; } } #ifdef COMPACTRACE V printf("Compaction bailed out.\n"); #endif #endif /* CompactTries */ return 0; } /* BEXPAND -- Expand pool call-back function. */ static void *bexpand(bufsize size) { void *np = NULL; bufsize cural, totfree, maxfree; unsigned long nget, nfree; /* Don't expand beyond the total allocated size given by PoolSize. */ bstats(&cural, &totfree, &maxfree, &nget, &nfree); if (cural < PoolSize) { np = (void *) malloc((unsigned) size); } #ifdef EXPTRACE V printf("Expand pool by %ld -- %s.\n", (unsigned long) size, np == NULL ? "failed" : "succeeded"); #endif return np; } /* BSHRINK -- Shrink buffer pool call-back function. */ static void bshrink(void *buf) { if (((char *) buf) == bp) { #ifdef EXPTRACE V printf("Initial pool released.\n"); #endif bp = NULL; } #ifdef EXPTRACE V printf("Shrink pool.\n"); #endif free((char *) buf); } #endif /* BECtl */ /* Restrict buffer requests to those large enough to contain our pointer and small enough for the CPU architecture. */ static bufsize blimit(bufsize bs) { if (bs < sizeof(char *)) { bs = sizeof(char *); } /* This is written out in this ugly fashion because the cool expression in sizeof(int) that auto-configured to any length int befuddled some compilers. */ if (sizeof(int) == 2) { if (bs > 32767) { bs = 32767; } } else { if (bs > 200000) { bs = 200000; } } return bs; } int main() { int i; double x; /* Seed the random number generator. If Repeatable is defined, we always use the same seed. Otherwise, we seed from the clock to shake things up from run to run. */ #ifdef Repeatable V srand(1234); #else V srand((int) time((unsigned long *) NULL)); #endif /* Compute x such that pow(x, p) ranges between 1 and 4*ExpIncr as p ranges from 0 to ExpIncr-1, with a concentration in the lower numbers. */ x = 4.0 * ExpIncr; x = log(x); x = exp(log(4.0 * ExpIncr) / (ExpIncr - 1.0)); #ifdef BECtl bectl(bcompact, bexpand, bshrink, (bufsize) ExpIncr); bp = malloc(ExpIncr); _assert_(bp != NULL); bpool((void *) bp, (bufsize) ExpIncr); #else bp = malloc(PoolSize); _assert_(bp != NULL); bpool((void *) bp, (bufsize) PoolSize); #endif stats("Create pool"); V bpoolv((void *) bp); bpoold((void *) bp, dumpAlloc, dumpFree); for (i = 0; i < TestProg; i++) { char *cb; bufsize bs = pow(x, (double) (rand() & (ExpIncr - 1))); _assert_(bs <= (((bufsize) 4) * ExpIncr)); bs = blimit(bs); if (rand() & 0x400) { cb = (char *) bgetz(bs); } else { cb = (char *) bget(bs); } if (cb == NULL) { #ifdef EasyOut break; #else char *bc = bchain; if (bc != NULL) { char *fb; fb = *((char **) bc); if (fb != NULL) { *((char **) bc) = *((char **) fb); brel((void *) fb); } continue; } #endif } *((char **) cb) = (char *) bchain; bchain = cb; /* Based on a random cast, release a random buffer in the list of allocated buffers. */ if ((rand() & 0x10) == 0) { char *bc = bchain; int i = rand() & 0x3; while (i > 0 && bc != NULL) { bc = *((char **) bc); i--; } if (bc != NULL) { char *fb; fb = *((char **) bc); if (fb != NULL) { *((char **) bc) = *((char **) fb); brel((void *) fb); } } } /* Based on a random cast, reallocate a random buffer in the list to a random size */ if ((rand() & 0x20) == 0) { char *bc = bchain; int i = rand() & 0x3; while (i > 0 && bc != NULL) { bc = *((char **) bc); i--; } if (bc != NULL) { char *fb; fb = *((char **) bc); if (fb != NULL) { char *newb; bs = pow(x, (double) (rand() & (ExpIncr - 1))); bs = blimit(bs); #ifdef BECtl protect = 1; /* Protect against compaction */ #endif newb = (char *) bgetr((void *) fb, bs); #ifdef BECtl protect = 0; #endif if (newb != NULL) { *((char **) bc) = newb; } } } } } stats("\nAfter allocation"); if (bp != NULL) { V bpoolv((void *) bp); bpoold((void *) bp, dumpAlloc, dumpFree); } while (bchain != NULL) { char *buf = bchain; bchain = *((char **) buf); brel((void *) buf); } stats("\nAfter release"); #ifndef BECtl if (bp != NULL) { V bpoolv((void *) bp); bpoold((void *) bp, dumpAlloc, dumpFree); } #endif return 0; } #endif
54c33ce36d877799f1893324c7570636e2f9d455
10a8580aa44d33b7458429023c00de8c01ceda98
/agent/lib_guzzle4.c
5045e7e70668a96c474bc0fd7d13688a41984931
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
newrelic/newrelic-php-agent
87ad20e0a5abf0d2855e7d27a25c36454ae4389a
dfb359f0dbb53e4cbc5106b52c8f3807c7fc8d42
refs/heads/main
2023-08-15T10:28:24.372352
2023-08-14T17:29:31
2023-08-14T17:29:31
302,112,572
116
67
Apache-2.0
2023-09-13T18:33:47
2020-10-07T17:35:01
C
UTF-8
C
false
false
18,110
c
lib_guzzle4.c
/* * Copyright 2020 New Relic Corporation. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Guzzle is a general purpose library for making HTTP requests. It supports * asynchronous, parallel requests using curl_multi_exec() while providing a * modern OO API for users. * * It is a required component in Drupal 8, and strongly recommended by other * frameworks, including Symfony 2. * * Our approach for Guzzle 4 and 5 is to use Guzzle's own event system: when a * GuzzleHttp\Client object is created, we attach a subscriber object that * registers its interest in the "before" and "complete" events (which are * basically what they sound like) and then tracks requests from there. * * Source : https://github.com/guzzle/guzzle * Docs : https://guzzle.readthedocs.org/en/latest/ */ #include "php_agent.h" #include "php_call.h" #include "php_user_instrument.h" #include "php_execute.h" #include "php_hash.h" #include "php_wrapper.h" #include "fw_hooks.h" #include "fw_support.h" #include "lib_guzzle_common.h" #include "lib_guzzle4.h" #include "nr_header.h" #include "nr_segment_external.h" #include "util_logging.h" #include "util_memory.h" /* * We rely on the const correctness of certain Zend functions that weren't * const correct before 5.3 and/or 5.4: since Guzzle 4 requires 5.4.0 anyway, * we just won't build the Guzzle 4 support on older versions and will instead * provide simple stubs for the two exported functions to avoid linking errors. */ #if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO /* {{{ Convenience functions for Guzzle interface checks */ /* * Purpose : Checks if the given object implements * GuzzleHttp\Event\EventInterface. * * Params : 1. The object to check. * * Returns : Non-zero if the object does implement the interface; zero * otherwise. */ static int nr_guzzle4_is_zval_an_event(zval* obj TSRMLS_DC) { return nr_php_object_instanceof_class( obj, "GuzzleHttp\\Event\\EventInterface" TSRMLS_CC); } /* * Purpose : Checks if the given object implements * GuzzleHttp\Event\EmitterInterface. * * Params : 1. The object to check. * * Returns : Non-zero if the object does implement the interface; zero * otherwise. */ static int nr_guzzle4_is_zval_an_emitter(zval* obj TSRMLS_DC) { return nr_php_object_instanceof_class( obj, "GuzzleHttp\\Event\\EmitterInterface" TSRMLS_CC); } /* * Purpose : Checks if the given object implements * GuzzleHttp\Message\RequestInterface. * * Params : 1. The object to check. * * Returns : Non-zero if the object does implement the interface; zero * otherwise. */ static int nr_guzzle4_is_zval_a_request(zval* obj TSRMLS_DC) { return nr_php_object_instanceof_class( obj, "GuzzleHttp\\Message\\RequestInterface" TSRMLS_CC); } /* * Purpose : Checks if the given object implements * GuzzleHttp\Message\ResponseInterface. * * Params : 1. The object to check. * * Returns : Non-zero if the object does implement the interface; zero * otherwise. */ static int nr_guzzle4_is_zval_a_response(zval* obj TSRMLS_DC) { return nr_php_object_instanceof_class( obj, "GuzzleHttp\\Message\\ResponseInterface" TSRMLS_CC); } /* }}} */ /* {{{ Static functions used by Subscriber methods */ /* * Purpose : Adds an event definition to an events array, formatted in the form * that Guzzle 4 expects from an object implementing * SubscriberInterface. * * Params : 1. The events array to add the event to. * 2. The event name. * 3. The method name that should be called when the event fires. * 4. The priority of the event. Guzzle's default is 0, and that's * probably always the right value for us. */ static void nr_guzzle4_add_event_to_events_array(zval* events, const char* event, const char* method, long priority) { zval* definition = nr_php_zval_alloc(); array_init(definition); nr_php_add_next_index_string(definition, method); add_next_index_long(definition, priority); nr_php_add_assoc_zval(events, event, definition); nr_php_zval_free(&definition); } /* * A structure representing the expected arguments received by a Guzzle event * handler. */ typedef struct _nr_guzzle4_subscriber_event_args_t { zval* event; /* The event object. */ char* name; /* The event name. */ nr_string_len_t name_len; /* The length of the event name. */ } nr_guzzle4_subscriber_event_args_t; /* * Purpose : Parses the parameters to an event handler function and validates * that they are the expected values. * * Params : 1. A pointer to a structure that will have the event arguments * filled into it. * 2. PHP's internal function parameters. * * Returns : NR_SUCCESS or NR_FAILURE. If NR_FAILURE is returned, then fields * in args should not be accessed. */ static nr_status_t nr_guzzle4_subscriber_event_get_args( nr_guzzle4_subscriber_event_args_t* args, INTERNAL_FUNCTION_PARAMETERS) { /* * A bunch of parameters are unused, so we'll suppress the errors. */ NR_UNUSED_RETURN_VALUE; NR_UNUSED_RETURN_VALUE_PTR; NR_UNUSED_RETURN_VALUE_USED; NR_UNUSED_THIS_PTR; if (NULL == args) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: %s got NULL args", __func__); return NR_FAILURE; } if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &args->event, &args->name, &args->name_len)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: zpp failed in %s", __func__); return NR_FAILURE; } if (!nr_guzzle4_is_zval_an_event(args->event TSRMLS_CC)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: event is not an EventInterface in %s", __func__); return NR_FAILURE; } return NR_SUCCESS; } /* }}} */ /* {{{ newrelic\Guzzle4\Subscriber class definition and methods */ /* * True global for the Subscriber class entry. */ zend_class_entry* nr_guzzle4_subscriber_ce; /* * Arginfo for the Subscriber methods. */ ZEND_BEGIN_ARG_INFO_EX(nr_guzzle4_subscriber_get_events_arginfo, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(nr_guzzle4_subscriber_on_before_arginfo, 0, 0, 2) ZEND_ARG_INFO(0, event) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(nr_guzzle4_subscriber_on_complete_arginfo, 0, 0, 2) ZEND_ARG_INFO(0, event) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() /* * The method implementations for the Subscriber class. */ /* * Proto : array Subscriber::getEvents() * * Purpose : Returns an array containing the events that we want to subscribe * to. * * Returns : An array, formatted in the style described in the Guzzle docs at * http://docs.guzzlephp.org/en/latest/events.html#event-subscribers. */ static PHP_NAMED_FUNCTION(nr_guzzle4_subscriber_get_events) { /* * Ignore unused parameters. */ NR_UNUSED_RETURN_VALUE_PTR; NR_UNUSED_RETURN_VALUE_USED; NR_UNUSED_THIS_PTR; if (FAILURE == zend_parse_parameters_none()) { RETURN_FALSE; } /* * Effectively, we're returning: * [ * 'before' => ['onBefore', 0], * 'complete' => ['onComplete', 0], * ] */ array_init(return_value); nr_guzzle4_add_event_to_events_array(return_value, "before", "onBefore", 0); nr_guzzle4_add_event_to_events_array(return_value, "complete", "onComplete", 0); } /* * Proto : boolean Subscriber::onBefore(BeforeEvent $event, $name) * * Purpose : Handles the "before" event emitted by Guzzle 4 when a request is * about to be sent. * * Params : 1. The BeforeEvent object containing the request. * 2. The name of the event (ignored). * * Returns : True on success; false otherwise. These values are ignored by * Guzzle 4, but may be useful for testing. */ static PHP_NAMED_FUNCTION(nr_guzzle4_subscriber_on_before) { nr_guzzle4_subscriber_event_args_t args; zval* request = NULL; nr_segment_t* segment; if (NR_FAILURE == nr_guzzle4_subscriber_event_get_args( &args, INTERNAL_FUNCTION_PARAM_PASSTHRU)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: onBefore() received unexpected arguments"); RETURN_FALSE; } /* * Pull the request out of the event object. */ request = nr_php_call(args.event, "getRequest"); if (!nr_guzzle4_is_zval_a_request(request TSRMLS_CC)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: onBefore() event did not return a request"); RETURN_FALSE; } /* * Add the request object to those we're tracking. */ segment = nr_guzzle_obj_add(request, "Guzzle 4" TSRMLS_CC); /* * Set the request headers. */ nr_guzzle_request_set_outbound_headers(request, segment TSRMLS_CC); nr_php_zval_free(&request); RETURN_TRUE; } /* * Proto : boolean Subscriber::onComplete(BeforeEvent $event, $name) * * Purpose : Handles the "complete" event emitted by Guzzle 4 when a request is * about to be sent. * * Params : 1. The CompleteEvent object containing the request and response. * 2. The name of the event (ignored). * * Returns : True on success; false otherwise. These values are ignored by * Guzzle 4, but may be useful for testing. */ static PHP_NAMED_FUNCTION(nr_guzzle4_subscriber_on_complete) { nr_guzzle4_subscriber_event_args_t args; zval* request = NULL; zval* response = NULL; zval* status = NULL; zval* method = NULL; nr_segment_t* segment; nr_segment_external_params_t external_params = {.library = "Guzzle 4/5"}; zval* url = NULL; if (NR_FAILURE == nr_guzzle4_subscriber_event_get_args( &args, INTERNAL_FUNCTION_PARAM_PASSTHRU)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: onComplete() received unexpected arguments"); RETVAL_FALSE; goto leave; } /* * Pull the request and response out of the event object. */ request = nr_php_call(args.event, "getRequest"); if (!nr_guzzle4_is_zval_a_request(request TSRMLS_CC)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: onComplete() event did not return a request"); RETVAL_FALSE; goto leave; } response = nr_php_call(args.event, "getResponse"); if (!nr_guzzle4_is_zval_a_response(response TSRMLS_CC)) { nrl_verbosedebug( NRL_FRAMEWORK, "Guzzle 4-5: onComplete() event did not return a response"); RETVAL_FALSE; goto leave; } /* * Find the original start time for the request. */ if (NR_FAILURE == nr_guzzle_obj_find_and_remove(request, &segment TSRMLS_CC)) { nrl_verbosedebug(NRL_INSTRUMENT, "Guzzle 4-5: Request completed without being tracked"); RETVAL_FALSE; goto leave; } /* * We also need the URL to create a useful metric. */ url = nr_php_call(request, "getUrl"); if (!nr_php_is_zval_valid_string(url)) { RETVAL_FALSE; goto leave; } external_params.uri = nr_strndup(Z_STRVAL_P(url), Z_STRLEN_P(url)); status = nr_php_call(response, "getStatusCode"); if (nr_php_is_zval_valid_integer(status)) { external_params.status = Z_LVAL_P(status); } /* * Grab the X-NewRelic-App-Data response header, if there is one. We don't * check for a valid string below as it's not an error if the header doesn't * exist (and hence NULL is returned). */ external_params.encoded_response_header = nr_guzzle_response_get_header(X_NEWRELIC_APP_DATA, response TSRMLS_CC); if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) { nrl_verbosedebug( NRL_CAT, "CAT: outbound response: transport='Guzzle 4-5' %s=" NRP_FMT, X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header)); } method = nr_php_call(request, "getMethod"); if (nr_php_is_zval_valid_string(method)) { external_params.procedure = nr_strndup(Z_STRVAL_P(method), Z_STRLEN_P(method)); } /* * Unlike Guzzle 3, we don't have any metadata available from Guzzle itself * to answer the question of how long the request took. Instead, we'll assume * that curl_multi_exec() calls back reasonably efficiently and just take the * wallclock time up to now. */ nr_segment_external_end(&segment, &external_params); RETVAL_TRUE; leave: nr_free(external_params.uri); nr_free(external_params.encoded_response_header); nr_free(external_params.procedure); nr_php_zval_free(&method); nr_php_zval_free(&request); nr_php_zval_free(&response); nr_php_zval_free(&url); nr_php_zval_free(&status); } /* * The method array for the Subscriber class. */ const zend_function_entry nr_guzzle4_subscriber_functions[] = {ZEND_FENTRY(getEvents, nr_guzzle4_subscriber_get_events, nr_guzzle4_subscriber_get_events_arginfo, ZEND_ACC_PUBLIC) ZEND_FENTRY(onBefore, nr_guzzle4_subscriber_on_before, nr_guzzle4_subscriber_on_before_arginfo, ZEND_ACC_PUBLIC) ZEND_FENTRY(onComplete, nr_guzzle4_subscriber_on_complete, nr_guzzle4_subscriber_on_complete_arginfo, ZEND_ACC_PUBLIC) PHP_FE_END}; /* }}} */ /* * Purpose : Registers an event subscriber for a newly instantiated * GuzzleHttp\Client object. */ NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) { zval* emitter = NULL; zval* retval = NULL; zval* subscriber = NULL; zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); (void)wraprec; NR_UNUSED_SPECIALFN; /* This is how we distinguish Guzzle 4/5 from other versions. */ if (0 == nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC)) { NR_PHP_WRAPPER_CALL; goto end; } NR_PHP_WRAPPER_CALL; /* * We can't have newrelic\Guzzle4\Subscriber implement * GuzzleHttp\Event\SubscriberInterface when the class is registered on * MINIT, because SubscriberInterface doesn't exist at that point. Instead, * we'll check now if the inheritance relationship has been set up, and if it * hasn't, then we'll set that up via zend_class_implements(). */ if (0 == nr_php_class_entry_instanceof_class( nr_guzzle4_subscriber_ce, "GuzzleHttp\\Event\\SubscriberInterface" TSRMLS_CC)) { zend_class_entry* subscriber_interface = nr_php_find_class("guzzlehttp\\event\\subscriberinterface" TSRMLS_CC); if (subscriber_interface) { zend_class_implements(nr_guzzle4_subscriber_ce TSRMLS_CC, 1, subscriber_interface); } else { nrl_info(NRL_FRAMEWORK, "Guzzle 4-5: cannot find SubscriberInterface class entry"); goto end; } } /* Register the subscriber. */ emitter = nr_php_call(this_var, "getEmitter"); if (!nr_guzzle4_is_zval_an_emitter(emitter TSRMLS_CC)) { nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: Client::getEmitter() didn't return an " "EmitterInterface object"); goto end; } subscriber = nr_php_zval_alloc(); object_init_ex(subscriber, nr_guzzle4_subscriber_ce); retval = nr_php_call(emitter, "attach", subscriber); if (NULL == retval) { nrl_info(NRL_FRAMEWORK, "Guzzle 4-5: Emitter::attach() failed"); nr_php_zval_free(&subscriber); goto end; } nr_php_zval_free(&retval); nrl_verbosedebug(NRL_FRAMEWORK, "Guzzle 4-5: subscriber attached to emitter"); end: nr_php_scope_release(&this_var); nr_php_zval_free(&emitter); nr_php_zval_free(&subscriber); } NR_PHP_WRAPPER_END void nr_guzzle4_enable(TSRMLS_D) { if (0 == NRINI(guzzle_enabled)) { return; } /* * Instrument Client::__construct() so we can register an event subscriber * when clients are instantiated. Guzzle 4 documents that you can attach * event handlers to Client objects and that you will then receive events * for all requests created on that client. */ nr_php_wrap_user_function(NR_PSTR("GuzzleHttp\\Client::__construct"), nr_guzzle_client_construct TSRMLS_CC); } void nr_guzzle4_minit(TSRMLS_D) { zend_class_entry ce; if (0 == NRINI(guzzle_enabled)) { return; } /* * Initialise the Guzzle 4 and 5 event subscriber class. */ INIT_CLASS_ENTRY(ce, "newrelic\\Guzzle4\\Subscriber", nr_guzzle4_subscriber_functions); nr_guzzle4_subscriber_ce = nr_php_zend_register_internal_class_ex(&ce, NULL TSRMLS_CC); /* Don't handle the implementation of the interface here, since we have to * do that during a request. */ } void nr_guzzle4_rshutdown(TSRMLS_D) { zend_class_entry* iface_ce = NULL; if (0 == NRINI(guzzle_enabled)) { return; } /* * We need to uninherit Subscriber from SubscriberInterface, otherwise we * may cause crashes by pointing to a destroyed class entry. * * Of course, if SubscriberInterface was never declared, we're good. Note * that nr_php_find_class requires the lowercase version of the class name. */ iface_ce = nr_php_find_class("guzzlehttp\\event\\subscriberinterface" TSRMLS_CC); if (NULL == iface_ce) { return; } nr_php_remove_interface_from_class(nr_guzzle4_subscriber_ce, iface_ce TSRMLS_CC); } #else /* PHP >= 5.4.0 */ /* * Stub implementations of the exported functions from this module for * PHP < 5.4. */ NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) { (void)wraprec; NR_UNUSED_SPECIALFN; NR_UNUSED_TSRMLS; } NR_PHP_WRAPPER_END void nr_guzzle4_enable(TSRMLS_D) { NR_UNUSED_TSRMLS } void nr_guzzle4_minit(TSRMLS_D) { NR_UNUSED_TSRMLS } void nr_guzzle4_rshutdown(TSRMLS_D) { NR_UNUSED_TSRMLS } #endif /* PHP >= 5.4.0 */
55465271bfdc3de0ab33c8e1ad391a35c6151fe1
f47cb02269307e83d86373d9ab4bfb8b46283d22
/src/libguac/socket-fd.c
742cc35d83166699d8663a483f340f6ad4c89369
[ "Apache-2.0" ]
permissive
apache/guacamole-server
7c8adf3f389f0539df353ef8f7ea6d44144ffb16
fe24e2d45ac0ac90588f64b43da6e0d518e59177
refs/heads/master
2023-09-04T02:42:34.907413
2023-08-30T22:57:11
2023-08-30T22:57:11
54,452,627
2,019
580
Apache-2.0
2023-09-13T00:15:57
2016-03-22T07:00:06
C
UTF-8
C
false
false
12,352
c
socket-fd.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include "config.h" #include "guacamole/error.h" #include "guacamole/socket.h" #include "wait-fd.h" #include <pthread.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <unistd.h> #ifdef ENABLE_WINSOCK #include <winsock2.h> #endif /** * Data associated with an open socket which writes to a file descriptor. */ typedef struct guac_socket_fd_data { /** * The associated file descriptor; */ int fd; /** * The number of bytes currently in the main write buffer. */ int written; /** * The main write buffer. Bytes written go here before being flushed * to the open file descriptor. */ char out_buf[GUAC_SOCKET_OUTPUT_BUFFER_SIZE]; /** * Lock which is acquired when an instruction is being written, and * released when the instruction is finished being written. */ pthread_mutex_t socket_lock; /** * Lock which protects access to the internal buffer of this socket, * guaranteeing atomicity of writes and flushes. */ pthread_mutex_t buffer_lock; } guac_socket_fd_data; /** * Writes the entire contents of the given buffer to the file descriptor * associated with the given socket, retrying as necessary until the whole * buffer is written, and aborting if an error occurs. * * @param socket * The guac_socket associated with the file descriptor to which the given * buffer should be written. * * @param buf * The buffer of data to write to the given guac_socket. * * @param count * The number of bytes within the given buffer. * * @return * The number of bytes written, which will be exactly the size of the given * buffer, or a negative value if an error occurs. */ ssize_t guac_socket_fd_write(guac_socket* socket, const void* buf, size_t count) { guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; const char* buffer = buf; /* Write until completely written */ while (count > 0) { int retval; #ifdef ENABLE_WINSOCK /* WSA only works with send() */ retval = send(data->fd, buffer, count, 0); #else /* Use write() for all other platforms */ retval = write(data->fd, buffer, count); #endif /* Record errors in guac_error */ if (retval < 0) { guac_error = GUAC_STATUS_SEE_ERRNO; guac_error_message = "Error writing data to socket"; return retval; } /* Advance buffer to next chunk */ buffer += retval; count -= retval; } return 0; } /** * Attempts to read from the underlying file descriptor of the given * guac_socket, populating the given buffer. * * @param socket * The guac_socket being read from. * * @param buf * The arbitrary buffer which we must populate with data. * * @param count * The maximum number of bytes to read into the buffer. * * @return * The number of bytes read, or -1 if an error occurs. */ static ssize_t guac_socket_fd_read_handler(guac_socket* socket, void* buf, size_t count) { guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; int retval; #ifdef ENABLE_WINSOCK /* Winsock only works with recv() */ retval = recv(data->fd, buf, count, 0); #else /* Use read() for all other platforms */ retval = read(data->fd, buf, count); #endif /* Record errors in guac_error */ if (retval < 0) { guac_error = GUAC_STATUS_SEE_ERRNO; guac_error_message = "Error reading data from socket"; } return retval; } /** * Flushes the contents of the output buffer of the given socket immediately, * without first locking access to the output buffer. This function must ONLY * be called if the buffer lock has already been acquired. * * @param socket * The guac_socket to flush. * * @return * Zero if the flush operation was successful, non-zero otherwise. */ static ssize_t guac_socket_fd_flush(guac_socket* socket) { guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Flush remaining bytes in buffer */ if (data->written > 0) { /* Write ALL bytes in buffer immediately */ if (guac_socket_fd_write(socket, data->out_buf, data->written)) return 1; data->written = 0; } return 0; } /** * Flushes the internal buffer of the given guac_socket, writing all data * to the underlying file descriptor. * * @param socket * The guac_socket to flush. * * @return * Zero if the flush operation was successful, non-zero otherwise. */ static ssize_t guac_socket_fd_flush_handler(guac_socket* socket) { int retval; guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Acquire exclusive access to buffer */ pthread_mutex_lock(&(data->buffer_lock)); /* Flush contents of buffer */ retval = guac_socket_fd_flush(socket); /* Relinquish exclusive access to buffer */ pthread_mutex_unlock(&(data->buffer_lock)); return retval; } /** * Writes the contents of the buffer to the output buffer of the given socket, * flushing the output buffer as necessary, without first locking access to the * output buffer. This function must ONLY be called if the buffer lock has * already been acquired. * * @param socket * The guac_socket to write the given buffer to. * * @param buf * The buffer to write to the given socket. * * @param count * The number of bytes in the given buffer. * * @return * The number of bytes written, or a negative value if an error occurs * during write. */ static ssize_t guac_socket_fd_write_buffered(guac_socket* socket, const void* buf, size_t count) { size_t original_count = count; const char* current = buf; guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Append to buffer, flush if necessary */ while (count > 0) { int chunk_size; int remaining = sizeof(data->out_buf) - data->written; /* If no space left in buffer, flush and retry */ if (remaining == 0) { /* Abort if error occurs during flush */ if (guac_socket_fd_flush(socket)) return -1; /* Retry buffer append */ continue; } /* Calculate size of chunk to be written to buffer */ chunk_size = count; if (chunk_size > remaining) chunk_size = remaining; /* Update output buffer */ memcpy(data->out_buf + data->written, current, chunk_size); data->written += chunk_size; /* Update provided buffer */ current += chunk_size; count -= chunk_size; } /* All bytes have been written, possibly some to the internal buffer */ return original_count; } /** * Appends the provided data to the internal buffer for future writing. The * actual write attempt will occur only upon flush, or when the internal buffer * is full. * * @param socket * The guac_socket being write to. * * @param buf * The arbitrary buffer containing the data to be written. * * @param count * The number of bytes contained within the buffer. * * @return * The number of bytes written, or -1 if an error occurs. */ static ssize_t guac_socket_fd_write_handler(guac_socket* socket, const void* buf, size_t count) { int retval; guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Acquire exclusive access to buffer */ pthread_mutex_lock(&(data->buffer_lock)); /* Write provided data to buffer */ retval = guac_socket_fd_write_buffered(socket, buf, count); /* Relinquish exclusive access to buffer */ pthread_mutex_unlock(&(data->buffer_lock)); return retval; } /** * Waits for data on the underlying file desriptor of the given socket to * become available such that the next read operation will not block. * * @param socket * The guac_socket to wait for. * * @param usec_timeout * The maximum amount of time to wait for data, in microseconds, or -1 to * potentially wait forever. * * @return * A positive value on success, zero if the timeout elapsed and no data is * available, or a negative value if an error occurs. */ static int guac_socket_fd_select_handler(guac_socket* socket, int usec_timeout) { /* Wait for data on socket */ guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; int retval = guac_wait_for_fd(data->fd, usec_timeout); /* Properly set guac_error */ if (retval < 0) { guac_error = GUAC_STATUS_SEE_ERRNO; guac_error_message = "Error while waiting for data on socket"; } else if (retval == 0) { guac_error = GUAC_STATUS_TIMEOUT; guac_error_message = "Timeout while waiting for data on socket"; } return retval; } /** * Frees all implementation-specific data associated with the given socket, but * not the socket object itself. * * @param socket * The guac_socket whose associated data should be freed. * * @return * Zero if the data was successfully freed, non-zero otherwise. This * implementation always succeeds, and will always return zero. */ static int guac_socket_fd_free_handler(guac_socket* socket) { guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Destroy locks */ pthread_mutex_destroy(&(data->socket_lock)); pthread_mutex_destroy(&(data->buffer_lock)); /* Close file descriptor */ close(data->fd); free(data); return 0; } /** * Acquires exclusive access to the given socket. * * @param socket * The guac_socket to which exclusive access is required. */ static void guac_socket_fd_lock_handler(guac_socket* socket) { guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Acquire exclusive access to socket */ pthread_mutex_lock(&(data->socket_lock)); } /** * Relinquishes exclusive access to the given socket. * * @param socket * The guac_socket to which exclusive access is no longer required. */ static void guac_socket_fd_unlock_handler(guac_socket* socket) { guac_socket_fd_data* data = (guac_socket_fd_data*) socket->data; /* Relinquish exclusive access to socket */ pthread_mutex_unlock(&(data->socket_lock)); } guac_socket* guac_socket_open(int fd) { pthread_mutexattr_t lock_attributes; /* Allocate socket and associated data */ guac_socket* socket = guac_socket_alloc(); guac_socket_fd_data* data = malloc(sizeof(guac_socket_fd_data)); /* Store file descriptor as socket data */ data->fd = fd; data->written = 0; socket->data = data; pthread_mutexattr_init(&lock_attributes); pthread_mutexattr_setpshared(&lock_attributes, PTHREAD_PROCESS_SHARED); /* Init locks */ pthread_mutex_init(&(data->socket_lock), &lock_attributes); pthread_mutex_init(&(data->buffer_lock), &lock_attributes); /* Set read/write handlers */ socket->read_handler = guac_socket_fd_read_handler; socket->write_handler = guac_socket_fd_write_handler; socket->select_handler = guac_socket_fd_select_handler; socket->lock_handler = guac_socket_fd_lock_handler; socket->unlock_handler = guac_socket_fd_unlock_handler; socket->flush_handler = guac_socket_fd_flush_handler; socket->free_handler = guac_socket_fd_free_handler; return socket; }
1d8840d990c1a08b8ae464cc490d136b4de50b17
2c73a693c2b3c162eae2ab94f649d8c4494878ba
/components/lvgl/exts/lv_gif/lv_gif.c
b639a74a2b1da688f2be2cd309b16231e581bcda
[ "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
4,764
c
lv_gif.c
/** * @file lv_gifenc.c * */ /********************* * INCLUDES *********************/ #include "gifdec.h" /********************* * DEFINES *********************/ #define LV_OBJX_NAME "lv_gif" /********************** * TYPEDEFS **********************/ typedef struct { lv_img_ext_t img_ext; gd_GIF *gif; lv_task_t * task; lv_img_dsc_t imgdsc; uint32_t last_call; }lv_gif_ext_t; /********************** * STATIC PROTOTYPES **********************/ static void next_frame_task_cb(lv_task_t * t); static lv_res_t lv_gif_signal(lv_obj_t * img, lv_signal_t sign, void * param); /********************** * STATIC VARIABLES **********************/ static lv_signal_cb_t ancestor_signal; /********************** * MACROS **********************/ /********************** * GLOBAL FUNCTIONS **********************/ lv_obj_t * lv_gif_create_from_file(lv_obj_t * parent, const char * path) { lv_obj_t * img = lv_img_create(parent, NULL); lv_gif_ext_t * ext = lv_obj_allocate_ext_attr(img, sizeof(lv_gif_ext_t)); LV_ASSERT_MEM(ext); if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(img); lv_obj_set_signal_cb(img, lv_gif_signal); ext->gif = gd_open_gif_file(path); if(ext->gif == NULL) return img; ext->imgdsc.data = ext->gif->canvas; ext->imgdsc.header.always_zero = 0; ext->imgdsc.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; ext->imgdsc.header.h = ext->gif->height; ext->imgdsc.header.w = ext->gif->width; ext->last_call = lv_tick_get(); lv_img_set_src(img, &ext->imgdsc); ext->task = lv_task_create(next_frame_task_cb, 10, LV_TASK_PRIO_HIGH, img); next_frame_task_cb(ext->task); /*Immediately process the first frame*/ return img; } lv_obj_t * lv_gif_create_from_data(lv_obj_t * parent, const void * data) { lv_obj_t * img = lv_img_create(parent, NULL); lv_gif_ext_t * ext = lv_obj_allocate_ext_attr(img, sizeof(lv_gif_ext_t)); LV_ASSERT_MEM(ext); if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(img); lv_obj_set_signal_cb(img, lv_gif_signal); ext->gif = gd_open_gif_data(data); if(ext->gif == NULL) return img; ext->imgdsc.data = ext->gif->canvas; ext->imgdsc.header.always_zero = 0; ext->imgdsc.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; ext->imgdsc.header.h = ext->gif->height; ext->imgdsc.header.w = ext->gif->width; ext->last_call = lv_tick_get(); lv_img_set_src(img, &ext->imgdsc); ext->task = lv_task_create(next_frame_task_cb, 10, LV_TASK_PRIO_HIGH, img); next_frame_task_cb(ext->task); /*Immediately process the first frame*/ return img; } void lv_gif_restart(lv_obj_t * gif) { lv_gif_ext_t * ext = lv_obj_get_ext_attr(gif); lv_task_set_prio(ext->task, LV_TASK_PRIO_HIGH); gd_rewind(ext->gif); } /********************** * STATIC FUNCTIONS **********************/ static void next_frame_task_cb(lv_task_t * t) { lv_obj_t * img = t->user_data; lv_gif_ext_t * ext = lv_obj_get_ext_attr(img); uint32_t elaps = lv_tick_elaps(ext->last_call); if(elaps < ext->gif->gce.delay * 10) return; ext->last_call = lv_tick_get(); int has_next = gd_get_frame(ext->gif); if(has_next == 0) { /*It was the last repeat*/ if(ext->gif->loop_count == 1) { lv_res_t res = lv_signal_send(img, LV_SIGNAL_LEAVE, NULL); if(res != LV_RES_OK) return; res = lv_event_send(img, LV_EVENT_LEAVE, NULL); if(res != LV_RES_OK) return; } else { if(ext->gif->loop_count > 1) ext->gif->loop_count--; gd_rewind(ext->gif); } } gd_render_frame(ext->gif, ext->imgdsc.data); lv_img_cache_invalidate_src(lv_img_get_src(img)); lv_obj_invalidate(img); } /** * Signal function of the image * @param img pointer to a image object * @param sign a signal type from lv_signal_t enum * @param param pointer to a signal specific variable * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted */ static lv_res_t lv_gif_signal(lv_obj_t * img, lv_signal_t sign, void * param) { lv_res_t res; /* Include the ancient signal function */ res = ancestor_signal(img, sign, param); if(res != LV_RES_OK) return res; if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); lv_gif_ext_t * ext = lv_obj_get_ext_attr(img); if(sign == LV_SIGNAL_CLEANUP) { lv_img_cache_invalidate_src(&ext->imgdsc); gd_close_gif(ext->gif); lv_task_del(ext->task); } else if (sign == LV_SIGNAL_LEAVE) { lv_task_set_prio(ext->task, LV_TASK_PRIO_OFF); } return LV_RES_OK; }
087915e33541fd381e86501faa2e02754b723439
6f006cc43df343e44494fab7b693366ff587be7f
/components/model.c
42141bfb6d53c9944801dce4b6d77f50192c3dde
[ "MIT" ]
permissive
EvilPudding/candle
a78cb0101a650c94755ca34ccb0eadf34e97feb8
a58afb0403776b1e52c90345baf9985f6931244e
refs/heads/master
2023-09-04T05:45:24.501633
2022-11-12T23:02:27
2022-11-12T23:02:27
117,313,783
402
20
MIT
2019-09-15T21:06:54
2018-01-13T04:26:37
C
UTF-8
C
false
false
28,369
c
model.c
#include "model.h" #include "node.h" #include "spatial.h" #include "light.h" #include "../utils/nk.h" #include "../utils/drawable.h" #include "../candle.h" #include "../systems/editmode.h" #ifdef _WIN32 #define CANDLE_NAN NAN #else #define CANDLE_NAN (0.f / 0.f) #endif static mat_t *g_missing_mat = NULL; static int c_model_position_changed(c_model_t *self); static int paint_3d(mesh_t *mesh, vertex_t *vert); static int paint_2d(mesh_t *mesh, vertex_t *vert); int c_model_menu(c_model_t *self, void *ctx); static vs_t *g_model_vs; static vs_t *g_widget_vs; struct edit_tool g_edit_tools[32]; int g_edit_tools_count = 0; vs_t *model_vs() { if(!g_model_vs) { g_model_vs = vs_new("model", false, 1, vertex_modifier_new( " {\n" "#ifdef MESH4\n" " float Y = cos(ANG4);\n" " float W = sin(ANG4);\n" " pos = vec4(vec3(P.x, P.y * Y + P.w * W, P.z), 1.0);\n" "#endif\n" " mat4 MV = camera(view) * M;\n" " $vertex_normal = (MV * vec4( N, 0.0f)).xyz;\n" " $vertex_tangent = (MV * vec4(TG, 0.0f)).xyz;\n" " pos = M * pos;\n" " $vertex_world_position = pos.xyz;\n" " pos = camera(view) * pos;\n" " $vertex_position = pos.xyz;\n" " pos = camera(projection) * pos;\n" " }\n" )); } return g_model_vs; } vs_t *widget_vs() { if(!g_widget_vs) { g_widget_vs = vs_new("widget", false, 1, vertex_modifier_new( " {\n" "#ifdef MESH4\n" " float Y = cos(ANG4);\n" " float W = sin(ANG4);\n" " pos = vec4(vec3(P.x, P.y * Y + P.w * W, P.z), 1.0);\n" "#endif\n" " mat4 MV = camera(view) * M;\n" " $vertex_normal = (MV * vec4( N, 0.0f)).xyz;\n" " $vertex_tangent = (MV * vec4(TG, 0.0f)).xyz;\n" " pos.xyz *= length($obj_pos - camera(pos));\n" " pos = M * pos;\n" " $vertex_world_position = pos.xyz;\n" " pos = camera(view) * pos;\n" " $vertex_position = pos.xyz;\n" " pos = camera(projection) * pos;\n" " }\n" )); } return g_widget_vs; } static int tool_circle_gui(void *ctx, struct conf_circle *conf) { nk_property_float(ctx, "#radius:", -10000, &conf->radius, 10000, 0.1, 0.05); nk_property_int(ctx, "#segments:", 1, &conf->segments, 1000, 1, 1); return 0; } static int tool_sphere_gui(void *ctx, void *conf) { return 0; } static int tool_subdivide_gui(void *ctx, struct conf_subdivide *conf) { nk_property_int(ctx, "#steps:", 0, &conf->steps, 4, 1, 1); return 0; } static int tool_icosphere_gui(void *ctx, struct conf_ico *conf) { nk_property_float(ctx, "#radius:", -10000, &conf->radius, 10000, 0.1, 0.05); nk_property_int(ctx, "#subdivisions:", 0, &conf->subdivisions, 4, 1, 1); return 0; } static int tool_disk_gui(void *ctx, struct conf_disk *conf) { nk_property_float(ctx, "#radius:", -10000, &conf->radius1, 10000, 0.1, 0.05); nk_property_float(ctx, "#inner radius:", -10000, &conf->radius2, 10000, 0.1, 0.05); nk_property_int(ctx, "#segments:", 1, &conf->segments, 1000, 1, 1); return 0; } static int tool_torus_gui(void *ctx, struct conf_torus *conf) { nk_property_float(ctx, "#radius:", -10000, &conf->radius1, 10000, 0.1, 0.05); nk_property_float(ctx, "#inner radius:", -10000, &conf->radius2, 10000, 0.1, 0.05); nk_property_int(ctx, "#segments:", 1, &conf->segments1, 1000, 1, 1); nk_property_int(ctx, "#inner segments:", 1, &conf->segments2, 1000, 1, 1); return 0; } static int tool_cube_gui(void *ctx, struct conf_cube *conf) { nk_property_float(ctx, "#size:", -10000, &conf->size, 10000, 0.1, 0.05); return 0; } static int tool_spherize_gui(void *ctx, struct conf_spherize *conf) { /* nk_property_float(ctx, "#scale:", -10000, &conf->scale, 10000, 0.1, 0.05); */ nk_property_float(ctx, "#roundness:", 0, &conf->roundness, 1, 0.01, 0.01); return 0; } static int tool_extrude_gui(void *ctx, struct conf_extrude *conf) { nk_layout_row_dynamic(ctx, 25, 1); nk_property_float(ctx, "#x:", -10000, &conf->offset.x, 10000, 0.1, 0.05); nk_property_float(ctx, "#y:", -10000, &conf->offset.y, 10000, 0.1, 0.05); nk_property_float(ctx, "#z:", -10000, &conf->offset.z, 10000, 0.1, 0.05); #ifdef MESH4 nk_property_float(ctx, "#w:", -10000, &conf->offset.w, 10000, 0.1, 0.05); #endif nk_property_float(ctx, "#scale:", -10000, &conf->scale, 10000, 0.1, 0.05); nk_property_int(ctx, "#steps:", 1, &conf->steps, 1000, 1, 1); /* 0.1+0.9*math.pow(x*2-1,2) */ nk_edit_string_zero_terminated(ctx, NK_EDIT_FIELD, conf->scale_e, sizeof(conf->scale_e), nk_filter_ascii); nk_edit_string_zero_terminated(ctx, NK_EDIT_FIELD, conf->offset_e, sizeof(conf->offset_e), nk_filter_ascii); return 0; } static int tool_deform_gui(void *ctx, struct conf_deform *conf) { nk_layout_row_dynamic(ctx, 25, 1); conf->normal = nk_check_label(ctx, "normal", conf->normal); if(!conf->normal) { nk_property_float(ctx, "#x:", -10000, &conf->direction.x, 10000, 0.1, 0.05); nk_property_float(ctx, "#y:", -10000, &conf->direction.y, 10000, 0.1, 0.05); nk_property_float(ctx, "#z:", -10000, &conf->direction.z, 10000, 0.1, 0.05); #ifdef MESH4 nk_property_float(ctx, "#w:", -10000, &conf->direction.w, 10000, 0.1, 0.05); #endif } nk_edit_string_zero_terminated(ctx, NK_EDIT_FIELD, conf->deform_e, sizeof(conf->deform_e), nk_filter_ascii); return 0; } static int tool_simplify_gui(void *ctx, struct conf_simplify *conf) { nk_layout_row_dynamic(ctx, 25, 1); nk_property_float(ctx, "#rate:", 0.f, &conf->rate, 1.f, 0.0001f, 0.01f); nk_property_float(ctx, "#eps:", 0.f, &conf->eps, 10.f, 0.1, 0.05); return 0; } static mesh_t *tool_circle_edit(mesh_t *state, struct conf_circle *conf) { state = mesh_clone(state); mesh_circle(state, conf->radius, conf->segments, VEC3(0.0, 1.0, 0.0)); mesh_select(state, SEL_EDITING, MESH_VERT, -1); mesh_for_each_selected(state, MESH_VERT, (iter_cb)paint_2d, NULL); return state; } static int tool_sphere_edit(void) { return 0; } static mesh_t *tool_spherize_edit(mesh_t *last, struct conf_spherize *conf) { mesh_t *state = mesh_clone(last); mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_spherize(state, conf->roundness); return state; } static mesh_t *tool_subdivide_edit( mesh_t *last, struct conf_subdivide *new, mesh_t *state, struct conf_subdivide *old) { if(state && new->steps > old->steps) { mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_subdivide(state, new->steps - old->steps); mesh_select(state, SEL_EDITING, MESH_FACE, -1); } else { state = mesh_clone(last); mesh_lock(state); if(new->steps) { mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_subdivide(state, new->steps); } mesh_unlock(state); } return state; } static mesh_t *tool_icosphere_edit( mesh_t *last, struct conf_ico *new, mesh_t *state, struct conf_ico *old) { if(state && (new->subdivisions > old->subdivisions && new->radius == old->radius)) { mesh_lock(state); mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_subdivide(state, new->subdivisions - old->subdivisions); mesh_spherize(state, 1); mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_for_each_selected(state, MESH_VERT, (iter_cb)paint_3d, NULL); mesh_unlock(state); } else { state = mesh_clone(last); mesh_lock(state); mesh_ico(state, new->radius / 2); if(new->subdivisions) { mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_subdivide(state, new->subdivisions); } mesh_spherize(state, 1); mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_for_each_selected(state, MESH_VERT, (iter_cb)paint_3d, NULL); mesh_unlock(state); } return state; } static mesh_t *tool_disk_edit(mesh_t *mesh, struct conf_disk *conf) { mesh = mesh_clone(mesh); mesh_lock(mesh); mesh_disk(mesh, conf->radius1, conf->radius2, conf->segments, VEC3(0.0, 1.0, 0.0)); mesh_select(mesh, SEL_EDITING, MESH_FACE, -1); mesh->has_texcoords = 0; mesh_unlock(mesh); return mesh; } static mesh_t *tool_torus_edit(mesh_t *mesh, struct conf_torus *conf) { /* mesh = mesh_clone(mesh); */ mesh = mesh_torus(conf->radius1, conf->radius2, conf->segments1, conf->segments2); return mesh; } static vec2_t encode_normal(vec3_t n) { float p; n = vec3_norm(n); p = sqrtf(n.z * 8.0f + 8.0f); if(p == 0) return vec2(0.0f, 0.0f); /* printf("%f ", p); vec3_print(n); */ return vec2_add_number(vec2_div_number(vec3_xy(n), p), 0.5f); } static int paint_2d(mesh_t *mesh, vertex_t *vert) { vec3_t norm = vec3_get_unit(vecN_xyz(vert->pos)); vec2_t n = encode_normal(norm); vert->color = vec4(vert->pos.y > 0, n.y, n.x, 1.0f); /* vert->color = vec4(_vec2(n), vert->pos.y > 0, 1.0f); */ return 1; } static int paint_3d(mesh_t *mesh, vertex_t *vert) { vec3_t norm = vec3_get_unit(vecN_xyz(vert->pos)); vec2_t n = encode_normal(norm); vert->color = vec4(vert->pos.z > 0, n.y, n.x, 1.0f); /* vert->color.xyz = vec3_add_number(vec3_scale(vert->pos, 0.5f), 0.5f); */ /* vert->color.a = vert->pos.w; */ return 1; } static mesh_t *tool_cube_edit(mesh_t *mesh, struct conf_cube *conf) { mesh = mesh_clone(mesh); mesh_lock(mesh); mesh_cube(mesh, conf->size, 1); mesh_select(mesh, SEL_EDITING, MESH_VERT, -1); mesh->has_texcoords = 0; mesh_for_each_selected(mesh, MESH_VERT, (iter_cb)paint_3d, NULL); mesh_unlock(mesh); return mesh; } struct int_int {int a, b;}; static float interpret_scale(mesh_t *self, float x, struct int_int *interpreters) { float y = CANDLE_NAN; struct set_var var = {"x"}; var.value = x; emit(ref("expr_var"), &var, NULL); emit(ref("expr_eval"), &interpreters->a, &y); if(y != y) return 0.0f; return y; } static float interpret_offset(mesh_t *self, float r, struct int_int *interpreters) { float y = CANDLE_NAN; struct set_var var = {"r"}; var.value = r; emit(ref("expr_var"), &var, NULL); emit(ref("expr_eval"), &interpreters->b, &y); if (y != y) return 0.0f; return y; } static mesh_t *tool_extrude_edit( mesh_t *last, struct conf_extrude *new, mesh_t *state, struct conf_extrude *old) { float result; struct int_int args; struct set_var var_r = {"r"}; struct set_var var_x = {"x"}; var_r.value = 0.0f; var_x.value = 0.0f; emit(ref("expr_var"), &var_r, NULL); emit(ref("expr_var"), &var_x, NULL); if(strcmp(new->scale_e, old->scale_e)) { if(old->scale_f) emit(ref("expr_del"), &old->scale_f, NULL); emit(ref("expr_load"), new->scale_e, &new->scale_f); if(new->scale_f == 0) return state; result = CANDLE_NAN; emit(ref("expr_eval"), &new->scale_f, &result); if(result != result) { new->scale_f = 0; return state; } } if(strcmp(new->offset_e, old->offset_e)) { if(old->offset_f) emit(ref("expr_del"), &old->offset_f, NULL); emit(ref("expr_load"), new->offset_e, &new->offset_f); if(new->offset_f == -1) return state; result = CANDLE_NAN; emit(ref("expr_eval"), &new->offset_f, &result); if(result != result) { new->offset_f = 0; return state; } } state = mesh_clone(last); args.a = new->scale_f; args.b = new->offset_f; mesh_lock(state); if(vector_count(state->faces)) { #ifdef MESH4 if(!state->triangulated) { mesh_select(state, SEL_EDITING, MESH_FACE, -1); mesh_triangulate(state); } mesh_extrude_faces(state, new->steps, new->offset, new->scale, new->scale_f ? (modifier_cb)interpret_scale : NULL, new->offset_f ? (modifier_cb)interpret_offset : NULL, &args); mesh_for_each_selected(state, MESH_VERT, (iter_cb)paint_3d, NULL); mesh_remove_lone_faces(state); #endif } else { mesh_extrude_edges(state, new->steps, new->offset, new->scale, new->scale_f ? (modifier_cb)interpret_scale : NULL, new->offset_f ? (modifier_cb)interpret_offset : NULL, &args); mesh_for_each_selected(state, MESH_VERT, (iter_cb)paint_2d, NULL); mesh_remove_lone_edges(state); mesh_triangulate(state); } mesh_unlock(state); return state; } static int deform(mesh_t *mesh, vertex_t *vert, struct conf_deform *conf) { float result = CANDLE_NAN; struct set_var var_x = {"x"}; struct set_var var_y = {"y"}; struct set_var var_z = {"z"}; #ifdef MESH4 struct set_var var_w = {"w"}; #endif vecN_t direction = /*conf->normal ? vert->n :*/ conf->direction; var_x.value = vert->pos.x; var_y.value = vert->pos.y; var_z.value = vert->pos.z; #ifdef MESH4 var_w.value = vert->pos.w; #endif emit(ref("expr_var"), &var_x, NULL); emit(ref("expr_var"), &var_y, NULL); emit(ref("expr_var"), &var_z, NULL); #ifdef MESH4 emit(ref("expr_var"), &var_w, NULL); #endif emit(ref("expr_eval"), &conf->deform_s, &result); if(vert->pos.y > 0.0f) { vecN_(print)(vert->pos); } if(result != result) return 1; vert->pos = vecN_(add)(vert->pos, vecN_(scale)(direction, result)); return 1; } static mesh_t *tool_deform_edit( mesh_t *last, struct conf_deform *new, mesh_t *state, struct conf_deform *old) /* (struct conf_deform){0, VEC3(0, 1, 0), "1"} */ { float result; struct set_var var_x = {"x"}; struct set_var var_y = {"y"}; struct set_var var_z = {"z"}; #ifdef MESH4 struct set_var var_w = {"w"}; #endif var_x.value = 0.0f; var_y.value = 0.0f; var_z.value = 0.0f; #ifdef MESH4 var_w.value = 0.0f; #endif emit(ref("expr_var"), &var_x, NULL); emit(ref("expr_var"), &var_y, NULL); emit(ref("expr_var"), &var_z, NULL); #ifdef MESH4 emit(ref("expr_var"), &var_w, NULL); #endif if(strcmp(new->deform_e, old->deform_e)) { if(old->deform_s) emit(ref("expr_del"), &old->deform_s, NULL); emit(ref("expr_load"), new->deform_e, &new->deform_s); if(new->deform_s == 0) return state; result = CANDLE_NAN; emit(ref("expr_eval"), &new->deform_s, &result); if(result != result) { new->deform_s = 0; return state; } } state = mesh_clone(last); if(new->deform_s) { mesh_select(state, SEL_EDITING, MESH_VERT, -1); mesh_lock(state); mesh_for_each_selected(state, MESH_VERT, (iter_cb)deform, new); mesh_unlock(state); } return state; } static mesh_t *tool_simplify_edit( mesh_t *last, struct conf_simplify *new, mesh_t *state, struct conf_simplify *old) { state = mesh_clone(last); simp_test(state, new->rate, new->eps); return state; } static void c_model_init(c_model_t *self) { if(!g_missing_mat) { g_missing_mat = mat_new("missing", "default"); mat4f(g_missing_mat, ref("albedo.color"), vec4(0.0, 0.9, 1.0, 1.0)); } self->visible_group = ref("visible"); self->shadow_group = ref("shadow"); self->transparent_group = ref("transparent"); self->selectable_group = ref("selectable"); self->visible = 1; self->history = vector_new(sizeof(mesh_history_t), FIXED_ORDER, NULL, NULL); } void c_model_init_drawables(c_model_t *self) { drawable_init(&self->draw, self->visible_group); drawable_add_group(&self->draw, ref("selectable")); drawable_set_entity(&self->draw, c_entity(self)); drawable_set_vs(&self->draw, model_vs()); } void c_model_run_command(c_model_t *self, mesh_t *last, mesh_history_t *cmd) { struct edit_tool *tool = &g_edit_tools[cmd->type]; mesh_t *result = tool->edit(last, cmd->conf_new, cmd->state, cmd->conf_old); if(result != cmd->state) { mesh_destroy(cmd->state); } memcpy(cmd->conf_old, cmd->conf_new, tool->size); cmd->state = result; } /* FIXME this function should not be needed */ /* update id change should be enough for mesh to update */ void c_model_dirty(c_model_t *self) { drawable_set_mesh(&self->draw, NULL); drawable_set_mesh(&self->draw, self->mesh); } void c_model_propagate_edit(c_model_t *self, int cmd_id) { int32_t i; int32_t last_update_id; mesh_t *last; if(cmd_id >= vector_count(self->history)) return; last_update_id = 0; if(self->mesh) { last_update_id = self->mesh->update_id; } /* int update_id = -1; */ if(self->base_mesh == self->mesh && self->mesh) { self->base_mesh = mesh_clone(self->base_mesh); } last = self->base_mesh; if(cmd_id > 0) { mesh_history_t *prev = vector_get(self->history, cmd_id - 1); last = prev->state; } if(last) { last->update_id++; } for(i = cmd_id; i < vector_count(self->history); i++) { mesh_history_t *cmd = vector_get(self->history, i); if(i > cmd_id) { mesh_destroy(cmd->state); cmd->state = NULL; } c_model_run_command(self, last, cmd); last = cmd->state; } if(!self->mesh && last) self->mesh = mesh_new(); mesh_lock(self->mesh); mesh_assign(self->mesh, last); self->mesh->update_id = last_update_id + 1; mesh_unlock(self->mesh); c_model_dirty(self); entity_signal_same(c_entity(self), sig("model_changed"), NULL, NULL); } void c_model_remove_edit(c_model_t *self, int cmd_id) { mesh_history_t *cmd = vector_get(self->history, cmd_id); if(cmd->state) mesh_destroy(cmd->state); vector_remove(self->history, cmd_id); c_model_propagate_edit(self, cmd_id); } void c_model_edit(c_model_t *self, mesh_edit_t type, geom_t target) { struct edit_tool *tool = &g_edit_tools[type]; mesh_history_t command = {0}; command.target = target; command.type = type; command.conf_new = calloc(1, tool->size); command.conf_old = calloc(1, tool->size); if(tool->defaults) { memcpy(command.conf_new, tool->defaults, tool->size); } vector_add(self->history, &command); c_model_propagate_edit(self, vector_count(self->history) - 1); } /* c_model_t *c_model_paint(c_model_t *self, int layer, mat_t *mat) */ /* { */ /* self->layers[layer].mat = mat; */ /* /1* drawable_t *gl = self->draw; *1/ */ /* /1* gl->groups[layer].mat = mat; *1/ */ /* return self; */ /* } */ c_model_t *c_model_cull_invert(c_model_t *self) { self->draw.cull = (~self->draw.cull) & 0x3; drawable_model_changed(&self->draw); return self; } c_model_t *c_model_cull_face(c_model_t *self, bool_t cull_front, bool_t cull_back) { drawable_set_cull(&self->draw, cull_front | (cull_back << 1)); return self; } void c_model_set_vs(c_model_t *self, vs_t *vs) { drawable_set_vs(&self->draw, vs); } void c_model_set_xray(c_model_t *self, bool_t xray) { drawable_set_xray(&self->draw, xray); } c_model_t *c_model_smooth(c_model_t *self, float smooth) { /* self->layers[layer].smooth_angle = smooth; */ self->mesh->smooth_angle = smooth; mesh_modified(self->mesh); drawable_model_changed(&self->draw); return self; } c_model_t *c_model_wireframe(c_model_t *self, bool_t wireframe) { drawable_set_wireframe(&self->draw, wireframe); return self; } /* static int visible_type_filter(drawable_t *drawable) */ /* { */ /* } */ void c_model_update_mat(c_model_t *self) { if (self->mat) { int transp = mat_is_transparent(self->mat); if(transp) { drawable_remove_group(&self->draw, self->visible_group); drawable_add_group(&self->draw, self->transparent_group); } else { drawable_remove_group(&self->draw, self->transparent_group); drawable_add_group(&self->draw, self->visible_group); } if(self->selectable_group) { drawable_add_group(&self->draw, self->selectable_group); } if(self->shadow_group && self->cast_shadow) { drawable_add_group(&self->draw, self->shadow_group); } self->mat_update_id = self->mat->update_id; } drawable_set_mat(&self->draw, self->mat); } void c_model_set_groups(c_model_t *self, uint32_t visible, uint32_t shadow, uint32_t transp, uint32_t selectable) { drawable_remove_group(&self->draw, self->selectable_group); drawable_remove_group(&self->draw, self->transparent_group); drawable_remove_group(&self->draw, self->visible_group); drawable_remove_group(&self->draw, self->shadow_group); self->visible_group = visible; self->transparent_group = transp; self->selectable_group = selectable; self->shadow_group = shadow; c_model_update_mat(self); } void c_model_set_mat(c_model_t *self, mat_t *mat) { if(!mat) { mat = g_mats[0]; } if(self->mat != mat) { self->mat = mat; c_model_update_mat(self); } } void c_model_set_cast_shadow(c_model_t *self, bool_t cast_shadow) { if(self->cast_shadow == cast_shadow) return; self->cast_shadow = cast_shadow; if(!self->cast_shadow) { drawable_remove_group(&self->draw, self->shadow_group); } else { drawable_add_group(&self->draw, self->shadow_group); } } void c_model_set_visible(c_model_t *self, bool_t visible) { self->visible = visible; drawable_set_mesh(&self->draw, visible ? self->mesh : NULL); } void c_model_set_mesh(c_model_t *self, mesh_t *mesh) { /* FIXME this is broken when the mesh is destroyed */ if(mesh != self->mesh) { mesh_t *old_mesh = self->mesh; self->mesh = mesh; self->base_mesh = mesh; if(self->visible) { drawable_set_mesh(&self->draw, mesh); } if(old_mesh) mesh_destroy(old_mesh); } } int c_model_created(c_model_t *self) { drawable_model_changed(&self->draw); return CONTINUE; } int c_model_tool(c_model_t *self, void *ctx) { int i; int sys = c_entity(self) == SYS; for(i = 0; i < g_edit_tools_count; i++) { struct edit_tool *tool = &g_edit_tools[i]; if(!sys && !tool->require_sys) { if(nk_button_label(ctx, tool->name)) { c_model_edit(self, i, MESH_FACE); return STOP; } } else if(sys && tool->require_sys) { if(nk_button_label(ctx, tool->name)) { entity_t ent = entity_new(c_model_new(NULL, mat_new("k", "default"), 1, 1)); c_editmode_select(c_editmode(&SYS), ent); c_model_edit(c_model(&ent), i, MESH_FACE); return STOP; } } } return CONTINUE; } int c_model_menu(c_model_t *self, void *ctx) { int i; int new_value; int changes = 0; float smooth; int cull_back; int cull_front; mesh_t *mesh; new_value = nk_check_label(ctx, "Visible", self->visible); if(new_value != self->visible) { c_model_set_visible(self, new_value); changes = 1; } new_value = nk_check_label(ctx, "Cast shadow", self->cast_shadow); if(new_value != self->cast_shadow) { c_model_set_cast_shadow(self, new_value); changes = 1; } /* if(nk_tree_push(ctx, NK_TREE_TAB, "Edit", NK_MAXIMIZED)) */ /* { */ if(self->mesh) { for(i = 0; i < vector_count(self->history); i++) { mesh_history_t *cmd = vector_get(self->history, i); struct edit_tool *tool = &g_edit_tools[cmd->type]; if(nk_tree_push_id(ctx, NK_TREE_TAB, tool->name, NK_MAXIMIZED, i)) { tool->gui(ctx, cmd->conf_new); if(nk_button_label(ctx, "remove")) { c_model_remove_edit(self, i); nk_tree_pop(ctx); break; } if(memcmp(cmd->conf_old, cmd->conf_new, tool->size)) { c_model_propagate_edit(self, i); } nk_tree_pop(ctx); } } /* nk_tree_pop(ctx); */ /* } */ mesh = self->mesh; new_value = nk_check_label(ctx, "Wireframe", self->draw.wireframe); if(new_value != self->draw.wireframe) { drawable_set_wireframe(&self->draw, new_value); } new_value = nk_check_label(ctx, "Receive Shadows", self->draw.receive_shadows); if(new_value != self->draw.receive_shadows) { drawable_set_receive_shadows(&self->draw, new_value); } smooth = mesh->smooth_angle; nk_property_float(ctx, "#smooth:", 0.0f, &smooth, 1.0f, 0.05f, 0.05f); if(smooth != mesh->smooth_angle) { mesh->smooth_angle = smooth; /* self->mesh->update_id++; */ mesh_modified(mesh); mesh_update(mesh); } cull_front = self->draw.cull & 0x1; cull_back = self->draw.cull >> 0x1; new_value = nk_check_label(ctx, "Cull front", cull_front); if(new_value != cull_front) { drawable_set_cull(&self->draw, cull_back | new_value); } new_value = nk_check_label(ctx, "Cull back", cull_back); if(new_value != cull_back) { drawable_set_cull(&self->draw, cull_front | (new_value << 1)); } } if(self->mat && self->mat->name[0] != '_') { changes |= mat_menu(self->mat, ctx); } if(changes) { drawable_model_changed(&self->draw); } /* nk_tree_pop(ctx); */ return CONTINUE; } static int c_model_position_changed(c_model_t *self) { /* mat4_t model = node->model; */ /* if(self->scale_dist > 0.0f) */ /* { */ /* vec3_t pos = mat4_mul_vec4(model, vec4(0,0,0,1)).xyz; */ /* float dist = vec3_dist(pos, c_renderer(&SYS)->bound_camera_pos); */ /* mat4_t model = mat4_scale_aniso(model, vec3(dist * self->scale_dist)); */ /* } */ self->modified = 1; return CONTINUE; } vs_t *sprite_vs(void); static int c_model_pre_draw(c_model_t *self) { c_node_t *node = c_node(self); if(!node) return CONTINUE; if (c_node_update_model(node)) { if(entity_exists(node->unpack_inheritance) && node->unpack_inheritance != SYS) { drawable_set_entity(&self->draw, node->unpack_inheritance); } else { drawable_set_entity(&self->draw, entity_null); } } if (self->mat && self->mat_update_id != self->mat->update_id) { c_model_update_mat(self); } if(self->modified) { self->modified = 0; drawable_set_transform(&self->draw, node->model); #ifdef MESH4 drawable_set_angle4(&self->draw, node->angle4); #endif } return CONTINUE; } void add_tool(char *name, tool_gui_cb gui, tool_edit_cb edit, size_t size, void *defaults, int require_sys) { struct edit_tool tool = {0}; tool.gui = gui; tool.edit = edit; tool.size = size; strcpy(tool.name, name); tool.ref = ref(name); tool.require_sys = require_sys; if(defaults) { tool.defaults = calloc(1, size); memcpy(tool.defaults, defaults, size); } g_edit_tools[g_edit_tools_count++] = tool; } static void c_model_destroy(c_model_t *self) { int i; drawable_set_mesh(&self->draw, NULL); for(i = 0; i < vector_count(self->history); i++) { mesh_history_t *cmd = vector_get(self->history, i); if(cmd->state) { mesh_destroy(cmd->state); cmd->state = NULL; } } if(self->mesh) mesh_destroy(self->mesh); } void ct_model(ct_t *self) { struct conf_circle circle_opts = {2, 10}; struct conf_cube cube_opts = {1.0f}; struct conf_torus torus_opts = {1.0f, 0.2f, 30, 20}; struct conf_disk disk_opts = {2.0f, 0.2f, 10}; struct conf_ico ico_opts = {1.0f, 0}; struct conf_extrude extrude_opts = {VEC3i(0.0f, 2.0f, 0.0f), 1.0f, 1}; struct conf_spherize spherize_opts = {1, 1}; struct conf_subdivide subdivide_opts = {1}; struct conf_deform deform_opts = {0, VEC3i(0, 1, 0), "1"}; struct conf_simplify simplify_opts = {0.5f, 0.f}; ct_init(self, "model", sizeof(c_model_t)); ct_set_init(self, (init_cb)c_model_init); ct_set_destroy(self, (destroy_cb)c_model_destroy); ct_add_dependency(self, ct_node); ct_add_listener(self, ENTITY, 0, ref("entity_created"), c_model_created); ct_add_listener(self, WORLD, 0, ref("component_menu"), c_model_menu); ct_add_listener(self, WORLD, 0, ref("component_tool"), c_model_tool); ct_add_listener(self, WORLD, 100, ref("world_pre_draw"), c_model_pre_draw); ct_add_listener(self, ENTITY, 0, ref("node_changed"), c_model_position_changed); add_tool("circle", (tool_gui_cb)tool_circle_gui, (tool_edit_cb)tool_circle_edit, sizeof(struct conf_circle), &circle_opts, 1); add_tool("sphere", (tool_gui_cb)tool_sphere_gui, (tool_edit_cb)tool_sphere_edit, sizeof(struct conf_sphere), NULL, 1); add_tool("cube", (tool_gui_cb)tool_cube_gui, (tool_edit_cb)tool_cube_edit, sizeof(struct conf_cube), &cube_opts, 1); add_tool("torus", (tool_gui_cb)tool_torus_gui, (tool_edit_cb)tool_torus_edit, sizeof(struct conf_torus), &torus_opts, 1); add_tool("disk", (tool_gui_cb)tool_disk_gui, (tool_edit_cb)tool_disk_edit, sizeof(struct conf_disk), &disk_opts, 1); add_tool("icosphere", (tool_gui_cb)tool_icosphere_gui, (tool_edit_cb)tool_icosphere_edit, sizeof(struct conf_ico), &ico_opts, 1); add_tool("extrude", (tool_gui_cb)tool_extrude_gui, (tool_edit_cb)tool_extrude_edit, sizeof(struct conf_extrude), &extrude_opts, 0); add_tool("spherize", (tool_gui_cb)tool_spherize_gui, (tool_edit_cb)tool_spherize_edit, sizeof(struct conf_spherize), &spherize_opts, 0); add_tool("subdivide", (tool_gui_cb)tool_subdivide_gui, (tool_edit_cb)tool_subdivide_edit, sizeof(struct conf_subdivide), &subdivide_opts, 0); add_tool("deform", (tool_gui_cb)tool_deform_gui, (tool_edit_cb)tool_deform_edit, sizeof(struct conf_deform), &deform_opts, 0); add_tool("simmplify", (tool_gui_cb)tool_simplify_gui, (tool_edit_cb)tool_simplify_edit, sizeof(struct conf_simplify), &simplify_opts, 0); } c_model_t *c_model_new(mesh_t *mesh, mat_t *mat, bool_t cast_shadow, bool_t visible) { c_model_t *self = component_new(ct_model); if(c_entity(self) == SYS) { self->super.ghost = 1; c_spatial(self)->super.ghost = 1; } c_model_init_drawables(self); c_model_set_mat(self, mat); c_model_set_cast_shadow(self, cast_shadow); c_model_set_mesh(self, mesh); c_model_set_visible(self, visible); c_model_position_changed(self); return self; }
3f89c10fa6d6200dfda9efdbdfc037fff8f8a747
fe86affa6ea97393800181c100da9d18e2783e01
/src/include/xhyve/log.h
6853e846f3ea9d13ef41d2fed0c4e34249e672bb
[ "BSD-2-Clause", "BSD-3-Clause", "GPL-3.0-only" ]
permissive
moby/hyperkit
251be6c6e86b5bbc4483e43e28c02c025709496e
3cb0d5475244761c61e6fd4a562702c26b46f846
refs/heads/master
2023-06-09T01:53:25.506216
2022-02-20T12:19:59
2022-02-20T12:19:59
55,985,023
2,854
305
BSD-2-Clause
2023-02-25T06:55:26
2016-04-11T15:36:20
C
UTF-8
C
false
false
193
h
log.h
#pragma once /* Initialize ASL logger and local buffer. */ void log_init(void); /* Send one character to the logger: wait for full lines before actually sending. */ void log_put(uint8_t _c);
7b32a5cc73539784ff710c1a8e4f089c740a4c93
837528ef9e9a55c416e9592ecb54e1c8f1ff9cf8
/Common/CFHDAllocator.h
ce74f78ea163a171fcce8b0e23c2fba216cc4e16
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
gopro/cineform-sdk
a38fbfa4e9c693ff840ceb934b688ab0fd238856
11574d0295771edccadd17af14af74a539f924c7
refs/heads/master
2023-03-08T15:53:26.569984
2022-02-18T18:36:15
2022-02-18T18:36:15
97,512,165
268
70
Apache-2.0
2022-09-21T13:36:49
2017-07-17T19:03:12
C
UTF-8
C
false
false
1,657
h
CFHDAllocator.h
/*! @file CFHDAllocator.h * * @brief Setting up and controlling the Allocator used within the CineForm SDKs * * @version 1.0.0 * * (C) Copyright 2017 GoPro Inc (http://gopro.com/). * * Licensed under either: * - Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0 * - MIT license, http://opensource.org/licenses/MIT * at your option. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #ifndef CFHD_ALLOCATOR_H #define CFHD_ALLOCATOR_H typedef void * (* UnalignedAllocProc)(void *allocator, size_t size); typedef void * (* AlignedAllocProc)(void *allocator, size_t size, size_t alignment); typedef void (* UnalignedFreeProc)(void *allocator, void *block); typedef void (* AlignedFreeProc)(void *allocator, void *block); // Table of function pointers in an instance of a C++ allocator interface struct cfhd_allocator_vtable { // Do not change the order of the procedure pointers UnalignedAllocProc unaligned_malloc; UnalignedFreeProc unaligned_free; AlignedAllocProc aligned_malloc; AlignedFreeProc aligned_free; }; typedef struct cfhd_allocator { // Pointer to the vtable in the allocator interface struct cfhd_allocator_vtable *vtable; // Add member variables here if they are accessed in the C code } ALLOCATOR; #define CFHD_ALLOCATOR ALLOCATOR #endif // CFHD_ALLOCATOR_H
b07843b00d9936d20aeb2f5b505b0bf7241ad1e5
85af3e305e5bcd7e42ea9c269afbeb8d8049e8fe
/GEDecompressor/func.h
13f00c87a66f2d2bfcb55ca35ff22dc1d1cd9524
[ "Unlicense" ]
permissive
jombo23/N64-Tools
d5729bf7c2c0b898b0ee66d610bfd34fdd83d9fb
4d935fdd48230ddd0cb5bd3739106e6765cac01e
refs/heads/master
2023-05-11T20:31:30.723225
2023-05-09T01:23:39
2023-05-09T01:23:39
148,819,274
229
150
Unlicense
2022-11-26T17:00:56
2018-09-14T17:11:31
C++
UTF-8
C
false
false
19,931
h
func.h
#define ERZ1_EP 0x80001340 #define ERZ2_EP 0x80000C50 unsigned char erz2[] = { 0x23, 0xBD, 0xFF, 0xB8, 0xAF, 0xA4, 0x00, 0x00, 0xAF, 0xA5, 0x00, 0x04, 0xAF, 0xA6, 0x00, 0x08, 0xAF, 0xA7, 0x00, 0x0C, 0xAF, 0xA8, 0x00, 0x10, 0xAF, 0xA9, 0x00, 0x14, 0xAF, 0xAA, 0x00, 0x18, 0xAF, 0xAB, 0x00, 0x1C, 0xAF, 0xAC, 0x00, 0x20, 0xAF, 0xAD, 0x00, 0x24, 0xAF, 0xAE, 0x00, 0x28, 0xAF, 0xAF, 0x00, 0x2C, 0xAF, 0xB0, 0x00, 0x30, 0xAF, 0xB1, 0x00, 0x34, 0xAF, 0xB2, 0x00, 0x38, 0xAF, 0xB3, 0x00, 0x3C, 0xAF, 0xBF, 0x00, 0x40, 0x3C, 0x0C, 0x80, 0x00, 0x25, 0x8C, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0xF8, 0x09, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xA4, 0x00, 0x00, 0x8F, 0xA5, 0x00, 0x04, 0x8F, 0xA6, 0x00, 0x08, 0x8F, 0xA7, 0x00, 0x0C, 0x8F, 0xA8, 0x00, 0x10, 0x8F, 0xA9, 0x00, 0x14, 0x8F, 0xAA, 0x00, 0x18, 0x8F, 0xAB, 0x00, 0x1C, 0x8F, 0xAC, 0x00, 0x20, 0x8F, 0xAD, 0x00, 0x24, 0x8F, 0xAE, 0x00, 0x28, 0x8F, 0xAF, 0x00, 0x2C, 0x8F, 0xB0, 0x00, 0x30, 0x8F, 0xB1, 0x00, 0x34, 0x8F, 0xB2, 0x00, 0x38, 0x8F, 0xB3, 0x00, 0x3C, 0x8F, 0xBF, 0x00, 0x40, 0x23, 0xBD, 0x00, 0x48, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x80, 0x70, 0x21, 0x00, 0xA0, 0x88, 0x21, 0x24, 0x0D, 0x00, 0x00, 0x3C, 0x0B, 0x80, 0x01, 0x25, 0x6B, 0x2F, 0x70, 0x25, 0xCE, 0x00, 0x04, 0x91, 0xCD, 0x00, 0x00, 0x91, 0xCC, 0x00, 0x01, 0x91, 0xD2, 0x00, 0x02, 0x91, 0xCF, 0x00, 0x03, 0x00, 0x0D, 0x6E, 0x00, 0x00, 0x0C, 0x64, 0x00, 0x00, 0x12, 0x92, 0x00, 0x01, 0xAC, 0x68, 0x25, 0x01, 0xB2, 0x68, 0x25, 0x01, 0xAF, 0x68, 0x25, 0x25, 0xCE, 0x00, 0x04, 0xAD, 0x6D, 0x00, 0x00, 0x01, 0xC0, 0x18, 0x21, 0x20, 0x63, 0x00, 0x0A, 0x02, 0x20, 0x28, 0x21, 0x00, 0xA0, 0x30, 0x21, 0x00, 0xCD, 0x30, 0x21, 0x91, 0xCD, 0x00, 0x00, 0x91, 0xCC, 0x00, 0x01, 0x91, 0xD2, 0x00, 0x02, 0x91, 0xCF, 0x00, 0x03, 0x00, 0x0D, 0x6E, 0x00, 0x00, 0x0C, 0x64, 0x00, 0x00, 0x12, 0x92, 0x00, 0x01, 0xAC, 0x68, 0x25, 0x01, 0xB2, 0x68, 0x25, 0x01, 0xAF, 0x68, 0x25, 0x25, 0xCE, 0x00, 0x04, 0x00, 0x60, 0x20, 0x21, 0x00, 0x8D, 0x20, 0x20, 0x21, 0x6B, 0xFF, 0xFE, 0xA5, 0x60, 0x00, 0x00, 0x3C, 0x0A, 0xFF, 0xFF, 0x35, 0x4A, 0xFF, 0x00, 0x24, 0x0F, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x44, 0x31, 0xEF, 0x00, 0x01, 0x24, 0x02, 0xFF, 0xFF, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x24, 0x02, 0xFF, 0xFE, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xB4, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xD0, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xD8, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xE1, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xEE, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xF6, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x03, 0xFE, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x09, 0x31, 0xEF, 0x00, 0x01, 0x24, 0x08, 0x00, 0x03, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x01, 0x29, 0x48, 0x21, 0x01, 0x2F, 0x48, 0x21, 0x00, 0x09, 0x7C, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x21, 0x08, 0xFF, 0xFF, 0x05, 0x01, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x21, 0x29, 0x00, 0x02, 0x90, 0x6C, 0x00, 0x00, 0x90, 0x72, 0x00, 0x01, 0xA0, 0xAC, 0x00, 0x00, 0xA0, 0xB2, 0x00, 0x01, 0x90, 0x6C, 0x00, 0x02, 0x90, 0x72, 0x00, 0x03, 0xA0, 0xAC, 0x00, 0x02, 0xA0, 0xB2, 0x00, 0x03, 0x24, 0x63, 0x00, 0x04, 0x21, 0x29, 0xFF, 0xFF, 0x05, 0x21, 0xFF, 0xF5, 0x20, 0xA5, 0x00, 0x04, 0x08, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xAD, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x40, 0x21, 0x01, 0x0F, 0x40, 0x21, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0F, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x21, 0x08, 0xFF, 0xFF, 0x01, 0x4A, 0x50, 0x20, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x40, 0x21, 0x01, 0x0F, 0x40, 0x21, 0x00, 0x08, 0x7C, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x21, 0x0C, 0xFF, 0xF7, 0x10, 0x0C, 0xFF, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xA4, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0F, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x01, 0x29, 0x48, 0x21, 0x01, 0x2F, 0x48, 0x21, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x14, 0x0F, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x14, 0x09, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x29, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x29, 0x48, 0x21, 0x01, 0x2F, 0x48, 0x21, 0x00, 0x09, 0x7C, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x00, 0x09, 0x62, 0x00, 0x31, 0x8C, 0xFF, 0x00, 0x00, 0x09, 0x4A, 0x02, 0x01, 0x2C, 0x48, 0x25, 0x31, 0x33, 0xFF, 0x00, 0x90, 0x69, 0x00, 0x00, 0x24, 0x63, 0x00, 0x01, 0x01, 0x33, 0x48, 0x25, 0x00, 0xA0, 0x70, 0x21, 0x01, 0xC9, 0x70, 0x22, 0x21, 0xCE, 0xFF, 0xFF, 0x31, 0x0F, 0x00, 0x01, 0x00, 0x08, 0x40, 0x42, 0x10, 0x0F, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x91, 0xCC, 0x00, 0x00, 0x21, 0xCE, 0x00, 0x01, 0xA0, 0xAC, 0x00, 0x00, 0x20, 0xA5, 0x00, 0x01, 0x21, 0x08, 0xFF, 0xFF, 0x14, 0x09, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x31, 0x33, 0xFF, 0x00, 0x91, 0xC9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x33, 0x48, 0x25, 0xA0, 0xA9, 0x00, 0x00, 0x21, 0x08, 0xFF, 0xFF, 0xA0, 0xA9, 0x00, 0x01, 0x05, 0x01, 0xFF, 0xFC, 0x20, 0xA5, 0x00, 0x02, 0x08, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x91, 0xD2, 0x00, 0x01, 0x91, 0xCC, 0x00, 0x00, 0xA0, 0xB2, 0x00, 0x01, 0xA0, 0xAC, 0x00, 0x00, 0x21, 0xCE, 0x00, 0x02, 0x21, 0x08, 0xFF, 0xFF, 0x05, 0x01, 0xFF, 0xF9, 0x20, 0xA5, 0x00, 0x02, 0x08, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x14, 0x0F, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x90, 0x6C, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0xA0, 0xAC, 0x00, 0x00, 0x20, 0xA5, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x14, 0x0F, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x90, 0x6C, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0xA0, 0xAC, 0x00, 0x00, 0x20, 0xA5, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x10, 0x0F, 0xFF, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0xFF, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x00, 0x02, 0x24, 0x09, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0F, 0xFF, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0F, 0xFF, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x21, 0x08, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x20, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0x00, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0F, 0xFF, 0x79, 0x00, 0x00, 0x00, 0x00, 0x90, 0x68, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x3B, 0x21, 0x08, 0x00, 0x08, 0x08, 0x00, 0x03, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x01, 0x29, 0x48, 0x21, 0x01, 0x2F, 0x48, 0x21, 0x00, 0x09, 0x7C, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x35, 0x29, 0x00, 0x04, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x10, 0x0A, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x14, 0x0F, 0xFF, 0x84, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x5D, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x65, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x6E, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x7D, 0x31, 0xEF, 0x00, 0x01, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x08, 0x00, 0x04, 0x88, 0x31, 0xEF, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x31, 0x4A, 0x00, 0xFF, 0x14, 0x0A, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x90, 0x6A, 0x00, 0x00, 0x20, 0x63, 0x00, 0x01, 0x01, 0x4A, 0x50, 0x21, 0x01, 0x4F, 0x50, 0x21, 0x00, 0x0A, 0x7A, 0x02, 0x31, 0xEF, 0x00, 0x01, 0x14, 0x0F, 0xFF, 0x88, 0x00, 0x00, 0x00, 0x00, 0x95, 0x6D, 0x00, 0x00, 0x21, 0x6B, 0x00, 0x02, 0x10, 0x0D, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x85, 0x70, 0x00, 0x00, 0x21, 0x6B, 0x00, 0x02, 0xA0, 0xB0, 0x00, 0x00, 0x20, 0xA5, 0x00, 0x01, 0x21, 0xAD, 0xFF, 0xFF, 0x14, 0x0D, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0xCB, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x70, 0x00, 0x00, 0x24, 0x02, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; unsigned char erz1[] = { 0x23, 0xBD, 0xFF, 0xA8, 0xAF, 0xA4, 0x00, 0x00, 0xAF, 0xA5, 0x00, 0x04, 0xAF, 0xA6, 0x00, 0x08, 0xAF, 0xA7, 0x00, 0x0C, 0xAF, 0xA8, 0x00, 0x10, 0xAF, 0xA9, 0x00, 0x14, 0xAF, 0xAA, 0x00, 0x18, 0xAF, 0xAB, 0x00, 0x1C, 0xAF, 0xAC, 0x00, 0x20, 0xAF, 0xAD, 0x00, 0x24, 0xAF, 0xAE, 0x00, 0x28, 0xAF, 0xAF, 0x00, 0x2C, 0xAF, 0xB0, 0x00, 0x30, 0xAF, 0xB1, 0x00, 0x34, 0xAF, 0xB2, 0x00, 0x38, 0xAF, 0xB3, 0x00, 0x3C, 0xAF, 0xB4, 0x00, 0x40, 0xAF, 0xB5, 0x00, 0x44, 0xAF, 0xB6, 0x00, 0x48, 0xAF, 0xB7, 0x00, 0x4C, 0xAF, 0xBF, 0x00, 0x50, 0x00, 0x80, 0x80, 0x21, 0x00, 0xA0, 0x88, 0x21, 0x0C, 0x00, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xA4, 0x00, 0x00, 0x8F, 0xA5, 0x00, 0x04, 0x8F, 0xA6, 0x00, 0x08, 0x8F, 0xA7, 0x00, 0x0C, 0x8F, 0xA8, 0x00, 0x10, 0x8F, 0xA9, 0x00, 0x14, 0x8F, 0xAA, 0x00, 0x18, 0x8F, 0xAB, 0x00, 0x1C, 0x8F, 0xAC, 0x00, 0x20, 0x8F, 0xAD, 0x00, 0x24, 0x8F, 0xAE, 0x00, 0x28, 0x8F, 0xAF, 0x00, 0x2C, 0x8F, 0xB0, 0x00, 0x30, 0x8F, 0xB1, 0x00, 0x34, 0x8F, 0xB2, 0x00, 0x38, 0x8F, 0xB3, 0x00, 0x3C, 0x8F, 0xB4, 0x00, 0x40, 0x8F, 0xB5, 0x00, 0x44, 0x8F, 0xB6, 0x00, 0x48, 0x8F, 0xB7, 0x00, 0x4C, 0x8F, 0xBF, 0x00, 0x50, 0x23, 0xBD, 0x00, 0x58, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x03, 0xFF, 0xFF, 0x30, 0x63, 0x00, 0xFF, 0x00, 0x03, 0x26, 0x00, 0x00, 0x03, 0x2F, 0xC0, 0x00, 0x05, 0x3C, 0x02, 0x00, 0x03, 0x30, 0x27, 0x23, 0xBD, 0xFE, 0x80, 0x03, 0xA0, 0x90, 0x21, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x22, 0x10, 0x00, 0x04, 0x0C, 0x00, 0x05, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x22, 0x13, 0x00, 0x0A, 0x02, 0x20, 0xA0, 0x21, 0x92, 0x6E, 0x00, 0x01, 0x92, 0x61, 0x00, 0x00, 0x00, 0x00, 0x78, 0x21, 0x00, 0x0E, 0x72, 0x00, 0x01, 0xC1, 0x70, 0x25, 0x02, 0x88, 0xA8, 0x20, 0x20, 0x08, 0x00, 0x02, 0x20, 0x09, 0x00, 0x02, 0x0C, 0x00, 0x05, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x02, 0x40, 0x80, 0x21, 0x0C, 0x00, 0x05, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x22, 0x50, 0x00, 0x80, 0x0C, 0x00, 0x05, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x22, 0x50, 0x01, 0x00, 0x0C, 0x00, 0x05, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0xFF, 0xFF, 0x20, 0x09, 0x00, 0x10, 0x0C, 0x00, 0x05, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x01, 0x00, 0x60, 0x21, 0x20, 0x01, 0xFF, 0xFF, 0x00, 0x01, 0x0C, 0x02, 0x21, 0x8C, 0xFF, 0xFF, 0x00, 0x2C, 0x60, 0x24, 0x08, 0x00, 0x05, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x22, 0x50, 0x00, 0x80, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x40, 0x21, 0x0C, 0x00, 0x05, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x23, 0x02, 0x88, 0x88, 0x20, 0x22, 0x31, 0xFF, 0xFF, 0x22, 0x50, 0x01, 0x00, 0x0C, 0x00, 0x05, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x22, 0x94, 0x00, 0x01, 0x92, 0x21, 0x00, 0x00, 0x22, 0x31, 0x00, 0x01, 0xA2, 0x81, 0xFF, 0xFF, 0x22, 0x94, 0x00, 0x01, 0x92, 0x21, 0x00, 0x00, 0x22, 0x31, 0x00, 0x01, 0xA2, 0x81, 0xFF, 0xFF, 0x15, 0x00, 0xFF, 0xFB, 0x21, 0x08, 0xFF, 0xFF, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x02, 0x40, 0x80, 0x21, 0x0C, 0x00, 0x05, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x21, 0x08, 0xFF, 0xFF, 0x05, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x0C, 0x00, 0x06, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x92, 0x61, 0x00, 0x01, 0x92, 0x68, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x28, 0x40, 0x25, 0x01, 0xE8, 0x40, 0x04, 0x20, 0x09, 0x00, 0x01, 0x01, 0xE9, 0x48, 0x04, 0x25, 0x29, 0xFF, 0xFF, 0x01, 0xC9, 0x70, 0x24, 0x01, 0x0E, 0x70, 0x25, 0x15, 0x80, 0xFF, 0xCD, 0x21, 0x8C, 0xFF, 0xFF, 0x02, 0x95, 0x08, 0x22, 0x04, 0x20, 0xFF, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x23, 0xBD, 0x01, 0x80, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x92, 0x08, 0x00, 0x00, 0x92, 0x01, 0x00, 0x01, 0x22, 0x10, 0x00, 0x02, 0x00, 0x08, 0x42, 0x00, 0x00, 0x28, 0x40, 0x25, 0x01, 0x0E, 0x40, 0x24, 0x92, 0x01, 0x00, 0x00, 0x92, 0x02, 0x00, 0x01, 0x22, 0x10, 0x00, 0x02, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x22, 0x08, 0x25, 0x01, 0x01, 0x40, 0x22, 0x15, 0x00, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE9, 0x78, 0x22, 0x05, 0xE1, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x0C, 0x00, 0x05, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x01, 0x2E, 0x70, 0x06, 0x92, 0x08, 0x00, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x21, 0x01, 0xFF, 0xFE, 0x04, 0x20, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x21, 0x08, 0xFF, 0xFF, 0x01, 0x00, 0x48, 0x21, 0x01, 0x00, 0x50, 0x21, 0x92, 0x01, 0x00, 0x3E, 0x92, 0x08, 0x00, 0x3F, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x28, 0x40, 0x25, 0x01, 0x0E, 0x40, 0x24, 0x01, 0xE9, 0x78, 0x22, 0x05, 0xE1, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x0C, 0x00, 0x05, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x01, 0x2E, 0x70, 0x06, 0x20, 0x01, 0x00, 0x01, 0x01, 0x41, 0x08, 0x04, 0x00, 0x28, 0x40, 0x25, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC8, 0x40, 0x24, 0x01, 0xE9, 0x78, 0x22, 0x05, 0xE1, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x0C, 0x00, 0x05, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x01, 0x2E, 0x70, 0x06, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE9, 0x78, 0x20, 0x01, 0xEE, 0x70, 0x06, 0x22, 0x73, 0x00, 0x04, 0x92, 0x61, 0xFF, 0xFE, 0x92, 0x62, 0xFF, 0xFF, 0x22, 0x73, 0xFF, 0xFE, 0x00, 0x01, 0x0C, 0x00, 0x00, 0x02, 0x16, 0x00, 0x01, 0xC2, 0x70, 0x25, 0x01, 0xC1, 0x70, 0x25, 0x01, 0x2F, 0x48, 0x22, 0x20, 0x0F, 0x00, 0x10, 0x01, 0xE9, 0x78, 0x22, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x09, 0x00, 0x03, 0x00, 0x08, 0x42, 0x00, 0x92, 0x01, 0x00, 0x00, 0x22, 0x10, 0x00, 0x01, 0x00, 0x28, 0x40, 0x25, 0x15, 0x20, 0xFF, 0xFB, 0x21, 0x29, 0xFF, 0xFF, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x1F, 0x20, 0x09, 0x00, 0x05, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x0C, 0x00, 0x05, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0x21, 0x08, 0xFF, 0xFF, 0x05, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x50, 0x21, 0x01, 0x00, 0x58, 0x21, 0x23, 0xBD, 0xFF, 0xF0, 0x03, 0xA0, 0x88, 0x21, 0x20, 0x08, 0x00, 0x0F, 0x20, 0x09, 0x00, 0x04, 0x23, 0xBD, 0xFF, 0xF8, 0xAF, 0xBF, 0x00, 0x00, 0x0C, 0x00, 0x05, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xBF, 0x00, 0x00, 0x23, 0xBD, 0x00, 0x08, 0xA2, 0x28, 0x00, 0x00, 0x22, 0x31, 0x00, 0x01, 0x15, 0x40, 0xFF, 0xF5, 0x21, 0x4A, 0xFF, 0xFF, 0x00, 0xA0, 0x40, 0x21, 0x20, 0x09, 0x00, 0x01, 0x00, 0x00, 0x50, 0x21, 0x23, 0xBD, 0xFF, 0xF0, 0xAF, 0xAD, 0x00, 0x00, 0xAF, 0xAE, 0x00, 0x04, 0xAF, 0xAF, 0x00, 0x08, 0x01, 0x60, 0x60, 0x21, 0x23, 0xB1, 0x00, 0x10, 0x92, 0x21, 0x00, 0x00, 0x22, 0x31, 0x00, 0x01, 0x15, 0x21, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0D, 0x00, 0x01, 0x01, 0x2D, 0x68, 0x04, 0x21, 0xAD, 0xFF, 0xFF, 0xA2, 0x0D, 0x00, 0x01, 0x00, 0x0D, 0x0A, 0x02, 0xA2, 0x01, 0x00, 0x00, 0x22, 0x10, 0x00, 0x02, 0x01, 0x40, 0x68, 0x21, 0x00, 0x0D, 0x0C, 0x00, 0x00, 0x0D, 0x6C, 0x02, 0x01, 0xA1, 0x68, 0x25, 0x01, 0x20, 0x78, 0x21, 0x21, 0xEF, 0xFF, 0xFF, 0x20, 0x01, 0xFF, 0xFF, 0x00, 0x01, 0x0C, 0x02, 0x00, 0x2E, 0x70, 0x24, 0x01, 0xA7, 0x08, 0x24, 0x00, 0x0D, 0x68, 0x40, 0x00, 0x0E, 0x70, 0x42, 0x10, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC7, 0x70, 0x25, 0x15, 0xE0, 0xFF, 0xF6, 0x21, 0xEF, 0xFF, 0xFF, 0x20, 0x0D, 0x00, 0x10, 0x01, 0xA9, 0x68, 0x22, 0x01, 0xAE, 0x70, 0x06, 0xA2, 0x0E, 0x00, 0x01, 0x00, 0x0E, 0x0A, 0x02, 0xA2, 0x01, 0x00, 0x00, 0x22, 0x10, 0x00, 0x02, 0xA2, 0x09, 0x00, 0x3C, 0x01, 0x60, 0x68, 0x21, 0x01, 0xAC, 0x68, 0x23, 0xA2, 0x0D, 0x00, 0x3D, 0x20, 0x0E, 0x00, 0x01, 0x25, 0xAD, 0xFF, 0xFF, 0x01, 0xAE, 0x70, 0x04, 0x25, 0xCE, 0xFF, 0xFF, 0xA2, 0x0E, 0x00, 0x3F, 0x00, 0x0E, 0x0A, 0x02, 0xA2, 0x01, 0x00, 0x3E, 0x01, 0x48, 0x50, 0x21, 0x15, 0x80, 0xFF, 0xD0, 0x21, 0x8C, 0xFF, 0xFF, 0x00, 0x08, 0x40, 0x42, 0x21, 0x29, 0x00, 0x01, 0x20, 0x01, 0x00, 0x11, 0x15, 0x21, 0xFF, 0xC9, 0x8F, 0xAD, 0x00, 0x00, 0x8F, 0xAE, 0x00, 0x04, 0x8F, 0xAF, 0x00, 0x08, 0x23, 0xBD, 0x00, 0x10, 0x23, 0xBD, 0x00, 0x10, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x92, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x81, 0x00, 0x00, 0x22, 0x94, 0x00, 0x01, 0x22, 0x73, 0x00, 0x01, 0x15, 0x00, 0xFF, 0xFA, 0x21, 0x08, 0xFF, 0xFF, 0x03, 0xE0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 };
20e18db10af86e3f6e335a762112d20588262792
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Plugins/Runtime/GoogleVR/GoogleVRHMD/Source/GoogleVRHMD/Public/GoogleVRAdbUtils.h
d52b0afc9f0757a88cc8da0a2a2f8b1d8472e3ed
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C
false
false
1,916
h
GoogleVRAdbUtils.h
// Copyright 2017 Google Inc. #pragma once #include "CoreMinimal.h" #include "Misc/Paths.h" #include "HAL/FileManager.h" // Copied from AndroidDeviceDetectionModule.cpp // TODO: would be nice if Unreal make that function public so we don't need to make a duplicate. inline void GetAdbPath(FString& OutAdbPath) { TCHAR AndroidDirectory[32768] = { 0 }; FPlatformMisc::GetEnvironmentVariable(TEXT("ANDROID_HOME"), AndroidDirectory, 32768); #if PLATFORM_MAC if (AndroidDirectory[0] == 0) { // didn't find ANDROID_HOME, so parse the .bash_profile file on MAC FArchive* FileReader = IFileManager::Get().CreateFileReader(*FString([@"~/.bash_profile" stringByExpandingTildeInPath])); if (FileReader) { const int64 FileSize = FileReader->TotalSize(); ANSICHAR* AnsiContents = (ANSICHAR*)FMemory::Malloc(FileSize + 1); FileReader->Serialize(AnsiContents, FileSize); FileReader->Close(); delete FileReader; AnsiContents[FileSize] = 0; TArray<FString> Lines; FString(ANSI_TO_TCHAR(AnsiContents)).ParseIntoArrayLines(Lines); FMemory::Free(AnsiContents); for (int32 Index = Lines.Num() - 1; Index >= 0; Index--) { if (AndroidDirectory[0] == 0 && Lines[Index].StartsWith(TEXT("export ANDROID_HOME="))) { FString Directory; Lines[Index].Split(TEXT("="), NULL, &Directory); Directory = Directory.Replace(TEXT("\""), TEXT("")); FCString::Strcpy(AndroidDirectory, *Directory); setenv("ANDROID_HOME", TCHAR_TO_ANSI(AndroidDirectory), 1); } } } } #endif if (AndroidDirectory[0] != 0) { #if PLATFORM_WINDOWS OutAdbPath = FString::Printf(TEXT("%s\\platform-tools\\adb.exe"), AndroidDirectory); #else OutAdbPath = FString::Printf(TEXT("%s/platform-tools/adb"), AndroidDirectory); #endif // if it doesn't exist then just clear the path as we might set it later if (!FPaths::FileExists(*OutAdbPath)) { OutAdbPath.Empty(); } } }
8c76aa5bf51e9fe2b773ba2cde95318a4f88f74d
984bc4181baec6e5a4b05a657e666b0e9f89f3f3
/3rdparty/mongo-c-driver-1.21.2/src/libmongoc/tests/test-mongoc-uri.c
d57bfff12df2aedc0805772193ef6dd484a35616
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
treefrogframework/treefrog-framework
0173245ff92162d2107af79861505981980d1eca
a1df97793e8cc628779378e5adae9af6987460c1
refs/heads/master
2023-08-22T03:57:58.891846
2023-05-18T14:00:42
2023-05-18T14:00:42
7,067,532
1,152
263
BSD-3-Clause
2023-08-08T20:25:03
2012-12-08T13:17:01
C++
UTF-8
C
false
false
104,258
c
test-mongoc-uri.c
#include <mongoc/mongoc.h> #include <mongoc/mongoc-util-private.h> #include "mongoc/mongoc-client-private.h" #include "mongoc/mongoc-topology-private.h" #include "mongoc/mongoc-uri-private.h" #include "mongoc/mongoc-host-list-private.h" #include "TestSuite.h" #include "test-libmongoc.h" #include "test-conveniences.h" static void test_mongoc_uri_new (void) { const mongoc_host_list_t *hosts; const bson_t *options; const bson_t *credentials; const bson_t *read_prefs_tags; const mongoc_read_prefs_t *read_prefs; bson_t properties; mongoc_uri_t *uri; bson_iter_t iter; bson_iter_t child; capture_logs (true); /* bad uris */ ASSERT (!mongoc_uri_new ("mongodb://")); ASSERT (!mongoc_uri_new ("mongodb://\x80")); ASSERT (!mongoc_uri_new ("mongodb://localhost/\x80")); ASSERT (!mongoc_uri_new ("mongodb://localhost:\x80/")); ASSERT (!mongoc_uri_new ("mongodb://localhost/?ipv6=\x80")); ASSERT (!mongoc_uri_new ("mongodb://localhost/?foo=\x80")); ASSERT (!mongoc_uri_new ("mongodb://localhost/?\x80=bar")); ASSERT (!mongoc_uri_new ("mongodb://\x80:pass@localhost")); ASSERT (!mongoc_uri_new ("mongodb://user:\x80@localhost")); ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" "?" MONGOC_URI_AUTHMECHANISM "=\x80")); ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=SERVICE_NAME:\x80")); ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=\x80:mongodb")); ASSERT (!mongoc_uri_new ("mongodb://::")); ASSERT (!mongoc_uri_new ("mongodb://[::1]::27017/")); ASSERT (!mongoc_uri_new ("mongodb://localhost::27017")); ASSERT (!mongoc_uri_new ("mongodb://localhost,localhost::")); ASSERT (!mongoc_uri_new ("mongodb://local1,local2,local3/d?k")); ASSERT (!mongoc_uri_new ("")); ASSERT (!mongoc_uri_new ("mongodb://,localhost:27017")); ASSERT (!mongoc_uri_new ("mongodb://localhost:27017,,b")); ASSERT (!mongoc_uri_new ("mongo://localhost:27017")); ASSERT (!mongoc_uri_new ("mongodb://localhost::27017")); ASSERT (!mongoc_uri_new ("mongodb://localhost::27017/")); ASSERT (!mongoc_uri_new ("mongodb://localhost::27017,abc")); ASSERT (!mongoc_uri_new ("mongodb://localhost:-1")); ASSERT (!mongoc_uri_new ("mongodb://localhost:65536")); ASSERT (!mongoc_uri_new ("mongodb://localhost:foo")); ASSERT (!mongoc_uri_new ("mongodb://localhost:65536/")); ASSERT (!mongoc_uri_new ("mongodb://localhost:0/")); ASSERT (!mongoc_uri_new ("mongodb://[::1%lo0]")); ASSERT (!mongoc_uri_new ("mongodb://[::1]:-1")); ASSERT (!mongoc_uri_new ("mongodb://[::1]:foo")); ASSERT (!mongoc_uri_new ("mongodb://[::1]:65536")); ASSERT (!mongoc_uri_new ("mongodb://[::1]:65536/")); ASSERT (!mongoc_uri_new ("mongodb://[::1]:0/")); ASSERT (!mongoc_uri_new ("mongodb://localhost:27017/test?replicaset=")); ASSERT (!mongoc_uri_new ("mongodb://local1,local2/?directConnection=true")); ASSERT (!mongoc_uri_new ("mongodb+srv://local1/?directConnection=true")); uri = mongoc_uri_new ( "mongodb://[::1]:27888,[::2]:27999/?ipv6=true&" MONGOC_URI_SAFE "=true"); BSON_ASSERT (uri); hosts = mongoc_uri_get_hosts (uri); BSON_ASSERT (hosts); ASSERT_CMPSTR (hosts->host, "::1"); BSON_ASSERT (hosts->port == 27888); ASSERT_CMPSTR (hosts->host_and_port, "[::1]:27888"); mongoc_uri_destroy (uri); /* should recognize IPv6 "scope" like "::1%lo0", with % escaped */ uri = mongoc_uri_new ("mongodb://[::1%25lo0]"); BSON_ASSERT (uri); hosts = mongoc_uri_get_hosts (uri); BSON_ASSERT (hosts); ASSERT_CMPSTR (hosts->host, "::1%lo0"); BSON_ASSERT (hosts->port == 27017); ASSERT_CMPSTR (hosts->host_and_port, "[::1%lo0]:27017"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://%2Ftmp%2Fmongodb-27017.sock/?"); ASSERT (uri); mongoc_uri_destroy (uri); /* should normalize to lowercase */ uri = mongoc_uri_new ("mongodb://cRaZyHoStNaMe"); BSON_ASSERT (uri); hosts = mongoc_uri_get_hosts (uri); BSON_ASSERT (hosts); ASSERT_CMPSTR (hosts->host, "crazyhostname"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?"); ASSERT (uri); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost:27017/test?replicaset=foo"); ASSERT (uri); hosts = mongoc_uri_get_hosts (uri); ASSERT (hosts); ASSERT (!hosts->next); ASSERT_CMPSTR (hosts->host, "localhost"); ASSERT_CMPINT (hosts->port, ==, 27017); ASSERT_CMPSTR (hosts->host_and_port, "localhost:27017"); ASSERT_CMPSTR (mongoc_uri_get_database (uri), "test"); options = mongoc_uri_get_options (uri); ASSERT (options); ASSERT (bson_iter_init_find (&iter, options, "replicaset")); ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "foo"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://local1,local2:999,local3/?replicaset=foo"); ASSERT (uri); hosts = mongoc_uri_get_hosts (uri); ASSERT (hosts); ASSERT (hosts->next); ASSERT (hosts->next->next); ASSERT (!hosts->next->next->next); ASSERT_CMPSTR (hosts->host, "local1"); ASSERT_CMPINT (hosts->port, ==, 27017); ASSERT_CMPSTR (hosts->next->host, "local2"); ASSERT_CMPINT (hosts->next->port, ==, 999); ASSERT_CMPSTR (hosts->next->next->host, "local3"); ASSERT_CMPINT (hosts->next->next->port, ==, 27017); options = mongoc_uri_get_options (uri); ASSERT (options); ASSERT (bson_iter_init_find (&iter, options, "replicaset")); ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "foo"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost:27017/" "?" MONGOC_URI_READPREFERENCE "=secondaryPreferred&" MONGOC_URI_READPREFERENCETAGS "=dc:ny&" MONGOC_URI_READPREFERENCETAGS "="); ASSERT (uri); read_prefs = mongoc_uri_get_read_prefs_t (uri); ASSERT (mongoc_read_prefs_get_mode (read_prefs) == MONGOC_READ_SECONDARY_PREFERRED); ASSERT (read_prefs); read_prefs_tags = mongoc_read_prefs_get_tags (read_prefs); ASSERT (read_prefs_tags); ASSERT_CMPINT (bson_count_keys (read_prefs_tags), ==, 2); ASSERT (bson_iter_init_find (&iter, read_prefs_tags, "0")); ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); ASSERT (bson_iter_recurse (&iter, &child)); ASSERT (bson_iter_next (&child)); ASSERT_CMPSTR (bson_iter_key (&child), "dc"); ASSERT_CMPSTR (bson_iter_utf8 (&child, NULL), "ny"); ASSERT (!bson_iter_next (&child)); ASSERT (bson_iter_next (&iter)); ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); ASSERT (bson_iter_recurse (&iter, &child)); ASSERT (!bson_iter_next (&child)); ASSERT (!bson_iter_next (&iter)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_SAFE "=false&" MONGOC_URI_JOURNAL "=false"); options = mongoc_uri_get_options (uri); ASSERT (options); ASSERT_CMPINT (bson_count_keys (options), ==, 2); ASSERT (bson_iter_init (&iter, options)); ASSERT (bson_iter_find_case (&iter, "" MONGOC_URI_SAFE "")); ASSERT (BSON_ITER_HOLDS_BOOL (&iter)); ASSERT (!bson_iter_bool (&iter)); ASSERT (bson_iter_find_case (&iter, MONGOC_URI_JOURNAL)); ASSERT (BSON_ITER_HOLDS_BOOL (&iter)); ASSERT (!bson_iter_bool (&iter)); ASSERT (!bson_iter_next (&iter)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb://%2Ftmp%2Fmongodb-27017.sock/?" MONGOC_URI_TLS "=false"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host, "/tmp/mongodb-27017.sock"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb://%2Ftmp%2Fmongodb-27017.sock,localhost:27017/?" MONGOC_URI_TLS "=false"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host, "/tmp/mongodb-27017.sock"); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->next->host_and_port, "localhost:27017"); ASSERT (!mongoc_uri_get_hosts (uri)->next->next); mongoc_uri_destroy (uri); /* should assign port numbers to correct hosts */ uri = mongoc_uri_new ("mongodb://host1,host2:30000/foo"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, "host1:27017"); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->next->host_and_port, "host2:30000"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb://localhost:27017,%2Ftmp%2Fmongodb-27017.sock/?" MONGOC_URI_TLS "=false"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, "localhost:27017"); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->next->host, "/tmp/mongodb-27017.sock"); ASSERT (!mongoc_uri_get_hosts (uri)->next->next); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_HEARTBEATFREQUENCYMS "=600"); ASSERT (uri); ASSERT_CMPINT32 ( 600, ==, mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 0)); mongoc_uri_destroy (uri); /* heartbeat frequency too short */ ASSERT (!mongoc_uri_new ( "mongodb://localhost/?" MONGOC_URI_HEARTBEATFREQUENCYMS "=499")); /* should use the " MONGOC_URI_AUTHSOURCE " over db when both are specified */ uri = mongoc_uri_new ( "mongodb://christian:secret@localhost:27017/foo?" MONGOC_URI_AUTHSOURCE "=abcd"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_username (uri), "christian"); ASSERT_CMPSTR (mongoc_uri_get_password (uri), "secret"); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "abcd"); mongoc_uri_destroy (uri); /* should use the default auth source and mechanism */ uri = mongoc_uri_new ("mongodb://christian:secret@localhost:27017"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "admin"); ASSERT (!mongoc_uri_get_auth_mechanism (uri)); mongoc_uri_destroy (uri); /* should use the db when no " MONGOC_URI_AUTHSOURCE " is specified */ uri = mongoc_uri_new ("mongodb://user:password@localhost/foo"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "foo"); mongoc_uri_destroy (uri); /* should recognize an empty password */ uri = mongoc_uri_new ("mongodb://samantha:@localhost"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_username (uri), "samantha"); ASSERT_CMPSTR (mongoc_uri_get_password (uri), ""); mongoc_uri_destroy (uri); /* should recognize no password */ uri = mongoc_uri_new ("mongodb://christian@localhost:27017"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_username (uri), "christian"); ASSERT (!mongoc_uri_get_password (uri)); mongoc_uri_destroy (uri); /* should recognize a url escaped character in the username */ uri = mongoc_uri_new ("mongodb://christian%40realm:pwd@localhost:27017"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_username (uri), "christian@realm"); mongoc_uri_destroy (uri); /* should fail on invalid escaped characters */ capture_logs (true); uri = mongoc_uri_new ("mongodb://u%ser:pwd@localhost:27017"); ASSERT (!uri); ASSERT_CAPTURED_LOG ( "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); uri = mongoc_uri_new ("mongodb://user:p%wd@localhost:27017"); ASSERT (!uri); ASSERT_CAPTURED_LOG ( "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); uri = mongoc_uri_new ("mongodb://user:pwd@local% host:27017"); ASSERT (!uri); ASSERT_CAPTURED_LOG ( "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); uri = mongoc_uri_new ( "mongodb://christian%40realm@localhost:27017/?replicaset=%20"); ASSERT (uri); options = mongoc_uri_get_options (uri); ASSERT (options); ASSERT (bson_iter_init_find (&iter, options, "replicaset")); ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), " "); mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb://christian%40realm@[::6]:27017/?replicaset=%20"); ASSERT (uri); options = mongoc_uri_get_options (uri); ASSERT (options); ASSERT (bson_iter_init_find (&iter, options, "replicaset")); ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), " "); mongoc_uri_destroy (uri); /* GSSAPI-specific options */ /* should recognize the GSSAPI mechanism, and use $external as source */ uri = mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "GSSAPI"); /*ASSERT_CMPSTR(mongoc_uri_get_auth_source(uri), "$external");*/ mongoc_uri_destroy (uri); /* use $external as source when db is specified */ uri = mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/foo" "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "$external"); mongoc_uri_destroy (uri); /* should not accept " MONGOC_URI_AUTHSOURCE " other than $external */ ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" "foo?" MONGOC_URI_AUTHMECHANISM "=GSSAPI&" MONGOC_URI_AUTHSOURCE "=bar")); /* should accept MONGOC_URI_AUTHMECHANISMPROPERTIES */ uri = mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:" "true"); ASSERT (uri); credentials = mongoc_uri_get_credentials (uri); ASSERT (credentials); ASSERT (mongoc_uri_get_mechanism_properties (uri, &properties)); BSON_ASSERT (bson_iter_init_find_case (&iter, &properties, "SERVICE_NAME") && BSON_ITER_HOLDS_UTF8 (&iter) && (0 == strcmp (bson_iter_utf8 (&iter, NULL), "other"))); BSON_ASSERT ( bson_iter_init_find_case (&iter, &properties, "CANONICALIZE_HOST_NAME") && BSON_ITER_HOLDS_UTF8 (&iter) && (0 == strcmp (bson_iter_utf8 (&iter, NULL), "true"))); mongoc_uri_destroy (uri); /* reverse order of arguments to ensure parsing still succeeds */ uri = mongoc_uri_new ( "mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISMPROPERTIES "=SERVICE_NAME:other&" MONGOC_URI_AUTHMECHANISM "=GSSAPI"); ASSERT (uri); mongoc_uri_destroy (uri); /* MONGODB-CR */ /* should recognize this mechanism */ uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM "=MONGODB-CR"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-CR"); mongoc_uri_destroy (uri); /* X509 */ /* should recognize this mechanism, and use $external as the source */ uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM "=MONGODB-X509"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509"); /*ASSERT_CMPSTR(mongoc_uri_get_auth_source(uri), "$external");*/ mongoc_uri_destroy (uri); /* use $external as source when db is specified */ uri = mongoc_uri_new ( "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality" "%2CST%3DmyState%2CC%3DmyCountry@localhost/foo" "?" MONGOC_URI_AUTHMECHANISM "=MONGODB-X509"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "$external"); mongoc_uri_destroy (uri); /* should not accept " MONGOC_URI_AUTHSOURCE " other than $external */ ASSERT (!mongoc_uri_new ( "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality" "%2CST%3DmyState%2CC%3DmyCountry@localhost/foo" "?" MONGOC_URI_AUTHMECHANISM "=MONGODB-X509&" MONGOC_URI_AUTHSOURCE "=bar")); /* should recognize the encoded username */ uri = mongoc_uri_new ( "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality" "%2CST%3DmyState%2CC%3DmyCountry@localhost/?" MONGOC_URI_AUTHMECHANISM "=MONGODB-X509"); ASSERT (uri); ASSERT_CMPSTR ( mongoc_uri_get_username (uri), "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"); mongoc_uri_destroy (uri); /* PLAIN */ /* should recognize this mechanism */ uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM "=PLAIN"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "PLAIN"); mongoc_uri_destroy (uri); /* SCRAM-SHA1 */ /* should recognize this mechanism */ uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM "=SCRAM-SHA1"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "SCRAM-SHA1"); mongoc_uri_destroy (uri); } static void test_mongoc_uri_authmechanismproperties (void) { mongoc_uri_t *uri; bson_t props; const bson_t *options; capture_logs (true); uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM "=SCRAM-SHA1" "&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=a:one,b:two"); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "SCRAM-SHA1"); ASSERT (mongoc_uri_get_mechanism_properties (uri, &props)); ASSERT_MATCH (&props, "{'a': 'one', 'b': 'two'}"); ASSERT (mongoc_uri_set_auth_mechanism (uri, "MONGODB-CR")); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-CR"); /* prohibited */ ASSERT (!mongoc_uri_set_option_as_utf8 ( uri, MONGOC_URI_AUTHMECHANISM, "SCRAM-SHA1")); ASSERT (!mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_AUTHMECHANISM, 1)); ASSERT_CAPTURED_LOG ("setting authmechanism=1", MONGOC_LOG_LEVEL_WARNING, "Unsupported value for \"authmechanism\": 1," " \"authmechanism\" is not an int32 option"); ASSERT (!mongoc_uri_set_option_as_utf8 ( uri, MONGOC_URI_AUTHMECHANISMPROPERTIES, "a:three")); ASSERT ( mongoc_uri_set_mechanism_properties (uri, tmp_bson ("{'a': 'four'}"))); ASSERT (mongoc_uri_get_mechanism_properties (uri, &props)); ASSERT_MATCH (&props, "{'a': 'four', 'b': {'$exists': false}}"); mongoc_uri_destroy (uri); /* deprecated gssapiServiceName option */ uri = mongoc_uri_new ("mongodb://christian%40realm.cc@localhost:27017/" "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI&" MONGOC_URI_GSSAPISERVICENAME "=blah"); ASSERT (uri); options = mongoc_uri_get_options (uri); ASSERT (options); BSON_ASSERT (0 == strcmp (mongoc_uri_get_auth_mechanism (uri), "GSSAPI")); BSON_ASSERT (0 == strcmp (mongoc_uri_get_username (uri), "christian@realm.cc")); ASSERT (mongoc_uri_get_mechanism_properties (uri, &props)); ASSERT_MATCH (&props, "{'SERVICE_NAME': 'blah'}"); mongoc_uri_destroy (uri); } static void test_mongoc_uri_functions (void) { mongoc_client_t *client; mongoc_uri_t *uri; mongoc_database_t *db; int32_t i; uri = mongoc_uri_new ( "mongodb://foo:bar@localhost:27017/baz?" MONGOC_URI_AUTHSOURCE "=source"); ASSERT_CMPSTR (mongoc_uri_get_username (uri), "foo"); ASSERT_CMPSTR (mongoc_uri_get_password (uri), "bar"); ASSERT_CMPSTR (mongoc_uri_get_database (uri), "baz"); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "source"); mongoc_uri_set_username (uri, "longer username that should work"); ASSERT_CMPSTR (mongoc_uri_get_username (uri), "longer username that should work"); mongoc_uri_set_password (uri, "longer password that should also work"); ASSERT_CMPSTR (mongoc_uri_get_password (uri), "longer password that should also work"); mongoc_uri_set_database (uri, "longer database that should work"); ASSERT_CMPSTR (mongoc_uri_get_database (uri), "longer database that should work"); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "source"); mongoc_uri_set_auth_source (uri, "longer authsource that should work"); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "longer authsource that should work"); ASSERT_CMPSTR (mongoc_uri_get_database (uri), "longer database that should work"); client = test_framework_client_new_from_uri (uri, NULL); mongoc_uri_destroy (uri); ASSERT_CMPSTR (mongoc_uri_get_username (client->uri), "longer username that should work"); ASSERT_CMPSTR (mongoc_uri_get_password (client->uri), "longer password that should also work"); ASSERT_CMPSTR (mongoc_uri_get_database (client->uri), "longer database that should work"); ASSERT_CMPSTR (mongoc_uri_get_auth_source (client->uri), "longer authsource that should work"); mongoc_client_destroy (client); uri = mongoc_uri_new ( "mongodb://localhost/?" MONGOC_URI_SERVERSELECTIONTIMEOUTMS "=3" "&" MONGOC_URI_JOURNAL "=true" "&" MONGOC_URI_WTIMEOUTMS "=42" "&" MONGOC_URI_CANONICALIZEHOSTNAME "=false"); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, "serverselectiontimeoutms", 18), ==, 3); ASSERT ( mongoc_uri_set_option_as_int32 (uri, "serverselectiontimeoutms", 18)); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, "serverselectiontimeoutms", 19), ==, 18); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 18), ==, 42); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 18), ==, 42); ASSERT (mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 18)); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 19), ==, 18); ASSERT (mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 20)); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 19), ==, 20); ASSERT (mongoc_uri_set_option_as_int32 ( uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 500)); i = mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 1000); ASSERT_CMPINT32 (i, ==, 500); capture_logs (true); /* Server Discovery and Monitoring Spec: "the driver MUST NOT permit users to * configure it less than minHeartbeatFrequencyMS (500ms)." */ ASSERT (!mongoc_uri_set_option_as_int32 ( uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 499)); ASSERT_CAPTURED_LOG ( "mongoc_uri_set_option_as_int32", MONGOC_LOG_LEVEL_WARNING, "Invalid \"heartbeatfrequencyms\" of 499: must be at least 500"); /* socketcheckintervalms isn't set, return our fallback */ ASSERT_CMPINT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 123), ==, 123); ASSERT (mongoc_uri_set_option_as_int32 ( uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 18)); ASSERT_CMPINT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 19), ==, 18); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_JOURNAL, false)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_CANONICALIZEHOSTNAME, true)); /* tls isn't set, return out fallback */ ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLS, true)); client = test_framework_client_new_from_uri (uri, NULL); mongoc_uri_destroy (uri); ASSERT ( mongoc_uri_get_option_as_bool (client->uri, MONGOC_URI_JOURNAL, false)); ASSERT (!mongoc_uri_get_option_as_bool ( client->uri, MONGOC_URI_CANONICALIZEHOSTNAME, true)); /* tls isn't set, return out fallback */ ASSERT (mongoc_uri_get_option_as_bool (client->uri, MONGOC_URI_TLS, true)); mongoc_client_destroy (client); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 (uri, "replicaset", "default"), "default"); ASSERT (mongoc_uri_set_option_as_utf8 (uri, "replicaset", "value")); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 (uri, "replicaset", "default"), "value"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_SOCKETTIMEOUTMS "=1&" MONGOC_URI_SOCKETCHECKINTERVALMS "=200"); ASSERT_CMPINT ( 1, ==, mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0)); ASSERT_CMPINT (200, ==, mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 0)); mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 2); ASSERT_CMPINT ( 2, ==, mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0)); mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 202); ASSERT_CMPINT (202, ==, mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 0)); client = test_framework_client_new_from_uri (uri, NULL); ASSERT_CMPINT (2, ==, client->cluster.sockettimeoutms); ASSERT_CMPINT (202, ==, client->cluster.socketcheckintervalms); mongoc_client_destroy (client); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://host/dbname0"); ASSERT_CMPSTR (mongoc_uri_get_database (uri), "dbname0"); mongoc_uri_set_database (uri, "dbname1"); client = test_framework_client_new_from_uri (uri, NULL); db = mongoc_client_get_default_database (client); ASSERT_CMPSTR (mongoc_database_get_name (db), "dbname1"); mongoc_database_destroy (db); mongoc_client_destroy (client); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://%2Ftmp%2FMongoDB-27017.sock/"); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host, "/tmp/MongoDB-27017.sock"); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, "/tmp/MongoDB-27017.sock"); mongoc_uri_destroy (uri); capture_logs (true); uri = mongoc_uri_new ("mongodb://host/?foobar=1"); ASSERT (uri); ASSERT_CAPTURED_LOG ("setting URI option foobar=1", MONGOC_LOG_LEVEL_WARNING, "Unsupported URI option \"foobar\""); mongoc_uri_destroy (uri); } static void test_mongoc_uri_new_with_error (void) { bson_error_t error = {0}; mongoc_uri_t *uri; capture_logs (true); ASSERT (!mongoc_uri_new_with_error ("mongodb://", NULL)); uri = mongoc_uri_new_with_error ("mongodb://localhost", NULL); ASSERT (uri); mongoc_uri_destroy (uri); ASSERT (!mongoc_uri_new_with_error ("mongodb://", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid host string in URI"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ("mongo://localhost", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid URI Schema, expecting 'mongodb://'"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/?readPreference=unknown", &error)); ASSERT_ERROR_CONTAINS ( error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Unsupported readPreference value [readPreference=unknown]"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/" "?appname=" "WayTooLongAppnameToBeValidSoThisShouldResultInAnErrorWayToLongAppnameToB" "eValidSoThisShouldResultInAnErrorWayToLongAppnameToBeValidSoThisShouldRe" "sultInAnError", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Unsupported value for \"appname\""); /* ... */ uri = mongoc_uri_new ("mongodb://localhost"); ASSERT (!mongoc_uri_set_option_as_utf8 ( uri, MONGOC_URI_APPNAME, "WayTooLongAppnameToBeValidSoThisShouldResultInAnErrorWayToLongAppnameToB" "eValidSoThisShouldResultInAnErrorWayToLongAppnameToBeValidSoThisShouldRe" "sultInAnError")); mongoc_uri_destroy (uri); memset (&error, 0, sizeof (bson_error_t)); ASSERT ( !mongoc_uri_new_with_error ("mongodb://user%p:pass@localhost/", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Incorrect URI escapes in username. Percent-encode " "username and password according to RFC 3986"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ("mongodb://l%oc, alhost/", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid host string in URI"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ("mongodb:///tmp/mongodb.sock", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid host string in URI") memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ("mongodb://localhost/db.na%me", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid database name in URI"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/db?journal=true&w=0", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Journal conflicts with w value [w=0]"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/db?journal=true&w=-1", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Journal conflicts with w value [w=-1]"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ("mongodb://localhost/db?w=-5", &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Unsupported w value [w=-5]"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/db?heartbeatfrequencyms=10", &error)); ASSERT_ERROR_CONTAINS ( error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid \"heartbeatfrequencyms\" of 10: must be at least 500"); memset (&error, 0, sizeof (bson_error_t)); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/db?zlibcompressionlevel=10", &error)); ASSERT_ERROR_CONTAINS ( error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid \"zlibcompressionlevel\" of 10: must be between -1 and 9"); } #undef ASSERT_SUPPRESS static void test_mongoc_uri_compound_setters (void) { mongoc_uri_t *uri; mongoc_read_prefs_t *prefs; const mongoc_read_prefs_t *prefs_result; mongoc_read_concern_t *rc; const mongoc_read_concern_t *rc_result; mongoc_write_concern_t *wc; const mongoc_write_concern_t *wc_result; uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS "=dc:ny&" MONGOC_URI_READCONCERNLEVEL "=majority&" MONGOC_URI_W "=3"); prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); mongoc_uri_set_read_prefs_t (uri, prefs); prefs_result = mongoc_uri_get_read_prefs_t (uri); ASSERT_CMPINT ( mongoc_read_prefs_get_mode (prefs_result), ==, MONGOC_READ_SECONDARY); ASSERT (bson_empty (mongoc_read_prefs_get_tags (prefs_result))); rc = mongoc_read_concern_new (); mongoc_read_concern_set_level (rc, "whatever"); mongoc_uri_set_read_concern (uri, rc); rc_result = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc_result), "whatever"); wc = mongoc_write_concern_new (); mongoc_write_concern_set_w (wc, 2); mongoc_uri_set_write_concern (uri, wc); wc_result = mongoc_uri_get_write_concern (uri); ASSERT_CMPINT32 (mongoc_write_concern_get_w (wc_result), ==, (int32_t) 2); mongoc_read_prefs_destroy (prefs); mongoc_read_concern_destroy (rc); mongoc_write_concern_destroy (wc); mongoc_uri_destroy (uri); } static void test_mongoc_host_list_from_string (void) { mongoc_host_list_t host_list = {0}; /* shouldn't be parsable */ capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, ":27017")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, "example.com:")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, "localhost:999999999")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, "::1234")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, "]:1234")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, "[]:1234")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT (!_mongoc_host_list_from_string (&host_list, "[::1] foo")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "Could not parse address"); capture_logs (true); ASSERT ( !_mongoc_host_list_from_string (&host_list, "[::1]extra_chars:27017")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "If present, port should immediately follow the \"]\"" "in an IPv6 address"); /* normal parsing, host and port are split, host is downcased */ ASSERT (_mongoc_host_list_from_string (&host_list, "localHOST:27019")); ASSERT_CMPSTR (host_list.host_and_port, "localhost:27019"); ASSERT_CMPSTR (host_list.host, "localhost"); ASSERT (host_list.port == 27019); ASSERT (!host_list.next); ASSERT (_mongoc_host_list_from_string (&host_list, "localhost")); ASSERT_CMPSTR (host_list.host_and_port, "localhost:27017"); ASSERT_CMPSTR (host_list.host, "localhost"); ASSERT (host_list.port == 27017); ASSERT (_mongoc_host_list_from_string (&host_list, "[::1]")); ASSERT_CMPSTR (host_list.host_and_port, "[::1]:27017"); ASSERT_CMPSTR (host_list.host, "::1"); /* no "[" or "]" */ ASSERT (host_list.port == 27017); ASSERT (_mongoc_host_list_from_string (&host_list, "[Fe80::1]:1234")); ASSERT_CMPSTR (host_list.host_and_port, "[fe80::1]:1234"); ASSERT_CMPSTR (host_list.host, "fe80::1"); ASSERT (host_list.port == 1234); ASSERT (_mongoc_host_list_from_string (&host_list, "[fe80::1%lo0]:1234")); ASSERT_CMPSTR (host_list.host_and_port, "[fe80::1%lo0]:1234"); ASSERT_CMPSTR (host_list.host, "fe80::1%lo0"); ASSERT (host_list.port == 1234); ASSERT (_mongoc_host_list_from_string (&host_list, "[fe80::1%lo0]:1234")); ASSERT_CMPSTR (host_list.host_and_port, "[fe80::1%lo0]:1234"); ASSERT_CMPSTR (host_list.host, "fe80::1%lo0"); ASSERT (host_list.port == 1234); /* preserves case */ ASSERT (_mongoc_host_list_from_string (&host_list, "/Path/to/file.sock")); ASSERT_CMPSTR (host_list.host_and_port, "/Path/to/file.sock"); ASSERT_CMPSTR (host_list.host, "/Path/to/file.sock"); /* weird cases that should still parse, without crashing */ ASSERT (_mongoc_host_list_from_string (&host_list, "/Path/to/file.sock:1")); ASSERT_CMPSTR (host_list.host, "/Path/to/file.sock"); ASSERT (host_list.family == AF_UNIX); ASSERT (_mongoc_host_list_from_string (&host_list, " :1234")); ASSERT_CMPSTR (host_list.host_and_port, " :1234"); ASSERT_CMPSTR (host_list.host, " "); ASSERT (host_list.port == 1234); ASSERT (_mongoc_host_list_from_string (&host_list, "[:1234")); ASSERT_CMPSTR (host_list.host_and_port, "[:1234"); ASSERT_CMPSTR (host_list.host, "["); ASSERT (host_list.port == 1234); ASSERT (_mongoc_host_list_from_string (&host_list, "[:]")); ASSERT_CMPSTR (host_list.host_and_port, "[:]:27017"); ASSERT_CMPSTR (host_list.host, ":"); ASSERT (host_list.port == 27017); } static void test_mongoc_uri_new_for_host_port (void) { mongoc_uri_t *uri; uri = mongoc_uri_new_for_host_port ("uber", 555); ASSERT (uri); ASSERT (!strcmp ("uber", mongoc_uri_get_hosts (uri)->host)); ASSERT (!strcmp ("uber:555", mongoc_uri_get_hosts (uri)->host_and_port)); ASSERT (555 == mongoc_uri_get_hosts (uri)->port); mongoc_uri_destroy (uri); } static void test_mongoc_uri_compressors (void) { mongoc_uri_t *uri; uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (bson_empty (mongoc_uri_get_compressors (uri))); #ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY capture_logs (true); mongoc_uri_set_compressors (uri, "snappy,unknown"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "unknown")); ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Unsupported compressor: 'unknown'"); #endif #ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY capture_logs (true); mongoc_uri_set_compressors (uri, "snappy"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "unknown")); ASSERT_NO_CAPTURED_LOGS ("snappy uri"); /* Overwrite the previous URI, effectively disabling snappy */ capture_logs (true); mongoc_uri_set_compressors (uri, "unknown"); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "unknown")); ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Unsupported compressor: 'unknown'"); #endif capture_logs (true); mongoc_uri_set_compressors (uri, ""); ASSERT (bson_empty (mongoc_uri_get_compressors (uri))); ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Unsupported compressor: ''"); /* Disable compression */ capture_logs (true); mongoc_uri_set_compressors (uri, NULL); ASSERT (bson_empty (mongoc_uri_get_compressors (uri))); ASSERT_NO_CAPTURED_LOGS ("Disable compression"); mongoc_uri_destroy (uri); #ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY uri = mongoc_uri_new ("mongodb://localhost/?compressors=snappy"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); mongoc_uri_destroy (uri); capture_logs (true); uri = mongoc_uri_new ("mongodb://localhost/?compressors=snappy,somethingElse"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "somethingElse")); ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Unsupported compressor: 'somethingElse'"); mongoc_uri_destroy (uri); #endif #ifdef MONGOC_ENABLE_COMPRESSION_ZLIB #ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY uri = mongoc_uri_new ("mongodb://localhost/?compressors=snappy,zlib"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_compressors (uri, "snappy,zlib")); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_compressors (uri, "zlib")); ASSERT (mongoc_uri_set_compressors (uri, "snappy")); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); mongoc_uri_destroy (uri); #endif uri = mongoc_uri_new ("mongodb://localhost/?compressors=zlib"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); mongoc_uri_destroy (uri); capture_logs (true); uri = mongoc_uri_new ("mongodb://localhost/?compressors=zlib,somethingElse"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "somethingElse")); ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Unsupported compressor: 'somethingElse'"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=-1"); ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); ASSERT_CMPINT32 ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 1), ==, -1); mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=9"); ASSERT_CMPINT32 ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 1), ==, 9); mongoc_uri_destroy (uri); capture_logs (true); uri = mongoc_uri_new ( "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=-2"); ASSERT_CAPTURED_LOG ( "mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Invalid \"zlibcompressionlevel\" of -2: must be between -1 and 9"); mongoc_uri_destroy (uri); capture_logs (true); uri = mongoc_uri_new ( "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=10"); ASSERT_CAPTURED_LOG ( "mongoc_uri_set_compressors", MONGOC_LOG_LEVEL_WARNING, "Invalid \"zlibcompressionlevel\" of 10: must be between -1 and 9"); mongoc_uri_destroy (uri); #endif } static void test_mongoc_uri_unescape (void) { #define ASSERT_URIDECODE_STR(_s, _e) \ do { \ char *str = mongoc_uri_unescape (_s); \ ASSERT (!strcmp (str, _e)); \ bson_free (str); \ } while (0) #define ASSERT_URIDECODE_FAIL(_s) \ do { \ char *str; \ capture_logs (true); \ str = mongoc_uri_unescape (_s); \ ASSERT (!str); \ ASSERT_CAPTURED_LOG ( \ "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); \ } while (0) ASSERT_URIDECODE_STR ("", ""); ASSERT_URIDECODE_STR ("%40", "@"); ASSERT_URIDECODE_STR ("me%40localhost@localhost", "me@localhost@localhost"); ASSERT_URIDECODE_STR ("%20", " "); ASSERT_URIDECODE_STR ("%24%21%40%2A%26%5E%21%40%2A%23%26%5E%21%40%23%2A%26" "%5E%21%40%2A%23%26%5E%21%40%2A%26%23%5E%7D%7B%7D%7B" "%22%22%27%7D%7B%5B%5D%3C%3E%3F", "$!@*&^!@*#&^!@#*&^!@*#&^!@*&#^}{}{\"\"'}{[]<>?"); ASSERT_URIDECODE_FAIL ("%"); ASSERT_URIDECODE_FAIL ("%%"); ASSERT_URIDECODE_FAIL ("%%%"); ASSERT_URIDECODE_FAIL ("%FF"); ASSERT_URIDECODE_FAIL ("%CC"); ASSERT_URIDECODE_FAIL ("%00"); #undef ASSERT_URIDECODE_STR #undef ASSERT_URIDECODE_FAIL } typedef struct { const char *uri; bool parses; mongoc_read_mode_t mode; bson_t *tags; const char *log_msg; } read_prefs_test; static void test_mongoc_uri_read_prefs (void) { const mongoc_read_prefs_t *rp; mongoc_uri_t *uri; const read_prefs_test *t; int i; bson_t *tags_dcny = BCON_NEW ("0", "{", "dc", "ny", "}"); bson_t *tags_dcny_empty = BCON_NEW ("0", "{", "dc", "ny", "}", "1", "{", "}"); bson_t *tags_dcnyusessd_dcsf_empty = BCON_NEW ("0", "{", "dc", "ny", "use", "ssd", "}", "1", "{", "dc", "sf", "}", "2", "{", "}"); bson_t *tags_empty = BCON_NEW ("0", "{", "}"); const char *conflicts = "Invalid readPreferences"; const read_prefs_test tests[] = { {"mongodb://localhost/", true, MONGOC_READ_PRIMARY, NULL}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=primary", true, MONGOC_READ_PRIMARY, NULL}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=primaryPreferred", true, MONGOC_READ_PRIMARY_PREFERRED, NULL}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=secondary", true, MONGOC_READ_SECONDARY, NULL}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=secondaryPreferred", true, MONGOC_READ_SECONDARY_PREFERRED, NULL}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=nearest", true, MONGOC_READ_NEAREST, NULL}, /* MONGOC_URI_READPREFERENCETAGS conflict with primary mode */ {"mongodb://localhost/?" MONGOC_URI_READPREFERENCETAGS "=", false, MONGOC_READ_PRIMARY, NULL, conflicts}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=primary&" MONGOC_URI_READPREFERENCETAGS "=", false, MONGOC_READ_PRIMARY, NULL, conflicts}, {"mongodb://localhost/" "?" MONGOC_URI_READPREFERENCE "=secondaryPreferred&" MONGOC_URI_READPREFERENCETAGS "=", true, MONGOC_READ_SECONDARY_PREFERRED, tags_empty}, {"mongodb://localhost/" "?" MONGOC_URI_READPREFERENCE "=secondaryPreferred&" MONGOC_URI_READPREFERENCETAGS "=dc:ny", true, MONGOC_READ_SECONDARY_PREFERRED, tags_dcny}, {"mongodb://localhost/" "?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS "=dc:ny&" MONGOC_URI_READPREFERENCETAGS "=", true, MONGOC_READ_NEAREST, tags_dcny_empty}, {"mongodb://localhost/" "?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS "=dc:ny,use:ssd&" MONGOC_URI_READPREFERENCETAGS "=dc:sf&" MONGOC_URI_READPREFERENCETAGS "=", true, MONGOC_READ_NEAREST, tags_dcnyusessd_dcsf_empty}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS "=foo", false, MONGOC_READ_NEAREST, NULL, "Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS "\": \"foo\""}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS "=foo,bar", false, MONGOC_READ_NEAREST, NULL, "Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS "\": \"foo,bar\""}, {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS "=1", false, MONGOC_READ_NEAREST, NULL, "Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS "\": \"1\""}, {NULL}}; for (i = 0; tests[i].uri; i++) { t = &tests[i]; capture_logs (true); uri = mongoc_uri_new (t->uri); if (t->parses) { BSON_ASSERT (uri); ASSERT_NO_CAPTURED_LOGS (t->uri); } else { BSON_ASSERT (!uri); if (t->log_msg) { ASSERT_CAPTURED_LOG (t->uri, MONGOC_LOG_LEVEL_WARNING, t->log_msg); } continue; } rp = mongoc_uri_get_read_prefs_t (uri); BSON_ASSERT (rp); BSON_ASSERT (t->mode == mongoc_read_prefs_get_mode (rp)); if (t->tags) { BSON_ASSERT (bson_equal (t->tags, mongoc_read_prefs_get_tags (rp))); } mongoc_uri_destroy (uri); } bson_destroy (tags_dcny); bson_destroy (tags_dcny_empty); bson_destroy (tags_dcnyusessd_dcsf_empty); bson_destroy (tags_empty); } typedef struct { const char *uri; bool parses; int32_t w; const char *wtag; int64_t wtimeoutms; const char *log_msg; } write_concern_test; static void test_mongoc_uri_write_concern (void) { const mongoc_write_concern_t *wr; mongoc_uri_t *uri; const write_concern_test *t; int i; static const write_concern_test tests[] = { {"mongodb://localhost/?" MONGOC_URI_SAFE "=false", true, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED}, {"mongodb://localhost/?" MONGOC_URI_SAFE "=true", true, 1}, {"mongodb://localhost/?" MONGOC_URI_W "=-1", true, MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED}, {"mongodb://localhost/?" MONGOC_URI_W "=0", true, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED}, {"mongodb://localhost/?" MONGOC_URI_W "=1", true, 1}, {"mongodb://localhost/?" MONGOC_URI_W "=2", true, 2}, {"mongodb://localhost/?" MONGOC_URI_W "=majority", true, MONGOC_WRITE_CONCERN_W_MAJORITY}, {"mongodb://localhost/?" MONGOC_URI_W "=10", true, 10}, {"mongodb://localhost/?" MONGOC_URI_W "=", true, MONGOC_WRITE_CONCERN_W_DEFAULT}, {"mongodb://localhost/?" MONGOC_URI_W "=mytag", true, MONGOC_WRITE_CONCERN_W_TAG, "mytag"}, {"mongodb://localhost/?" MONGOC_URI_W "=mytag&" MONGOC_URI_SAFE "=false", true, MONGOC_WRITE_CONCERN_W_TAG, "mytag"}, {"mongodb://localhost/?" MONGOC_URI_W "=1&" MONGOC_URI_SAFE "=false", true, 1}, {"mongodb://localhost/?" MONGOC_URI_JOURNAL "=true", true, MONGOC_WRITE_CONCERN_W_DEFAULT}, {"mongodb://localhost/?" MONGOC_URI_W "=1&" MONGOC_URI_JOURNAL "=true", true, 1}, {"mongodb://localhost/?" MONGOC_URI_W "=2&" MONGOC_URI_WTIMEOUTMS "=1000", true, 2, NULL, 1000}, {"mongodb://localhost/?" MONGOC_URI_W "=2&" MONGOC_URI_WTIMEOUTMS "=2147483648", true, 2, NULL, 2147483648LL}, {"mongodb://localhost/?" MONGOC_URI_W "=majority&" MONGOC_URI_WTIMEOUTMS "=1000", true, MONGOC_WRITE_CONCERN_W_MAJORITY, NULL, 1000}, {"mongodb://localhost/?" MONGOC_URI_W "=mytag&" MONGOC_URI_WTIMEOUTMS "=1000", true, MONGOC_WRITE_CONCERN_W_TAG, "mytag", 1000}, {"mongodb://localhost/?" MONGOC_URI_W "=0&" MONGOC_URI_JOURNAL "=true", false, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED, NULL, 0, "Journal conflicts with w value [" MONGOC_URI_W "=0]"}, {"mongodb://localhost/?" MONGOC_URI_W "=-1&" MONGOC_URI_JOURNAL "=true", false, MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED, NULL, 0, "Journal conflicts with w value [" MONGOC_URI_W "=-1]"}, {NULL}}; for (i = 0; tests[i].uri; i++) { t = &tests[i]; capture_logs (true); uri = mongoc_uri_new (t->uri); if (tests[i].log_msg) { ASSERT_CAPTURED_LOG ( tests[i].uri, MONGOC_LOG_LEVEL_WARNING, tests[i].log_msg); } else { ASSERT_NO_CAPTURED_LOGS (tests[i].uri); } capture_logs (false); /* clear captured logs */ if (t->parses) { BSON_ASSERT (uri); } else { BSON_ASSERT (!uri); continue; } wr = mongoc_uri_get_write_concern (uri); BSON_ASSERT (wr); BSON_ASSERT (t->w == mongoc_write_concern_get_w (wr)); if (t->wtag) { BSON_ASSERT (0 == strcmp (t->wtag, mongoc_write_concern_get_wtag (wr))); } if (t->wtimeoutms) { BSON_ASSERT (t->wtimeoutms == mongoc_write_concern_get_wtimeout_int64 (wr)); } mongoc_uri_destroy (uri); } } static void test_mongoc_uri_read_concern (void) { const mongoc_read_concern_t *rc; mongoc_uri_t *uri; uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL "=majority"); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "majority"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/" "?" MONGOC_URI_READCONCERNLEVEL "=" MONGOC_READ_CONCERN_LEVEL_MAJORITY); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "majority"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/" "?" MONGOC_URI_READCONCERNLEVEL "=" MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "linearizable"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL "=local"); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "local"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL "=" MONGOC_READ_CONCERN_LEVEL_LOCAL); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "local"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL "=randomstuff"); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "randomstuff"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); rc = mongoc_uri_get_read_concern (uri); ASSERT (mongoc_read_concern_get_level (rc) == NULL); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL "="); rc = mongoc_uri_get_read_concern (uri); ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), ""); mongoc_uri_destroy (uri); } static void test_mongoc_uri_long_hostname (void) { char *host; char *host_and_port; size_t len = BSON_HOST_NAME_MAX; char *uri_str; mongoc_uri_t *uri; /* hostname of exactly maximum length */ host = bson_malloc (len + 1); memset (host, 'a', len); host[len] = '\0'; host_and_port = bson_strdup_printf ("%s:12345", host); uri_str = bson_strdup_printf ("mongodb://%s", host_and_port); uri = mongoc_uri_new (uri_str); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, host_and_port); mongoc_uri_destroy (uri); uri = mongoc_uri_new_for_host_port (host, 12345); ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, host_and_port); mongoc_uri_destroy (uri); bson_free (uri_str); bson_free (host_and_port); bson_free (host); /* hostname length exceeds maximum by one */ len++; host = bson_malloc (len + 1); memset (host, 'a', len); host[len] = '\0'; host_and_port = bson_strdup_printf ("%s:12345", host); uri_str = bson_strdup_printf ("mongodb://%s", host_and_port); capture_logs (true); ASSERT (!mongoc_uri_new (uri_str)); ASSERT_CAPTURED_LOG ("mongoc_uri_new", MONGOC_LOG_LEVEL_ERROR, "too long"); clear_captured_logs (); ASSERT (!mongoc_uri_new_for_host_port (host, 12345)); ASSERT_CAPTURED_LOG ("mongoc_uri_new", MONGOC_LOG_LEVEL_ERROR, "too long"); bson_free (uri_str); bson_free (host_and_port); bson_free (host); } static void test_mongoc_uri_tls_ssl (const char *tls, const char *tlsCertificateKeyFile, const char *tlsCertificateKeyPassword, const char *tlsCAFile, const char *tlsAllowInvalidCertificates, const char *tlsAllowInvalidHostnames) { const char *tlsalt; char url_buffer[2048]; mongoc_uri_t *uri; bson_error_t err; bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://CN=client,OU=kerneluser,O=10Gen,L=New York City," "ST=New York,C=US@ldaptest.10gen.cc/?" "%s=true&authMechanism=MONGODB-X509&" "%s=tests/x509gen/legacy-x509.pem&" "%s=tests/x509gen/legacy-ca.crt&" "%s=true", tls, tlsCertificateKeyFile, tlsCAFile, tlsAllowInvalidHostnames); uri = mongoc_uri_new (url_buffer); ASSERT_CMPSTR ( mongoc_uri_get_username (uri), "CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US"); ASSERT (!mongoc_uri_get_password (uri)); ASSERT (!mongoc_uri_get_database (uri)); ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "$external"); ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), "tests/x509gen/legacy-x509.pem"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), "none"); ASSERT_CMPSTR ( mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), "tests/x509gen/legacy-ca.crt"); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true&%s=key.pem&%s=ca.pem", tls, tlsCertificateKeyFile, tlsCAFile); uri = mongoc_uri_new (url_buffer); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE, "none"), "key.pem"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), "key.pem"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD, "none"), "none"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), "none"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE, "none"), "ca.pem"); ASSERT_CMPSTR ( mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), "ca.pem"); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); mongoc_uri_destroy (uri); bson_snprintf ( url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tls); uri = mongoc_uri_new (url_buffer); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), "none"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), "none"); ASSERT_CMPSTR ( mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), "none"); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true&%s=pa$$word!&%s=encrypted.pem", tls, tlsCertificateKeyPassword, tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE, "none"), "encrypted.pem"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), "encrypted.pem"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD, "none"), "pa$$word!"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), "pa$$word!"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE, "none"), "none"); ASSERT_CMPSTR ( mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), "none"); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true&%s=true", tls, tlsAllowInvalidCertificates); uri = mongoc_uri_new (url_buffer); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), "none"); ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), "none"); ASSERT_CMPSTR ( mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), "none"); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCAFile); uri = mongoc_uri_new (url_buffer); ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidCertificates); uri = mongoc_uri_new (url_buffer); ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidHostnames); uri = mongoc_uri_new (url_buffer); ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=true", tls, tlsAllowInvalidCertificates); uri = mongoc_uri_new (url_buffer); ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=false", tls, tlsAllowInvalidHostnames); uri = mongoc_uri_new (url_buffer); ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, true)); ASSERT (!mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true)); mongoc_uri_destroy (uri); if (!strcmp (tls, "ssl")) { tlsalt = "tls"; } else { tlsalt = "ssl"; } /* Mixing options okay so long as they match */ capture_logs (true); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true&%s=true", tls, tlsalt); uri = mongoc_uri_new (url_buffer); ASSERT (mongoc_uri_get_option_as_bool (uri, tls, false)); ASSERT_NO_CAPTURED_LOGS (url_buffer); mongoc_uri_destroy (uri); /* Same option with different values okay, latter overrides */ capture_logs (true); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true&%s=false", tls, tls); uri = mongoc_uri_new (url_buffer); ASSERT (!mongoc_uri_get_option_as_bool (uri, tls, true)); if (strcmp (tls, "tls")) { ASSERT_CAPTURED_LOG ("option: ssl", MONGOC_LOG_LEVEL_WARNING, "Overwriting previously provided value for 'ssl'"); } else { ASSERT_CAPTURED_LOG ("option: tls", MONGOC_LOG_LEVEL_WARNING, "Overwriting previously provided value for 'tls'"); } mongoc_uri_destroy (uri); /* Mixing options not okay if values differ */ capture_logs (false); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true&%s=false", tls, tlsalt); uri = mongoc_uri_new_with_error (url_buffer, &err); if (strcmp (tls, "tls")) { ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Deprecated option 'ssl=true' conflicts with " "canonical name 'tls=false'"); } else { ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Deprecated option 'ssl=false' conflicts with " "canonical name 'tls=true'"); } mongoc_uri_destroy (uri); /* No conflict appears with implicit tls=true via SRV */ capture_logs (false); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb+srv://a.b.c/?%s=foo.pem", tlsCAFile); uri = mongoc_uri_new (url_buffer); ASSERT (mongoc_uri_get_option_as_bool (uri, tls, false)); mongoc_uri_destroy (uri); /* Set TLS options after creating mongoc_uri_t from connection string */ uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_option_as_utf8 ( uri, tlsCertificateKeyFile, "/path/to/pem")); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_option_as_utf8 ( uri, tlsCertificateKeyPassword, "password")); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_option_as_utf8 (uri, tlsCAFile, "/path/to/pem")); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT ( mongoc_uri_set_option_as_bool (uri, tlsAllowInvalidCertificates, false)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_option_as_bool (uri, tlsAllowInvalidHostnames, true)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); } static void test_mongoc_uri_tls (void) { bson_error_t err = {0}; mongoc_uri_t *uri; test_mongoc_uri_tls_ssl (MONGOC_URI_TLS, MONGOC_URI_TLSCERTIFICATEKEYFILE, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, MONGOC_URI_TLSCAFILE, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES); /* non-canonical case for tls options */ test_mongoc_uri_tls_ssl ("tls", "TlsCertificateKeyFile", "tlsCertificateKeyFilePASSWORD", "tlsCAFILE", "TLSALLOWINVALIDCERTIFICATES", "tLSaLLOWiNVALIDhOSTNAMES"); /* non-canonical case for tls option */ uri = mongoc_uri_new ("mongodb://localhost/?tLs=true"); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_option_as_bool (uri, "TLS", true)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); /* tls-only option */ uri = mongoc_uri_new ("mongodb://localhost/?tlsInsecure=true"); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSINSECURE, false)); mongoc_uri_destroy (uri); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/?tlsInsecure=true&tlsAllowInvalidHostnames=false", &err)); ASSERT_ERROR_CONTAINS ( err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "tlsinsecure may not be specified with " "tlsallowinvalidcertificates, tlsallowinvalidhostnames, " "tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck"); ASSERT (!mongoc_uri_new_with_error ( "mongodb://localhost/" "?tlsInsecure=true&tlsAllowInvalidCertificates=true", &err)); ASSERT_ERROR_CONTAINS ( err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "tlsinsecure may not be specified with " "tlsallowinvalidcertificates, tlsallowinvalidhostnames, " "tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck"); } static void test_mongoc_uri_ssl (void) { mongoc_uri_t *uri; test_mongoc_uri_tls_ssl (MONGOC_URI_SSL, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES); /* non-canonical case for ssl options */ test_mongoc_uri_tls_ssl ("ssl", "SslClientCertificateKeyFile", "sslClientCertificateKeyPASSWORD", "sslCERTIFICATEAUTHORITYFILE", "SSLALLOWINVALIDCERTIFICATES", "sSLaLLOWiNVALIDhOSTNAMES"); /* non-canonical case for ssl option */ uri = mongoc_uri_new ("mongodb://localhost/?sSl=true"); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/"); ASSERT (mongoc_uri_set_option_as_bool (uri, "SSL", true)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); } static void test_mongoc_uri_local_threshold_ms (void) { mongoc_uri_t *uri; uri = mongoc_uri_new ("mongodb://localhost/"); /* localthresholdms isn't set, return the default */ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS); ASSERT ( mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_LOCALTHRESHOLDMS, 99)); ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 99); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_LOCALTHRESHOLDMS "=0"); ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 0); ASSERT ( mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_LOCALTHRESHOLDMS, 99)); ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 99); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_LOCALTHRESHOLDMS "=-1"); /* localthresholdms is invalid, return the default */ capture_logs (true); ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS); ASSERT_CAPTURED_LOG ("mongoc_uri_get_local_threshold_option", MONGOC_LOG_LEVEL_WARNING, "Invalid localThresholdMS: -1"); mongoc_uri_destroy (uri); } #define INVALID(_uri, _host) \ BSON_ASSERT (!mongoc_uri_upsert_host ((_uri), (_host), 1, &error)); \ ASSERT_ERROR_CONTAINS (error, \ MONGOC_ERROR_STREAM, \ MONGOC_ERROR_STREAM_NAME_RESOLUTION, \ "must be subdomain") #define VALID(_uri, _host) \ ASSERT_OR_PRINT (mongoc_uri_upsert_host ((_uri), (_host), 1, &error), error) static void test_mongoc_uri_srv (void) { mongoc_uri_t *uri; bson_error_t error; capture_logs (true); ASSERT (!mongoc_uri_new ("mongodb+srv://")); /* requires a subdomain, domain, and TLD: "a.example.com" */ ASSERT (!mongoc_uri_new ("mongodb+srv://foo")); ASSERT (!mongoc_uri_new ("mongodb+srv://foo.")); ASSERT (!mongoc_uri_new ("mongodb+srv://.foo")); ASSERT (!mongoc_uri_new ("mongodb+srv://..")); ASSERT (!mongoc_uri_new ("mongodb+srv://.a.")); ASSERT (!mongoc_uri_new ("mongodb+srv://.a.b.c.com")); ASSERT (!mongoc_uri_new ("mongodb+srv://foo\x08\x00bar")); ASSERT (!mongoc_uri_new ("mongodb+srv://foo%00bar")); ASSERT (!mongoc_uri_new ("mongodb+srv://example.com")); uri = mongoc_uri_new ("mongodb+srv://c.d.com"); BSON_ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_srv_hostname (uri), "c.d.com"); BSON_ASSERT (mongoc_uri_get_hosts (uri) == NULL); /* tls is set to true when we use SRV */ ASSERT_MATCH (mongoc_uri_get_options (uri), "{'tls': true}"); /* but we can override tls */ mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb+srv://c.d.com/?tls=false"); BSON_ASSERT (uri); ASSERT_MATCH (mongoc_uri_get_options (uri), "{'tls': false}"); INVALID (uri, "com"); INVALID (uri, "foo.com"); INVALID (uri, "d.com"); INVALID (uri, "cd.com"); VALID (uri, "c.d.com"); VALID (uri, "bc.d.com"); VALID (uri, "longer-string.d.com"); INVALID (uri, ".c.d.com"); VALID (uri, "b.c.d.com"); INVALID (uri, ".b.c.d.com"); INVALID (uri, "..b.c.d.com"); VALID (uri, "a.b.c.d.com"); mongoc_uri_destroy (uri); uri = mongoc_uri_new ("mongodb+srv://b.c.d.com"); INVALID (uri, "foo.com"); INVALID (uri, "a.b.d.com"); INVALID (uri, "d.com"); VALID (uri, "b.c.d.com"); VALID (uri, "a.b.c.d.com"); VALID (uri, "foo.a.b.c.d.com"); mongoc_uri_destroy (uri); /* trailing dot is OK */ uri = mongoc_uri_new ("mongodb+srv://service.consul."); BSON_ASSERT (uri); ASSERT_CMPSTR (mongoc_uri_get_srv_hostname (uri), "service.consul."); BSON_ASSERT (mongoc_uri_get_hosts (uri) == NULL); INVALID (uri, ".consul."); INVALID (uri, "service.consul"); INVALID (uri, "a.service.consul"); INVALID (uri, "service.a.consul"); INVALID (uri, "a.com"); VALID (uri, "service.consul."); VALID (uri, "a.service.consul."); VALID (uri, "a.b.service.consul."); mongoc_uri_destroy (uri); } #define PROHIBITED(_key, _value, _type, _where) \ do { \ const char *option = _key "=" #_value; \ char *lkey = bson_strdup (_key); \ mongoc_lowercase (lkey, lkey); \ mongoc_uri_parse_options (uri, option, true /* from dns */, &error); \ ASSERT_ERROR_CONTAINS (error, \ MONGOC_ERROR_COMMAND, \ MONGOC_ERROR_COMMAND_INVALID_ARG, \ "prohibited in TXT record"); \ BSON_ASSERT (!bson_has_field (mongoc_uri_get_##_where (uri), lkey)); \ bson_free (lkey); \ } while (0) static void test_mongoc_uri_dns_options (void) { mongoc_uri_t *uri; bson_error_t error; uri = mongoc_uri_new ("mongodb+srv://a.b.c"); BSON_ASSERT (uri); BSON_ASSERT (!mongoc_uri_parse_options ( uri, "tls=false", true /* from dsn */, &error)); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "prohibited in TXT record"); ASSERT_MATCH (mongoc_uri_get_options (uri), "{'tls': true}"); /* key we want to set, value, value type, whether it's option/credential */ PROHIBITED (MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true, bool, options); PROHIBITED (MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, true, bool, options); PROHIBITED (MONGOC_URI_GSSAPISERVICENAME, malicious, utf8, credentials); /* the two options allowed in TXT records, case-insensitive */ BSON_ASSERT (mongoc_uri_parse_options (uri, "authsource=db", true, NULL)); BSON_ASSERT (mongoc_uri_parse_options (uri, "RepLIcaSET=rs", true, NULL)); /* test that URI string overrides TXT record options */ mongoc_uri_destroy (uri); uri = mongoc_uri_new ( "mongodb+srv://user@a.b.c/?authSource=db1&replicaSet=rs1"); capture_logs (true); /* parse_options returns true, but logs warnings */ BSON_ASSERT (mongoc_uri_parse_options ( uri, "authSource=db2&replicaSet=db2", true, NULL)); ASSERT_CAPTURED_LOG ("parsing TXT record", MONGOC_LOG_LEVEL_WARNING, "Cannot override URI option \"authSource\""); ASSERT_CAPTURED_LOG ("parsing TXT record", MONGOC_LOG_LEVEL_WARNING, "Cannot override URI option \"replicaSet\""); capture_logs (false); ASSERT_MATCH (mongoc_uri_get_credentials (uri), "{'authsource': 'db1'}"); ASSERT_MATCH (mongoc_uri_get_options (uri), "{'replicaset': 'rs1'}"); mongoc_uri_destroy (uri); } /* test some invalid accesses and a crash, found with a fuzzer */ static void test_mongoc_uri_utf8 (void) { bson_error_t err; /* start of 3-byte character, but it's incomplete */ BSON_ASSERT (!mongoc_uri_new_with_error ("mongodb://\xe8\x03", &err)); ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid UTF-8 in URI"); /* start of 6-byte CESU-8 character, but it's incomplete */ BSON_ASSERT (!mongoc_uri_new_with_error ("mongodb://\xfa", &err)); ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid UTF-8 in URI"); /* "a<NIL>z" with NIL expressed as two-byte sequence */ BSON_ASSERT (!mongoc_uri_new_with_error ("mongodb://a\xc0\x80z", &err)); ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "Invalid UTF-8 in URI"); } /* test behavior on duplicate values for an options. */ static void test_mongoc_uri_duplicates (void) { mongoc_uri_t *uri = NULL; bson_error_t err; const char *str; const mongoc_write_concern_t *wc; const mongoc_read_concern_t *rc; const bson_t *bson; const mongoc_read_prefs_t *rp; bson_iter_t iter = {0}; #define RECREATE_URI(opts) \ mongoc_uri_destroy (uri); \ uri = mongoc_uri_new_with_error ("mongodb://user:pwd@localhost/test?" opts, \ &err); \ ASSERT_OR_PRINT (uri, err); #define ASSERT_LOG_DUPE(opt) \ ASSERT_CAPTURED_LOG ("option: " opt, \ MONGOC_LOG_LEVEL_WARNING, \ "Overwriting previously provided value for '" opt \ "'"); /* iterate iter to key, and check that no other occurrences exist. */ #define BSON_ITER_UNIQUE(key) \ do { \ bson_iter_t tmp; \ BSON_ASSERT (bson_iter_init_find (&iter, bson, key)); \ tmp = iter; \ while (bson_iter_next (&tmp)) { \ if (strcmp (bson_iter_key (&tmp), key) == 0) { \ ASSERT_WITH_MSG (false, "bson has duplicate keys for: " key); \ } \ } \ } while (0); capture_logs (true); /* test all URI options, in the order they are defined in mongoc-uri.h. */ RECREATE_URI (MONGOC_URI_APPNAME "=a&" MONGOC_URI_APPNAME "=b"); ASSERT_LOG_DUPE (MONGOC_URI_APPNAME); str = mongoc_uri_get_appname (uri); BSON_ASSERT (strcmp (str, "b") == 0); RECREATE_URI (MONGOC_URI_AUTHMECHANISM "=a&" MONGOC_URI_AUTHMECHANISM "=b"); ASSERT_LOG_DUPE (MONGOC_URI_AUTHMECHANISM); bson = mongoc_uri_get_credentials (uri); BSON_ITER_UNIQUE (MONGOC_URI_AUTHMECHANISM); BSON_ASSERT (strcmp (bson_iter_utf8 (&iter, NULL), "b") == 0); RECREATE_URI (MONGOC_URI_AUTHMECHANISMPROPERTIES "=a:x&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=b:y"); ASSERT_LOG_DUPE (MONGOC_URI_AUTHMECHANISMPROPERTIES); bson = mongoc_uri_get_credentials (uri); BSON_ASSERT ( bson_compare ( bson, tmp_bson ("{'authmechanismproperties': {'b': 'y' }}")) == 0); RECREATE_URI (MONGOC_URI_AUTHSOURCE "=a&" MONGOC_URI_AUTHSOURCE "=b"); ASSERT_LOG_DUPE (MONGOC_URI_AUTHSOURCE); str = mongoc_uri_get_auth_source (uri); BSON_ASSERT (strcmp (str, "b") == 0); RECREATE_URI (MONGOC_URI_CANONICALIZEHOSTNAME "=false&" MONGOC_URI_CANONICALIZEHOSTNAME "=true"); ASSERT_LOG_DUPE (MONGOC_URI_CANONICALIZEHOSTNAME); BSON_ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_CANONICALIZEHOSTNAME, false)); RECREATE_URI (MONGOC_URI_CONNECTTIMEOUTMS "=1&" MONGOC_URI_CONNECTTIMEOUTMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_CONNECTTIMEOUTMS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_CONNECTTIMEOUTMS, 0) == 2); #if defined(MONGOC_ENABLE_COMPRESSION_SNAPPY) && \ defined(MONGOC_ENABLE_COMPRESSION_ZLIB) RECREATE_URI (MONGOC_URI_COMPRESSORS "=snappy&" MONGOC_URI_COMPRESSORS "=zlib"); ASSERT_LOG_DUPE (MONGOC_URI_COMPRESSORS); bson = mongoc_uri_get_compressors (uri); BSON_ASSERT (bson_compare (bson, tmp_bson ("{'zlib': 'yes'}")) == 0); #endif /* exception: GSSAPISERVICENAME does not overwrite. */ RECREATE_URI (MONGOC_URI_GSSAPISERVICENAME "=a&" MONGOC_URI_GSSAPISERVICENAME "=b"); ASSERT_CAPTURED_LOG ( "option: " MONGOC_URI_GSSAPISERVICENAME, MONGOC_LOG_LEVEL_WARNING, "Overwriting previously provided value for 'gssapiservicename'"); bson = mongoc_uri_get_credentials (uri); BSON_ASSERT ( bson_compare ( bson, tmp_bson ("{'authmechanismproperties': {'SERVICE_NAME': 'b' }}")) == 0); RECREATE_URI (MONGOC_URI_HEARTBEATFREQUENCYMS "=500&" MONGOC_URI_HEARTBEATFREQUENCYMS "=501"); ASSERT_LOG_DUPE (MONGOC_URI_HEARTBEATFREQUENCYMS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 0) == 501); RECREATE_URI (MONGOC_URI_JOURNAL "=false&" MONGOC_URI_JOURNAL "=true"); ASSERT_LOG_DUPE (MONGOC_URI_JOURNAL); BSON_ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_JOURNAL, false)); RECREATE_URI (MONGOC_URI_LOCALTHRESHOLDMS "=1&" MONGOC_URI_LOCALTHRESHOLDMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_LOCALTHRESHOLDMS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_LOCALTHRESHOLDMS, 0) == 2); RECREATE_URI (MONGOC_URI_MAXIDLETIMEMS "=1&" MONGOC_URI_MAXIDLETIMEMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_MAXIDLETIMEMS); BSON_ASSERT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MAXIDLETIMEMS, 0) == 2); RECREATE_URI (MONGOC_URI_MAXPOOLSIZE "=1&" MONGOC_URI_MAXPOOLSIZE "=2"); ASSERT_LOG_DUPE (MONGOC_URI_MAXPOOLSIZE); BSON_ASSERT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MAXPOOLSIZE, 0) == 2); RECREATE_URI (MONGOC_URI_READPREFERENCE "=secondary&" MONGOC_URI_MAXSTALENESSSECONDS "=1&" MONGOC_URI_MAXSTALENESSSECONDS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_MAXSTALENESSSECONDS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_MAXSTALENESSSECONDS, 0) == 2); RECREATE_URI (MONGOC_URI_MINPOOLSIZE "=1&" MONGOC_URI_MINPOOLSIZE "=2"); ASSERT_LOG_DUPE (MONGOC_URI_MINPOOLSIZE); BSON_ASSERT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MINPOOLSIZE, 0) == 2); RECREATE_URI (MONGOC_URI_READCONCERNLEVEL "=local&" MONGOC_URI_READCONCERNLEVEL "=majority"); ASSERT_LOG_DUPE (MONGOC_URI_READCONCERNLEVEL); rc = mongoc_uri_get_read_concern (uri); BSON_ASSERT (strcmp (mongoc_read_concern_get_level (rc), "majority") == 0); RECREATE_URI (MONGOC_URI_READPREFERENCE "=secondary&" MONGOC_URI_READPREFERENCE "=primary"); ASSERT_LOG_DUPE (MONGOC_URI_READPREFERENCE); rp = mongoc_uri_get_read_prefs_t (uri); BSON_ASSERT (mongoc_read_prefs_get_mode (rp) == MONGOC_READ_PRIMARY); /* exception: read preference tags get appended. */ RECREATE_URI (MONGOC_URI_READPREFERENCE "=secondary&" MONGOC_URI_READPREFERENCETAGS "=a:x&" MONGOC_URI_READPREFERENCETAGS "=b:y"); bson = mongoc_uri_get_read_prefs (uri); BSON_ASSERT (bson_compare ( bson, tmp_bson ("{'0': {'a': 'x'}, '1': {'b': 'y'}}")) == 0); RECREATE_URI (MONGOC_URI_REPLICASET "=a&" MONGOC_URI_REPLICASET "=b"); ASSERT_LOG_DUPE (MONGOC_URI_REPLICASET); str = mongoc_uri_get_replica_set (uri); BSON_ASSERT (strcmp (str, "b") == 0); RECREATE_URI (MONGOC_URI_RETRYREADS "=false&" MONGOC_URI_RETRYREADS "=true"); ASSERT_LOG_DUPE (MONGOC_URI_RETRYREADS); BSON_ASSERT ( mongoc_uri_get_option_as_bool (uri, MONGOC_URI_RETRYREADS, false)); RECREATE_URI (MONGOC_URI_RETRYWRITES "=false&" MONGOC_URI_RETRYWRITES "=true"); ASSERT_LOG_DUPE (MONGOC_URI_RETRYWRITES); BSON_ASSERT ( mongoc_uri_get_option_as_bool (uri, MONGOC_URI_RETRYWRITES, false)); RECREATE_URI (MONGOC_URI_SAFE "=false&" MONGOC_URI_SAFE "=true"); ASSERT_LOG_DUPE (MONGOC_URI_SAFE); BSON_ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SAFE, false)); RECREATE_URI (MONGOC_URI_SERVERSELECTIONTIMEOUTMS "=1&" MONGOC_URI_SERVERSELECTIONTIMEOUTMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_SERVERSELECTIONTIMEOUTMS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 0) == 2); RECREATE_URI (MONGOC_URI_SERVERSELECTIONTRYONCE "=false&" MONGOC_URI_SERVERSELECTIONTRYONCE "=true"); ASSERT_LOG_DUPE (MONGOC_URI_SERVERSELECTIONTRYONCE); BSON_ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false)); RECREATE_URI (MONGOC_URI_SOCKETCHECKINTERVALMS "=1&" MONGOC_URI_SOCKETCHECKINTERVALMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_SOCKETCHECKINTERVALMS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 0) == 2); RECREATE_URI (MONGOC_URI_SOCKETTIMEOUTMS "=1&" MONGOC_URI_SOCKETTIMEOUTMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_SOCKETTIMEOUTMS); BSON_ASSERT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0) == 2); RECREATE_URI (MONGOC_URI_TLS "=false&" MONGOC_URI_TLS "=true"); ASSERT_LOG_DUPE (MONGOC_URI_TLS); BSON_ASSERT (mongoc_uri_get_tls (uri)); RECREATE_URI (MONGOC_URI_TLSCERTIFICATEKEYFILE "=a&" MONGOC_URI_TLSCERTIFICATEKEYFILE "=b"); ASSERT_LOG_DUPE (MONGOC_URI_TLSCERTIFICATEKEYFILE); str = mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, ""); BSON_ASSERT (strcmp (str, "b") == 0); RECREATE_URI (MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "=a&" MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "=b"); ASSERT_LOG_DUPE (MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD); str = mongoc_uri_get_option_as_utf8 ( uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, ""); BSON_ASSERT (strcmp (str, "b") == 0); RECREATE_URI (MONGOC_URI_TLSCAFILE "=a&" MONGOC_URI_TLSCAFILE "=b"); ASSERT_LOG_DUPE (MONGOC_URI_TLSCAFILE); str = mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, ""); BSON_ASSERT (strcmp (str, "b") == 0); RECREATE_URI (MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "=false&" MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "=true"); ASSERT_LOG_DUPE (MONGOC_URI_TLSALLOWINVALIDCERTIFICATES); BSON_ASSERT (mongoc_uri_get_option_as_bool ( uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); RECREATE_URI (MONGOC_URI_W "=1&" MONGOC_URI_W "=0"); ASSERT_LOG_DUPE (MONGOC_URI_W); wc = mongoc_uri_get_write_concern (uri); BSON_ASSERT (mongoc_write_concern_get_w (wc) == 0); /* exception: a string write concern takes precedence over an int */ RECREATE_URI (MONGOC_URI_W "=majority&" MONGOC_URI_W "=0"); ASSERT_LOG_DUPE (MONGOC_URI_W); wc = mongoc_uri_get_write_concern (uri); BSON_ASSERT (mongoc_write_concern_get_w (wc) == MONGOC_WRITE_CONCERN_W_MAJORITY); RECREATE_URI (MONGOC_URI_WAITQUEUEMULTIPLE "=1&" MONGOC_URI_WAITQUEUEMULTIPLE "=2"); ASSERT_LOG_DUPE (MONGOC_URI_WAITQUEUEMULTIPLE); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_WAITQUEUEMULTIPLE, 0) == 2); RECREATE_URI (MONGOC_URI_WAITQUEUETIMEOUTMS "=1&" MONGOC_URI_WAITQUEUETIMEOUTMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_WAITQUEUETIMEOUTMS); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_WAITQUEUETIMEOUTMS, 0) == 2); RECREATE_URI (MONGOC_URI_WTIMEOUTMS "=1&" MONGOC_URI_WTIMEOUTMS "=2"); ASSERT_LOG_DUPE (MONGOC_URI_WTIMEOUTMS); BSON_ASSERT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0) == 2); BSON_ASSERT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0) == 2); RECREATE_URI (MONGOC_URI_ZLIBCOMPRESSIONLEVEL "=1&" MONGOC_URI_ZLIBCOMPRESSIONLEVEL "=2"); ASSERT_LOG_DUPE (MONGOC_URI_ZLIBCOMPRESSIONLEVEL); BSON_ASSERT (mongoc_uri_get_option_as_int32 ( uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0) == 2); mongoc_uri_destroy (uri); } /* Tests behavior of int32 and int64 options */ static void test_mongoc_uri_int_options (void) { mongoc_uri_t *uri; capture_logs (true); uri = mongoc_uri_new ("mongodb://localhost/"); /* Set an int64 option as int64 succeeds */ ASSERT (mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 10)); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 10); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 10); /* Set an int64 option as int32 succeeds */ ASSERT (mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 15)); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 15); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 15); /* Setting an int32 option through _as_int64 succeeds for 32-bit values but * emits a warning */ ASSERT ( mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 9)); ASSERT_CAPTURED_LOG ("option: " MONGOC_URI_ZLIBCOMPRESSIONLEVEL, MONGOC_LOG_LEVEL_WARNING, "Setting value for 32-bit option " "\"zlibcompressionlevel\" through 64-bit method"); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), ==, 9); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), ==, 9); clear_captured_logs (); ASSERT (!mongoc_uri_set_option_as_int64 ( uri, MONGOC_URI_CONNECTTIMEOUTMS, 2147483648LL)); ASSERT_CAPTURED_LOG ( "option: " MONGOC_URI_CONNECTTIMEOUTMS, MONGOC_LOG_LEVEL_WARNING, "Unsupported value for \"connecttimeoutms\": 2147483648," " \"connecttimeoutms\" is not an int64 option"); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_CONNECTTIMEOUTMS, 0), ==, 0); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_CONNECTTIMEOUTMS, 0), ==, 0); clear_captured_logs (); /* Setting an int32 option as int32 succeeds */ ASSERT ( mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 9)); ASSERT_CMPINT ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), ==, 9); ASSERT_CMPINT ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), ==, 9); /* Truncating a 64-bit value when fetching as 32-bit emits a warning */ ASSERT (mongoc_uri_set_option_as_int64 ( uri, MONGOC_URI_WTIMEOUTMS, 2147483648LL)); ASSERT_CMPINT32 ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 5), ==, 5); ASSERT_CAPTURED_LOG ( "option: " MONGOC_URI_WTIMEOUTMS " with 64-bit value", MONGOC_LOG_LEVEL_WARNING, "Cannot read 64-bit value for \"wtimeoutms\": 2147483648"); ASSERT_CMPINT64 ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 5), ==, 2147483648LL); clear_captured_logs (); ASSERT (mongoc_uri_set_option_as_int64 ( uri, MONGOC_URI_WTIMEOUTMS, -2147483649LL)); ASSERT_CMPINT32 ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 5), ==, 5); ASSERT_CAPTURED_LOG ( "option: " MONGOC_URI_WTIMEOUTMS " with 64-bit value", MONGOC_LOG_LEVEL_WARNING, "Cannot read 64-bit value for \"wtimeoutms\": -2147483649"); ASSERT_CMPINT64 ( mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 5), ==, -2147483649LL); clear_captured_logs (); /* Setting a INT_MAX and INT_MIN values doesn't cause truncation errors */ ASSERT ( mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, INT32_MAX)); ASSERT_CMPINT32 ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, INT32_MAX); ASSERT_NO_CAPTURED_LOGS ("INT_MAX"); ASSERT ( mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, INT32_MIN)); ASSERT_CMPINT32 ( mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, INT32_MIN); ASSERT_NO_CAPTURED_LOGS ("INT_MIN"); mongoc_uri_destroy (uri); } static void test_one_tls_option_enables_tls (void) { const char *opts[] = {MONGOC_URI_TLS "=true", MONGOC_URI_TLSCERTIFICATEKEYFILE "=file.pem", MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "=file.pem", MONGOC_URI_TLSCAFILE "=file.pem", MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "=true", MONGOC_URI_TLSALLOWINVALIDHOSTNAMES "=true", MONGOC_URI_TLSINSECURE "=true", MONGOC_URI_SSL "=true", MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE "=file.pem", MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD "=file.pem", MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE "=file.pem", MONGOC_URI_SSLALLOWINVALIDCERTIFICATES "=true", MONGOC_URI_SSLALLOWINVALIDHOSTNAMES "=true", MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK "=true", MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK "=true"}; int i; for (i = 0; i < sizeof (opts) / sizeof (opts[0]); i++) { mongoc_uri_t *uri; bson_error_t error; char *uri_string; uri_string = bson_strdup_printf ("mongodb://localhost:27017/?%s", opts[i]); uri = mongoc_uri_new_with_error (uri_string, &error); bson_free (uri_string); ASSERT_OR_PRINT (uri, error); if (!mongoc_uri_get_tls (uri)) { test_error ( "unexpected tls not enabled when following option set: %s\n", opts[i]); } mongoc_uri_destroy (uri); } } static void test_casing_options (void) { mongoc_uri_t *uri; bson_error_t error; uri = mongoc_uri_new ("mongodb://localhost:27017/"); mongoc_uri_set_option_as_bool (uri, "TLS", true); mongoc_uri_parse_options (uri, "ssl=false", false, &error); ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, "conflicts"); mongoc_uri_destroy (uri); } void test_uri_install (TestSuite *suite) { TestSuite_Add (suite, "/Uri/new", test_mongoc_uri_new); TestSuite_Add (suite, "/Uri/new_with_error", test_mongoc_uri_new_with_error); TestSuite_Add ( suite, "/Uri/new_for_host_port", test_mongoc_uri_new_for_host_port); TestSuite_Add (suite, "/Uri/compressors", test_mongoc_uri_compressors); TestSuite_Add (suite, "/Uri/unescape", test_mongoc_uri_unescape); TestSuite_Add (suite, "/Uri/read_prefs", test_mongoc_uri_read_prefs); TestSuite_Add (suite, "/Uri/read_concern", test_mongoc_uri_read_concern); TestSuite_Add (suite, "/Uri/write_concern", test_mongoc_uri_write_concern); TestSuite_Add ( suite, "/HostList/from_string", test_mongoc_host_list_from_string); TestSuite_Add (suite, "/Uri/auth_mechanism_properties", test_mongoc_uri_authmechanismproperties); TestSuite_Add (suite, "/Uri/functions", test_mongoc_uri_functions); TestSuite_Add (suite, "/Uri/ssl", test_mongoc_uri_ssl); TestSuite_Add (suite, "/Uri/tls", test_mongoc_uri_tls); TestSuite_Add ( suite, "/Uri/compound_setters", test_mongoc_uri_compound_setters); TestSuite_Add (suite, "/Uri/long_hostname", test_mongoc_uri_long_hostname); TestSuite_Add ( suite, "/Uri/local_threshold_ms", test_mongoc_uri_local_threshold_ms); TestSuite_Add (suite, "/Uri/srv", test_mongoc_uri_srv); TestSuite_Add (suite, "/Uri/dns_options", test_mongoc_uri_dns_options); TestSuite_Add (suite, "/Uri/utf8", test_mongoc_uri_utf8); TestSuite_Add (suite, "/Uri/duplicates", test_mongoc_uri_duplicates); TestSuite_Add (suite, "/Uri/int_options", test_mongoc_uri_int_options); TestSuite_Add (suite, "/Uri/one_tls_option_enables_tls", test_one_tls_option_enables_tls); TestSuite_Add (suite, "/Uri/options_casing", test_casing_options); }
8acdc0f4d717837bf4866c28cf6bf9c8b0355b7d
7f6c235b0598353549959c18f69eefd20b766907
/src/appmake/svi.c
ddc75d3866a9fac457805994e0614f8cb79118e4
[ "ClArtistic" ]
permissive
z88dk/z88dk
46dfd4905f36d99333173cadd0a660839befc9f0
8b07f37cc43c5d9ffe69b563c80763491d8faff7
refs/heads/master
2023-09-04T19:29:49.254958
2023-09-03T20:51:24
2023-09-03T20:51:24
54,035,569
820
263
NOASSERTION
2023-09-05T11:09:04
2016-03-16T13:48:16
Assembly
UTF-8
C
false
false
9,908
c
svi.c
/* * Spectravideo SVI Cassette file * * BLOAD "CAS:",R * * By Stefano Bodrato * * $Id: svi.c $ */ #include "appmake.h" static char *binname = NULL; static char *crtfile = NULL; static char *outfile = NULL; static int origin = -1; static char audio = 0; static char c_disk = 0; static char fast = 0; static char khz_22 = 0; static char dumb = 0; static char loud = 0; static char help = 0; static unsigned char h_lvl; static unsigned char l_lvl; static int create_disk(); /* Options that are available for this module */ option_t svi_options[] = { { 'h', "help", "Display this help", OPT_BOOL, &help}, { 'b', "binfile", "Linked binary file", OPT_STR, &binname }, { 'c', "crt0file", "crt0 file used in linking", OPT_STR, &crtfile }, { 'o', "output", "Name of output file", OPT_STR, &outfile }, { 0 , "org", "Origin of the binary", OPT_INT, &origin }, { 0, "audio", "Create also a WAV file", OPT_BOOL, &audio }, { 0, "fast", "Tweak the audio tones to run a bit faster", OPT_BOOL, &fast }, { 0, "22", "22050hz bitrate option", OPT_BOOL, &khz_22 }, { 0, "dumb", "Just convert to WAV a tape file", OPT_BOOL, &dumb }, { 0, "loud", "Louder audio volume", OPT_BOOL, &loud }, { 0, "disk", "Create a .dsk image", OPT_BOOL, &c_disk }, { 0, NULL, NULL, OPT_NONE, NULL } }; /* two fast cycles for '0', two slow cycles for '1' */ void sv_bit(FILE* fpout, int bit, char tweak) { int i, period0, period1, period1lo; if (fast) { period1 = 14; period0 = 9; } else { period1 = 18; period0 = 9; } if (fast) period1lo = period1 + 3; else period1lo = period1 + 1; if (tweak) period1 += 3; if (bit) { /* '1' */ for (i = 0; i < period0; i++) fputc(h_lvl, fpout); for (i = 0; i < period0; i++) fputc(l_lvl, fpout); } else { /* '0' */ for (i = 0; i < period1; i++) fputc(h_lvl, fpout); for (i = 0; i < period1lo; i++) fputc(l_lvl, fpout); } } void sv_rawout(FILE* fpout, unsigned char b) { static unsigned char c[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; int i; /* Start bit */ sv_bit(fpout, 1, 1); /* byte */ for (i = 0; i < 8; i++) sv_bit(fpout, (b & c[i]), 0); } void sv_tone(FILE* fpout) { int i; for (i = 0; (i < 1600); i++) /* workaround (64 bit gcc bug ?) */ sv_bit(fpout, 0, (i & 4) ? 1 : 0); sv_bit(fpout, 1, 1); } /* 10101....0101010101111111 */ void headtune(FILE* fp) { int i; for (i = 0; i < 16; i++) writebyte(85, fp); writebyte(127, fp); } int svi_exec(char* target) { char filename[FILENAME_MAX + 1]; char wavfile[FILENAME_MAX + 1]; char name[11]; FILE *fpin, *fpout; int c; int i; int pos; int len; if (help) return -1; if (binname == NULL || (!dumb && (crtfile == NULL && origin == -1))) { return -1; } if ( c_disk ) { return create_disk(); } if (origin != -1) { pos = origin; } else { if ((pos = get_org_addr(crtfile)) == -1) { exit_log(1,"Could not find parameter ZORG (not z88dk compiled?)\n"); } } if (loud) { h_lvl = 0xFF; l_lvl = 0; } else { h_lvl = 0xe0; l_lvl = 0x20; } if (dumb) { strcpy(filename, binname); } else { if (outfile == NULL) { strcpy(filename, binname); suffix_change(filename, ".cas"); } else { strcpy(filename, outfile); } if (strcmp(binname, filename) == 0) { exit_log(1, "Input and output file names must be different\n"); } if ((fpin = fopen_bin(binname, crtfile)) == NULL) { exit_log(1,"Can't open input file\n"); } /* * Now we try to determine the size of the file * to be converted */ if (fseek(fpin, 0, SEEK_END)) { fclose(fpin); exit_log(1,"Couldn't determine size of file\n"); } len = ftell(fpin); fseek(fpin, 0L, SEEK_SET); if ((fpout = fopen(filename, "wb")) == NULL) { printf("Can't open output file\n"); exit(1); } /* Write out the header file */ headtune(fpout); for (i = 0; i < 10; i++) writebyte(208, fpout); /* Deal with the filename */ snprintf(name, sizeof(name), "%-*s", (int) sizeof(name)-1, binname); for (i = 0; i < 6; i++) writebyte(name[i], fpout); writeword(0, fpout); /* Now, the body */ headtune(fpout); writeword(pos, fpout); /* Start Address */ writeword(pos + len + 1, fpout); /* End Address */ writeword(pos, fpout); /* Call Address */ /* (58 bytes written so far...) */ /* We append the binary file */ for (i = 0; i < len; i++) { c = getc(fpin); writebyte(c, fpout); } /* Append some zeros, just to be sure not to get an error*/ for (i = 0; i < 16384; i++) writebyte(0, fpout); fclose(fpin); fclose(fpout); } /* ***************************************** */ /* Now, if requested, create the audio file */ /* ***************************************** */ if ((audio) || (fast) || (khz_22) || (loud)) { if ((fpin = fopen(filename, "rb")) == NULL) { exit_log(1, "Can't open file %s for wave conversion\n", filename); } if (fseek(fpin, 0, SEEK_END)) { fclose(fpin); exit_log(1,"Couldn't determine size of file\n"); } len = ftell(fpin); fseek(fpin, 0, SEEK_SET); strcpy(wavfile, filename); suffix_change(wavfile, ".RAW"); if ((fpout = fopen(wavfile, "wb")) == NULL) { exit_log(1, "Can't open output raw audio file %s\n", wavfile); } /* leading silence and tone*/ for (i = 0; i < 0x3000; i++) fputc(0x80, fpout); sv_tone(fpout); /* Write $7f */ sv_bit(fpout, 0, 1); for (i = 0; i < 7; i++) sv_bit(fpout, 1, 1); /* Skip the tone leader bytes */ for (i = 0; (i < 17); i++) c = getc(fpin); len -= 17; /* Copy the header */ if (dumb) printf("\nInfo: Program Name found in header: "); for (i = 0; (i < 18); i++) { c = getc(fpin); if (dumb && i > 10 && i < 17) printf("%c", c); sv_rawout(fpout, c); } len -= 18; /* leading silence and tone*/ for (i = 0; i < 0x8000; i++) fputc(h_lvl, fpout); sv_tone(fpout); /* Write $7f */ sv_bit(fpout, 0, 1); for (i = 0; i < 7; i++) sv_bit(fpout, 1, 1); /* Skip the tone leader bytes */ for (i = 0; (i < 17); i++) c = getc(fpin); len -= 17; /* program block */ if (len > 0) { for (i = 0; i < len; i++) { c = getc(fpin); sv_rawout(fpout, c); } } fclose(fpin); fclose(fpout); /* Now complete with the WAV header */ if (khz_22) raw2wav_22k(wavfile,2); else raw2wav(wavfile); } /* END of WAV CONVERSION BLOCK */ return 0; } static uint8_t sectorbuf[256]; static int create_disk() { char disc_name[FILENAME_MAX+1]; char bootname[FILENAME_MAX+1]; FILE *fpin,*fpout; int track, sector; size_t binlen; if ( outfile == NULL ) { strcpy(disc_name,binname); suffix_change(disc_name,".svi"); } else { strcpy(disc_name,outfile); } strcpy(bootname, binname); suffix_change(bootname, "_BOOTSTRAP.bin"); if ( (fpin=fopen_bin(bootname, crtfile) ) == NULL ) { exit_log(1,"Can't open input file %s\n",bootname); } if ( fseek(fpin,0,SEEK_END) ) { fclose(fpin); exit_log(1,"Couldn't determine size of file\n"); } binlen = ftell(fpin); fseek(fpin,0L,SEEK_SET); if ( binlen > 128 ) { exit_log(1, "Bootstrap has length %d > 128", binlen); } memset(sectorbuf, 0, sizeof(sectorbuf)); if (binlen != fread(sectorbuf, 1, 128, fpin)) { fclose(fpin); exit_log(1, "Could not read required data from <%s>\n",bootname); } fclose(fpin); if ( (fpout = fopen(disc_name, "wb")) == NULL ) { exit_log(1,"Can't open output file %s\n",disc_name); } if ((fpin = fopen_bin(binname, crtfile)) == NULL) { exit_log(1,"Can't open input file %s\n",bootname); } // First track has 18 sectors of 128 bytes fwrite(sectorbuf, 1, 128, fpout); // Track 0, sector 0 // And now we're on track 1, we have 17 sectors of 256 bytes for ( track = 0; track < 40; track++ ) { for ( sector = (track == 0 ? 1 : 0); sector < (track == 0 ? 18 : 17); sector++ ) { int size = track == 0 ? 128 : 256; memset(sectorbuf, 0, sizeof(sectorbuf)); if ( !feof(fpin) ) { if (0 == fread(sectorbuf, 1, size, fpin)) { fclose(fpin); exit_log(1, "Could not read required data from <%s>\n",binname); } } fwrite(sectorbuf, 1, size, fpout); } } fclose(fpout); fclose(fpin); return 0; }
191b30e68cfa644b05fe87ef4b7554c4be5d5500
07327b5e8b2831b12352bf7c6426bfda60129da7
/Include/10.0.16299.0/um/Snmp.h
badd88df8d985f2e488189e83e8fe9daa40408ce
[]
no_license
tpn/winsdk-10
ca279df0fce03f92036e90fb04196d6282a264b7
9b69fd26ac0c7d0b83d378dba01080e93349c2ed
refs/heads/master
2021-01-10T01:56:18.586459
2018-02-19T21:26:31
2018-02-19T21:29:50
44,352,845
218
432
null
null
null
null
UTF-8
C
false
false
24,341
h
Snmp.h
/*++ Copyright (C) 1992-1999 Microsoft Corporation Module Name: snmp.h Abstract: Definitions for SNMP development. --*/ #ifndef _INC_SNMP #define _INC_SNMP #if _MSC_VER > 1000 #pragma once #endif #include <winapifamily.h> #pragma region Desktop Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) /////////////////////////////////////////////////////////////////////////////// // // // Additional Header Files // // // /////////////////////////////////////////////////////////////////////////////// #include <windows.h> #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////////////// // // // SNMP Type Definitions // // // /////////////////////////////////////////////////////////////////////////////// #include <pshpack4.h> typedef struct { BYTE * stream; UINT length; BOOL dynamic; } AsnOctetString; typedef struct { UINT idLength; UINT * ids; } AsnObjectIdentifier; typedef LONG AsnInteger32; typedef ULONG AsnUnsigned32; typedef ULARGE_INTEGER AsnCounter64; typedef AsnUnsigned32 AsnCounter32; typedef AsnUnsigned32 AsnGauge32; typedef AsnUnsigned32 AsnTimeticks; typedef AsnOctetString AsnBits; typedef AsnOctetString AsnSequence; typedef AsnOctetString AsnImplicitSequence; typedef AsnOctetString AsnIPAddress; typedef AsnOctetString AsnNetworkAddress; typedef AsnOctetString AsnDisplayString; typedef AsnOctetString AsnOpaque; typedef struct { BYTE asnType; union { AsnInteger32 number; // ASN_INTEGER // ASN_INTEGER32 AsnUnsigned32 unsigned32; // ASN_UNSIGNED32 AsnCounter64 counter64; // ASN_COUNTER64 AsnOctetString string; // ASN_OCTETSTRING AsnBits bits; // ASN_BITS AsnObjectIdentifier object; // ASN_OBJECTIDENTIFIER AsnSequence sequence; // ASN_SEQUENCE AsnIPAddress address; // ASN_IPADDRESS AsnCounter32 counter; // ASN_COUNTER32 AsnGauge32 gauge; // ASN_GAUGE32 AsnTimeticks ticks; // ASN_TIMETICKS AsnOpaque arbitrary; // ASN_OPAQUE } asnValue; } AsnAny; typedef AsnObjectIdentifier AsnObjectName; typedef AsnAny AsnObjectSyntax; typedef struct { AsnObjectName name; AsnObjectSyntax value; } SnmpVarBind; typedef struct { SnmpVarBind * list; UINT len; } SnmpVarBindList; #include <poppack.h> #ifndef _INC_WINSNMP /////////////////////////////////////////////////////////////////////////////// // // // ASN/BER Base Types // // // /////////////////////////////////////////////////////////////////////////////// #define ASN_UNIVERSAL 0x00 #define ASN_APPLICATION 0x40 #define ASN_CONTEXT 0x80 #define ASN_PRIVATE 0xC0 #define ASN_PRIMITIVE 0x00 #define ASN_CONSTRUCTOR 0x20 /////////////////////////////////////////////////////////////////////////////// // // // PDU Type Values // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) #define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) #define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) #define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) #define SNMP_PDU_V1TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) #define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) #define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) #define SNMP_PDU_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) #endif // _INC_WINSNMP /////////////////////////////////////////////////////////////////////////////// // // // SNMP Simple Syntax Values // // // /////////////////////////////////////////////////////////////////////////////// #define ASN_INTEGER (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x02) #define ASN_BITS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) #define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04) #define ASN_NULL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x05) #define ASN_OBJECTIDENTIFIER (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x06) #define ASN_INTEGER32 ASN_INTEGER /////////////////////////////////////////////////////////////////////////////// // // // SNMP Constructor Syntax Values // // // /////////////////////////////////////////////////////////////////////////////// #define ASN_SEQUENCE (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10) #define ASN_SEQUENCEOF ASN_SEQUENCE /////////////////////////////////////////////////////////////////////////////// // // // SNMP Application Syntax Values // // // /////////////////////////////////////////////////////////////////////////////// #define ASN_IPADDRESS (ASN_APPLICATION | ASN_PRIMITIVE | 0x00) #define ASN_COUNTER32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x01) #define ASN_GAUGE32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02) #define ASN_TIMETICKS (ASN_APPLICATION | ASN_PRIMITIVE | 0x03) #define ASN_OPAQUE (ASN_APPLICATION | ASN_PRIMITIVE | 0x04) #define ASN_COUNTER64 (ASN_APPLICATION | ASN_PRIMITIVE | 0x06) #define ASN_UINTEGER32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x07) #define ASN_RFC2578_UNSIGNED32 ASN_GAUGE32 /////////////////////////////////////////////////////////////////////////////// // // // SNMP Exception Conditions // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_EXCEPTION_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x00) #define SNMP_EXCEPTION_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x01) #define SNMP_EXCEPTION_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x02) /////////////////////////////////////////////////////////////////////////////// // // // SNMP Request Types (used in SnmpExtensionQueryEx) // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_EXTENSION_GET SNMP_PDU_GET #define SNMP_EXTENSION_GET_NEXT SNMP_PDU_GETNEXT #define SNMP_EXTENSION_GET_BULK SNMP_PDU_GETBULK #define SNMP_EXTENSION_SET_TEST (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x0) #define SNMP_EXTENSION_SET_COMMIT SNMP_PDU_SET #define SNMP_EXTENSION_SET_UNDO (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x1) #define SNMP_EXTENSION_SET_CLEANUP (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x2) /////////////////////////////////////////////////////////////////////////////// // // // SNMP Error Codes // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_ERRORSTATUS_NOERROR 0 #define SNMP_ERRORSTATUS_TOOBIG 1 #define SNMP_ERRORSTATUS_NOSUCHNAME 2 #define SNMP_ERRORSTATUS_BADVALUE 3 #define SNMP_ERRORSTATUS_READONLY 4 #define SNMP_ERRORSTATUS_GENERR 5 #define SNMP_ERRORSTATUS_NOACCESS 6 #define SNMP_ERRORSTATUS_WRONGTYPE 7 #define SNMP_ERRORSTATUS_WRONGLENGTH 8 #define SNMP_ERRORSTATUS_WRONGENCODING 9 #define SNMP_ERRORSTATUS_WRONGVALUE 10 #define SNMP_ERRORSTATUS_NOCREATION 11 #define SNMP_ERRORSTATUS_INCONSISTENTVALUE 12 #define SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE 13 #define SNMP_ERRORSTATUS_COMMITFAILED 14 #define SNMP_ERRORSTATUS_UNDOFAILED 15 #define SNMP_ERRORSTATUS_AUTHORIZATIONERROR 16 #define SNMP_ERRORSTATUS_NOTWRITABLE 17 #define SNMP_ERRORSTATUS_INCONSISTENTNAME 18 /////////////////////////////////////////////////////////////////////////////// // // // SNMPv1 Trap Types // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_GENERICTRAP_COLDSTART 0 #define SNMP_GENERICTRAP_WARMSTART 1 #define SNMP_GENERICTRAP_LINKDOWN 2 #define SNMP_GENERICTRAP_LINKUP 3 #define SNMP_GENERICTRAP_AUTHFAILURE 4 #define SNMP_GENERICTRAP_EGPNEIGHLOSS 5 #define SNMP_GENERICTRAP_ENTERSPECIFIC 6 /////////////////////////////////////////////////////////////////////////////// // // // SNMP Access Types // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_ACCESS_NONE 0 #define SNMP_ACCESS_NOTIFY 1 #define SNMP_ACCESS_READ_ONLY 2 #define SNMP_ACCESS_READ_WRITE 3 #define SNMP_ACCESS_READ_CREATE 4 /////////////////////////////////////////////////////////////////////////////// // // // SNMP API Return Code Definitions // // // /////////////////////////////////////////////////////////////////////////////// #define SNMPAPI INT #define SNMP_FUNC_TYPE WINAPI #define SNMPAPI_NOERROR TRUE #define SNMPAPI_ERROR FALSE /////////////////////////////////////////////////////////////////////////////// // // // SNMP Extension API Prototypes // // // /////////////////////////////////////////////////////////////////////////////// BOOL SNMP_FUNC_TYPE SnmpExtensionInit( DWORD dwUptimeReference, HANDLE * phSubagentTrapEvent, AsnObjectIdentifier * pFirstSupportedRegion ); BOOL SNMP_FUNC_TYPE SnmpExtensionInitEx( AsnObjectIdentifier * pNextSupportedRegion ); BOOL SNMP_FUNC_TYPE SnmpExtensionMonitor( LPVOID pAgentMgmtData ); BOOL SNMP_FUNC_TYPE SnmpExtensionQuery( BYTE bPduType, SnmpVarBindList * pVarBindList, AsnInteger32 * pErrorStatus, AsnInteger32 * pErrorIndex ); BOOL SNMP_FUNC_TYPE SnmpExtensionQueryEx( UINT nRequestType, UINT nTransactionId, SnmpVarBindList * pVarBindList, AsnOctetString * pContextInfo, AsnInteger32 * pErrorStatus, AsnInteger32 * pErrorIndex ); BOOL SNMP_FUNC_TYPE SnmpExtensionTrap( AsnObjectIdentifier * pEnterpriseOid, AsnInteger32 * pGenericTrapId, AsnInteger32 * pSpecificTrapId, AsnTimeticks * pTimeStamp, SnmpVarBindList * pVarBindList ); VOID SNMP_FUNC_TYPE SnmpExtensionClose( ); /////////////////////////////////////////////////////////////////////////////// // // // SNMP Extension API Type Definitions // // // /////////////////////////////////////////////////////////////////////////////// typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONINIT)( DWORD dwUpTimeReference, HANDLE * phSubagentTrapEvent, AsnObjectIdentifier * pFirstSupportedRegion ); typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONINITEX)( AsnObjectIdentifier * pNextSupportedRegion ); typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONMONITOR)( LPVOID pAgentMgmtData ); typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONQUERY)( BYTE bPduType, SnmpVarBindList * pVarBindList, AsnInteger32 * pErrorStatus, AsnInteger32 * pErrorIndex ); typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONQUERYEX)( UINT nRequestType, UINT nTransactionId, SnmpVarBindList * pVarBindList, AsnOctetString * pContextInfo, AsnInteger32 * pErrorStatus, AsnInteger32 * pErrorIndex ); typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONTRAP)( AsnObjectIdentifier * pEnterpriseOid, AsnInteger32 * pGenericTrapId, AsnInteger32 * pSpecificTrapId, AsnTimeticks * pTimeStamp, SnmpVarBindList * pVarBindList ); typedef VOID (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONCLOSE)( ); /////////////////////////////////////////////////////////////////////////////// // // // SNMP API Prototypes // // // /////////////////////////////////////////////////////////////////////////////// SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCpy( AsnObjectIdentifier * pOidDst, AsnObjectIdentifier * pOidSrc ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidAppend( AsnObjectIdentifier * pOidDst, AsnObjectIdentifier * pOidSrc ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidNCmp( AsnObjectIdentifier * pOid1, AsnObjectIdentifier * pOid2, UINT nSubIds ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCmp( AsnObjectIdentifier * pOid1, AsnObjectIdentifier * pOid2 ); VOID SNMP_FUNC_TYPE SnmpUtilOidFree( AsnObjectIdentifier * pOid ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCmp( AsnOctetString * pOctets1, AsnOctetString * pOctets2 ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsNCmp( AsnOctetString * pOctets1, AsnOctetString * pOctets2, UINT nChars ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilOctetsCpy( AsnOctetString * pOctetsDst, AsnOctetString * pOctetsSrc ); VOID SNMP_FUNC_TYPE SnmpUtilOctetsFree( AsnOctetString * pOctets ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilAsnAnyCpy( AsnAny * pAnyDst, AsnAny * pAnySrc ); VOID SNMP_FUNC_TYPE SnmpUtilAsnAnyFree( AsnAny * pAny ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindCpy( SnmpVarBind * pVbDst, SnmpVarBind * pVbSrc ); VOID SNMP_FUNC_TYPE SnmpUtilVarBindFree( SnmpVarBind * pVb ); SNMPAPI SNMP_FUNC_TYPE SnmpUtilVarBindListCpy( SnmpVarBindList * pVblDst, SnmpVarBindList * pVblSrc ); VOID SNMP_FUNC_TYPE SnmpUtilVarBindListFree( SnmpVarBindList * pVbl ); VOID SNMP_FUNC_TYPE SnmpUtilMemFree( LPVOID pMem ); LPVOID SNMP_FUNC_TYPE SnmpUtilMemAlloc( UINT nBytes ); LPVOID SNMP_FUNC_TYPE SnmpUtilMemReAlloc( LPVOID pMem, UINT nBytes ); LPSTR SNMP_FUNC_TYPE SnmpUtilOidToA( IN AsnObjectIdentifier *Oid ); LPSTR SNMP_FUNC_TYPE SnmpUtilIdsToA( IN UINT *Ids, IN UINT IdLength ); VOID SNMP_FUNC_TYPE SnmpUtilPrintOid( IN AsnObjectIdentifier *Oid ); VOID SNMP_FUNC_TYPE SnmpUtilPrintAsnAny( AsnAny * pAny ); DWORD SNMP_FUNC_TYPE SnmpSvcGetUptime( ); VOID SNMP_FUNC_TYPE SnmpSvcSetLogLevel( INT nLogLevel ); VOID SNMP_FUNC_TYPE SnmpSvcSetLogType( INT nLogType ); /////////////////////////////////////////////////////////////////////////////// // // // SNMP Debugging Definitions // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_LOG_SILENT 0x0 #define SNMP_LOG_FATAL 0x1 #define SNMP_LOG_ERROR 0x2 #define SNMP_LOG_WARNING 0x3 #define SNMP_LOG_TRACE 0x4 #define SNMP_LOG_VERBOSE 0x5 #define SNMP_OUTPUT_TO_CONSOLE 0x1 #define SNMP_OUTPUT_TO_LOGFILE 0x2 #define SNMP_OUTPUT_TO_EVENTLOG 0x4 // no longer supported #define SNMP_OUTPUT_TO_DEBUGGER 0x8 /////////////////////////////////////////////////////////////////////////////// // // // SNMP Debugging Prototypes // // // /////////////////////////////////////////////////////////////////////////////// VOID SNMP_FUNC_TYPE SnmpUtilDbgPrint( IN INT nLogLevel, // see log levels above... _In_ _Printf_format_string_ LPSTR szFormat, IN ... ); #if DBG #define SNMPDBG(_x_) SnmpUtilDbgPrint _x_ #else #define SNMPDBG(_x_) #endif /////////////////////////////////////////////////////////////////////////////// // // // Miscellaneous definitions // // // /////////////////////////////////////////////////////////////////////////////// #define DEFINE_SIZEOF(Array) (sizeof(Array)/sizeof((Array)[0])) #define DEFINE_OID(SubIdArray) {DEFINE_SIZEOF(SubIdArray),(SubIdArray)} #define DEFINE_NULLOID() {0,NULL} #define DEFINE_NULLOCTETS() {NULL,0,FALSE} #define DEFAULT_SNMP_PORT_UDP 161 #define DEFAULT_SNMP_PORT_IPX 36879 #define DEFAULT_SNMPTRAP_PORT_UDP 162 #define DEFAULT_SNMPTRAP_PORT_IPX 36880 #define SNMP_MAX_OID_LEN 128 /////////////////////////////////////////////////////////////////////////////// // // // API Error Code Definitions // // // /////////////////////////////////////////////////////////////////////////////// #define SNMP_MEM_ALLOC_ERROR 1 #define SNMP_BERAPI_INVALID_LENGTH 10 #define SNMP_BERAPI_INVALID_TAG 11 #define SNMP_BERAPI_OVERFLOW 12 #define SNMP_BERAPI_SHORT_BUFFER 13 #define SNMP_BERAPI_INVALID_OBJELEM 14 #define SNMP_PDUAPI_UNRECOGNIZED_PDU 20 #define SNMP_PDUAPI_INVALID_ES 21 #define SNMP_PDUAPI_INVALID_GT 22 #define SNMP_AUTHAPI_INVALID_VERSION 30 #define SNMP_AUTHAPI_INVALID_MSG_TYPE 31 #define SNMP_AUTHAPI_TRIV_AUTH_FAILED 32 /////////////////////////////////////////////////////////////////////////////// // // // Support for old definitions (support disabled via SNMPSTRICT) // // // /////////////////////////////////////////////////////////////////////////////// #ifndef SNMPSTRICT #define SNMP_oidcpy SnmpUtilOidCpy #define SNMP_oidappend SnmpUtilOidAppend #define SNMP_oidncmp SnmpUtilOidNCmp #define SNMP_oidcmp SnmpUtilOidCmp #define SNMP_oidfree SnmpUtilOidFree #define SNMP_CopyVarBindList SnmpUtilVarBindListCpy #define SNMP_FreeVarBindList SnmpUtilVarBindListFree #define SNMP_CopyVarBind SnmpUtilVarBindCpy #define SNMP_FreeVarBind SnmpUtilVarBindFree #define SNMP_printany SnmpUtilPrintAsnAny #define SNMP_free SnmpUtilMemFree #define SNMP_malloc SnmpUtilMemAlloc #define SNMP_realloc SnmpUtilMemReAlloc #define SNMP_DBG_free SnmpUtilMemFree #define SNMP_DBG_malloc SnmpUtilMemAlloc #define SNMP_DBG_realloc SnmpUtilMemReAlloc #define ASN_RFC1155_IPADDRESS ASN_IPADDRESS #define ASN_RFC1155_COUNTER ASN_COUNTER32 #define ASN_RFC1155_GAUGE ASN_GAUGE32 #define ASN_RFC1155_TIMETICKS ASN_TIMETICKS #define ASN_RFC1155_OPAQUE ASN_OPAQUE #define ASN_RFC1213_DISPSTRING ASN_OCTETSTRING #define ASN_RFC1157_GETREQUEST SNMP_PDU_GET #define ASN_RFC1157_GETNEXTREQUEST SNMP_PDU_GETNEXT #define ASN_RFC1157_GETRESPONSE SNMP_PDU_RESPONSE #define ASN_RFC1157_SETREQUEST SNMP_PDU_SET #define ASN_RFC1157_TRAP SNMP_PDU_V1TRAP #define ASN_CONTEXTSPECIFIC ASN_CONTEXT #define ASN_PRIMATIVE ASN_PRIMITIVE #define RFC1157VarBindList SnmpVarBindList #define RFC1157VarBind SnmpVarBind #define AsnInteger AsnInteger32 #define AsnCounter AsnCounter32 #define AsnGauge AsnGauge32 #define ASN_UNSIGNED32 ASN_UINTEGER32 #endif // SNMPSTRICT #ifdef __cplusplus } #endif #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ #pragma endregion #endif // _INC_SNMP
ecc6ccffbfa91a7e3830e45a87f5d5c3f6798c39
802f0c1dd855693f709da4024b50d6d4938c13ff
/examples/c/crane_dae_model/crane_dae_model.h
ce6102491fdb37ca375664e6d8215e8c3cf69952
[ "BSD-2-Clause" ]
permissive
acados/acados
9cd480da3462725506f06199838e3cdae007d0c8
64166a37859108ab74ce6bf7408501f9bd4a89da
refs/heads/master
2023-08-16T13:03:44.298740
2023-08-15T13:07:48
2023-08-15T13:07:48
55,497,573
558
213
NOASSERTION
2023-09-01T09:01:33
2016-04-05T10:06:48
C
UTF-8
C
false
false
5,287
h
crane_dae_model.h
/* * Copyright (c) The acados authors. * * This file is part of acados. * * The 2-Clause BSD 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE.; */ #ifndef EXAMPLES_C_CRANE_DAE #define EXAMPLES_C_CRANE_DAE #ifdef __cplusplus extern "C" { #endif // this is a crane model with an artificially added algebraic equation to test gnsf & dae integrators /* implicit ODE */ // implicit ODE int crane_dae_impl_ode_fun(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); int crane_dae_impl_ode_fun_work(int *, int *, int *, int *); const int *crane_dae_impl_ode_fun_sparsity_in(int); const int *crane_dae_impl_ode_fun_sparsity_out(int); int crane_dae_impl_ode_fun_n_in(); int crane_dae_impl_ode_fun_n_out(); // implicit ODE int crane_dae_impl_ode_fun_jac_x_xdot(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); int crane_dae_impl_ode_fun_jac_x_xdot_work(int *, int *, int *, int *); const int *crane_dae_impl_ode_fun_jac_x_xdot_sparsity_in(int); const int *crane_dae_impl_ode_fun_jac_x_xdot_sparsity_out(int); int crane_dae_impl_ode_fun_jac_x_xdot_n_in(); int crane_dae_impl_ode_fun_jac_x_xdot_n_out(); // implicit ODE int crane_dae_impl_ode_jac_x_xdot_u(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); int crane_dae_impl_ode_jac_x_xdot_u_work(int *, int *, int *, int *); const int *crane_dae_impl_ode_jac_x_xdot_u_sparsity_in(int); const int *crane_dae_impl_ode_jac_x_xdot_u_sparsity_out(int); int crane_dae_impl_ode_jac_x_xdot_u_n_in(); int crane_dae_impl_ode_jac_x_xdot_u_n_out(); // implicit ODE - for lifted_irk int crane_dae_impl_ode_fun_jac_x_xdot_u(const real_t** arg, real_t** res, int* iw, real_t* w, void *mem); int crane_dae_impl_ode_fun_jac_x_xdot_u_work(int *, int *, int *, int *); const int *crane_dae_impl_ode_fun_jac_x_xdot_u_sparsity_in(int); const int *crane_dae_impl_ode_fun_jac_x_xdot_u_sparsity_out(int); int crane_dae_impl_ode_fun_jac_x_xdot_u_n_in(); int crane_dae_impl_ode_fun_jac_x_xdot_u_n_out(); /* GNSF Functions */ // used to import model matrices int crane_dae_get_matrices_fun(const double** arg, double** res, int* iw, double* w, void *mem); int crane_dae_get_matrices_fun_work(int *, int *, int *, int *); const int *crane_dae_get_matrices_fun_sparsity_in(int); const int *crane_dae_get_matrices_fun_sparsity_out(int); int crane_dae_get_matrices_fun_n_in(); int crane_dae_get_matrices_fun_n_out(); // phi_fun int crane_dae_phi_fun(const double** arg, double** res, int* iw, double* w, void *mem); int crane_dae_phi_fun_work(int *, int *, int *, int *); const int *crane_dae_phi_fun_sparsity_in(int); const int *crane_dae_phi_fun_sparsity_out(int); int crane_dae_phi_fun_n_in(); int crane_dae_phi_fun_n_out(); // phi_fun_jac_y int crane_dae_phi_fun_jac_y(const double** arg, double** res, int* iw, double* w, void *mem); int crane_dae_phi_fun_jac_y_work(int *, int *, int *, int *); const int *crane_dae_phi_fun_jac_y_sparsity_in(int); const int *crane_dae_phi_fun_jac_y_sparsity_out(int); int crane_dae_phi_fun_jac_y_n_in(); int crane_dae_phi_fun_jac_y_n_out(); // phi_jac_y_uhat int crane_dae_phi_jac_y_uhat(const double** arg, double** res, int* iw, double* w, void *mem); int crane_dae_phi_jac_y_uhat_work(int *, int *, int *, int *); const int *crane_dae_phi_jac_y_uhat_sparsity_in(int); const int *crane_dae_phi_jac_y_uhat_sparsity_out(int); int crane_dae_phi_jac_y_uhat_n_in(); int crane_dae_phi_jac_y_uhat_n_out(); // f_lo_fun_jac_x1k1uz int crane_dae_f_lo_fun_jac_x1k1uz(const double** arg, double** res, int* iw, double* w, void *mem); int crane_dae_f_lo_fun_jac_x1k1uz_work(int *, int *, int *, int *); const int *crane_dae_f_lo_fun_jac_x1k1uz_sparsity_in(int); const int *crane_dae_f_lo_fun_jac_x1k1uz_sparsity_out(int); int crane_dae_f_lo_fun_jac_x1k1uz_n_in(); int crane_dae_f_lo_fun_jac_x1k1uz_n_out(); #ifdef __cplusplus } /* extern "C" */ #endif #endif // EXAMPLES_C_CRANE_DAE
b9d47ec011a3fc8592e38f0ccd44263eb166b8ea
7f6191833a9fb98c395e9d763585e479f7649d67
/edlib/include/edlib.h
acce6b20efbcefd233199d53fbe19aacd907af49
[ "MIT" ]
permissive
Martinsos/edlib
ecbbbc409cc549de3cd2547c6c32c14f7a4005b9
931be2b0909985551eb17d767694a6e64e31ebfa
refs/heads/master
2023-09-02T03:07:46.962444
2023-04-18T21:45:47
2023-04-19T11:53:10
16,056,308
475
251
MIT
2023-07-07T06:06:00
2014-01-19T23:05:09
C++
UTF-8
C
false
false
11,041
h
edlib.h
#ifndef EDLIB_H #define EDLIB_H /** * @file * @author Martin Sosic * @brief Main header file, containing all public functions and structures. */ // Define EDLIB_API macro to properly export symbols #ifdef EDLIB_SHARED # ifdef _WIN32 # ifdef EDLIB_BUILD # define EDLIB_API __declspec(dllexport) # else # define EDLIB_API __declspec(dllimport) # endif # else # define EDLIB_API __attribute__ ((visibility ("default"))) # endif #else # define EDLIB_API #endif #ifdef __cplusplus extern "C" { #endif // Status codes #define EDLIB_STATUS_OK 0 #define EDLIB_STATUS_ERROR 1 /** * Alignment methods - how should Edlib treat gaps before and after query? */ typedef enum { /** * Global method. This is the standard method. * Useful when you want to find out how similar is first sequence to second sequence. */ EDLIB_MODE_NW, /** * Prefix method. Similar to global method, but with a small twist - gap at query end is not penalized. * What that means is that deleting elements from the end of second sequence is "free"! * For example, if we had "AACT" and "AACTGGC", edit distance would be 0, because removing "GGC" from the end * of second sequence is "free" and does not count into total edit distance. This method is appropriate * when you want to find out how well first sequence fits at the beginning of second sequence. */ EDLIB_MODE_SHW, /** * Infix method. Similar as prefix method, but with one more twist - gaps at query end and start are * not penalized. What that means is that deleting elements from the start and end of second sequence is "free"! * For example, if we had ACT and CGACTGAC, edit distance would be 0, because removing CG from the start * and GAC from the end of second sequence is "free" and does not count into total edit distance. * This method is appropriate when you want to find out how well first sequence fits at any part of * second sequence. * For example, if your second sequence was a long text and your first sequence was a sentence from that text, * but slightly scrambled, you could use this method to discover how scrambled it is and where it fits in * that text. In bioinformatics, this method is appropriate for aligning read to a sequence. */ EDLIB_MODE_HW } EdlibAlignMode; /** * Alignment tasks - what do you want Edlib to do? */ typedef enum { EDLIB_TASK_DISTANCE, //!< Find edit distance and end locations. EDLIB_TASK_LOC, //!< Find edit distance, end locations and start locations. EDLIB_TASK_PATH //!< Find edit distance, end locations and start locations and alignment path. } EdlibAlignTask; /** * Describes cigar format. * @see http://samtools.github.io/hts-specs/SAMv1.pdf * @see http://drive5.com/usearch/manual/cigar.html */ typedef enum { EDLIB_CIGAR_STANDARD, //!< Match: 'M', Insertion: 'I', Deletion: 'D', Mismatch: 'M'. EDLIB_CIGAR_EXTENDED //!< Match: '=', Insertion: 'I', Deletion: 'D', Mismatch: 'X'. } EdlibCigarFormat; // Edit operations. #define EDLIB_EDOP_MATCH 0 //!< Match. #define EDLIB_EDOP_INSERT 1 //!< Insertion to target = deletion from query. #define EDLIB_EDOP_DELETE 2 //!< Deletion from target = insertion to query. #define EDLIB_EDOP_MISMATCH 3 //!< Mismatch. /** * @brief Defines two given characters as equal. */ typedef struct { char first; char second; } EdlibEqualityPair; /** * @brief Configuration object for edlibAlign() function. */ typedef struct { /** * Set k to non-negative value to tell edlib that edit distance is not larger than k. * Smaller k can significantly improve speed of computation. * If edit distance is larger than k, edlib will set edit distance to -1. * Set k to negative value and edlib will internally auto-adjust k until score is found. */ int k; /** * Alignment method. * EDLIB_MODE_NW: global (Needleman-Wunsch) * EDLIB_MODE_SHW: prefix. Gap after query is not penalized. * EDLIB_MODE_HW: infix. Gaps before and after query are not penalized. */ EdlibAlignMode mode; /** * Alignment task - tells Edlib what to calculate. Less to calculate, faster it is. * EDLIB_TASK_DISTANCE - find edit distance and end locations of optimal alignment paths in target. * EDLIB_TASK_LOC - find edit distance and start and end locations of optimal alignment paths in target. * EDLIB_TASK_PATH - find edit distance, alignment path (and start and end locations of it in target). */ EdlibAlignTask task; /** * List of pairs of characters, where each pair defines two characters as equal. * This way you can extend edlib's definition of equality (which is that each character is equal only * to itself). * This can be useful if you have some wildcard characters that should match multiple other characters, * or e.g. if you want edlib to be case insensitive. * Can be set to NULL if there are none. */ const EdlibEqualityPair* additionalEqualities; /** * Number of additional equalities, which is non-negative number. * 0 if there are none. */ int additionalEqualitiesLength; } EdlibAlignConfig; /** * Helper method for easy construction of configuration object. * @return Configuration object filled with given parameters. */ EDLIB_API EdlibAlignConfig edlibNewAlignConfig( int k, EdlibAlignMode mode, EdlibAlignTask task, const EdlibEqualityPair* additionalEqualities, int additionalEqualitiesLength ); /** * @return Default configuration object, with following defaults: * k = -1, mode = EDLIB_MODE_NW, task = EDLIB_TASK_DISTANCE, no additional equalities. */ EDLIB_API EdlibAlignConfig edlibDefaultAlignConfig(void); /** * Container for results of alignment done by edlibAlign() function. */ typedef struct { /** * EDLIB_STATUS_OK or EDLIB_STATUS_ERROR. If error, all other fields will have undefined values. */ int status; /** * -1 if k is non-negative and edit distance is larger than k. */ int editDistance; /** * Array of zero-based positions in target where optimal alignment paths end. * If gap after query is penalized, gap counts as part of query (NW), otherwise not. * Set to NULL if edit distance is larger than k. * If you do not free whole result object using edlibFreeAlignResult(), do not forget to use free(). */ int* endLocations; /** * Array of zero-based positions in target where optimal alignment paths start, * they correspond to endLocations. * If gap before query is penalized, gap counts as part of query (NW), otherwise not. * Set to NULL if not calculated or if edit distance is larger than k. * If you do not free whole result object using edlibFreeAlignResult(), do not forget to use free(). */ int* startLocations; /** * Number of end (and start) locations. */ int numLocations; /** * Alignment is found for first pair of start and end locations. * Set to NULL if not calculated. * Alignment is sequence of numbers: 0, 1, 2, 3. * 0 stands for match. * 1 stands for insertion to target. * 2 stands for insertion to query. * 3 stands for mismatch. * Alignment aligns query to target from begining of query till end of query. * If gaps are not penalized, they are not in alignment. * If you do not free whole result object using edlibFreeAlignResult(), do not forget to use free(). */ unsigned char* alignment; /** * Length of alignment. */ int alignmentLength; /** * Number of different characters in query and target together. */ int alphabetLength; } EdlibAlignResult; /** * Frees memory in EdlibAlignResult that was allocated by edlib. * If you do not use it, make sure to free needed members manually using free(). */ EDLIB_API void edlibFreeAlignResult(EdlibAlignResult result); /** * Aligns two sequences (query and target) using edit distance (levenshtein distance). * Through config parameter, this function supports different alignment methods (global, prefix, infix), * as well as different modes of search (tasks). * It always returns edit distance and end locations of optimal alignment in target. * It optionally returns start locations of optimal alignment in target and alignment path, * if you choose appropriate tasks. * @param [in] query First sequence. * @param [in] queryLength Number of characters in first sequence. * @param [in] target Second sequence. * @param [in] targetLength Number of characters in second sequence. * @param [in] config Additional alignment parameters, like alignment method and wanted results. * @return Result of alignment, which can contain edit distance, start and end locations and alignment path. * Make sure to clean up the object using edlibFreeAlignResult() or by manually freeing needed members. */ EDLIB_API EdlibAlignResult edlibAlign( const char* query, int queryLength, const char* target, int targetLength, const EdlibAlignConfig config ); /** * Builds cigar string from given alignment sequence. * @param [in] alignment Alignment sequence. * 0 stands for match. * 1 stands for insertion to target. * 2 stands for insertion to query. * 3 stands for mismatch. * @param [in] alignmentLength * @param [in] cigarFormat Cigar will be returned in specified format. * @return Cigar string. * I stands for insertion. * D stands for deletion. * X stands for mismatch. (used only in extended format) * = stands for match. (used only in extended format) * M stands for (mis)match. (used only in standard format) * String is null terminated. * Needed memory is allocated and given pointer is set to it. * Do not forget to free it later using free()! */ EDLIB_API char* edlibAlignmentToCigar( const unsigned char* alignment, int alignmentLength, EdlibCigarFormat cigarFormat ); #ifdef __cplusplus } #endif #endif // EDLIB_H
f558bfcf4aa8caccbaa83416d8b6651616ab26c6
d9ea45dbc964799991b9191ae620d2f150652a3d
/Tests/MultiWindow/Sources/multiwindow.c
1a2bf12461aad3ae264d0c2933cb293517ad83d2
[ "Zlib" ]
permissive
Kode/Kinc
6ebb1cfa11c6e9ed0e153c486f573f1d7dca5664
d90b7478b192c8270e0ee32c0c3ee18977becd7a
refs/heads/main
2023-08-08T16:50:01.534587
2023-08-07T20:22:46
2023-08-07T20:22:46
10,254,751
283
249
Zlib
2023-08-26T12:27:36
2013-05-23T22:22:58
C
UTF-8
C
false
false
4,760
c
multiwindow.c
#include <kinc/graphics4/graphics.h> #include <kinc/graphics4/indexbuffer.h> #include <kinc/graphics4/pipeline.h> #include <kinc/graphics4/shader.h> #include <kinc/graphics4/vertexbuffer.h> #include <kinc/input/mouse.h> #include <kinc/io/filereader.h> #include <kinc/log.h> #include <kinc/system.h> #include <kinc/window.h> #include <assert.h> #include <stdlib.h> static kinc_g4_shader_t vertex_shader; static kinc_g4_shader_t fragment_shader; static kinc_g4_pipeline_t pipeline; static kinc_g4_vertex_buffer_t vertices; static kinc_g4_index_buffer_t indices; #define WINDOW_COUNT 2 static struct window { int index; bool open; bool mouse_down; } windows[WINDOW_COUNT] = {0}; #define HEAP_SIZE 1024 * 1024 static uint8_t *heap = NULL; static size_t heap_top = 0; static void *allocate(size_t size) { size_t old_top = heap_top; heap_top += size; assert(heap_top <= HEAP_SIZE); return &heap[old_top]; } static void update(void *data) { for (int window = 0; window < WINDOW_COUNT; window++) { if (windows[window].open) { kinc_g4_begin(window); kinc_g4_clear(KINC_G4_CLEAR_COLOR, windows[window].mouse_down ? 0xff0000ff : 0, 0.0f, 0); kinc_g4_set_pipeline(&pipeline); kinc_g4_set_vertex_buffer(&vertices); kinc_g4_set_index_buffer(&indices); kinc_g4_draw_indexed_vertices(); kinc_g4_end(window); } } kinc_g4_swap_buffers(); } static void load_shader(const char *filename, kinc_g4_shader_t *shader, kinc_g4_shader_type_t shader_type) { kinc_file_reader_t file; kinc_file_reader_open(&file, filename, KINC_FILE_TYPE_ASSET); size_t data_size = kinc_file_reader_size(&file); uint8_t *data = allocate(data_size); kinc_file_reader_read(&file, data, data_size); kinc_file_reader_close(&file); kinc_g4_shader_init(shader, data, data_size, shader_type); } static void mouse_down(int window, int button, int x, int y) { windows[window].mouse_down = true; } static void mouse_up(int window, int button, int x, int y) { windows[window].mouse_down = false; } static bool window_close(void *data) { struct window *window = data; window->open = false; return true; } static char *copy_callback(void *data) { return "Hello World!"; } static void paste_callback(char *text, void *data) { kinc_log(KINC_LOG_LEVEL_INFO, "Pasted: %s", text); } static void drop_files_callback(wchar_t *text, void *data) { char dest[1024]; wcstombs(dest, text, sizeof(dest)); kinc_log(KINC_LOG_LEVEL_INFO, "Dropped: %s", dest); } int kickstart(int argc, char **argv) { kinc_window_options_t first_window_options; kinc_window_options_set_defaults(&first_window_options); // first_window_options.mode = KINC_WINDOW_MODE_FULLSCREEN; int first_window = kinc_init("MultiWindow", 1024, 768, &first_window_options, NULL); // return 0; kinc_set_update_callback(update, NULL); heap = (uint8_t *)malloc(HEAP_SIZE); assert(heap != NULL); load_shader("shader.vert", &vertex_shader, KINC_G4_SHADER_TYPE_VERTEX); load_shader("shader.frag", &fragment_shader, KINC_G4_SHADER_TYPE_FRAGMENT); kinc_g4_vertex_structure_t structure; kinc_g4_vertex_structure_init(&structure); kinc_g4_vertex_structure_add(&structure, "pos", KINC_G4_VERTEX_DATA_FLOAT3); kinc_g4_pipeline_init(&pipeline); pipeline.vertex_shader = &vertex_shader; pipeline.fragment_shader = &fragment_shader; pipeline.input_layout[0] = &structure; pipeline.input_layout[1] = NULL; kinc_g4_pipeline_compile(&pipeline); kinc_g4_vertex_buffer_init(&vertices, 3, &structure, KINC_G4_USAGE_STATIC, 0); { float *v = kinc_g4_vertex_buffer_lock_all(&vertices); int i = 0; v[i++] = -1; v[i++] = -1; v[i++] = 0.5; v[i++] = 1; v[i++] = -1; v[i++] = 0.5; v[i++] = -1; v[i++] = 1; v[i++] = 0.5; kinc_g4_vertex_buffer_unlock_all(&vertices); } kinc_g4_index_buffer_init(&indices, 3, KINC_G4_INDEX_BUFFER_FORMAT_32BIT, KINC_G4_USAGE_STATIC); { uint32_t *i = (uint32_t *)kinc_g4_index_buffer_lock_all(&indices); i[0] = 0; i[1] = 1; i[2] = 2; kinc_g4_index_buffer_unlock_all(&indices); } kinc_window_options_t options; kinc_framebuffer_options_t frame_options; kinc_window_options_set_defaults(&options); kinc_framebuffer_options_set_defaults(&frame_options); int window_two = kinc_window_create(&options, &frame_options); windows[0].index = 0; windows[0].open = true; windows[1].index = 1; windows[1].open = true; kinc_window_set_close_callback(first_window, window_close, &windows[0]); kinc_window_set_close_callback(window_two, window_close, &windows[1]); kinc_mouse_set_press_callback(mouse_down); kinc_mouse_set_release_callback(mouse_up); kinc_set_copy_callback(copy_callback, NULL); kinc_set_paste_callback(paste_callback, NULL); kinc_set_drop_files_callback(drop_files_callback, NULL); kinc_start(); return 0; }
c66f4a37abb0080a14f7e018efc440313e8579ae
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Adense.c
1575f3ce7bcfe17623cb20b0046450be161540ec
[ "IJG", "Zlib", "LicenseRef-scancode-proprietary-license", "SMLNJ", "BSD-3-Clause", "BSD-4.3TAHOE", "LicenseRef-scancode-free-unknown", "Spencer-86", "LicenseRef-scancode-llnl", "FSFUL", "Libpng", "libtiff", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-hdf5", "MIT", "NTP", "LicenseRef-scancode-mit-old-style", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-2.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
InsightSoftwareConsortium/ITK
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
refs/heads/master
2023-08-31T17:21:47.754304
2023-08-31T00:58:51
2023-08-31T14:12:21
800,928
1,229
656
Apache-2.0
2023-09-14T17:54:00
2010-07-27T15:48:04
C++
UTF-8
C
false
false
81,062
c
H5Adense.c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- * * Created: H5Adense.c * Dec 4 2006 * Quincey Koziol * * Purpose: Routines for operating on "dense" attribute storage * for an object. * *------------------------------------------------------------------------- */ /****************/ /* Module Setup */ /****************/ #include "H5Amodule.h" /* This source code file is part of the H5A module */ #define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5SMprivate.h" /* Shared object header messages */ #include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* v2 B-tree creation macros for 'name' field index */ #define H5A_NAME_BT2_NODE_SIZE 512 #define H5A_NAME_BT2_MERGE_PERC 40 #define H5A_NAME_BT2_SPLIT_PERC 100 /* v2 B-tree creation macros for 'corder' field index */ #define H5A_CORDER_BT2_NODE_SIZE 512 #define H5A_CORDER_BT2_MERGE_PERC 40 #define H5A_CORDER_BT2_SPLIT_PERC 100 /* Size of stack buffer for serialized attributes */ #define H5A_ATTR_BUF_SIZE 128 /******************/ /* Local Typedefs */ /******************/ /* * Data exchange structure for dense attribute storage. This structure is * passed through the v2 B-tree layer when modifying the attribute data value. */ typedef struct H5A_bt2_od_wrt_t { /* downward */ H5F_t * f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle to operate on */ H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ H5A_t * attr; /* Attribute to write */ haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_od_wrt_t; /* * Data exchange structure to pass through the v2 B-tree layer for the * H5B2_iterate function when iterating over densely stored attributes. */ typedef struct { /* downward (internal) */ H5F_t * f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle */ H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ hsize_t count; /* # of attributes examined */ /* downward (from application) */ hid_t loc_id; /* Object ID for application callback */ hsize_t skip; /* Number of attributes to skip */ const H5A_attr_iter_op_t *attr_op; /* Callback for each attribute */ void * op_data; /* Callback data for each attribute */ /* upward */ int op_ret; /* Return value from callback */ } H5A_bt2_ud_it_t; /* * Data exchange structure to pass through the fractal heap layer for the * H5HF_op function when copying an attribute stored in densely stored attributes. * (or the shared message heap) */ typedef struct { /* downward (internal) */ H5F_t * f; /* Pointer to file that fractal heap is in */ const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ /* upward */ H5A_t *attr; /* Copy of attribute */ } H5A_fh_ud_cp_t; /* * Data exchange structure for dense attribute storage. This structure is * passed through the v2 B-tree layer when removing attributes. */ typedef struct H5A_bt2_ud_rm_t { /* downward */ H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_ud_rm_t; /* * Data exchange structure for dense attribute storage. This structure is * passed through the v2 B-tree layer when removing attributes by index. */ typedef struct H5A_bt2_ud_rmbi_t { /* downward */ H5F_t * f; /* Pointer to file that fractal heap is in */ H5HF_t * fheap; /* Fractal heap handle */ H5HF_t * shared_fheap; /* Fractal heap handle for shared messages */ H5_index_t idx_type; /* Index type for operation */ haddr_t other_bt2_addr; /* v2 B-tree address of "other" index */ } H5A_bt2_ud_rmbi_t; /********************/ /* Package Typedefs */ /********************/ /********************/ /* Local Prototypes */ /********************/ /*********************/ /* Package Variables */ /*********************/ /*****************************/ /* Library Private Variables */ /*****************************/ /*******************/ /* Local Variables */ /*******************/ /*------------------------------------------------------------------------- * Function: H5A__dense_create * * Purpose: Creates dense attribute storage structures for an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 4 2006 * *------------------------------------------------------------------------- */ herr_t H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) { H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ H5HF_t * fheap = NULL; /* Fractal heap handle */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for names */ H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); /* Set fractal heap creation parameters */ /* XXX: Give some control of these to applications? */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5O_FHEAP_MAN_START_BLOCK_SIZE; fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; /* Create fractal heap for storing attributes */ if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create fractal heap") /* Retrieve the heap's address in the file */ if (H5HF_get_heap_addr(fheap, &ainfo->fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address") #ifndef NDEBUG { size_t fheap_id_len; /* Fractal heap ID length */ /* Retrieve the heap's ID length in the file */ if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); } #endif /* NDEBUG */ /* Create the name index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); bt2_cparam.cls = H5A_BT2_NAME; bt2_cparam.node_size = (size_t)H5A_NAME_BT2_NODE_SIZE; bt2_cparam.rrec_size = 4 + /* Name's hash value */ 4 + /* Creation order index */ 1 + /* Message flags */ H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_NAME_BT2_MERGE_PERC; if (NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ if (H5B2_get_addr(bt2_name, &ainfo->name_bt2_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index") /* Check if we should create a creation order index v2 B-tree */ if (ainfo->index_corder) { /* Create the creation order index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); bt2_cparam.cls = H5A_BT2_CORDER; bt2_cparam.node_size = (size_t)H5A_CORDER_BT2_NODE_SIZE; bt2_cparam.rrec_size = 4 + /* Creation order index */ 1 + /* Message flags */ H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_CORDER_BT2_MERGE_PERC; if (NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ if (H5B2_get_addr(bt2_corder, &ainfo->corder_bt2_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index") } /* end if */ done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_create() */ /*------------------------------------------------------------------------- * Function: H5A__dense_fnd_cb * * Purpose: Callback when an attribute is located in an index * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) { const H5A_t **user_attr = (const H5A_t **)_user_attr; /* User data from v2 B-tree attribute lookup */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check arguments */ HDassert(attr); HDassert(user_attr); HDassert(took_ownership); /* * If there is an attribute already stored in "user_attr", * we need to free the dynamially allocated spaces for the * attribute, otherwise we got infinite loop closing library due to * outstanding allocation. (HDFFV-10659) * * This callback is used by H5A__dense_remove() to close/free the * attribute stored in "user_attr" (via H5O__msg_free_real()) after * the attribute node is deleted from the name index v2 B-tree. * The issue is: * When deleting the attribute node from the B-tree, * if the attribute is found in the intermediate B-tree nodes, * which may be merged/redistributed, we need to free the dynamically * allocated spaces for the intermediate decoded attribute. */ if (*user_attr != NULL) { H5A_t *old_attr = *(H5A_t **)_user_attr; /* Free any dynamically allocated items */ if (old_attr->shared) if (H5A__shared_free(old_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") old_attr = H5FL_FREE(H5A_t, old_attr); } /* end if */ /* Take over attribute ownership */ *user_attr = attr; *took_ownership = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fnd_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_open * * Purpose: Open an attribute in dense storage structures for an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 * *------------------------------------------------------------------------- */ H5A_t * H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ htri_t attr_exists; /* Attribute exists in v2 B-tree */ H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(name); /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record find */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = shared_fheap; udata.name = name; udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); udata.flags = 0; udata.corder = 0; udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.found_op_data = &ret_value; /* Find & copy the attribute in the 'name' index */ if ((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't search for attribute in name index") else if (attr_exists == FALSE) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute in name index") done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_open() */ /*------------------------------------------------------------------------- * Function: H5A__dense_insert * * Purpose: Insert an attribute into dense storage structures for an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 4 2006 * *------------------------------------------------------------------------- */ herr_t H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) { H5A_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ H5HF_t * fheap = NULL; /* Fractal heap handle for attributes */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ H5WB_t * wb = NULL; /* Wrapped buffer for attribute data */ uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing message */ unsigned mesg_flags = 0; /* Flags for storing message */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(attr); /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ /* Check if message is already shared */ if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") else if (shared_mesg > 0) /* Mark the message as shared */ mesg_flags |= H5O_MSG_FLAG_SHARED; else { /* Should this attribute be written as a SOHM? */ if (H5SM_try_share(f, NULL, 0, H5O_ATTR_ID, attr, &mesg_flags) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Attributes can't be "unique be shareable" yet */ HDassert(!(mesg_flags & H5O_MSG_FLAG_SHAREABLE)); } /* end else */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check for inserting shared attribute */ if (mesg_flags & H5O_MSG_FLAG_SHARED) { /* Sanity check */ HDassert(attr_sharable); /* Use heap ID for shared message heap */ udata.id = attr->sh_loc.u.heap_id; } /* end if */ else { void * attr_ptr; /* Pointer to serialized message */ size_t attr_size; /* Size of serialized attribute in the heap */ /* Find out the size of buffer needed for serialized message */ if ((attr_size = H5O_msg_raw_size(f, H5O_ATTR_ID, FALSE, attr)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get message size") /* Wrap the local buffer for serialized attributes */ if (NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for attribute */ if (NULL == (attr_ptr = H5WB_actual(wb, attr_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of attribute or shared message */ if (H5O_msg_encode(f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute") /* Insert the serialized attribute into the fractal heap */ /* (sets the heap ID in the user data) */ if (H5HF_insert(fheap, attr_size, attr_ptr, &udata.id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert attribute into fractal heap") } /* end else */ /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ udata.common.f = f; udata.common.fheap = fheap; udata.common.shared_fheap = shared_fheap; udata.common.name = attr->shared->name; udata.common.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); H5_CHECKED_ASSIGN(udata.common.flags, uint8_t, mesg_flags, unsigned); udata.common.corder = attr->shared->crt_idx; udata.common.found_op = NULL; udata.common.found_op_data = NULL; /* udata.id already set */ /* Insert attribute into 'name' tracking v2 B-tree */ if (H5B2_insert(bt2_name, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") /* Check if we should create a creation order index v2 B-tree record */ if (ainfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); if (NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ if (H5B2_insert(bt2_corder, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") } /* end if */ done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_insert() */ /*------------------------------------------------------------------------- * Function: H5A__dense_write_bt2_cb2 * * Purpose: v2 B-tree 'modify' callback to update the record for a creation * order index * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, February 20, 2007 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) { H5A_dense_bt2_corder_rec_t *record = (H5A_dense_bt2_corder_rec_t *)_record; /* Record from B-tree */ H5O_fheap_id_t *new_heap_id = (H5O_fheap_id_t *)_op_data; /* "op data" from v2 B-tree modify */ FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(record); HDassert(new_heap_id); /* Update record's heap ID */ record->id = *new_heap_id; /* Note that the record changed */ *changed = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5A__dense_write_bt2_cb2() */ /*------------------------------------------------------------------------- * Function: H5A__dense_write_bt2_cb * * Purpose: v2 B-tree 'modify' callback to update the data for an attribute * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, December 5, 2006 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) { H5A_dense_bt2_name_rec_t *record = (H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ H5A_bt2_od_wrt_t * op_data = (H5A_bt2_od_wrt_t *)_op_data; /* "op data" from v2 B-tree modify */ H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ H5WB_t * wb = NULL; /* Wrapped buffer for attribute data */ uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check arguments */ HDassert(record); HDassert(op_data); /* Check for modifying shared attribute */ if (record->flags & H5O_MSG_FLAG_SHARED) { /* Update the shared attribute in the SOHM info */ if (H5O__attr_update_shared(op_data->f, NULL, op_data->attr, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute in shared storage") /* Update record's heap ID */ record->id = op_data->attr->sh_loc.u.heap_id; /* Check if we need to modify the creation order index with new heap ID */ if (H5F_addr_defined(op_data->corder_bt2_addr)) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ /* Open the creation order index v2 B-tree */ if (NULL == (bt2_corder = H5B2_open(op_data->f, op_data->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Create the "udata" information for v2 B-tree record modify */ udata.f = op_data->f; udata.fheap = NULL; udata.shared_fheap = NULL; udata.name = NULL; udata.name_hash = 0; udata.flags = 0; udata.corder = op_data->attr->shared->crt_idx; udata.found_op = NULL; udata.found_op_data = NULL; /* Modify record for creation order index */ if (H5B2_modify(bt2_corder, &udata, H5A__dense_write_bt2_cb2, &op_data->attr->sh_loc.u.heap_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to modify record in v2 B-tree") } /* end if */ /* Note that the record changed */ *changed = TRUE; } /* end if */ else { void * attr_ptr; /* Pointer to serialized message */ size_t attr_size; /* Size of serialized attribute in the heap */ /* Find out the size of buffer needed for serialized attribute */ if ((attr_size = H5O_msg_raw_size(op_data->f, H5O_ATTR_ID, FALSE, op_data->attr)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get attribute size") /* Wrap the local buffer for serialized attributes */ if (NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for attribute */ if (NULL == (attr_ptr = H5WB_actual(wb, attr_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of attribute */ if (H5O_msg_encode(op_data->f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, op_data->attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute") /* Sanity check */ #ifndef NDEBUG { size_t obj_len; /* Length of existing encoded attribute */ if (H5HF_get_obj_len(op_data->fheap, &record->id, &obj_len) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get object size") HDassert(obj_len == attr_size); } #endif /* NDEBUG */ /* Update existing attribute in heap */ /* (might be more efficient as fractal heap 'op' callback, but leave that for later -QAK) */ if (H5HF_write(op_data->fheap, &record->id, changed, attr_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute in heap") } /* end else */ done: /* Release resources */ if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write_bt2_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_write * * Purpose: Modify an attribute in dense storage structures for an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 4 2006 * *------------------------------------------------------------------------- */ herr_t H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5A_bt2_od_wrt_t op_data; /* "Op data" for v2 B-tree modify */ H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(H5F_addr_defined(ainfo->fheap_addr)); HDassert(H5F_addr_defined(ainfo->name_bt2_addr)); HDassert(attr); /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = shared_fheap; udata.name = attr->shared->name; udata.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); udata.flags = 0; udata.corder = 0; udata.found_op = NULL; udata.found_op_data = NULL; /* Create the "op_data" for the v2 B-tree record 'modify' callback */ op_data.f = f; op_data.fheap = fheap; op_data.shared_fheap = shared_fheap; op_data.attr = attr; op_data.corder_bt2_addr = ainfo->corder_bt2_addr; /* Modify attribute through 'name' tracking v2 B-tree */ if (H5B2_modify(bt2_name, &udata, H5A__dense_write_bt2_cb, &op_data) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to modify record in v2 B-tree") done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write() */ /*------------------------------------------------------------------------- * Function: H5A__dense_copy_fh_cb * * Purpose: Callback for fractal heap operator, to make copy of attribute * for calling routine * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 5 2006 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_copy_fh_cb(const void *obj, size_t obj_len, void *_udata) { H5A_fh_ud_cp_t *udata = (H5A_fh_ud_cp_t *)_udata; /* User data for fractal heap 'op' callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode attribute information & keep a copy */ /* (we make a copy instead of calling the user/library callback directly in * this routine because this fractal heap 'op' callback routine is called * with the direct block protected and if the callback routine invokes an * HDF5 routine, it could attempt to re-protect that direct block for the * heap, causing the HDF5 routine called to fail) */ if (NULL == (udata->attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, FAIL, "can't decode attribute") /* Set the creation order index for the attribute */ udata->attr->shared->crt_idx = udata->record->corder; /* Check whether we should "reconstitute" the shared message info */ if (udata->record->flags & H5O_MSG_FLAG_SHARED) H5SM_reconstitute(&(udata->attr->sh_loc), udata->f, H5O_ATTR_ID, udata->record->id); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_copy_fh_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_rename * * Purpose: Rename an attribute in dense storage structures for an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Jan 3 2007 * *------------------------------------------------------------------------- */ herr_t H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, const char *new_name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */ H5A_t * attr_copy = NULL; /* Copy of attribute to rename */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ htri_t attr_exists; /* Attribute exists in v2 B-tree */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(old_name); HDassert(new_name); /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = shared_fheap; udata.name = old_name; udata.name_hash = H5_checksum_lookup3(old_name, HDstrlen(old_name), 0); udata.flags = 0; udata.corder = 0; udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.found_op_data = &attr_copy; /* Get copy of attribute through 'name' tracking v2 B-tree */ if ((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") else if (attr_exists == FALSE) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute in name index") HDassert(attr_copy); /* Check if message is already shared */ if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") else if (shared_mesg > 0) { /* Reset shared status of copy */ /* (so it will get shared again if necessary) */ attr_copy->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; } /* end if */ /* Change name of attribute */ H5MM_xfree(attr_copy->shared->name); attr_copy->shared->name = H5MM_xstrdup(new_name); /* Recompute the version to encode the attribute with */ if (H5A__set_version(f, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "unable to update attribute version") /* Need to remove the attribute from the creation order index v2 B-tree */ if (ainfo->index_corder) { htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */ /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); if (NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation index") /* Set up the creation order to search for */ udata.corder = attr_copy->shared->crt_idx; if ((corder_attr_exists = H5B2_find(bt2_corder, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") if (corder_attr_exists) { H5A_bt2_ud_rm_t rm_udata; /* Set up the creation order in user data for the v2 B-tree 'record remove' callback */ rm_udata.common.corder = attr_copy->shared->crt_idx; /* Remove the record from the creation order index v2 B-tree */ if (H5B2_remove(bt2_corder, &rm_udata, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree") } } /* Insert renamed attribute back into dense storage */ /* (Possibly making it shared) */ if (H5A__dense_insert(f, ainfo, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage") /* Was this attribute shared? */ if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) > 0) { hsize_t attr_rc; /* Attribute's ref count in shared message storage */ /* Retrieve ref count for shared attribute */ if (H5SM_get_refcount(f, H5O_ATTR_ID, &attr_copy->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If the newly shared attribute needs to share "ownership" of the shared * components (ie. its reference count is 1), increment the reference * count on any shared components of the attribute, so that they won't * be removed from the file. (Essentially a "copy on write" operation). * * *ick* -QAK, 2007/01/08 */ if (attr_rc == 1) { /* Increment reference count on attribute components */ if (H5O__attr_link(f, NULL, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ } /* end if */ else if (shared_mesg == 0) { /* Increment reference count on attribute components */ /* (so that they aren't deleted when the attribute is removed shortly) */ if (H5O__attr_link(f, NULL, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ else if (shared_mesg < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Delete old attribute from dense storage */ if (H5A__dense_remove(f, ainfo, old_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") if (attr_copy) H5O_msg_free(H5O_ATTR_ID, attr_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_rename() */ /*------------------------------------------------------------------------- * Function: H5A__dense_iterate_bt2_cb * * Purpose: v2 B-tree callback for dense attribute storage iterator * * Return: H5_ITER_ERROR/H5_ITER_CONT/H5_ITER_STOP * * Programmer: Quincey Koziol * Dec 5 2006 * *------------------------------------------------------------------------- */ static int H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) { const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ H5A_bt2_ud_it_t *bt2_udata = (H5A_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC /* Check for skipping attributes */ if (bt2_udata->skip > 0) --bt2_udata->skip; else { H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ H5HF_t * fheap; /* Fractal heap handle for attribute storage */ /* Check for iterating over shared attribute */ if (record->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; /* Prepare user data for callback */ /* down */ fh_udata.f = bt2_udata->f; fh_udata.record = record; fh_udata.attr = NULL; /* Call fractal heap 'op' routine, to copy the attribute information */ if (H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, H5_ITER_ERROR, "heap op callback failed") /* Check which type of callback to make */ switch (bt2_udata->attr_op->op_type) { case H5A_ATTR_OP_APP2: { H5A_info_t ainfo; /* Info for attribute */ /* Get the attribute information */ if (H5A__get_info(fh_udata.attr, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") /* Make the application callback */ ret_value = (bt2_udata->attr_op->u.app_op2)(bt2_udata->loc_id, fh_udata.attr->shared->name, &ainfo, bt2_udata->op_data); break; } #ifndef H5_NO_DEPRECATED_SYMBOLS case H5A_ATTR_OP_APP: /* Make the application callback */ ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->shared->name, bt2_udata->op_data); break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ case H5A_ATTR_OP_LIB: /* Call the library's callback */ ret_value = (bt2_udata->attr_op->u.lib_op)(fh_udata.attr, bt2_udata->op_data); break; default: HDassert("unknown attribute op type" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute op type") #endif /* NDEBUG */ } /* end switch */ /* Release the space allocated for the attribute */ H5O_msg_free(H5O_ATTR_ID, fh_udata.attr); } /* end else */ /* Increment the number of attributes passed through */ /* (whether we skipped them or not) */ bt2_udata->count++; /* Check for callback failure and pass along return value */ if (ret_value < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate_bt2_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_iterate * * Purpose: Iterate over attributes in dense storage structures for an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 5 2006 * *------------------------------------------------------------------------- */ herr_t H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(H5F_addr_defined(ainfo->fheap_addr)); HDassert(H5F_addr_defined(ainfo->name_bt2_addr)); HDassert(attr_op); /* Determine the address of the index to use */ if (idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. */ if (order == H5_ITER_NATIVE) { HDassert(H5F_addr_defined(ainfo->name_bt2_addr)); bt2_addr = ainfo->name_bt2_addr; } /* end if */ else bt2_addr = HADDR_UNDEF; } /* end if */ else { HDassert(idx_type == H5_INDEX_CRT_ORDER); /* This address may not be defined if creation order is tracked, but * there's no index on it. If there's no v2 B-tree that indexes * the links, a table will be built. */ bt2_addr = ainfo->corder_bt2_addr; } /* end else */ /* Check on iteration order */ if (order == H5_ITER_NATIVE && H5F_addr_defined(bt2_addr)) { H5A_bt2_ud_it_t udata; /* User data for iterator callback */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the index v2 B-tree */ if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = shared_fheap; udata.loc_id = loc_id; udata.skip = skip; udata.count = 0; udata.attr_op = attr_op; udata.op_data = op_data; /* Iterate over the records in the v2 B-tree's "native" order */ /* (by hash of name) */ if ((ret_value = H5B2_iterate(bt2, H5A__dense_iterate_bt2_cb, &udata)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); /* Update the last attribute examined, if requested */ if (last_attr) *last_attr = udata.count; } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ if (H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Iterate over attributes in table */ if ((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate() */ /*------------------------------------------------------------------------- * Function: H5A__dense_remove_bt2_cb * * Purpose: v2 B-tree callback for dense attribute storage record removal * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_remove_bt2_cb(const void *_record, void *_udata) { const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; H5A_bt2_ud_rm_t * udata = (H5A_bt2_ud_rm_t *)_udata; /* User data for callback */ H5A_t * attr = *(H5A_t **)udata->common.found_op_data; /* Pointer to attribute to remove */ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for removing the link from the creation order index */ if (H5F_addr_defined(udata->corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if (NULL == (bt2_corder = H5B2_open(udata->common.f, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ udata->common.corder = attr->shared->crt_idx; /* Remove the record from the creation order index v2 B-tree */ if (H5B2_remove(bt2_corder, udata, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree") } /* end if */ /* Check for removing shared attribute */ if (record->flags & H5O_MSG_FLAG_SHARED) { /* Decrement the reference count on the shared attribute message */ if (H5SM_delete(udata->common.f, NULL, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { /* Perform the deletion action on the attribute */ /* (takes care of shared & committed datatype/dataspace components) */ if (H5O__attr_delete(udata->common.f, NULL, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") /* Remove record from fractal heap */ if (H5HF_remove(udata->common.fheap, &record->id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") } /* end else */ done: /* Release resources */ if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_bt2_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_remove * * Purpose: Remove an attribute from the dense storage of an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 * *------------------------------------------------------------------------- */ herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { H5A_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ H5A_t * attr_copy = NULL; /* Copy of attribute to remove */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(name && *name); /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ udata.common.f = f; udata.common.fheap = fheap; udata.common.shared_fheap = shared_fheap; udata.common.name = name; udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); udata.common.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.common.found_op_data = &attr_copy; udata.corder_bt2_addr = ainfo->corder_bt2_addr; /* Remove the record from the name index v2 B-tree */ if (H5B2_remove(bt2_name, &udata, H5A__dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from name index v2 B-tree") done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") if (attr_copy) H5O_msg_free_real(H5O_MSG_ATTR, attr_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove() */ /*------------------------------------------------------------------------- * Function: H5A__dense_remove_by_idx_bt2_cb * * Purpose: v2 B-tree callback for dense attribute storage record removal by index * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Feb 14 2007 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { H5HF_t * fheap; /* Fractal heap handle */ H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* v2 B-tree record */ H5A_bt2_ud_rmbi_t * bt2_udata = (H5A_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ H5O_shared_t sh_loc; /* Shared message info for attribute */ hbool_t use_sh_loc; /* Whether to use the attribute's shared location or the separate one */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Set up the user data for fractal heap 'op' callback */ fh_udata.f = bt2_udata->f; fh_udata.record = record; fh_udata.attr = NULL; /* Get correct fractal heap handle to use for operations */ if (record->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; /* Check whether to make a copy of the attribute or just need the shared location info */ if (H5F_addr_defined(bt2_udata->other_bt2_addr) || !(record->flags & H5O_MSG_FLAG_SHARED)) { /* Call fractal heap 'op' routine, to make copy of attribute to remove */ if (H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "attribute removal callback failed") HDassert(fh_udata.attr); /* Use the attribute's shared location */ use_sh_loc = FALSE; } /* end if */ else { /* Create a shared message location from the heap ID for this record */ H5SM_reconstitute(&sh_loc, bt2_udata->f, H5O_ATTR_ID, record->id); /* Use the separate shared location */ use_sh_loc = TRUE; } /* end else */ /* Check for removing the link from the "other" index (creation order, when name used and vice versa) */ if (H5F_addr_defined(bt2_udata->other_bt2_addr)) { H5A_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ /* Determine the index being used */ if (bt2_udata->idx_type == H5_INDEX_NAME) { /* Set up the user data for the v2 B-tree 'record remove' callback */ other_bt2_udata.corder = fh_udata.attr->shared->crt_idx; } /* end if */ else { HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set up the user data for the v2 B-tree 'record remove' callback */ other_bt2_udata.f = bt2_udata->f; other_bt2_udata.fheap = bt2_udata->fheap; other_bt2_udata.shared_fheap = bt2_udata->shared_fheap; other_bt2_udata.name = fh_udata.attr->shared->name; other_bt2_udata.name_hash = H5_checksum_lookup3(fh_udata.attr->shared->name, HDstrlen(fh_udata.attr->shared->name), 0); other_bt2_udata.found_op = NULL; other_bt2_udata.found_op_data = NULL; } /* end else */ /* Open the index v2 B-tree */ if (NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set the common information for the v2 B-tree remove operation */ /* Remove the record from the "other" index v2 B-tree */ if (H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove record from 'other' index v2 B-tree") } /* end if */ /* Check for removing shared attribute */ if (record->flags & H5O_MSG_FLAG_SHARED) { H5O_shared_t *sh_loc_ptr; /* Pointer to shared message info for attribute */ /* Set up pointer to correct shared location */ if (use_sh_loc) sh_loc_ptr = &sh_loc; else sh_loc_ptr = &(fh_udata.attr->sh_loc); /* Decrement the reference count on the shared attribute message */ if (H5SM_delete(bt2_udata->f, NULL, sh_loc_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { /* Perform the deletion action on the attribute */ /* (takes care of shared & committed datatype/dataspace components) */ if (H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") /* Remove record from fractal heap */ if (H5HF_remove(fheap, &record->id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") } /* end else */ done: /* Release resources */ if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") if (fh_udata.attr) H5O_msg_free(H5O_ATTR_ID, fh_udata.attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx_bt2_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_remove_by_idx * * Purpose: Remove an attribute from the dense storage of an object, * according to the order within an index * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Feb 14 2007 * *------------------------------------------------------------------------- */ herr_t H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); /* Determine the address of the index to use */ if (idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. */ if (order == H5_ITER_NATIVE) { bt2_addr = ainfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ else bt2_addr = HADDR_UNDEF; } /* end if */ else { HDassert(idx_type == H5_INDEX_CRT_ORDER); /* This address may not be defined if creation order is tracked, but * there's no index on it. If there's no v2 B-tree that indexes * the links, a table will be built. */ bt2_addr = ainfo->corder_bt2_addr; } /* end else */ /* If there is an index defined for the field, use it */ if (H5F_addr_defined(bt2_addr)) { H5A_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the index v2 B-tree */ if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = shared_fheap; udata.idx_type = idx_type; udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? ainfo->corder_bt2_addr : ainfo->name_bt2_addr; /* Remove the record from the name index v2 B-tree */ if (H5B2_remove_by_idx(bt2, order, n, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from v2 B-tree index") } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ if (H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Check for skipping too many attributes */ if (n >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Delete appropriate attribute from dense storage */ if (H5A__dense_remove(f, ainfo, ((atable.attrs[n])->shared)->name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end else */ done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx() */ /*------------------------------------------------------------------------- * Function: H5A__dense_exists * * Purpose: Check if an attribute exists in dense storage structures for * an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 * *------------------------------------------------------------------------- */ htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5HF_t * fheap = NULL; /* Fractal heap handle */ H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); HDassert(name); /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ } /* end if */ /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record 'find' */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = shared_fheap; udata.name = name; udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); udata.flags = 0; udata.corder = 0; udata.found_op = NULL; /* v2 B-tree comparison callback */ udata.found_op_data = NULL; /* Find the attribute in the 'name' index */ if ((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_exists() */ /*------------------------------------------------------------------------- * Function: H5A__dense_delete_bt2_cb * * Purpose: v2 B-tree callback for dense attribute storage deletion * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Jan 3 2007 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_delete_bt2_cb(const void *_record, void *_bt2_udata) { const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ H5A_bt2_ud_common_t *bt2_udata = (H5A_bt2_ud_common_t *)_bt2_udata; /* User data for callback */ H5A_t * attr = NULL; /* Attribute being removed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for shared attribute */ if (record->flags & H5O_MSG_FLAG_SHARED) { H5O_shared_t sh_mesg; /* Temporary shared message info */ /* "reconstitute" the shared message info for the attribute */ H5SM_reconstitute(&sh_mesg, bt2_udata->f, H5O_ATTR_ID, record->id); /* Decrement the reference count on the shared attribute message */ if (H5SM_delete(bt2_udata->f, NULL, &sh_mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ /* Prepare user data for callback */ /* down */ fh_udata.f = bt2_udata->f; fh_udata.record = record; /* up */ fh_udata.attr = NULL; /* Call fractal heap 'op' routine, to copy the attribute information */ if (H5HF_op(bt2_udata->fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "heap op callback failed") attr = fh_udata.attr; /* Perform the deletion action on the attribute */ /* (takes care of shared/committed datatype & dataspace components) */ if (H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end else */ done: /* Release resources */ if (attr) H5O_msg_free_real(H5O_MSG_ATTR, attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete_bt2_cb() */ /*------------------------------------------------------------------------- * Function: H5A__dense_delete * * Purpose: Delete all dense storage structures for attributes on an object * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 6 2006 * *------------------------------------------------------------------------- */ herr_t H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo) { H5A_bt2_ud_common_t udata; /* v2 B-tree user data for deleting attributes */ H5HF_t * fheap = NULL; /* Fractal heap handle */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); HDassert(ainfo); /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Create the "udata" information for v2 B-tree 'delete' */ udata.f = f; udata.fheap = fheap; udata.shared_fheap = NULL; udata.name = NULL; udata.name_hash = 0; udata.flags = 0; udata.found_op = NULL; /* v2 B-tree comparison callback */ udata.found_op_data = NULL; /* Delete name index v2 B-tree */ if (H5B2_delete(f, ainfo->name_bt2_addr, NULL, H5A__dense_delete_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") ainfo->name_bt2_addr = HADDR_UNDEF; /* Release resources */ if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") fheap = NULL; /* Check if we should delete the creation order index v2 B-tree */ if (H5F_addr_defined(ainfo->corder_bt2_addr)) { /* Delete the creation order index, without adjusting the ref. count on the attributes */ if (H5B2_delete(f, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") ainfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ /* Delete fractal heap */ if (H5HF_delete(f, ainfo->fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") ainfo->fheap_addr = HADDR_UNDEF; done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete() */
5089b7e6a131c6a6f2bd77fd6870e7eaff08ac1b
3082eabb774ec5bbd71ce522f8fe052bd237ad8b
/AnKi/Shaders/Include/TraditionalDeferredShadingTypes.h
8ebdfaf86bdeb15b777694809a526ef84ca641d3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
godlikepanos/anki-3d-engine
b8099d53ec92849a93e428f2a2df9b1a02698aa8
fd12a5f960b55568c86130cd54941179969c9348
refs/heads/master
2023-09-02T05:52:37.099035
2023-04-08T12:16:49
2023-04-08T12:16:49
23,955,091
1,204
93
NOASSERTION
2023-04-08T12:16:50
2014-09-12T09:41:20
C++
UTF-8
C
false
false
1,653
h
TraditionalDeferredShadingTypes.h
// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include <AnKi/Shaders/Include/Common.h> ANKI_BEGIN_NAMESPACE struct DeferredPointLightUniforms { // Use these to get the correct face UVs Vec2 m_inputTexUvScale; Vec2 m_inputTexUvBias; Vec2 m_fbUvScale; Vec2 m_fbUvBias; Mat4 m_invViewProjMat; Vec3 m_camPos; F32 m_padding; // Light props Vec3 m_position; F32 m_oneOverSquareRadius; // 1/radius^2 Vec3 m_diffuseColor; F32 m_padding2; }; struct DeferredSpotLightUniforms { // Use these to get the correct face UVs Vec2 m_inputTexUvScale; Vec2 m_inputTexUvBias; Vec2 m_fbUvScale; Vec2 m_fbUvBias; Mat4 m_invViewProjMat; Vec3 m_camPos; F32 m_padding; // Light props Vec3 m_position; F32 m_oneOverSquareRadius; // 1/radius^2 Vec3 m_diffuseColor; F32 m_outerCos; Vec3 m_lightDir; F32 m_innerCos; }; struct DeferredDirectionalLightUniforms { // Use these to get the correct face UVs Vec2 m_inputTexUvScale; Vec2 m_inputTexUvBias; Vec2 m_fbUvScale; Vec2 m_fbUvBias; Mat4 m_invViewProjMat; Vec3 m_camPos; F32 m_near; // Light props Vec3 m_diffuseColor; F32 m_far; Vec3 m_lightDir; F32 m_effectiveShadowDistance; Mat4 m_lightMatrix; }; struct DeferredVertexUniforms { Mat4 m_mvp; }; struct DeferredSkyboxUniforms { #if ANKI_GLSL ANKI_RP Vec3 m_solidColor; #else RVec3 m_solidColor; #endif F32 m_padding1; Vec2 m_inputTexUvScale; Vec2 m_inputTexUvBias; Mat4 m_invertedViewProjectionMat; Vec3 m_cameraPos; F32 m_padding2; }; ANKI_END_NAMESPACE
be082db873f23f94ff6eadb749e11ee75f34f3f4
2c052c996d4267623276a681308bf87ea7388f60
/src/hyperv/utilities/vmbus_shutdown.c
98f876170aeb2934ff1ba024d5e3a2ace5afa99c
[ "Apache-2.0" ]
permissive
nanovms/nanos
17d3ce113b63c4370e40d291b8fd8fb9d943c02d
9085e091e5250fc58bf036591c8959e05fd7957f
refs/heads/master
2023-08-25T16:49:14.521701
2023-08-25T14:00:54
2023-08-25T14:14:13
115,159,616
2,055
131
Apache-2.0
2023-09-14T17:16:19
2017-12-23T00:25:34
C
UTF-8
C
false
false
4,730
c
vmbus_shutdown.c
/*- * Copyright (c) 2014,2016 Microsoft Corp. * 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 unmodified, 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 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 <kernel.h> #include <hyperv_internal.h> #include "vmbus_icvar.h" #include "vmbus_icreg.h" #include "vmbus.h" #include "io.h" #include "hyperv_platform.h" #define VMBUS_SHUTDOWN_FWVER_MAJOR 3 #define VMBUS_SHUTDOWN_FWVER \ VMBUS_IC_VERSION(VMBUS_SHUTDOWN_FWVER_MAJOR, 0) #define VMBUS_SHUTDOWN_MSGVER_MAJOR 3 #define VMBUS_SHUTDOWN_MSGVER \ VMBUS_IC_VERSION(VMBUS_SHUTDOWN_MSGVER_MAJOR, 0) static const struct hyperv_guid vmbus_shutdown_device_type = { .hv_guid = { 0x31, 0x60, 0x0b, 0x0e, 0x13, 0x52, 0x34, 0x49, 0x81, 0x8b, 0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb } }; closure_function(0, 1, void, hv_sync_complete, int, status) { HV_SHUTDOWN(); } void unix_shutdown(void); static void vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) { struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; struct vmbus_icmsg_shutdown *msg; int dlen, error, do_shutdown = 0; uint64_t xactid; void *data; /* * Receive request. */ data = sc->ic_buf; dlen = sc->ic_buflen; error = vmbus_chan_recv(chan, data, &dlen, &xactid); assert(error != ENOBUFS); // icbuf is not large enough if (error) return; if (dlen < sizeof(*hdr)) { vmbus_util_debug("invalid data len %d", dlen); return; } hdr = data; /* * Update request, which will be echoed back as response. */ switch (hdr->ic_type) { case VMBUS_ICMSG_TYPE_NEGOTIATE: error = vmbus_ic_negomsg(sc, data, &dlen, VMBUS_SHUTDOWN_FWVER, VMBUS_SHUTDOWN_MSGVER); if (error) return; break; case VMBUS_ICMSG_TYPE_SHUTDOWN: if (dlen < VMBUS_ICMSG_SHUTDOWN_SIZE_MIN) { vmbus_util_debug("invalid shutdown len %d", dlen); return; } msg = data; /* XXX ic_flags definition? */ if (msg->ic_haltflags == 0 || msg->ic_haltflags == 1) { vmbus_util_debug("shutdown requested"); hdr->ic_status = VMBUS_ICMSG_STATUS_OK; do_shutdown = 1; } else { vmbus_util_debug("unknown shutdown flags 0x%08x", msg->ic_haltflags); hdr->ic_status = VMBUS_ICMSG_STATUS_FAIL; } break; default: vmbus_util_debug("got 0x%08x icmsg", hdr->ic_type); break; } /* * Send response by echoing the request back. */ vmbus_ic_sendresp(sc, chan, data, dlen, xactid); if (do_shutdown) unix_shutdown(); } static status vmbus_shutdown_attach(kernel_heaps kh, hv_device* device) { heap h = heap_general(kh); struct vmbus_ic_softc *sc = allocate_zero(h, sizeof(struct vmbus_ic_softc)); assert(sc != INVALID_ADDRESS); sc->general = h; sc->hs_dev = device; vmbus_ic_attach(sc, vmbus_shutdown_cb); vm_halt = closure(sc->general, hv_sync_complete); return STATUS_OK; } closure_function(1, 3, boolean, vmbus_shutdown_probe, kernel_heaps, kh, struct hv_device*, device, storage_attach, unused, boolean*, unused1) { status s = vmbus_shutdown_attach(bound(kh), device); if (!is_ok(s)) { msg_err("attach failed with status %v\n", s); return false; } return true; } void init_vmbus_shutdown(kernel_heaps kh) { register_vmbus_driver(&vmbus_shutdown_device_type, closure(heap_general(kh), vmbus_shutdown_probe, kh)); }
b5f5561f58a872adcf11d7853ebb4aedafea8800
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/parisc/include/asm/page.h
637fe031aa8476d743a8141ca9b549019985a0c6
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
5,212
h
page.h
#ifndef _PARISC_PAGE_H #define _PARISC_PAGE_H #include <linux/const.h> #if defined(CONFIG_PARISC_PAGE_SIZE_4KB) # define PAGE_SHIFT 12 #elif defined(CONFIG_PARISC_PAGE_SIZE_16KB) # define PAGE_SHIFT 14 #elif defined(CONFIG_PARISC_PAGE_SIZE_64KB) # define PAGE_SHIFT 16 #else # error "unknown default kernel page size" #endif #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE-1)) #ifndef __ASSEMBLY__ #include <asm/types.h> #include <asm/cache.h> #define clear_page(page) clear_page_asm((void *)(page)) #define copy_page(to, from) copy_page_asm((void *)(to), (void *)(from)) struct page; void clear_page_asm(void *page); void copy_page_asm(void *to, void *from); #define clear_user_page(vto, vaddr, page) clear_page_asm(vto) void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, struct page *pg); /* #define CONFIG_PARISC_TMPALIAS */ #ifdef CONFIG_PARISC_TMPALIAS void clear_user_highpage(struct page *page, unsigned long vaddr); #define clear_user_highpage clear_user_highpage struct vm_area_struct; void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr, struct vm_area_struct *vma); #define __HAVE_ARCH_COPY_USER_HIGHPAGE #endif /* * These are used to make use of C type-checking.. */ #define STRICT_MM_TYPECHECKS #ifdef STRICT_MM_TYPECHECKS typedef struct { unsigned long pte; } pte_t; /* either 32 or 64bit */ /* NOTE: even on 64 bits, these entries are __u32 because we allocate * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */ typedef struct { __u32 pmd; } pmd_t; typedef struct { __u32 pgd; } pgd_t; typedef struct { unsigned long pgprot; } pgprot_t; #define pte_val(x) ((x).pte) /* These do not work lvalues, so make sure we don't use them as such. */ #define pmd_val(x) ((x).pmd + 0) #define pgd_val(x) ((x).pgd + 0) #define pgprot_val(x) ((x).pgprot) #define __pte(x) ((pte_t) { (x) } ) #define __pmd(x) ((pmd_t) { (x) } ) #define __pgd(x) ((pgd_t) { (x) } ) #define __pgprot(x) ((pgprot_t) { (x) } ) #define __pmd_val_set(x,n) (x).pmd = (n) #define __pgd_val_set(x,n) (x).pgd = (n) #else /* * .. while these make it easier on the compiler */ typedef unsigned long pte_t; typedef __u32 pmd_t; typedef __u32 pgd_t; typedef unsigned long pgprot_t; #define pte_val(x) (x) #define pmd_val(x) (x) #define pgd_val(x) (x) #define pgprot_val(x) (x) #define __pte(x) (x) #define __pmd(x) (x) #define __pgd(x) (x) #define __pgprot(x) (x) #define __pmd_val_set(x,n) (x) = (n) #define __pgd_val_set(x,n) (x) = (n) #endif /* STRICT_MM_TYPECHECKS */ typedef struct page *pgtable_t; typedef struct __physmem_range { unsigned long start_pfn; unsigned long pages; /* PAGE_SIZE pages */ } physmem_range_t; extern physmem_range_t pmem_ranges[]; extern int npmem_ranges; #endif /* !__ASSEMBLY__ */ /* WARNING: The definitions below must match exactly to sizeof(pte_t) * etc */ #ifdef CONFIG_64BIT #define BITS_PER_PTE_ENTRY 3 #define BITS_PER_PMD_ENTRY 2 #define BITS_PER_PGD_ENTRY 2 #else #define BITS_PER_PTE_ENTRY 2 #define BITS_PER_PMD_ENTRY 2 #define BITS_PER_PGD_ENTRY BITS_PER_PMD_ENTRY #endif #define PGD_ENTRY_SIZE (1UL << BITS_PER_PGD_ENTRY) #define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY) #define PTE_ENTRY_SIZE (1UL << BITS_PER_PTE_ENTRY) #define LINUX_GATEWAY_SPACE 0 /* This governs the relationship between virtual and physical addresses. * If you alter it, make sure to take care of our various fixed mapping * segments in fixmap.h */ #ifdef CONFIG_64BIT #define __PAGE_OFFSET (0x40000000) /* 1GB */ #else #define __PAGE_OFFSET (0x10000000) /* 256MB */ #endif #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) /* The size of the gateway page (we leave lots of room for expansion) */ #define GATEWAY_PAGE_SIZE 0x4000 /* The start of the actual kernel binary---used in vmlinux.lds.S * Leave some space after __PAGE_OFFSET for detecting kernel null * ptr derefs */ #define KERNEL_BINARY_TEXT_START (__PAGE_OFFSET + 0x100000) /* These macros don't work for 64-bit C code -- don't allow in C at all */ #ifdef __ASSEMBLY__ # define PA(x) ((x)-__PAGE_OFFSET) # define VA(x) ((x)+__PAGE_OFFSET) #endif #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) #ifndef CONFIG_DISCONTIGMEM #define pfn_valid(pfn) ((pfn) < max_mapnr) #endif /* CONFIG_DISCONTIGMEM */ #ifdef CONFIG_HUGETLB_PAGE #define HPAGE_SHIFT 22 /* 4MB (is this fixed?) */ #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) #define HPAGE_MASK (~(HPAGE_SIZE - 1)) #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) #endif #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) #include <asm-generic/memory_model.h> #include <asm-generic/getorder.h> #include <asm/pdc.h> #define PAGE0 ((struct zeropage *)__PAGE_OFFSET) /* DEFINITION OF THE ZERO-PAGE (PAG0) */ /* based on work by Jason Eckhardt (jason@equator.com) */ #endif /* _PARISC_PAGE_H */
681025cc7c9801325adc113234e218ca9708de40
21c92afbd7fd022a206fb31294c523aebb770104
/SuiteSparse/CHOLMOD/Tcov/cctest.c
f46f917dec80df8532f026c4bc8fd235e4f55804
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-or-later", "GPL-3.0-only", "LGPL-2.1-or-later", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-generic-cla", "GPL-2.0-only" ]
permissive
jlblancoc/suitesparse-metis-for-windows
70e6bcab2b525afb41758d61f823efa0618f67cf
5ee2eb4bc7bfd6d27af2f7fb027b1545cfc0fa3f
refs/heads/master
2023-08-30T21:15:39.624300
2023-03-09T10:16:48
2023-03-09T10:16:48
16,236,582
423
251
BSD-3-Clause
2023-03-09T10:18:08
2014-01-25T18:06:21
C
UTF-8
C
false
false
12,429
c
cctest.c
/* ========================================================================== */ /* === Tcov/cctest ========================================================== */ /* ========================================================================== */ /* ----------------------------------------------------------------------------- * CHOLMOD/Tcov Module. Copyright (C) 2005-2006, Timothy A. Davis * http://www.suitesparse.com * -------------------------------------------------------------------------- */ /* Test for ccolamd v1.0. Not used if NCAMD defined at compile time. */ #include "cm.h" #ifndef NCAMD #include "ccolamd.h" /* ========================================================================== */ /* === check_constraints ==================================================== */ /* ========================================================================== */ /* Check to see if P obeys the constraints */ Int check_constraints (Int *P, Int *Cmember, Int n) { Int c, clast, k, i ; if ((P == NULL) || !CHOLMOD(print_perm) (P, n, n, "ccolamd perm", cm)) { printf ("cctest: Perm is bad\n") ; return (FALSE) ; } clast = EMPTY ; for (k = 0 ; k < n ; k++) { i = P [k] ; c = Cmember [i] ; if (c < clast) { printf ("cctest: constraints are incorrect\n") ; return (FALSE) ; } clast = c ; } return (TRUE) ; } /* ========================================================================== */ /* === cctest =============================================================== */ /* ========================================================================== */ void cctest (cholmod_sparse *A) { double knobs [CCOLAMD_KNOBS], knobs2 [CCOLAMD_KNOBS] ; Int *P, *Cmember, *Cp, *Ci, *Front_npivcol, *Front_nrows, *Front_ncols, *Front_parent, *Front_cols, *InFront, *Si, *Sp ; cholmod_sparse *C, *A2, *B, *S ; Int nrow, ncol, alen, ok, stats [CCOLAMD_STATS], csets, i, nfr, c, p ; size_t s ; /* ---------------------------------------------------------------------- */ /* get inputs */ /* ---------------------------------------------------------------------- */ my_srand (42) ; /* RAND reset */ printf ("\nCCOLAMD test\n") ; if (A == NULL) { return ; } if (A->stype) { A2 = CHOLMOD(copy) (A, 0, 0, cm) ; B = A2 ; } else { A2 = NULL ; B = A ; } S = CHOLMOD(copy_sparse) (A, cm) ; nrow = B->nrow ; ncol = B->ncol ; Si = S->i ; Sp = S->p ; /* ---------------------------------------------------------------------- */ /* allocate workspace and Cmember for ccolamd */ /* ---------------------------------------------------------------------- */ P = CHOLMOD(malloc) (nrow+1, sizeof (Int), cm) ; Cmember = CHOLMOD(malloc) (nrow, sizeof (Int), cm) ; Front_npivcol = CHOLMOD(malloc) (nrow+1, sizeof (Int), cm) ; Front_nrows = CHOLMOD(malloc) (nrow+1, sizeof (Int), cm) ; Front_ncols = CHOLMOD(malloc) (nrow+1, sizeof (Int), cm) ; Front_parent = CHOLMOD(malloc) (nrow+1, sizeof (Int), cm) ; Front_cols = CHOLMOD(malloc) (nrow+1, sizeof (Int), cm) ; InFront = CHOLMOD(malloc) (ncol, sizeof (Int), cm) ; csets = MIN (6, nrow) ; for (i = 0 ; i < nrow ; i++) { Cmember [i] = nrand (csets) ; } CCOLAMD_set_defaults (knobs) ; CCOLAMD_set_defaults (knobs2) ; CCOLAMD_set_defaults (NULL) ; CCOLAMD_report (NULL) ; CSYMAMD_report (NULL) ; alen = CCOLAMD_recommended (B->nzmax, ncol, nrow) ; C = CHOLMOD(allocate_sparse) (ncol, nrow, alen, TRUE, TRUE, 0, CHOLMOD_PATTERN, cm) ; Cp = C->p ; Ci = C->i ; /* ---------------------------------------------------------------------- */ /* order with ccolamd */ /* ---------------------------------------------------------------------- */ ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; CHOLMOD(print_sparse) (C, "C for ccolamd", cm) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, NULL, stats, Cmember) ; CCOLAMD_report (stats) ; OK (ok) ; ok = stats [CCOLAMD_STATUS] ; ok = (ok == CCOLAMD_OK || ok == CCOLAMD_OK_BUT_JUMBLED) ; OK (ok) ; /* permutation returned in C->p, if the ordering succeeded */ /* make sure P obeys the constraints */ OK (check_constraints (Cp, Cmember, nrow)) ; /* ---------------------------------------------------------------------- */ /* order with ccolamd2 */ /* ---------------------------------------------------------------------- */ ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; ok = CCOLAMD_2 (ncol, nrow, alen, Ci, Cp, NULL, stats, Front_npivcol, Front_nrows, Front_ncols, Front_parent, Front_cols, &nfr, InFront, Cmember) ; CCOLAMD_report (stats) ; OK (check_constraints (Cp, Cmember, nrow)) ; /* ---------------------------------------------------------------------- */ /* with a small dense-row threshold */ /* ---------------------------------------------------------------------- */ knobs2 [CCOLAMD_DENSE_ROW] = 0 ; ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs2, stats, Cmember) ; CCOLAMD_report (stats) ; knobs2 [CCOLAMD_DENSE_ROW] = 0.625 ; knobs2 [CCOLAMD_DENSE_COL] = 0 ; ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs2, stats, Cmember) ; CCOLAMD_report (stats) ; knobs2 [CCOLAMD_DENSE_ROW] = 0.625 ; knobs2 [CCOLAMD_DENSE_COL] = -1 ; ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs2, stats, Cmember) ; CCOLAMD_report (stats) ; knobs2 [CCOLAMD_DENSE_COL] = 0 ; /* ---------------------------------------------------------------------- */ /* duplicate entries */ /* ---------------------------------------------------------------------- */ if (ncol > 2 && nrow > 2) { ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; if (Cp [1] - Cp [0] > 2) { Ci [0] = Ci [1] ; } ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs2, stats, Cmember) ; CCOLAMD_report (stats) ; OK (CHOLMOD(print_perm) (Cp, nrow, nrow, "ccolamd perm", cm)) ; } /* ---------------------------------------------------------------------- */ /* csymamd */ /* ---------------------------------------------------------------------- */ if (nrow == ncol) { Int n = nrow ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; OK (ok) ; OK (check_constraints (P, Cmember, n)) ; CSYMAMD_report (stats) ; /* ------------------------------------------------------------------ */ /* csymamd errors */ /* ------------------------------------------------------------------ */ ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, NULL, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); ok = CSYMAMD_MAIN (n, NULL, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; ok = CSYMAMD_MAIN (n, Si, NULL, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; ok = CSYMAMD_MAIN (-1, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; p = Sp [n] ; Sp [n] = -1 ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; Sp [n] = p ; Sp [0] = -1 ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; Sp [0] = 0 ; if (n > 2 && Sp [n] > 3) { p = Sp [1] ; Sp [1] = -1 ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; Sp [1] = p ; i = Si [0] ; Si [0] = -1 ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT (ok); CSYMAMD_report (stats) ; Si [0] = i ; /* ok, but jumbled */ i = Si [0] ; Si [0] = Si [1] ; Si [1] = i ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; OK (ok); CSYMAMD_report (stats) ; i = Si [0] ; Si [0] = Si [1] ; Si [1] = i ; test_memory_handler ( ) ; ok = CSYMAMD_MAIN (n, Si, Sp, P, NULL, stats, SuiteSparse_config.calloc_func, SuiteSparse_config.free_func, Cmember, A->stype) ; NOT(ok); CSYMAMD_report (stats) ; normal_memory_handler ( ) ; } } /* ---------------------------------------------------------------------- */ /* error tests */ /* ---------------------------------------------------------------------- */ ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; ok = CCOLAMD_MAIN (ncol, nrow, 0, Ci, Cp, knobs, stats, Cmember) ; NOT (ok) ; CCOLAMD_report (stats) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, NULL, Cp, knobs, stats, Cmember); NOT (ok) ; CCOLAMD_report (stats) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, NULL, knobs, stats, Cmember); NOT (ok) ; CCOLAMD_report (stats) ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs, NULL, Cmember) ; NOT (ok) ; CCOLAMD_report (stats) ; ok = CCOLAMD_MAIN (-1, nrow, alen, Ci, Cp, knobs, stats, Cmember) ; NOT (ok) ; CCOLAMD_report (stats) ; ok = CCOLAMD_MAIN (ncol, -1, alen, Ci, Cp, knobs, stats, Cmember) ; NOT (ok) ; CCOLAMD_report (stats) ; ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; Cp [nrow] = -1 ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs, stats, Cmember) ; NOT (ok) ; CCOLAMD_report (stats) ; Cp [0] = 1 ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs, stats, Cmember) ; NOT (ok) ; CCOLAMD_report (stats) ; ok = CHOLMOD(transpose_unsym) (B, 0, NULL, NULL, 0, C, cm) ; OK (ok) ; if (nrow > 0 && alen > 0 && Cp [1] > 0) { c = Cmember [0] ; Cmember [0] = -1 ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs, stats, Cmember) ;NOT(ok); CCOLAMD_report (stats) ; Cmember [0] = c ; p = Cp [1] ; Cp [1] = -1 ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs, stats, Cmember) ;NOT(ok); CCOLAMD_report (stats) ; Cp [1] = p ; i = Ci [0] ; Ci [0] = -1 ; ok = CCOLAMD_MAIN (ncol, nrow, alen, Ci, Cp, knobs, stats, Cmember) ;NOT(ok); CCOLAMD_report (stats) ; Ci [0] = i ; } s = CCOLAMD_recommended (-1, 0, 0) ; OK (s == 0) ; /* ---------------------------------------------------------------------- */ /* free workspace */ /* ---------------------------------------------------------------------- */ CHOLMOD(free) (nrow+1, sizeof (Int), Front_npivcol, cm) ; CHOLMOD(free) (nrow+1, sizeof (Int), Front_nrows, cm) ; CHOLMOD(free) (nrow+1, sizeof (Int), Front_ncols, cm) ; CHOLMOD(free) (nrow+1, sizeof (Int), Front_parent, cm) ; CHOLMOD(free) (nrow+1, sizeof (Int), Front_cols, cm) ; CHOLMOD(free) (nrow+1, sizeof (Int), P, cm) ; CHOLMOD(free) (nrow, sizeof (Int), Cmember, cm) ; CHOLMOD(free) (ncol, sizeof (Int), InFront, cm) ; CHOLMOD(free_sparse) (&S, cm) ; CHOLMOD(free_sparse) (&A2, cm) ; CHOLMOD(free_sparse) (&C, cm) ; cm->print = 1 ; } #else void cctest (cholmod_sparse *A) { if (A == NULL) { return ; } cm->print = 1 ; } #endif
368f2b35eff749c26d08deb1ee03558290e395ef
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/musl/src/time/timer_delete.c
b0bfac0968a74df8c74db8bf94146085300f0794
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-musl-exception" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C
false
false
315
c
timer_delete.c
#include <time.h> #include <limits.h> #include "pthread_impl.h" int timer_delete(timer_t t) { if ((intptr_t)t < 0) { pthread_t td = (void *)((uintptr_t)t << 1); a_store(&td->timer_id, td->timer_id | INT_MIN); __syscall(SYS_tkill, td->tid, SIGTIMER); return 0; } return __syscall(SYS_timer_delete, t); }
8236ed10a2840bd55fa8d3cac135d5aa95c35174
7664f318ed04bd0680f3d82321c18896e3ef6ad5
/src/overlays/actors/ovl_En_Owl/z_en_owl.h
4f92ef1b419fb01520419769ec889d1e853a2cde
[]
no_license
zeldaret/oot
9c80ce17f2d8fd61514b375f92ee4739b5ce9d4e
2875ab4fcf5c5f81d76353d1ee0024c9ea8d0b23
refs/heads/master
2023-08-29T05:29:31.356427
2023-08-28T22:48:52
2023-08-28T22:48:52
247,875,738
4,401
802
null
2023-09-14T13:34:38
2020-03-17T04:02:19
C
UTF-8
C
false
false
1,286
h
z_en_owl.h
#ifndef Z_EN_OWL_H #define Z_EN_OWL_H #include "ultra64.h" #include "global.h" struct EnOwl; typedef void (*EnOwlActionFunc)(struct EnOwl*, PlayState*); typedef void (*OwlFunc)(struct EnOwl*); typedef struct EnOwl { /* 0x0000 */ Actor actor; /* 0x014C */ ColliderCylinder collider; /* 0x0198 */ SkelAnime skelAnime; /* 0x01DC */ Vec3s jointTable[21]; /* 0x025A */ Vec3s morphTable[21]; /* 0x02D8 */ SkelAnime skelAnime2; /* 0x031C */ Vec3s jointTable2[16]; /* 0x037C */ Vec3s morphTable2[16]; /* 0x03DC */ SkelAnime* curSkelAnime; /* 0x03E0 */ Vec3f eye; /* 0x03EC */ s16 unk_3EC; /* 0x03EE */ s16 unk_3EE; /* 0x03F0 */ s16 unk_3F0; /* 0x03F2 */ s16 unk_3F2; /* 0x03F4 */ s16 eyeTexIndex; /* 0x03F6 */ s16 blinkTimer; /* 0x03F8 */ f32 unk_3F8; /* 0x03FC */ u16 actionFlags; /* 0x03FE */ u16 unk_3FE; /* 0x0400 */ s16 unk_400; /* 0x0402 */ s16 subCamId; /* 0x0404 */ u8 unk_404; /* 0x0405 */ u8 unk_405; /* 0x0406 */ u8 unk_406; /* 0x0407 */ u8 unk_407; /* 0x0408 */ u8 unk_408; /* 0x0409 */ u8 unk_409; /* 0x040A */ u8 unk_40A; /* 0x040B */ u8 unk_40B; /* 0x040C */ EnOwlActionFunc actionFunc; /* 0x0410 */ OwlFunc unk_410; } EnOwl; // size = 0x0414 #endif
f9baa3b90bf95e34af237843899c3338e1399dee
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/sysutils/hal/files/hald-netbsd/vfsstat.c
9a09c0ef531c4e8d46d58b74b249917bb277fda1
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
4,676
c
vfsstat.c
/* $NetBSD: vfsstat.c,v 1.1 2008/12/01 02:02:33 jmcneill Exp $ */ /*- * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <sys/types.h> #include <sys/statvfs.h> #include <sys/ioctl.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <string.h> #include <paths.h> #include <unistd.h> #include "../osspec.h" #include "../logger.h" #include "../hald.h" #include "../hald_dbus.h" #include "../hald_runner.h" #include "../device_info.h" #include "../util.h" #include "../ids.h" #include "hotplug.h" #include "devinfo.h" #include "vfsstat.h" #include "drvctl.h" static void vfsstat_cleanup_mountpoint_cb(HalDevice *d, guint32 exit_type, gint return_code, gchar **error, gpointer data1, gpointer data2) { char *mount_point = data1; HAL_INFO (("cleaned up mount point %s", mount_point)); g_free (mount_point); } void vfsstat_event(HalDevice *volume) { GSList *volumes, *v; HalDevice *d; struct statvfs *statvfs; int nmounts, i; if (volume == NULL) volumes = hal_device_store_match_multiple_key_value_string (hald_get_gdl (), "info.category", "volume"); else volumes = g_slist_append (NULL, volume); if (volumes == NULL) return; nmounts = getvfsstat (NULL, 0, ST_WAIT); if (nmounts <= 0) return; statvfs = calloc (nmounts, sizeof (*statvfs)); if (statvfs == NULL) return; nmounts = getvfsstat (statvfs, nmounts * sizeof (*statvfs), ST_WAIT); if (nmounts <= 0) goto done; for (i = 0; i < nmounts; i++) for (v = volumes; v; v = g_slist_next (v)) { const char *devpath; d = HAL_DEVICE (v->data); devpath = hal_device_property_get_string (d, "block.device"); if (devpath == NULL || strlen (devpath) == 0) continue; if (strcmp (devpath, statvfs[i].f_mntfromname) != 0) continue; device_property_atomic_update_begin (); hal_device_property_set_bool (d, "volume.is_mounted", TRUE); hal_device_property_set_bool (d, "volume.is_mounted_read_only", statvfs[i].f_flag & ST_RDONLY ? TRUE : FALSE); hal_device_property_set_string (d, "volume.mount_point", statvfs[i].f_mntonname); device_property_atomic_update_end (); volumes = g_slist_delete_link (volumes, v); } for (v = volumes; v; v = g_slist_next (v)) { const char *mount_path; d = HAL_DEVICE (v->data); mount_path = g_strdup (hal_device_property_get_string (d, "volume.mount_point")); if (mount_path == NULL || strlen (mount_path) == 0) { if (mount_path) g_free (mount_path); continue; } device_property_atomic_update_begin (); hal_device_property_set_bool (d, "volume.is_mounted", FALSE); hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE); hal_device_property_set_string (d, "volume.mount_point", ""); device_property_atomic_update_end (); if (hal_util_is_mounted_by_hald (mount_path)) { char *cleanup_stdin; char *extra_env[2]; extra_env[0] = g_strdup_printf ("HALD_CLEANUP=%s", mount_path); extra_env[1] = NULL; cleanup_stdin = "\n"; hald_runner_run_method (d, "hal-storage-cleanup-mountpoint", extra_env, cleanup_stdin, TRUE, 0, vfsstat_cleanup_mountpoint_cb, g_strdup (mount_path), NULL); g_free (extra_env[0]); } g_free (mount_path); } g_slist_free (volumes); done: free (statvfs); }
be6ac2ef0713ec2855b7ffb6c4d0079fa35a5765
ecea7c1f53661a57736d9b3f6deec97712ff22fc
/SecurityExploits/Android/Qualcomm/CVE-2022-22057/cpu_utils.h
85f53b345c649395703a8aecb9e9d65b6656b7f3
[ "MIT" ]
permissive
github/securitylab
088d785622a1a1e86fa171f9296d2a66542bc88f
80e2d6abadad8cb77e8c9f659e32eaee6b3a98ed
refs/heads/main
2023-09-03T04:21:06.795016
2023-07-06T15:31:30
2023-07-06T15:31:30
221,101,274
1,079
225
MIT
2023-08-16T16:41:27
2019-11-12T01:14:24
C
UTF-8
C
false
false
98
h
cpu_utils.h
#ifndef CPU_UTILS #define CPU_UTILS int migrate_to_cpu(int i); int check_cpu_affinity(); #endif
4474feb4cc028e6a539bfd29c7400e23bc3d2083
0cc343d927d5db6693006018986715c43acab961
/examples/preprocessor/directorytest/main.c
f4d6f8e12864716f96b37ebf213d8216e94a17a6
[ "MIT" ]
permissive
verifast/verifast
ec0101fc4a69bd33c5f66be4444169c4e060ead8
d152da790c7ebf72ce616533a6c83082629adbdb
refs/heads/master
2023-08-25T00:13:51.464802
2023-08-13T10:00:00
2023-08-13T10:00:00
14,519,163
325
64
NOASSERTION
2023-08-10T21:16:08
2013-11-19T08:57:02
OCaml
UTF-8
C
false
false
88
c
main.c
#include "header1.h" int main() //@ requires true; //@ ensures true; { return 0; }
fef8d1c7b5ceb0ac89fffcc62404c52a356f5901
03666e5f961946fc1a0ac67781ac1425562ef0d7
/src/databases/GMV/GMVPluginInfo.C
d35f50cc93334d3e4b9f700d1ec79d8ed3d8bd46
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
visit-dav/visit
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
601ae46e0bef2e18425b482a755d03490ade0493
refs/heads/develop
2023-09-06T08:19:38.397058
2023-09-05T21:29:32
2023-09-05T21:29:32
165,565,988
335
120
BSD-3-Clause
2023-09-14T00:53:37
2019-01-13T23:27:26
C
UTF-8
C
false
false
4,467
c
GMVPluginInfo.C
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt // Project developers. See the top-level LICENSE file for dates and other // details. No copyright assignment is required to contribute to VisIt. // **************************************************************************** // File: GMVPluginInfo.C // **************************************************************************** #include <GMVPluginInfo.h> #include <visit-config.h> VISIT_PLUGIN_VERSION(GMV,DBP_EXPORT) VISIT_DATABASE_PLUGIN_ENTRY(GMV,General) // **************************************************************************** // Method: GMVGeneralPluginInfo::GetName // // Purpose: // Return the name of the database plugin. // // Returns: A pointer to the name of the database plugin. // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** const char * GMVGeneralPluginInfo::GetName() const { return "GMV"; } // **************************************************************************** // Method: GMVGeneralPluginInfo::GetVersion // // Purpose: // Return the version of the database plugin. // // Returns: A pointer to the version of the database plugin. // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** const char * GMVGeneralPluginInfo::GetVersion() const { return "1.0"; } // **************************************************************************** // Method: GMVGeneralPluginInfo::GetID // // Purpose: // Return the id of the database plugin. // // Returns: A pointer to the id of the database plugin. // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** const char * GMVGeneralPluginInfo::GetID() const { return "GMV_1.0"; } // **************************************************************************** // Method: GMVGeneralPluginInfo::EnabledByDefault // // Purpose: // Return true if this plugin should be enabled by default; false otherwise. // // Returns: true/false // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** bool GMVGeneralPluginInfo::EnabledByDefault() const { return true; } // **************************************************************************** // Method: GMVGeneralPluginInfo::HasWriter // // Purpose: // Return true if this plugin has a database writer. // // Returns: true/false // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** bool GMVGeneralPluginInfo::HasWriter() const { return false; } // **************************************************************************** // Method: GMVGeneralPluginInfo::GetDefaultFilePatterns // // Purpose: // Returns the default patterns for a GMV database. // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** std::vector<std::string> GMVGeneralPluginInfo::GetDefaultFilePatterns() const { std::vector<std::string> defaultPatterns; defaultPatterns.push_back("*.gmv"); defaultPatterns.push_back("*.gmvG"); return defaultPatterns; } // **************************************************************************** // Method: GMVGeneralPluginInfo::AreDefaultFilePatternsStrict // // Purpose: // Returns if the file patterns for a GMV database are // intended to be interpreted strictly by default. // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** bool GMVGeneralPluginInfo::AreDefaultFilePatternsStrict() const { return false; } // **************************************************************************** // Method: GMVGeneralPluginInfo::OpensWholeDirectory // // Purpose: // Returns if the GMV plugin opens a whole directory name // instead of a single file. // // Programmer: generated by xml2info // Creation: omitted // // **************************************************************************** bool GMVGeneralPluginInfo::OpensWholeDirectory() const { return false; }
bc98fcea6b269134e6473ec46978edc612f66603
5de7df0be411b4bad61f927cae845bdb8223308f
/src/libs/png_utils/ascent_png_utils_exports.h
717afe094b94fae34699d449dc0502ae203fa3ff
[ "BSD-3-Clause", "Zlib" ]
permissive
Alpine-DAV/ascent
cb40429167a93c62f78fe650a0121258be279162
e52b7bb8c9fd131f2fd49edf58037cc5ef77a166
refs/heads/develop
2023-09-06T07:57:11.558238
2023-08-25T16:05:31
2023-08-25T16:05:31
81,366,855
151
61
NOASSERTION
2023-09-13T19:31:09
2017-02-08T19:21:22
C++
UTF-8
C
false
false
1,518
h
ascent_png_utils_exports.h
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// // Copyright (c) Lawrence Livermore National Security, LLC and other Ascent // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and // other details. No copyright assignment is required to contribute to Ascent. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //----------------------------------------------------------------------------- /// /// file: ascent_png_utils_exports.h /// //----------------------------------------------------------------------------- #ifndef ASCENT_PNG_UTILS_EXPORTS_H #define ASCENT_PNG_UTILS_EXPORTS_H //----------------------------------------------------------------------------- // -- define proper lib exports for various platforms -- //----------------------------------------------------------------------------- #if defined(_WIN32) #if defined(ASCENT_EXPORTS_FLAG) #define ASCENT_API __declspec(dllexport) #else #define ASCENT_API __declspec(dllimport) #endif #if defined(_MSC_VER) // Turn off warning about lack of DLL interface #pragma warning(disable:4251) // Turn off warning non-dll class is base for dll-interface class. #pragma warning(disable:4275) // Turn off warning about identifier truncation #pragma warning(disable:4786) #endif #else # if __GNUC__ >= 4 && defined(ASCENT_EXPORTS_FLAG) # define ASCENT_API __attribute__ ((visibility("default"))) # else # define ASCENT_API /* hidden by default */ # endif #endif #endif
ef69efd66dd1f13f34127e8e799fbdbe13a9c4b3
41c7328eadeab5ed7c0584b7db51996a05dd9f2d
/F0:F030,F042,F072/Socket_fans/flash.h
8e7b9b6f1f03727b30b9bd4eddc18812a6c7c279
[]
no_license
eddyem/stm32samples
1c00ccb8593ea270cae536c85f178a522f704ed5
dce73d358b1fca3e7fa397f5c6d0d5c1cb28aba0
refs/heads/master
2023-07-28T11:13:10.361942
2023-07-24T20:04:22
2023-07-24T20:04:22
32,647,425
152
42
null
null
null
null
UTF-8
C
false
false
1,648
h
flash.h
/* * This file is part of the SockFans project. * Copyright 2020 Edward V. Emelianov <edward.emelianoff@gmail.com>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #ifndef FLASH_H__ #define FLASH_H__ #include "hardware.h" #define FLASH_BLOCK_SIZE (1024) #define FLASH_SIZE_REG ((uint32_t)0x1FFFF7CC) #define FLASH_SIZE *((uint16_t*)FLASH_SIZE_REG) #define TMINNO (3) #define TMAXNO (4) /* * struct to save user configurations */ typedef struct __attribute__((packed, aligned(4))){ uint16_t userconf_sz; // "magick number" uint32_t Tturnoff; // wait for Tturnoff ms before turning power off uint32_t Thyst; // Thysteresis int16_t Tmin[TMINNO]; // minT int16_t Tmax[TMAXNO]; // maxT } user_conf; extern user_conf the_conf; // global user config (read from FLASH to RAM) // data from ld-file: start address of storage extern const uint32_t __varsstart; void flashstorage_init(); int store_userconf(); void dump_userconf(); #endif // FLASH_H__
8a73af5eed725e00d0c3c00430376d1dde0fdcc1
83b8b30ebb633eecd29ca0a7a20cc43a293c9333
/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c
0bf11403d2e25121defd5a0452119ef9c6b6755b
[ "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
14,511
c
PWMOut.c
/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George * Copyright (c) 2019 Artur Pacholec * * 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 <stdint.h> #include "py/runtime.h" #include "common-hal/pwmio/PWMOut.h" #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/microcontroller/Pin.h" #include "sdk/drivers/pwm/fsl_pwm.h" #include "supervisor/shared/translate/translate.h" #include "periph.h" static PWM_Type *const _flexpwms[] = PWM_BASE_PTRS; // 4 bits for each submodule in each FlexPWM. static uint16_t _pwm_never_reset[MP_ARRAY_SIZE(_flexpwms)]; // Bitmask of whether state machines are use for variable frequency. static uint8_t _pwm_variable_frequency[MP_ARRAY_SIZE(_flexpwms)]; // Configured frequency for each submodule. static uint32_t _pwm_sm_frequencies[MP_ARRAY_SIZE(_flexpwms)][FSL_FEATURE_PWM_SUBMODULE_COUNT]; // Channels use is tracked using the OUTEN register. // The SDK gives use clocks per submodule but they all share the same value! So, ignore the // submodule and only turn off the clock when no other submodules are in use. static const clock_ip_name_t _flexpwm_clocks[][FSL_FEATURE_PWM_SUBMODULE_COUNT] = PWM_CLOCKS; static void config_periph_pin(const mcu_pwm_obj_t *periph) { IOMUXC_SetPinMux( periph->pin->mux_reg, periph->mux_mode, periph->input_reg, periph->input_idx, periph->pin->cfg_reg, 0); IOMUXC_SetPinConfig(0, 0, 0, 0, periph->pin->cfg_reg, IOMUXC_SW_PAD_CTL_PAD_HYS(0) | IOMUXC_SW_PAD_CTL_PAD_PUS(1) | IOMUXC_SW_PAD_CTL_PAD_PUE(1) | IOMUXC_SW_PAD_CTL_PAD_PKE(1) | IOMUXC_SW_PAD_CTL_PAD_ODE(0) | IOMUXC_SW_PAD_CTL_PAD_SPEED(1) | IOMUXC_SW_PAD_CTL_PAD_DSE(6) | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); } static uint16_t _outen_mask(pwm_submodule_t submodule, pwm_channels_t channel) { uint16_t outen_mask = 0; uint8_t sm_mask = 1 << submodule; switch (channel) { case kPWM_PwmX: outen_mask |= PWM_OUTEN_PWMX_EN(sm_mask); break; case kPWM_PwmA: outen_mask |= PWM_OUTEN_PWMA_EN(sm_mask); break; case kPWM_PwmB: outen_mask |= PWM_OUTEN_PWMB_EN(sm_mask); break; } return outen_mask; } void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) { common_hal_never_reset_pin(self->pin); _pwm_never_reset[self->flexpwm_index] |= (1 << (self->pwm->submodule * 4 + self->pwm->channel)); } STATIC void _maybe_disable_clock(uint8_t instance) { if ((_flexpwms[instance]->MCTRL & PWM_MCTRL_RUN_MASK) == 0) { CLOCK_DisableClock(_flexpwm_clocks[instance][0]); } } void reset_all_flexpwm(void) { for (size_t i = 1; i < MP_ARRAY_SIZE(_pwm_never_reset); i++) { PWM_Type *flexpwm = _flexpwms[i]; for (size_t submodule = 0; submodule < FSL_FEATURE_PWM_SUBMODULE_COUNT; submodule++) { uint8_t sm_mask = 1 << submodule; for (size_t channel = 0; channel < 3; channel++) { uint16_t channel_mask = 0x1 << (submodule * 4 + channel); if ((_pwm_never_reset[i] & channel_mask) != 0) { continue; } // Turn off the channel. flexpwm->OUTEN &= ~_outen_mask(submodule, channel); } uint16_t submodule_mask = 0xf << (submodule * 4); if ((_pwm_never_reset[i] & submodule_mask) != 0) { // Leave the submodule on since a channel is marked for never_reset. continue; } flexpwm->MCTRL &= ~(sm_mask << PWM_MCTRL_RUN_SHIFT); _pwm_variable_frequency[i] &= ~sm_mask; _pwm_sm_frequencies[i][submodule] = 0; } _maybe_disable_clock(i); } } #define PWM_SRC_CLK_FREQ CLOCK_GetFreq(kCLOCK_IpgClk) static int calculate_pulse_count(uint32_t frequency, uint8_t *prescaler) { if (frequency > PWM_SRC_CLK_FREQ / 2) { return 0; } for (int shift = 0; shift < 8; shift++) { int pulse_count = PWM_SRC_CLK_FREQ / (1 << shift) / frequency; if (pulse_count >= 65535) { continue; } *prescaler = shift; return pulse_count; } return 0; } pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self, const mcu_pin_obj_t *pin, uint16_t duty, uint32_t frequency, bool variable_frequency) { self->pin = pin; self->variable_frequency = variable_frequency; for (uint32_t i = 0; i < MP_ARRAY_SIZE(mcu_pwm_list); ++i) { if (mcu_pwm_list[i].pin != pin) { continue; } self->pwm = &mcu_pwm_list[i]; break; } if (self->pwm == NULL) { return PWMOUT_INVALID_PIN; } PWM_Type *flexpwm = self->pwm->pwm; pwm_submodule_t submodule = self->pwm->submodule; uint16_t sm_mask = 1 << submodule; pwm_channels_t channel = self->pwm->channel; uint8_t flexpwm_index = 1; for (; flexpwm_index < MP_ARRAY_SIZE(_flexpwms); flexpwm_index++) { if (_flexpwms[flexpwm_index] == flexpwm) { break; } } self->flexpwm_index = flexpwm_index; uint16_t outen_mask = _outen_mask(submodule, channel); self->pulse_count = calculate_pulse_count(frequency, &self->prescaler); if (self->pulse_count == 0) { return PWMOUT_INVALID_FREQUENCY; } // The submodule is already running if (((flexpwm->MCTRL >> PWM_MCTRL_RUN_SHIFT) & sm_mask) != 0) { // Another output has claimed this submodule for variable frequency already. if ((_pwm_variable_frequency[flexpwm_index] & sm_mask) != 0) { return PWMOUT_ALL_TIMERS_ON_PIN_IN_USE; } // We want variable frequency but another class has already claim a fixed frequency. if (variable_frequency) { return PWMOUT_VARIABLE_FREQUENCY_NOT_AVAILABLE; } // Another pin is already using this output. if ((flexpwm->OUTEN & outen_mask) != 0) { return PWMOUT_ALL_TIMERS_ON_PIN_IN_USE; } if (frequency != _pwm_sm_frequencies[flexpwm_index][submodule]) { return PWMOUT_INVALID_FREQUENCY_ON_PIN; } // Submodule is already running at our target frequency and the output // is free. } else { pwm_config_t pwmConfig; /* * pwmConfig.enableDebugMode = false; * pwmConfig.enableWait = false; * pwmConfig.reloadSelect = kPWM_LocalReload; * pwmConfig.faultFilterCount = 0; * pwmConfig.faultFilterPeriod = 0; * pwmConfig.clockSource = kPWM_BusClock; * pwmConfig.prescale = kPWM_Prescale_Divide_1; * pwmConfig.initializationControl = kPWM_Initialize_LocalSync; * pwmConfig.forceTrigger = kPWM_Force_Local; * pwmConfig.reloadFrequency = kPWM_LoadEveryOportunity; * pwmConfig.reloadLogic = kPWM_ReloadImmediate; * pwmConfig.pairOperation = kPWM_Independent; */ PWM_GetDefaultConfig(&pwmConfig); pwmConfig.reloadLogic = kPWM_ReloadPwmFullCycle; pwmConfig.enableWait = true; pwmConfig.enableDebugMode = true; pwmConfig.prescale = self->prescaler; if (PWM_Init(flexpwm, submodule, &pwmConfig) != kStatus_Success) { return PWMOUT_INITIALIZATION_ERROR; } // Disable all fault inputs flexpwm->SM[submodule].DISMAP[0] = 0; PWM_SetPwmLdok(flexpwm, sm_mask, false); flexpwm->SM[submodule].CTRL = PWM_CTRL_FULL_MASK | PWM_CTRL_PRSC(self->prescaler); flexpwm->SM[submodule].CTRL2 = PWM_CTRL2_INDEP_MASK | PWM_CTRL2_WAITEN_MASK | PWM_CTRL2_DBGEN_MASK; // Set the reload value to zero so we're in unsigned mode. flexpwm->SM[submodule].INIT = 0; // Set the top/reload value. flexpwm->SM[submodule].VAL1 = self->pulse_count; // Clear the other channels. flexpwm->SM[submodule].VAL0 = 0; flexpwm->SM[submodule].VAL2 = 0; flexpwm->SM[submodule].VAL3 = 0; flexpwm->SM[submodule].VAL4 = 0; flexpwm->SM[submodule].VAL5 = 0; PWM_SetPwmLdok(flexpwm, sm_mask, true); PWM_StartTimer(flexpwm, sm_mask); _pwm_sm_frequencies[flexpwm_index][submodule] = frequency; if (variable_frequency) { _pwm_variable_frequency[flexpwm_index] = sm_mask; } } common_hal_pwmio_pwmout_set_duty_cycle(self, duty); flexpwm->OUTEN |= outen_mask; // Configure the IOMUX once we know everything else is working. config_periph_pin(self->pwm); return PWMOUT_OK; } bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t *self) { return self->pin == NULL; } void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self) { if (common_hal_pwmio_pwmout_deinited(self)) { return; } _pwm_never_reset[self->flexpwm_index] &= ~(1 << (self->pwm->submodule * 4 + self->pwm->channel)); PWM_Type *flexpwm = self->pwm->pwm; pwm_submodule_t submodule = self->pwm->submodule; uint16_t sm_mask = 1 << submodule; // Reset the pin before we turn it off. common_hal_reset_pin(self->pin); self->pin = NULL; // Always disable the output. flexpwm->OUTEN &= ~_outen_mask(submodule, self->pwm->channel); uint16_t all_sm_channels = _outen_mask(submodule, kPWM_PwmX) | _outen_mask(submodule, kPWM_PwmA) | _outen_mask(submodule, kPWM_PwmB); // Turn off the submodule if it doesn't have any outputs active. if ((flexpwm->OUTEN & all_sm_channels) == 0) { // Deinit ourselves because the SDK turns off the clock to the whole FlexPWM on deinit. flexpwm->MCTRL &= ~(sm_mask << PWM_MCTRL_RUN_SHIFT); _pwm_variable_frequency[self->flexpwm_index] &= ~sm_mask; _pwm_sm_frequencies[self->flexpwm_index][submodule] = 0; } _maybe_disable_clock(self->flexpwm_index); } void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t duty) { // we do not use PWM_UpdatePwmDutycycle because ... // * it works in integer percents // * it can't set the "X" duty cycle // As mentioned in the setting up of the frequency code // A - Uses VAL2 to turn on (0) and VAL3=duty to turn off // B - Uses VAL4 to turn on (0) and VAL5 to turn off // X - As mentioned above VAL1 turns off, but it's set to the timing for frequency. so // VAL0 turns on, so we set it to VAL1 - duty self->duty_cycle = duty; PWM_Type *base = self->pwm->pwm; uint8_t sm_mask = 1 << self->pwm->submodule; uint16_t duty_scaled; if (duty == 65535) { // X channels can't do a full 100% duty cycle. if (self->pwm->channel == kPWM_PwmX) { mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_duty_cycle); } duty_scaled = self->pulse_count + 1; } else { duty_scaled = ((uint32_t)duty * self->pulse_count) / 65535; } PWM_SetPwmLdok(self->pwm->pwm, sm_mask, false); switch (self->pwm->channel) { case kPWM_PwmX: // PWM X Signals always having a falling edge at the reload value. (Otherwise we'd // change the PWM frequency.) So, we adjust the rising edge to get the correct duty // cycle. base->SM[self->pwm->submodule].VAL0 = self->pulse_count - duty_scaled; break; case kPWM_PwmA: // The other two channels always have their rising edge at 0 and vary their falling // edge. base->SM[self->pwm->submodule].VAL3 = duty_scaled; break; case kPWM_PwmB: base->SM[self->pwm->submodule].VAL5 = duty_scaled; } PWM_SetPwmLdok(self->pwm->pwm, sm_mask, true); } uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t *self) { return self->duty_cycle; } void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t frequency) { int pulse_count = calculate_pulse_count(frequency, &self->prescaler); if (pulse_count == 0) { mp_arg_error_invalid(MP_QSTR_frequency); } self->pulse_count = pulse_count; // a small glitch can occur when adjusting the prescaler, from the setting // of CTRL just below to the setting of the Ldok register in // set_duty_cycle. // Clear LDOK so that we can update the values. PWM_SetPwmLdok(self->pwm->pwm, 1 << self->pwm->submodule, false); uint32_t reg = self->pwm->pwm->SM[self->pwm->submodule].CTRL; reg &= ~(PWM_CTRL_PRSC_MASK); reg |= PWM_CTRL_PRSC(self->prescaler); self->pwm->pwm->SM[self->pwm->submodule].CTRL = reg; self->pwm->pwm->SM[self->pwm->submodule].VAL1 = self->pulse_count; // we need to recalculate the duty cycle. As a side effect of this common_hal_pwmio_pwmout_set_duty_cycle(self, self->duty_cycle); } uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t *self) { return PWM_SRC_CLK_FREQ / self->pulse_count / (1 << self->prescaler); } bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t *self) { return self->variable_frequency; } const mcu_pin_obj_t *common_hal_pwmio_pwmout_get_pin(pwmio_pwmout_obj_t *self) { return self->pin; }
00a66b2f0d7ead0701bcc4bc25c0d5f11530886c
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/board/esd/pci405/cmd_pci405.c
55c20d02d3126f6b3cd4131133fc185c256d8f4a
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "GPL-2.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
1,820
c
cmd_pci405.c
/* * (C) Copyright 2002-2004 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <command.h> #include <malloc.h> #include <net.h> #include <asm/io.h> #include <pci.h> #include <asm/4xx_pci.h> #include <asm/processor.h> #include "pci405.h" #if defined(CONFIG_CMD_BSP) /* * Command loadpci: wait for signal from host and boot image. */ int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned int *ptr = 0; int count = 0; int count2 = 0; int i; char addr[16]; char str[] = "\\|/-"; char *local_args[2]; /* * Mark sync address */ ptr = 0; *ptr = 0xffffffff; puts("\nWaiting for image from pci host -"); /* * Wait for host to write the start address */ while (*ptr == 0xffffffff) { count++; if (!(count % 100)) { count2++; putc(0x08); /* backspace */ putc(str[count2 % 4]); } /* Abort if ctrl-c was pressed */ if (ctrlc()) { puts("\nAbort\n"); return 0; } udelay(1000); } if (*ptr == PCI_RECONFIG_MAGIC) { /* * Save own pci configuration in PRAM */ memset((char *)PCI_REGS_ADDR, 0, PCI_REGS_LEN); ptr = (unsigned int *)PCI_REGS_ADDR + 1; for (i=0; i<0x40; i+=4) { pci_read_config_dword(PCIDEVID_405GP, i, ptr++); } ptr = (unsigned int *)PCI_REGS_ADDR; *ptr = crc32(0, (uchar *)PCI_REGS_ADDR+4, PCI_REGS_LEN-4); printf("\nStoring PCI Configuration Regs...\n"); } else { sprintf(addr, "%08x", *ptr); /* * Boot image via bootm */ printf("\nBooting Image at addr 0x%s ...\n", addr); setenv("loadaddr", addr); local_args[0] = argv[0]; local_args[1] = NULL; do_bootm (cmdtp, 0, 1, local_args); } return 0; } U_BOOT_CMD( loadpci, 1, 1, do_loadpci, "Wait for pci-image and boot it", "" ); #endif
5c8e49ade0685fc5095c4519ff37e7b32f416891
fb57dc0efeab3e51e6c59c8d58c654ac253c3ba9
/Sharing/Src/Source/Common/SideCarAPI.h
cb99d7101116e6f75a0b4d18a179945184f57ed8
[ "MIT" ]
permissive
microsoft/MixedRealityToolkit
aa7eddbeb36cbb5894beea32e2ff91cef29afcdf
8454abcce504effd83c9d6e20725f6037c11e2b4
refs/heads/main
2023-07-08T11:15:38.879033
2023-06-28T19:21:12
2023-06-28T19:21:12
46,008,487
251
61
MIT
2023-06-28T19:21:13
2015-11-11T20:37:59
C++
UTF-8
C
false
false
1,239
h
SideCarAPI.h
////////////////////////////////////////////////////////////////////////// // SideCarAPI.h // // Single include file that includes all the other files that make up the // XTools SideCar API // // Copyright (C) 2014 Microsoft Corp. All Rights Reserved ////////////////////////////////////////////////////////////////////////// #pragma once #define XTOOLS_SIDECAR #include <Public/Environment.h> #include <Public/BasicTypes.h> #include <Public/XToolsTypes.h> #include <Public/Utils/RefCounted.h> #include <Public/Utils/AtomicRefCounted.h> #include <Public/Utils/GetPointer.h> #include <Public/Utils/RefPtr.h> #include <Public/Utils/Receipt.h> #include <Public/Utils/SwigHelperMacros.h> #include <Public/Utils/LogManager.h> #include <Public/Reflection.h> #include <Public/XToolsMessageTypes.h> #include <Public/XString.h> #include <Public/Listener.h> #include <Public/NetworkOutMessage.h> #include <Public/NetworkInMessage.h> #include <Public/NetworkConnectionListener.h> #include <Public/User.h> #include <Public/NetworkConnection.h> #include <Public/ProfileManager.h> #include <Public/SideCarContext.h> #include <Public/SideCar.h> #include <Public/SideCarFunctions.h> #include <Public/SideCarMacros.h> #include <Public/ScopedProfile.h>
851425ce62f552c6192cd66bff64cb9a16433bf3
c9bc99866cfab223c777cfb741083be3e9439d81
/module/cmn650/src/cmn650_ccix.c
8f7ffbfe2843b9b324d3da0ccf2d8e95cb36b37f
[ "BSD-3-Clause" ]
permissive
ARM-software/SCP-firmware
4738ca86ce42d82588ddafc2226a1f353ff2c797
f6bcca436768359ffeadd84d65e8ea0c3efc7ef1
refs/heads/master
2023-09-01T16:13:36.962036
2023-08-17T13:00:20
2023-08-31T07:43:37
134,399,880
211
165
NOASSERTION
2023-09-13T14:27:10
2018-05-22T10:35:56
C
UTF-8
C
false
false
31,799
c
cmn650_ccix.c
/* * Arm SCP/MCP Software * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <cmn650.h> #include <cmn650_ccix.h> #include <internal/cmn650_ctx.h> #include <mod_timer.h> #include <fwk_assert.h> #include <fwk_log.h> #include <fwk_math.h> #include <inttypes.h> #define MOD_NAME "[CMN650_CCIX] " struct mod_cmn650_ccix_ctx { /* RAID value common to all function */ uint8_t raid_value; /* Port Aggregation context flag */ bool is_prog_for_port_agg; }; static struct mod_cmn650_ccix_ctx cmn650_ccix_ctx; static uint8_t port_aggregate_group_id; /* Pointer to the current CCIX configuration data */ static const struct mod_cmn650_ccix_config *config; static unsigned int get_ldid(bool program_for_port_aggregation) { return (program_for_port_aggregation) ? config->port_aggregate_ldid : config->ldid; } static bool cxg_link_wait_condition(void *data) { uint64_t val1; uint64_t val2; uint8_t linkid; struct cmn650_cxg_ra_reg *cxg_ra_reg; struct cmn650_cxg_ha_reg *cxg_ha_reg; fwk_assert(data != NULL); struct cxg_wait_condition_data *wait_data = (struct cxg_wait_condition_data *)data; struct cmn650_device_ctx *ctx = wait_data->ctx; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); linkid = wait_data->linkid; cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; switch (wait_data->cond) { case CXG_LINK_CTRL_EN_BIT_SET: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL; val2 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL; return ( ((val1 & CXG_LINK_CTRL_EN_MASK) && (val2 & CXG_LINK_CTRL_EN_MASK)) != 0); case CXG_LINK_CTRL_UP_BIT_CLR: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL; val2 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL; return ( (((val1 & CXG_LINK_CTRL_UP_MASK) == 0) && ((val2 & CXG_LINK_CTRL_UP_MASK) == 0)) != 0); case CXG_LINK_STATUS_DWN_BIT_SET: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; val2 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; return ( ((val1 & CXG_LINK_STATUS_DOWN_MASK) && (val2 & CXG_LINK_STATUS_DOWN_MASK)) != 0); case CXG_LINK_STATUS_DWN_BIT_CLR: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; val2 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; return ( (((val1 & CXG_LINK_STATUS_DOWN_MASK) == 0) && ((val2 & CXG_LINK_STATUS_DOWN_MASK) == 0)) != 0); case CXG_LINK_STATUS_ACK_BIT_SET: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; val2 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; return ( ((val1 & CXG_LINK_STATUS_ACK_MASK) && (val2 & CXG_LINK_STATUS_ACK_MASK)) != 0); case CXG_LINK_STATUS_ACK_BIT_CLR: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; val2 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; return ( (((val1 & CXG_LINK_STATUS_ACK_MASK) == 0) && ((val2 & CXG_LINK_STATUS_ACK_MASK) == 0)) != 0); case CXG_LINK_STATUS_HA_DVMDOMAIN_ACK_BIT_SET: val1 = cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; return (((val1 & CXG_LINK_STATUS_DVMDOMAIN_ACK_MASK)) != 0); case CXG_LINK_STATUS_RA_DVMDOMAIN_ACK_BIT_SET: val1 = cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_STATUS; return (((val1 & CXG_LINK_STATUS_DVMDOMAIN_ACK_MASK)) != 0); default: fwk_unexpected(); return false; } } static void program_cxg_ra_rnf_ldid_to_raid_reg( struct cmn650_device_ctx *ctx, uint8_t ldid_value, uint8_t raid) { uint32_t reg_offset = 0; uint32_t ldid_value_offset = 0; struct cmn650_cxg_ra_reg *cxg_ra_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; /* Each 64-bit RA RNF LDID-to-RAID register holds 8 LDIDs */ reg_offset = ldid_value / 8; ldid_value_offset = ldid_value % 8; /* Adding raid_value into LDID-to-RAID register */ cxg_ra_reg->CXG_RA_RNF_LDID_TO_RAID_REG[reg_offset] |= ((uint64_t)raid << (ldid_value_offset * NUM_BITS_RESERVED_FOR_RAID)); /* Set corresponding valid bit */ cxg_ra_reg->CXG_RA_RNF_LDID_TO_RAID_VAL |= ((uint64_t)0x1 << ldid_value); cmn650_ccix_ctx.raid_value++; } static void program_cxg_ra_rni_ldid_to_raid_reg( struct cmn650_device_ctx *ctx, uint8_t ldid_value, uint8_t raid) { uint32_t reg_offset = 0; uint32_t ldid_value_offset = 0; struct cmn650_cxg_ra_reg *cxg_ra_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; /* Each 64-bit RA RNI LDID-to-RAID register holds 8 LDIDs */ reg_offset = ldid_value / 8; ldid_value_offset = ldid_value % 8; /* Adding raid_value into LDID-to-RAID register */ cxg_ra_reg->CXG_RA_RNI_LDID_TO_RAID_REG[reg_offset] |= ((uint64_t)raid << (ldid_value_offset * NUM_BITS_RESERVED_FOR_RAID)); /* Set corresponding valid bit */ cxg_ra_reg->CXG_RA_RNI_LDID_TO_RAID_VAL |= ((uint64_t)0x1 << ldid_value); cmn650_ccix_ctx.raid_value++; } static void program_cxg_ra_rnd_ldid_to_raid_reg( struct cmn650_device_ctx *ctx, uint8_t ldid_value, uint8_t raid) { uint32_t reg_offset = 0; uint32_t ldid_value_offset = 0; struct cmn650_cxg_ra_reg *cxg_ra_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; /* Each 64-bit RA RND LDID-to-RAID register holds 8 LDIDs */ reg_offset = ldid_value / 8; ldid_value_offset = ldid_value % 8; /* Adding raid_value into LDID-to-RAID register */ cxg_ra_reg->CXG_RA_RND_LDID_TO_RAID_REG[reg_offset] |= ((uint64_t)raid << (ldid_value_offset * NUM_BITS_RESERVED_FOR_RAID)); /* Set corresponding valid bit */ cxg_ra_reg->CXG_RA_RND_LDID_TO_RAID_VAL |= ((uint64_t)0x1 << ldid_value); cmn650_ccix_ctx.raid_value++; } static void program_agentid_to_linkid_reg( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *config) { uint32_t agentid; uint32_t reg_index = 0; uint8_t linkid = 0; uint32_t agentid_bit_offset = 0; struct cmn650_cxg_ra_reg *cxg_ra_reg; struct cmn650_cxg_ha_reg *cxg_ha_reg; struct cmn650_cxla_reg *cxla_reg; unsigned int remote_agentid_start; unsigned int remote_agentid_end; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; cxla_reg = ctx->cxla_reg_table[cxg_ldid].cxla_reg; for (linkid = 0; linkid < CMN650_MAX_CCIX_PROTOCOL_LINKS; linkid++) { remote_agentid_start = config->remote_agentid_to_linkid_map[linkid].remote_agentid_start; remote_agentid_end = config->remote_agentid_to_linkid_map[linkid].remote_agentid_end; /* * Skip configuring link if both start and end are 0, indicating * there's no link */ if ((remote_agentid_start == 0) && (remote_agentid_end == 0)) continue; FWK_LOG_INFO( MOD_NAME " Remote [AgentID %d - AgentID %d] Link %d", remote_agentid_start, remote_agentid_end, linkid); for (agentid = remote_agentid_start; agentid <= remote_agentid_end; agentid++) { /* Each register is 64 bits and holds 8 AgentID/LinkID mappings */ reg_index = agentid / 8; agentid_bit_offset = agentid % 8; /* Writing AgentID-to-LinkID mappings */ cxg_ra_reg->CXG_RA_AGENTID_TO_LINKID_REG[reg_index] |= ((uint64_t)linkid << (agentid_bit_offset * NUM_BITS_RESERVED_FOR_LINKID)); cxg_ha_reg->CXG_HA_AGENTID_TO_LINKID_REG[reg_index] |= ((uint64_t)linkid << (agentid_bit_offset * NUM_BITS_RESERVED_FOR_LINKID)); cxla_reg->CXLA_AGENTID_TO_LINKID_REG[reg_index] |= ((uint64_t)linkid << (agentid_bit_offset * NUM_BITS_RESERVED_FOR_LINKID)); /* Setting corresponding valid bits */ cxg_ra_reg->CXG_RA_AGENTID_TO_LINKID_VAL |= ((uint64_t)0x1 << agentid); cxg_ha_reg->CXG_HA_AGENTID_TO_LINKID_VAL |= ((uint64_t)0x1 << agentid); cxla_reg->CXLA_AGENTID_TO_LINKID_VAL |= ((uint64_t)0x1 << agentid); } } } static void program_cxg_ha_id(struct cmn650_device_ctx *ctx) { struct cmn650_cxg_ha_reg *cxg_ha_reg; unsigned int cxg_haid; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; cxg_haid = cmn650_ccix_ctx.is_prog_for_port_agg ? config->port_aggregate_haid : config->haid; cxg_ha_reg->CXG_HA_ID = cxg_haid; FWK_LOG_INFO( MOD_NAME "HAID for CCIX %d with nodeid %d: HAID %d", cxg_ldid, get_node_id(cxg_ha_reg), cxg_haid); } static void program_cxg_ha_raid_to_ldid_lut( struct cmn650_device_ctx *ctx, uint8_t raid_id, uint8_t ldid_value) { uint32_t reg_index = 0; uint32_t raid_bit_offset = 0; struct cmn650_cxg_ha_reg *cxg_ha_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; /* Each 64-bit RAID-to-LDID register holds 8 mappings, 8 bits each. */ reg_index = raid_id / 8; raid_bit_offset = raid_id % 8; /* Write RAID-to-LDID mapping (with RNF bit set) */ cxg_ha_reg->CXG_HA_RNF_RAID_TO_LDID_REG[reg_index] |= ((uint64_t)(ldid_value | CXG_HA_RAID_TO_LDID_RNF_MASK) << (raid_bit_offset * NUM_BITS_RESERVED_FOR_LDID)); /* Set corresponding valid bit */ cxg_ha_reg->CXG_HA_RNF_RAID_TO_LDID_VAL |= ((uint64_t)0x1 << raid_id); } static void program_hnf_ldid_to_chi_node_id_reg( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *config) { uint32_t agentid; uint32_t reg_index = 0; uint32_t reg_bit_offset = 0; uint32_t i = 0; struct cmn650_hnf_reg *hnf_reg = NULL; uint32_t nodeid_ra, cpa_nodeid_ra; uint8_t linkid = 0; unsigned int remote_agentid_start; unsigned int remote_agentid_end; unsigned int bit_pos; unsigned int group; /* Assign the NodeID of CXHA as the RA's NodeID */ nodeid_ra = ctx->cxg_ha_reg_table[config->ldid].node_id; cpa_nodeid_ra = ctx->cxg_ha_reg_table[config->port_aggregate_ldid].node_id; if (cmn650_ccix_ctx.is_prog_for_port_agg) { /* * if programming for port aggregation support, reset the remote rnf * ldid value to the previous iteration in order to program . */ ctx->remote_rnf_ldid_value -= ctx->rnf_count; } for (linkid = 0; linkid < CMN650_MAX_CCIX_PROTOCOL_LINKS; linkid++) { remote_agentid_start = config->remote_agentid_to_linkid_map[linkid].remote_agentid_start; remote_agentid_end = config->remote_agentid_to_linkid_map[linkid].remote_agentid_end; /* * Skip configuring link if both start and end are 0, indicating * there's no link */ if ((remote_agentid_start == 0) && (remote_agentid_end == 0)) continue; FWK_LOG_INFO( MOD_NAME " Remote [AgentID %d - AgentID %d] Node Id: %" PRIu32, remote_agentid_start, remote_agentid_end, nodeid_ra); for (agentid = remote_agentid_start; agentid <= remote_agentid_end; agentid++) { /* Each 64-bit register holds 2 sets of config data, 32 bits each */ reg_index = ctx->remote_rnf_ldid_value / 2; reg_bit_offset = ctx->remote_rnf_ldid_value % 2; for (i = 0; i < ctx->hnf_count; i++) { hnf_reg = (struct cmn650_hnf_reg *)ctx->hnf_node[i]; /* Write CXHA NodeID, local/remote and valid bit */ hnf_reg->RN_PHYS_ID[reg_index] |= ((uint64_t)( nodeid_ra | (REMOTE_CCIX_NODE << HNF_RN_PHYS_RN_LOCAL_REMOTE_SHIFT_VAL) | (port_aggregate_group_id << HNF_RN_PHYS_CPA_GRP_RA_SHIFT_VAL) | ((uint64_t)(config->port_aggregate) << HNF_RN_PHYS_CPA_EN_RA_SHIFT_VAL) | (UINT64_C(0x1) << HNF_RN_PHYS_RN_ID_VALID_SHIFT_VAL)) << (reg_bit_offset * NUM_BITS_RESERVED_FOR_PHYS_ID)); if (config->port_aggregate) { group = (port_aggregate_group_id * NUM_PORTS_PER_CPA_GROUP) / CMN_PORT_AGGR_GRP_PAG_TGTID_PER_GROUP; bit_pos = ((port_aggregate_group_id * NUM_PORTS_PER_CPA_GROUP) * CMN_PORT_AGGR_GRP_PAG_TGTID_WIDTH); hnf_reg->CML_PORT_AGGR_GRP[group] |= ((uint64_t)nodeid_ra) << bit_pos; group = ((port_aggregate_group_id * NUM_PORTS_PER_CPA_GROUP) + 1) / CMN_PORT_AGGR_GRP_PAG_TGTID_PER_GROUP; bit_pos = ((((port_aggregate_group_id * NUM_PORTS_PER_CPA_GROUP) + 1) * CMN_PORT_AGGR_GRP_PAG_TGTID_WIDTH) % CMN_PORT_AGGR_GRP_PAG_TGTID_WIDTH_PER_GROUP); hnf_reg->CML_PORT_AGGR_GRP[group] |= (uint64_t)cpa_nodeid_ra << bit_pos; } } ctx->remote_rnf_ldid_value++; } } if (cmn650_ccix_ctx.is_prog_for_port_agg) { for (i = 0; i < ctx->hnf_count; i++) { hnf_reg = (struct cmn650_hnf_reg *)ctx->hnf_node[i]; /* Considering only 2 port support */ hnf_reg->CML_PORT_AGGR_CTRL |= UINT64_C(0x1) << (port_aggregate_group_id * CML_PORT_AGGR_CTRL_NUM_CXG_PAG_WIDTH); } /* Finally increment the group id for the next group utilization */ port_aggregate_group_id++; } } static int enable_smp_mode( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *config) { struct cmn650_cxg_ra_reg *cxg_ra_reg; struct cmn650_cxg_ha_reg *cxg_ha_reg; struct cmn650_cxla_reg *cxla_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; cxla_reg = ctx->cxla_reg_table[cxg_ldid].cxla_reg; cxg_ra_reg->CXG_RA_AUX_CTRL |= (1 << CXG_RA_AUX_CTRL_SMP_MODE_EN_SHIFT_VAL); cxg_ha_reg->CXG_HA_AUX_CTRL |= (1 << CXG_HA_AUX_CTRL_SMP_MODE_EN_SHIFT_VAL); cxla_reg->CXLA_AUX_CTRL |= (UINT64_C(0x1) << CXLA_AUX_CTRL_SMP_MODE_EN_SHIFT_VAL); FWK_LOG_INFO(MOD_NAME "SMP Mode Enabled"); return FWK_SUCCESS; } static void program_cxg_ra_sam_addr_region( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *config) { unsigned int i, remote_haid; uint64_t blocks; uint64_t size; struct cmn650_cxg_ra_reg *cxg_ra_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; FWK_LOG_INFO( MOD_NAME "Configuring RA SAM for CXRA NodeID %d", get_node_id(cxg_ra_reg)); for (i = 0; i < CMN650_MAX_RA_SAM_ADDR_REGION; i++) { /* If the size is zero, skip that entry */ if (config->ra_mmap_table[i].size == 0) continue; /* Size must be a multiple of SAM_GRANULARITY */ fwk_assert((config->ra_mmap_table[i].size % (64 * FWK_KIB)) == 0); /* Size also must be a power of two */ fwk_assert( (config->ra_mmap_table[i].size & (config->ra_mmap_table[i].size - 1)) == 0); /* Region base should be naturally aligned to the region size */ fwk_assert( config->ra_mmap_table[i].base % config->ra_mmap_table[i].size == 0); if (cmn650_ccix_ctx.is_prog_for_port_agg) remote_haid = config->port_aggregate_remote_haid[i]; else remote_haid = config->ra_mmap_table[i].remote_haid; FWK_LOG_INFO( MOD_NAME " [0x%llx - 0x%llx] HAID %d", config->ra_mmap_table[i].base, config->ra_mmap_table[i].base + config->ra_mmap_table[i].size - 1, remote_haid); blocks = config->ra_mmap_table[i].size / (64 * FWK_KIB); size = fwk_math_log2(blocks); cxg_ra_reg->CXG_RA_SAM_ADDR_REGION_REG[i] = size | (config->ra_mmap_table[i].base) | ((uint64_t)remote_haid << SAM_ADDR_TARGET_HAID_SHIFT) | (SAM_ADDR_REG_VALID_MASK); i++; } } static int enable_and_start_ccix_link_up_sequence( struct cmn650_device_ctx *ctx, uint8_t linkid) { int status; struct cxg_wait_condition_data wait_data; struct cmn650_cxg_ra_reg *cxg_ra_reg; struct cmn650_cxg_ha_reg *cxg_ha_reg; unsigned int cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; if (linkid > 2) return FWK_E_PARAM; wait_data.ctx = ctx; wait_data.linkid = linkid; FWK_LOG_INFO(MOD_NAME "Enabling CCIX link %d...", linkid); /* Set link enable bit to enable the CCIX link */ cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL = CXG_LINK_CTRL_EN_MASK; cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL = CXG_LINK_CTRL_EN_MASK; /* Wait until link enable bits are set */ wait_data.cond = CXG_LINK_CTRL_EN_BIT_SET; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_CTRL_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR(MOD_NAME "Enabling CCIX link %d... Failed", linkid); return status; } FWK_LOG_INFO(MOD_NAME "Enabling CCIX link %d... Done", linkid); FWK_LOG_INFO(MOD_NAME "Verifying link down status..."); /* Wait till link up bits are cleared in control register */ wait_data.cond = CXG_LINK_CTRL_UP_BIT_CLR; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_CTRL_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR(MOD_NAME "Verifying link down status... Failed"); return status; } /* Wait till link down bits are set in status register */ wait_data.cond = CXG_LINK_STATUS_DWN_BIT_SET; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_CTRL_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR(MOD_NAME "Verifying link down status... Failed"); return status; } /* Wait till link ACK bits are cleared in status register */ wait_data.cond = CXG_LINK_STATUS_ACK_BIT_CLR; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_CTRL_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR(MOD_NAME "Verifying link down status... Failed"); return status; } FWK_LOG_INFO(MOD_NAME "Verifying link down status... Done"); FWK_LOG_INFO(MOD_NAME "Bringing up link..."); /* Bring up link using link request bit */ cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL |= CXG_LINK_CTRL_REQ_MASK; cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL |= CXG_LINK_CTRL_REQ_MASK; /* Wait till link ACK bits are set in status register */ wait_data.cond = CXG_LINK_STATUS_ACK_BIT_SET; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_CTRL_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR(MOD_NAME "Bringing up link... Failed"); return status; } /* Wait till link down bits are cleared in status register */ wait_data.cond = CXG_LINK_STATUS_DWN_BIT_CLR; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_CTRL_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR(MOD_NAME "Bringing up link... Failed"); return status; } FWK_LOG_INFO(MOD_NAME "Bringing up link... Done"); return FWK_SUCCESS; } int ccix_setup( const unsigned int chip_id, struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *ccix_config) { unsigned int i; unsigned int unique_remote_rnf_ldid_value; uint8_t rnf_ldid; uint8_t rni_ldid; uint8_t rnd_ldid; uint8_t agentid; uint8_t remote_agentid; uint8_t offset_id; uint8_t local_ra_cnt; int status; FWK_LOG_INFO(MOD_NAME "Programming CCIX gateway..."); /* Assign the max count among the RNs as local_ra_cnt */ if ((ctx->rnf_count > ctx->rnd_count) && (ctx->rnf_count > ctx->rni_count)) local_ra_cnt = ctx->rnf_count; else if (ctx->rnd_count > ctx->rni_count) local_ra_cnt = ctx->rnd_count; else local_ra_cnt = ctx->rni_count; cmn650_ccix_ctx.is_prog_for_port_agg = false; do { /* Set the global config data */ config = ccix_config; if (ccix_config->smp_mode) { status = enable_smp_mode(ctx, ccix_config); if (status != FWK_SUCCESS) return status; } /* * In order to assign unique AgentIDs across multiple chips, chip_id is * used as factor to offset the AgentID value */ cmn650_ccix_ctx.raid_value = 0; offset_id = chip_id * local_ra_cnt; for (rnf_ldid = 0; rnf_ldid < ctx->rnf_count; rnf_ldid++) { agentid = cmn650_ccix_ctx.raid_value + offset_id; /* Program RAID values in CXRA LDID to RAID LUT */ program_cxg_ra_rnf_ldid_to_raid_reg(ctx, rnf_ldid, agentid); } /* Program agentid to linkid LUT for remote agents in CXRA/CXHA/CXLA */ program_agentid_to_linkid_reg(ctx, ccix_config); /* Program HN-F ldid to CHI NodeID for remote RN-F agents */ program_hnf_ldid_to_chi_node_id_reg(ctx, ccix_config); /* * unique_remote_rnf_ldid_value is used to keep track of the * ldid of the remote RNF agents */ unique_remote_rnf_ldid_value = ctx->rnf_count; if (ccix_config->remote_rnf_count && (ctx->rnf_count == 0)) { FWK_LOG_ERR( MOD_NAME "Remote RN-F Count can't be %u when RN-F count is zero", ccix_config->remote_rnf_count); fwk_unexpected(); } for (i = 0; i < ccix_config->remote_rnf_count; i++) { /* * The remote_agentid should not include the current chip's * AgentIDs. If `block` is less than the current chip_id, then * include the AgentIDs starting from chip 0 till (not including) * current chip. If the `block` is equal or greater than the current * chip, then include the AgentIDs from next chip till the max chip. */ if ((i / ctx->rnf_count) < chip_id) remote_agentid = i; else remote_agentid = i + ctx->rnf_count; /* Program the CXHA raid to ldid LUT */ program_cxg_ha_raid_to_ldid_lut( ctx, remote_agentid, unique_remote_rnf_ldid_value); unique_remote_rnf_ldid_value++; } /* Program the unique HAID for the CXHA block */ program_cxg_ha_id(ctx); cmn650_ccix_ctx.raid_value = 0; offset_id = chip_id * local_ra_cnt; for (rnd_ldid = 0; rnd_ldid < ctx->rnd_count; rnd_ldid++) { /* Determine agentid of the remote agents */ agentid = cmn650_ccix_ctx.raid_value + offset_id; /* Program RAID values in CXRA LDID to RAID LUT */ program_cxg_ra_rnd_ldid_to_raid_reg(ctx, rnd_ldid, agentid); } cmn650_ccix_ctx.raid_value = 0; offset_id = chip_id * local_ra_cnt; for (rni_ldid = 0; rni_ldid < ctx->rni_count; rni_ldid++) { /* Determine agentid of the remote agents */ agentid = cmn650_ccix_ctx.raid_value + offset_id; /* Program RAID values in CXRA LDID to RAID LUT */ program_cxg_ra_rni_ldid_to_raid_reg(ctx, rni_ldid, agentid); } /* * Program the CXRA SAM with the address range and the corresponding * remote HAID */ program_cxg_ra_sam_addr_region(ctx, ccix_config); /* Program the Link Control registers present in CXRA/CXHA/CXLA */ status = enable_and_start_ccix_link_up_sequence(ctx, 0); if (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg == false) { cmn650_ccix_ctx.is_prog_for_port_agg = true; FWK_LOG_INFO(MOD_NAME "Programming CCIX gateway for Port Aggregation..."); } else cmn650_ccix_ctx.is_prog_for_port_agg = false; } while (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg); return status; } int ccix_exchange_protocol_credit( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *ccix_config) { int linkid; struct cmn650_cxg_ra_reg *cxg_ra_reg; struct cmn650_cxg_ha_reg *cxg_ha_reg; unsigned int cxg_ldid; cmn650_ccix_ctx.is_prog_for_port_agg = false; do { config = ccix_config; cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; /* TODO Add support to enable multiple links */ linkid = 0; FWK_LOG_INFO( MOD_NAME "Exchanging protocol credits for link %d...", linkid); /* Exchange protocol credits using link up bit */ cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL |= CXG_LINK_CTRL_UP_MASK; cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL |= CXG_LINK_CTRL_UP_MASK; FWK_LOG_INFO( MOD_NAME "Exchanging protocol credits for link %d... Done", linkid); if (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg == false) { cmn650_ccix_ctx.is_prog_for_port_agg = true; FWK_LOG_INFO(MOD_NAME "Exchange Protocol Credit for Port Aggregation..."); } else cmn650_ccix_ctx.is_prog_for_port_agg = false; } while (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg); return FWK_SUCCESS; } int ccix_enter_system_coherency( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *ccix_config) { struct cxg_wait_condition_data wait_data; int status; int linkid; struct cmn650_cxg_ha_reg *cxg_ha_reg; unsigned int cxg_ldid; cmn650_ccix_ctx.is_prog_for_port_agg = false; do { config = ccix_config; cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ha_reg = ctx->cxg_ha_reg_table[cxg_ldid].cxg_ha_reg; /* TODO Add support to enable multiple links */ linkid = 0; wait_data.ctx = ctx; wait_data.linkid = linkid; FWK_LOG_INFO( MOD_NAME "Entering system coherency for link %d...", linkid); /* Enter system coherency by setting DVMDOMAIN request bit */ cxg_ha_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL |= CXG_LINK_CTRL_DVMDOMAIN_REQ_MASK; /* Wait till DVMDOMAIN ACK bit is set in status register */ wait_data.cond = CXG_LINK_STATUS_HA_DVMDOMAIN_ACK_BIT_SET; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_DVMDOMAIN_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR( MOD_NAME "Entering system coherency for link %d... Failed", linkid); return status; } FWK_LOG_INFO( MOD_NAME "Entering system coherency for link %d... Done", linkid); if (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg == false) { cmn650_ccix_ctx.is_prog_for_port_agg = true; FWK_LOG_INFO(MOD_NAME "Enter system coherency for Port Aggregation..."); } else cmn650_ccix_ctx.is_prog_for_port_agg = false; } while (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg); return FWK_SUCCESS; } int ccix_enter_dvm_domain( struct cmn650_device_ctx *ctx, const struct mod_cmn650_ccix_config *ccix_config) { struct cxg_wait_condition_data wait_data; int status; int linkid; struct cmn650_cxg_ra_reg *cxg_ra_reg; unsigned int cxg_ldid; cmn650_ccix_ctx.is_prog_for_port_agg = false; do { config = ccix_config; cxg_ldid = get_ldid(cmn650_ccix_ctx.is_prog_for_port_agg); cxg_ra_reg = ctx->cxg_ra_reg_table[cxg_ldid].cxg_ra_reg; /* TODO Add support to enable multiple links */ linkid = 0; wait_data.ctx = ctx; wait_data.linkid = linkid; FWK_LOG_INFO(MOD_NAME "Entering DVM domain for link %d...", linkid); /* DVM domain entry by setting DVMDOMAIN request bit */ cxg_ra_reg->LINK_REGS[linkid].CXG_PRTCL_LINK_CTRL |= CXG_LINK_CTRL_DVMDOMAIN_REQ_MASK; /* Wait till DVMDOMAIN ACK bit is set in status register */ wait_data.cond = CXG_LINK_STATUS_RA_DVMDOMAIN_ACK_BIT_SET; status = ctx->timer_api->wait( FWK_ID_ELEMENT(FWK_MODULE_IDX_TIMER, 0), CXG_PRTCL_LINK_DVMDOMAIN_TIMEOUT, cxg_link_wait_condition, &wait_data); if (status != FWK_SUCCESS) { FWK_LOG_ERR( MOD_NAME "Entering DVM domain for link %d... Failed", linkid); return status; } FWK_LOG_INFO( MOD_NAME "Entering DVM domain for link %d... Done", linkid); if (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg == false) { cmn650_ccix_ctx.is_prog_for_port_agg = true; FWK_LOG_INFO(MOD_NAME "Entering DVM domain for Port Aggregation..."); } else cmn650_ccix_ctx.is_prog_for_port_agg = false; } while (config->port_aggregate && cmn650_ccix_ctx.is_prog_for_port_agg); return FWK_SUCCESS; }
c44d6c12de887513f9fa65621b2a716c6672b95d
0577a46d8d28e1fd8636893bbdd2b18270bb8eb8
/update_notifier/thirdparty/wxWidgets/docs/doxygen/groups/funcmacro_thread.h
ba09a3f3daa954118ca1e032116d7f745251ff92
[ "BSD-3-Clause", "LicenseRef-scancode-other-copyleft", "WxWindows-exception-3.1", "LGPL-2.0-or-later", "GPL-1.0-or-later", "IJG", "GPL-2.0-only", "LGPL-2.0-only" ]
permissive
ric2b/Vivaldi-browser
388a328b4cb838a4c3822357a5529642f86316a5
87244f4ee50062e59667bf8b9ca4d5291b6818d7
refs/heads/master
2022-12-21T04:44:13.804535
2022-12-17T16:30:35
2022-12-17T16:30:35
86,637,416
166
41
BSD-3-Clause
2021-03-31T18:49:30
2017-03-29T23:09:05
null
UTF-8
C
false
false
1,017
h
funcmacro_thread.h
///////////////////////////////////////////////////////////////////////////// // Name: funcmacro_thread.h // Purpose: Threads function and macro group docs // Author: wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @defgroup group_funcmacro_thread Threads @ingroup group_funcmacro The functions and macros here mainly exist to make it possible to write code which may be compiled in multi thread build (wxUSE_THREADS = 1) as well as in single thread configuration (wxUSE_THREADS = 0). For example, a static variable must be protected against simultaneous access by multiple threads in the former configuration but in the latter the extra overhead of using the critical section is not needed. To solve this problem, the wxCRITICAL_SECTION() macro may be used to create and use the critical section only when needed. @sa wxThread, wxMutex, @ref overview_thread Related class group: @ref group_class_threading */
60ceef682fbbbc2d3a5e751ca29c905f0fc4a579
ff44afc42082479d929e59c0100457f63cdf1028
/dart-if/include/dash/dart/if/dart_io.h
fe04ad1acebe222e62376cc98fc7cae2403f9dfa
[ "BSD-3-Clause" ]
permissive
dash-project/dash
122f3f3106c4d6b0215908a3a28c565d46d66f56
99f299572bbb42f6668fbe704b179b9b5d0da92b
refs/heads/development
2021-08-19T13:28:46.595300
2021-04-28T08:24:20
2021-04-28T08:24:20
45,930,061
178
47
NOASSERTION
2021-06-09T12:24:54
2015-11-10T17:56:37
C++
UTF-8
C
false
false
624
h
dart_io.h
/** * \file dash/dart/if/dart_io.h * * A set of utility routines used to provide parallel io support * */ #ifndef DART__IO_H_ #define DART__IO_H_ #include <dash/dart/if/dart_types.h> #include <dash/dart/if/dart_util.h> /** * \defgroup DartIO Interface for parallel IO * \ingroup DartInterface */ #ifdef __cplusplus extern "C" { #endif #define DART_INTERFACE_ON /** * setup hdf5 for parallel io using mpi-io */ dart_ret_t dart__io__hdf5__prep_mpio( hid_t plist_id, dart_team_t teamid) DART_NOTHROW; #define DART_INTERFACE_OFF #ifdef __cplusplus } /* extern "C" */ #endif #endif /* DART__IO_H_*/
ced42eb254b13dc30f3ce95a942eda2ed55c7f8c
03b2c80dbc41e904b167d504666e27d798da5447
/src/intern_symbol_32.h
15c15ed70894779352232123b7c1a1039e49bb8b
[ "Unlicense" ]
permissive
nptcl/npt
7c1570b497cdce0b8971cb445fbc04cb500232d3
aa714a2370ac9fa5348c2fc96159b40b9de3de07
refs/heads/master
2023-03-20T09:13:54.669118
2022-07-02T11:17:44
2022-07-02T11:17:44
171,985,905
160
12
Unlicense
2023-03-11T01:36:37
2019-02-22T03:11:34
C
UTF-8
C
false
false
164,499
h
intern_symbol_32.h
{ CONSTANT_AMPERSAND_WHOLE, COMMON, "&WHOLE", 6, 0x4F489C78ULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_OPTIONAL, COMMON, "&OPTIONAL", 9, 0x159E9EC4ULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_REST, COMMON, "&REST", 5, 0x5345527FULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_BODY, COMMON, "&BODY", 5, 0x444F4284ULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_KEY, COMMON, "&KEY", 4, 0x59454B2AULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_ALLOW, COMMON, "&ALLOW-OTHER-KEYS", 17, 0x47042C5AULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_AUX, COMMON, "&AUX", 4, 0x5855412AULL, 0, 0, 0 }, { CONSTANT_AMPERSAND_ENVIRONMENT, COMMON, "&ENVIRONMENT", 12, 0x78EBDCC8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ABORT, KEYWORD, "ABORT", 5, 0x524F429AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ABSOLUTE, KEYWORD, "ABSOLUTE", 8, 0x14A79795ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ACCESSOR, KEYWORD, "ACCESSOR", 8, 0x1792969CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ADJUSTABLE, KEYWORD, "ADJUSTABLE", 10, 0x178BDDEAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_AFTER, KEYWORD, "AFTER", 5, 0x45544698ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ALLOCATION, KEYWORD, "ALLOCATION", 10, 0x18A0DBDDULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ALLOW_OTHER_KEYS, KEYWORD, "ALLOW-OTHER-KEYS", 16, 0x2447043BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_AND, KEYWORD, "AND", 3, 0x00444E44ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_APPEND, KEYWORD, "APPEND", 6, 0x45509495ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ARRAY, KEYWORD, "ARRAY", 5, 0x4152529FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ARGUMENT_PRECEDENCE_ORDER, KEYWORD, "ARGUMENT-PRECEDENCE-ORDER", 25, 0x26B5C306ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ARGUMENTS, KEYWORD, "ARGUMENTS", 9, 0x299597EAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_AROUND, KEYWORD, "AROUND", 6, 0x554F9695ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_BASE, KEYWORD, "BASE", 4, 0x45534146ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_BEFORE, KEYWORD, "BEFORE", 6, 0x4F468A9AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_BLOCK, KEYWORD, "BLOCK", 5, 0x434F4C92ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CAPITALIZE, KEYWORD, "CAPITALIZE", 10, 0x129CC7FBULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CASE, KEYWORD, "CASE", 4, 0x45534147ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CLASS, KEYWORD, "CLASS", 5, 0x53414C9BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CIRCLE, KEYWORD, "CIRCLE", 6, 0x43528E95ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_COMMON, KEYWORD, "COMMON", 6, 0x4D4D9D98ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_COMMON_LISP_USER, KEYWORD, "COMMON-LISP-USER", 16, 0x19104440ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_COMPILE_TOPLEVEL, KEYWORD, "COMPILE-TOPLEVEL", 16, 0x16284135ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CONC_NAME, KEYWORD, "CONC-NAME", 9, 0x108F9DBEULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CONSTRUCTOR, KEYWORD, "CONSTRUCTOR", 11, 0x16F5F0F6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_COPIER, KEYWORD, "COPIER", 6, 0x4950A18EULL, 0, 0, 0 }, { CONSTANT_KEYWORD_COUNT, KEYWORD, "COUNT", 5, 0x4E554F9CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CREATE, KEYWORD, "CREATE", 6, 0x4145979DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CURRENT, KEYWORD, "CURRENT", 7, 0x52A6A38FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DATUM, KEYWORD, "DATUM", 5, 0x55544196ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DECLARE, KEYWORD, "DECLARE", 7, 0x4C88978CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DEFAULT, KEYWORD, "DEFAULT", 7, 0x419A91A0ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DEFAULT_INITARGS, KEYWORD, "DEFAULT-INITARGS", 16, 0x162B3233ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DEFAULTS, KEYWORD, "DEFAULTS", 8, 0x149A91A1ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DESCRIPTION, KEYWORD, "DESCRIPTION", 11, 0x17F1DDEAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DEVICE, KEYWORD, "DEVICE", 6, 0x49568A8DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DIRECTION, KEYWORD, "DIRECTION", 9, 0x149B9DDEULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DIRECTORY, KEYWORD, "DIRECTORY", 9, 0x17A19DE9ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DISPLACED_TO, KEYWORD, "DISPLACED-TO", 12, 0x64EAB7E0ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DISPLACED_INDEX_OFFSET, KEYWORD, "DISPLACED-INDEX-OFFSET", 22, 0x647E97C2ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DOCUMENTATION, KEYWORD, "DOCUMENTATION", 13, 0x78DAE92DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_DOWNCASE, KEYWORD, "DOWNCASE", 8, 0x13AA908FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ELEMENT_TYPE, KEYWORD, "ELEMENT-TYPE", 12, 0x3FE9F3EAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_END, KEYWORD, "END", 3, 0x00444E48ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_END1, KEYWORD, "END1", 4, 0x31444E49ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_END2, KEYWORD, "END2", 4, 0x32444E49ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ENVIRONMENT, KEYWORD, "ENVIRONMENT", 11, 0x16F8EBE7ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ERROR, KEYWORD, "ERROR", 5, 0x4F52529CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ESCAPE, KEYWORD, "ESCAPE", 6, 0x4143989BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_EXECUTE, KEYWORD, "EXECUTE", 7, 0x438AACA1ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_EXPECTED_TYPE, KEYWORD, "EXPECTED-TYPE", 13, 0x59EF0107ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_EXPORT, KEYWORD, "EXPORT", 6, 0x4F50AC9DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_EXTERNAL, KEYWORD, "EXTERNAL", 8, 0x1195A69FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_EXTERNAL_FORMAT, KEYWORD, "EXTERNAL-FORMAT", 15, 0x64392E20ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_FILL, KEYWORD, "FILL", 4, 0x4C4C494AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_FILL_POINTER, KEYWORD, "FILL-POINTER", 12, 0x67E0EDCDULL, 0, 0, 0 }, { CONSTANT_KEYWORD_FROM_END, KEYWORD, "FROM-END", 8, 0x119D977BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_FORMAT_ARGUMENTS, KEYWORD, "FORMAT-ARGUMENTS", 16, 0x2F29392EULL, 0, 0, 0 }, { CONSTANT_KEYWORD_FORMAT_CONTROL, KEYWORD, "FORMAT-CONTROL", 14, 0x62D43E33ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_FULL, KEYWORD, "FULL", 4, 0x4C4C554AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_GENERIC_FUNCTION, KEYWORD, "GENERIC-FUNCTION", 16, 0x042F2D43ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_GENERIC_FUNCTION_CLASS, KEYWORD, "GENERIC-FUNCTION-CLASS", 22, 0x457BC3C9ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_GENSYM, KEYWORD, "GENSYM", 6, 0x534E92A6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_HOST, KEYWORD, "HOST", 4, 0x54534F4CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IDENTITY, KEYWORD, "IDENTITY", 8, 0x27998DA5ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IDENTITY_WITH_ONE_ARGUMENT, KEYWORD, "IDENTITY-WITH-ONE-ARGUMENT", 26, 0x61C0E906ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IF_DOES_NOT_EXIST, KEYWORD, "IF-DOES-NOT-EXIST", 17, 0x721E3390ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IF_EXISTS, KEYWORD, "IF-EXISTS", 9, 0x19808FFDULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IMPORT_FROM, KEYWORD, "IMPORT-FROM", 11, 0x15CAF0F8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INCLUDE, KEYWORD, "INCLUDE", 7, 0x4C8892A5ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INDEX, KEYWORD, "INDEX", 5, 0x45444EA6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INITARG, KEYWORD, "INITARG", 7, 0x5490A091ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INITFORM, KEYWORD, "INITFORM", 8, 0x219B9D97ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INITIAL_ELEMENT, KEYWORD, "INITIAL-ELEMENT", 15, 0x4F2F2A2BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INITIAL_CONTENTS, KEYWORD, "INITIAL-CONTENTS", 16, 0x29382D2AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INITIAL_OFFSET, KEYWORD, "INITIAL-OFFSET", 14, 0x54DC2A34ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INITIAL_VALUE, KEYWORD, "INITIAL-VALUE", 13, 0x56E1D13AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INHERITED, KEYWORD, "INHERITED", 9, 0x0A9C97E8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INPUT, KEYWORD, "INPUT", 5, 0x55504EA2ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INSTANCE, KEYWORD, "INSTANCE", 8, 0x19969C92ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INTERACTIVE, KEYWORD, "INTERACTIVE", 11, 0x19DCE5EFULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INTERACTIVE_FUNCTION, KEYWORD, "INTERACTIVE-FUNCTION", 20, 0x587A8492ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INTERN, KEYWORD, "INTERN", 6, 0x45549CA1ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INTERNAL, KEYWORD, "INTERNAL", 8, 0x11959CA3ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_INVERT, KEYWORD, "INVERT", 6, 0x4556A2A1ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IO, KEYWORD, "IO", 2, 0x00004F4BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_JUNK_ALLOWED, KEYWORD, "JUNK-ALLOWED", 12, 0x5BDFEDD2ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_KEY, KEYWORD, "KEY", 3, 0x0059454EULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LAMBDA_LIST, KEYWORD, "LAMBDA-LIST", 11, 0x0ECED5E4ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LENGTH, KEYWORD, "LENGTH", 6, 0x474E8DA6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LEVEL, KEYWORD, "LEVEL", 5, 0x4556459DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LINEAR, KEYWORD, "LINEAR", 6, 0x454E9B93ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LINE, KEYWORD, "LINE", 4, 0x454E4950ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LINE_RELATIVE, KEYWORD, "LINE-RELATIVE", 13, 0x67DCF00CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LINES, KEYWORD, "LINES", 5, 0x454E49A4ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LOAD_TOPLEVEL, KEYWORD, "LOAD-TOPLEVEL", 13, 0x59E6E91EULL, 0, 0, 0 }, { CONSTANT_KEYWORD_LOCAL, KEYWORD, "LOCAL", 5, 0x41434F9DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_MANDATORY, KEYWORD, "MANDATORY", 9, 0x169D95F0ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_METACLASS, KEYWORD, "METACLASS", 9, 0x149591ECULL, 0, 0, 0 }, { CONSTANT_KEYWORD_METHOD, KEYWORD, "METHOD", 6, 0x485489A2ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_METHOD_CLASS, KEYWORD, "METHOD-CLASS", 12, 0x5ED4CAF4ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_METHOD_COMBINATION, KEYWORD, "METHOD-COMBINATION", 18, 0x1E18669AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_MISER, KEYWORD, "MISER", 5, 0x455349A4ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_MISER_WIDTH, KEYWORD, "MISER-WIDTH", 11, 0x0EF2CAEEULL, 0, 0, 0 }, { CONSTANT_KEYWORD_MOST_SPECIFIC_FIRST, KEYWORD, "MOST-SPECIFIC-FIRST", 19, 0x2C846C65ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_MOST_SPECIFIC_LAST, KEYWORD, "MOST-SPECIFIC-LAST", 18, 0x24366D65ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NAME, KEYWORD, "NAME", 4, 0x454D4152ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NAMED, KEYWORD, "NAMED", 5, 0x454D4197ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NEW_VERSION, KEYWORD, "NEW-VERSION", 11, 0x00F7D9F8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NEWEST, KEYWORD, "NEWEST", 6, 0x455799A7ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NICKNAMES, KEYWORD, "NICKNAMES", 9, 0x10908AF8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NO_ERROR, KEYWORD, "NO-ERROR", 8, 0x177CA1A8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_NOT, KEYWORD, "NOT", 3, 0x00544F51ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OBJECT, KEYWORD, "OBJECT", 6, 0x454A9698ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OPERANDS, KEYWORD, "OPERANDS", 8, 0x25899E98ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OPERATION, KEYWORD, "OPERATION", 9, 0x218EA4E7ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OPERATOR, KEYWORD, "OPERATOR", 8, 0x2494A498ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OR, KEYWORD, "OR", 2, 0x00005251ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ORDER, KEYWORD, "ORDER", 5, 0x454452A6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OUTPUT, KEYWORD, "OUTPUT", 6, 0x5054A9AAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OUTPUT_FILE, KEYWORD, "OUTPUT-FILE", 11, 0x16C6F5F8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OVERRIDE, KEYWORD, "OVERRIDE", 8, 0x17899FA9ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_OVERWRITE, KEYWORD, "OVERWRITE", 9, 0x268EA8F4ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PACKAGE, KEYWORD, "PACKAGE", 7, 0x4B888898ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PATHNAME, KEYWORD, "PATHNAME", 8, 0x0DA182A6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PER_LINE_PREFIX, KEYWORD, "PER-LINE-PREFIX", 15, 0x384B281EULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PPRINT_DISPATCH, KEYWORD, "PPRINT-DISPATCH", 15, 0x4F183B4AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PREDICATE, KEYWORD, "PREDICATE", 9, 0x188695E7ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PREFIX, KEYWORD, "PREFIX", 6, 0x4645AA9FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PRESERVE, KEYWORD, "PRESERVE", 8, 0x189BA49DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PRESERVE_WHITESPACE, KEYWORD, "PRESERVE-WHITESPACE", 19, 0x327C846AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PRETTY, KEYWORD, "PRETTY", 6, 0x5445ABAAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PRINT, KEYWORD, "PRINT", 5, 0x4E4952A9ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PRINT_FUNCTION, KEYWORD, "PRINT-FUNCTION", 14, 0x6CE4114FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PRINT_OBJECT, KEYWORD, "PRINT-OBJECT", 12, 0x64DBC4FAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PROBE, KEYWORD, "PROBE", 5, 0x424F529AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_RADIX, KEYWORD, "RADIX", 5, 0x494441AFULL, 0, 0, 0 }, { CONSTANT_KEYWORD_READ_ONLY, KEYWORD, "READ-ONLY", 9, 0x108F94E1ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_READABLY, KEYWORD, "READABLY", 8, 0x1D8D879BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_READER, KEYWORD, "READER", 6, 0x4441979DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_REHASH_SIZE, KEYWORD, "REHASH-SIZE", 11, 0x14BAE7F9ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_REHASH_THRESHOLD, KEYWORD, "REHASH-THRESHOLD", 16, 0x2D072F45ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_RELATIVE, KEYWORD, "RELATIVE", 8, 0x06A28EAEULL, 0, 0, 0 }, { CONSTANT_KEYWORD_RENAME, KEYWORD, "RENAME", 6, 0x414E8AA5ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_RENAME_AND_DELETE, KEYWORD, "RENAME-AND-DELETE", 17, 0x1AEE1B88ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_REPORT, KEYWORD, "REPORT", 6, 0x4F5099AAULL, 0, 0, 0 }, { CONSTANT_KEYWORD_REPORT_FUNCTION, KEYWORD, "REPORT-FUNCTION", 15, 0x6A0F3751ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_REQUIRED, KEYWORD, "REQUIRED", 8, 0x199697A3ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_RIGHT_MARGIN, KEYWORD, "RIGHT-MARGIN", 12, 0x57DDBE04ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SECTION, KEYWORD, "SECTION", 7, 0x549194A3ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SECTION_RELATIVE, KEYWORD, "SECTION-RELATIVE", 16, 0x08342352ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SHADOW, KEYWORD, "SHADOW", 6, 0x44419FA8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SHADOWING_IMPORT_FROM, KEYWORD, "SHADOWING-IMPORT-FROM", 21, 0x037862C8ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SIZE, KEYWORD, "SIZE", 4, 0x455A4957ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SLOT_NAMES, KEYWORD, "SLOT-NAMES", 10, 0x2190EDCFULL, 0, 0, 0 }, { CONSTANT_KEYWORD_START, KEYWORD, "START", 5, 0x524154ACULL, 0, 0, 0 }, { CONSTANT_KEYWORD_START1, KEYWORD, "START1", 6, 0x524185ADULL, 0, 0, 0 }, { CONSTANT_KEYWORD_START2, KEYWORD, "START2", 6, 0x524186ADULL, 0, 0, 0 }, { CONSTANT_KEYWORD_STREAM, KEYWORD, "STREAM", 6, 0x4552A19AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SUFFIX, KEYWORD, "SUFFIX", 6, 0x4646ADA2ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SUPERSEDE, KEYWORD, "SUPERSEDE", 9, 0x0995A8F3ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_TEST, KEYWORD, "TEST", 4, 0x54534558ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_TEST_FUNCTION, KEYWORD, "TEST-FUNCTION", 13, 0x71F1E01FULL, 0, 0, 0 }, { CONSTANT_KEYWORD_TEST_NOT, KEYWORD, "TEST-NOT", 8, 0x28A29389ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_TYPE, KEYWORD, "TYPE", 4, 0x45505958ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_UNSPECIFIC, KEYWORD, "UNSPECIFIC", 10, 0x169CD4EDULL, 0, 0, 0 }, { CONSTANT_KEYWORD_UP, KEYWORD, "UP", 2, 0x00005057ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_UPCASE, KEYWORD, "UPCASE", 6, 0x414395AEULL, 0, 0, 0 }, { CONSTANT_KEYWORD_USE, KEYWORD, "USE", 3, 0x00455358ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_VERBOSE, KEYWORD, "VERBOSE", 7, 0x429798ACULL, 0, 0, 0 }, { CONSTANT_KEYWORD_VERSION, KEYWORD, "VERSION", 7, 0x53A094A6ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_WILD, KEYWORD, "WILD", 4, 0x444C495BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_WILD_INFERIORS, KEYWORD, "WILD-INFERIORS", 14, 0x59E43829ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_WRITER, KEYWORD, "WRITER", 6, 0x5449A4A2ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_ARGS, KEYWORD, "ARGS", 4, 0x53475245ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_CACHE, KEYWORD, "CACHE", 5, 0x4843418DULL, 0, 0, 0 }, { CONSTANT_KEYWORD_EXIT, KEYWORD, "EXIT", 4, 0x54495849ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IF_ERROR_EXISTS, KEYWORD, "IF-ERROR-EXISTS", 15, 0x6128322AULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IF_INPUT_DOES_NOT_EXIST, KEYWORD, "IF-INPUT-DOES-NOT-EXIST", 23, 0x0AB988CBULL, 0, 0, 0 }, { CONSTANT_KEYWORD_IF_OUTPUT_EXISTS, KEYWORD, "IF-OUTPUT-EXISTS", 16, 0x50171B4BULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PIPE, KEYWORD, "PIPE", 4, 0x45504954ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_PROGRAM, KEYWORD, "PROGRAM", 7, 0x479C93A9ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_SEARCH, KEYWORD, "SEARCH", 6, 0x52418D9CULL, 0, 0, 0 }, { CONSTANT_KEYWORD_VALUE, KEYWORD, "VALUE", 5, 0x554C41A0ULL, 0, 0, 0 }, { CONSTANT_KEYWORD_WAIT, KEYWORD, "WAIT", 4, 0x5449415BULL, 0, 0, 0 }, { CONSTANT_COMMON_ASTERISK, COMMON, "*", 1, 0x0000002BULL, 0, 0, 0 }, { CONSTANT_COMMON_ASTERISK2, COMMON, "**", 2, 0x00002A2CULL, 0, 0, 0 }, { CONSTANT_COMMON_ASTERISK3, COMMON, "***", 3, 0x002A2A2DULL, 0, 0, 0 }, { CONSTANT_COMMON_PLUS, COMMON, "+", 1, 0x0000002CULL, 0, 0, 0 }, { CONSTANT_COMMON_PLUS2, COMMON, "++", 2, 0x00002B2DULL, 0, 0, 0 }, { CONSTANT_COMMON_PLUS3, COMMON, "+++", 3, 0x002B2B2EULL, 0, 0, 0 }, { CONSTANT_COMMON_MINUS, COMMON, "-", 1, 0x0000002EULL, 0, 0, 0 }, { CONSTANT_COMMON_SLASH, COMMON, "/", 1, 0x00000030ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLASH2, COMMON, "//", 2, 0x00002F31ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLASH3, COMMON, "///", 3, 0x002F2F32ULL, 0, 0, 0 }, { CONSTANT_COMMON_ONE_PLUS, COMMON, "1+", 2, 0x00002B33ULL, 0, 0, 0 }, { CONSTANT_COMMON_ONE_MINUS, COMMON, "1-", 2, 0x00002D33ULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER_EQUAL, COMMON, "=", 1, 0x0000003EULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER_NOT_EQUAL, COMMON, "/=", 2, 0x00003D31ULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER_LESS, COMMON, "<", 1, 0x0000003DULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER_GREATER, COMMON, ">", 1, 0x0000003FULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER_LESS_EQUAL, COMMON, "<=", 2, 0x00003D3EULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER_GREATER_EQUAL, COMMON, ">=", 2, 0x00003D40ULL, 0, 0, 0 }, { CONSTANT_COMMON_ABORT, COMMON, "ABORT", 5, 0x524F429AULL, 0, 0, 0 }, { CONSTANT_COMMON_ABS, COMMON, "ABS", 3, 0x00534244ULL, 0, 0, 0 }, { CONSTANT_COMMON_ACONS, COMMON, "ACONS", 5, 0x4E4F4399ULL, 0, 0, 0 }, { CONSTANT_COMMON_ACOS, COMMON, "ACOS", 4, 0x534F4345ULL, 0, 0, 0 }, { CONSTANT_COMMON_ACOSH, COMMON, "ACOSH", 5, 0x534F438EULL, 0, 0, 0 }, { CONSTANT_COMMON_ADD_METHOD, COMMON, "ADD-METHOD", 10, 0x7598CDE7ULL, 0, 0, 0 }, { CONSTANT_COMMON_ADJOIN, COMMON, "ADJOIN", 6, 0x4F4A9290ULL, 0, 0, 0 }, { CONSTANT_COMMON_ADJUST_ARRAY, COMMON, "ADJUST-ARRAY", 12, 0x6FB8EAF2ULL, 0, 0, 0 }, { CONSTANT_COMMON_ADJUSTABLE_ARRAY_P, COMMON, "ADJUSTABLE-ARRAY-P", 18, 0x31FA8071ULL, 0, 0, 0 }, { CONSTANT_COMMON_ALPHA_CHAR_P, COMMON, "ALPHA-CHAR-P", 12, 0x60C0CBCFULL, 0, 0, 0 }, { CONSTANT_COMMON_ALPHANUMERICP, COMMON, "ALPHANUMERICP", 13, 0x58EEED24ULL, 0, 0, 0 }, { CONSTANT_COMMON_AND, COMMON, "AND", 3, 0x00444E44ULL, 0, 0, 0 }, { CONSTANT_COMMON_ATOM, COMMON, "ATOM", 4, 0x4D4F5445ULL, 0, 0, 0 }, { CONSTANT_COMMON_APPEND, COMMON, "APPEND", 6, 0x45509495ULL, 0, 0, 0 }, { CONSTANT_COMMON_APPLY, COMMON, "APPLY", 5, 0x4C50509FULL, 0, 0, 0 }, { CONSTANT_COMMON_APROPOS, COMMON, "APROPOS", 7, 0x4FA59F98ULL, 0, 0, 0 }, { CONSTANT_COMMON_APROPOS_LIST, COMMON, "APROPOS-LIST", 12, 0x50F8E8E9ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARITHMETIC_ERROR, COMMON, "ARITHMETIC-ERROR", 16, 0x400B3534ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARITHMETIC_ERROR_OPERANDS, COMMON, "ARITHMETIC-ERROR-OPERANDS", 25, 0x49A9C60FULL, 0, 0, 0 }, { CONSTANT_COMMON_ARITHMETIC_ERROR_OPERATION, COMMON, "ARITHMETIC-ERROR-OPERATION", 26, 0x4EB0140CULL, 0, 0, 0 }, { CONSTANT_COMMON_AREF, COMMON, "AREF", 4, 0x46455245ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY, COMMON, "ARRAY", 5, 0x4152529FULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_DIMENSION, COMMON, "ARRAY-DIMENSION", 15, 0x5E33143FULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_DIMENSION_LIMIT, COMMON, "ARRAY-DIMENSION-LIMIT", 21, 0x54805DE5ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_DIMENSIONS, COMMON, "ARRAY-DIMENSIONS", 16, 0x31331440ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_ELEMENT_TYPE, COMMON, "ARRAY-ELEMENT-TYPE", 18, 0x35313F95ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_HAS_FILL_POINTER_P, COMMON, "ARRAY-HAS-FILL-POINTER-P", 24, 0x408994E5ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_DISPLACEMENT, COMMON, "ARRAY-DISPLACEMENT", 18, 0x11306990ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_IN_BOUNDS_P, COMMON, "ARRAY-IN-BOUNDS-P", 17, 0x123E0676ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_RANK, COMMON, "ARRAY-RANK", 10, 0x02A4CAF2ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_RANK_LIMIT, COMMON, "ARRAY-RANK-LIMIT", 16, 0x231B1841ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_ROW_MAJOR_INDEX, COMMON, "ARRAY-ROW-MAJOR-INDEX", 21, 0x44884AF1ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_TOTAL_SIZE, COMMON, "ARRAY-TOTAL-SIZE", 16, 0x034D0A51ULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAY_TOTAL_SIZE_LIMIT, COMMON, "ARRAY-TOTAL-SIZE-LIMIT", 22, 0x5096AACDULL, 0, 0, 0 }, { CONSTANT_COMMON_ARRAYP, COMMON, "ARRAYP", 6, 0x4152A2A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_ASH, COMMON, "ASH", 3, 0x00485344ULL, 0, 0, 0 }, { CONSTANT_COMMON_ASIN, COMMON, "ASIN", 4, 0x4E495345ULL, 0, 0, 0 }, { CONSTANT_COMMON_ASINH, COMMON, "ASINH", 5, 0x4E49538EULL, 0, 0, 0 }, { CONSTANT_COMMON_ASSERT, COMMON, "ASSERT", 6, 0x4553A799ULL, 0, 0, 0 }, { CONSTANT_COMMON_ASSOC, COMMON, "ASSOC", 5, 0x4F535389ULL, 0, 0, 0 }, { CONSTANT_COMMON_ASSOC_IF, COMMON, "ASSOC-IF", 8, 0x159C808CULL, 0, 0, 0 }, { CONSTANT_COMMON_ASSOC_IF_NOT, COMMON, "ASSOC-IF-NOT", 12, 0x69EBCEBDULL, 0, 0, 0 }, { CONSTANT_COMMON_ATAN, COMMON, "ATAN", 4, 0x4E415445ULL, 0, 0, 0 }, { CONSTANT_COMMON_ATANH, COMMON, "ATANH", 5, 0x4E41548EULL, 0, 0, 0 }, { CONSTANT_COMMON_BASE_CHAR, COMMON, "BASE-CHAR", 9, 0x069B84CAULL, 0, 0, 0 }, { CONSTANT_COMMON_BASE_STRING, COMMON, "BASE-STRING", 11, 0x17EEE2C3ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIGNUM, COMMON, "BIGNUM", 6, 0x4E47969DULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT, COMMON, "BIT", 3, 0x00544945ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_AND, COMMON, "BIT-AND", 7, 0x2D98978AULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_ANDC1, COMMON, "BIT-ANDC1", 9, 0x709897BDULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_ANDC2, COMMON, "BIT-ANDC2", 9, 0x709897BEULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_EQV, COMMON, "BIT-EQV", 7, 0x2DAA9A8EULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_IOR, COMMON, "BIT-IOR", 7, 0x2DA69892ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_NAND, COMMON, "BIT-NAND", 8, 0x71A28A98ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_NOR, COMMON, "BIT-NOR", 7, 0x2DA69897ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_NOT, COMMON, "BIT-NOT", 7, 0x2DA89897ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_ORC1, COMMON, "BIT-ORC1", 8, 0x5E979B99ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_ORC2, COMMON, "BIT-ORC2", 8, 0x5F979B99ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_VECTOR, COMMON, "BIT-VECTOR", 10, 0x0197E0F1ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_VECTOR_P, COMMON, "BIT-VECTOR-P", 12, 0x51C4E0F3ULL, 0, 0, 0 }, { CONSTANT_COMMON_BIT_XOR, COMMON, "BIT-XOR", 7, 0x2DA698A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_BLOCK, COMMON, "BLOCK", 5, 0x434F4C92ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE, COMMON, "BOOLE", 5, 0x4C4F4F8CULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_1, COMMON, "BOOLE-1", 7, 0x4C807C8EULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_2, COMMON, "BOOLE-2", 7, 0x4C817C8EULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_AND, COMMON, "BOOLE-AND", 9, 0x1A907CD4ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_ANDC1, COMMON, "BOOLE-ANDC1", 11, 0x1AC1BFD6ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_ANDC2, COMMON, "BOOLE-ANDC2", 11, 0x1AC2BFD6ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_C1, COMMON, "BOOLE-C1", 8, 0x7D927C8FULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_C2, COMMON, "BOOLE-C2", 8, 0x7E927C8FULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_CLR, COMMON, "BOOLE-CLR", 9, 0x18927CE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_EQV, COMMON, "BOOLE-EQV", 9, 0x1D947CE6ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_IOR, COMMON, "BOOLE-IOR", 9, 0x1B987CE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_NAND, COMMON, "BOOLE-NAND", 10, 0x0D9DC0DFULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_NOR, COMMON, "BOOLE-NOR", 9, 0x1B9D7CE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_ORC1, COMMON, "BOOLE-ORC1", 10, 0x1E9EADD4ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_ORC2, COMMON, "BOOLE-ORC2", 10, 0x1E9EAED4ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_SET, COMMON, "BOOLE-SET", 9, 0x11A27CE4ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLE_XOR, COMMON, "BOOLE-XOR", 9, 0x1BA77CE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_BOOLEAN, COMMON, "BOOLEAN", 7, 0x4C9D908EULL, 0, 0, 0 }, { CONSTANT_COMMON_BOTH_CASE_P, COMMON, "BOTH-CASE-P", 11, 0x1BE5BFBFULL, 0, 0, 0 }, { CONSTANT_COMMON_BOUNDP, COMMON, "BOUNDP", 6, 0x4E559F8CULL, 0, 0, 0 }, { CONSTANT_COMMON_BREAK, COMMON, "BREAK", 5, 0x41455292ULL, 0, 0, 0 }, { CONSTANT_COMMON_BROADCAST_STREAM, COMMON, "BROADCAST-STREAM", 16, 0x3625083CULL, 0, 0, 0 }, { CONSTANT_COMMON_BROADCAST_STREAM_STREAMS, COMMON, "BROADCAST-STREAM-STREAMS", 24, 0x5BC69CB6ULL, 0, 0, 0 }, { CONSTANT_COMMON_BUILT_IN_CLASS, COMMON, "BUILT-IN-CLASS", 14, 0x5BDF1924ULL, 0, 0, 0 }, { CONSTANT_COMMON_BUTLAST, COMMON, "BUTLAST", 7, 0x4CA8A88AULL, 0, 0, 0 }, { CONSTANT_COMMON_BYTE, COMMON, "BYTE", 4, 0x45545946ULL, 0, 0, 0 }, { CONSTANT_COMMON_BYTE_SIZE, COMMON, "BYTE-SIZE", 9, 0x1F9DACBDULL, 0, 0, 0 }, { CONSTANT_COMMON_BYTE_POSITION, COMMON, "BYTE-POSITION", 13, 0x67ECFE13ULL, 0, 0, 0 }, { CONSTANT_COMMON_CALL_ARGUMENTS_LIMIT, COMMON, "CALL-ARGUMENTS-LIMIT", 20, 0x025A7076ULL, 0, 0, 0 }, { CONSTANT_COMMON_CALL_METHOD, COMMON, "CALL-METHOD", 11, 0x20D5DDC3ULL, 0, 0, 0 }, { CONSTANT_COMMON_CALL_NEXT_METHOD, COMMON, "CALL-NEXT-METHOD", 16, 0x2E2E0528ULL, 0, 0, 0 }, { CONSTANT_COMMON_CAR, COMMON, "CAR", 3, 0x00524146ULL, 0, 0, 0 }, { CONSTANT_COMMON_CDR, COMMON, "CDR", 3, 0x00524446ULL, 0, 0, 0 }, { CONSTANT_COMMON_CAAR, COMMON, "CAAR", 4, 0x52414147ULL, 0, 0, 0 }, { CONSTANT_COMMON_CADR, COMMON, "CADR", 4, 0x52444147ULL, 0, 0, 0 }, { CONSTANT_COMMON_CDAR, COMMON, "CDAR", 4, 0x52414447ULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDR, COMMON, "CDDR", 4, 0x52444447ULL, 0, 0, 0 }, { CONSTANT_COMMON_CAAAR, COMMON, "CAAAR", 5, 0x4141419AULL, 0, 0, 0 }, { CONSTANT_COMMON_CAADR, COMMON, "CAADR", 5, 0x4441419AULL, 0, 0, 0 }, { CONSTANT_COMMON_CADAR, COMMON, "CADAR", 5, 0x4144419AULL, 0, 0, 0 }, { CONSTANT_COMMON_CADDR, COMMON, "CADDR", 5, 0x4444419AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDAAR, COMMON, "CDAAR", 5, 0x4141449AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDADR, COMMON, "CDADR", 5, 0x4441449AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDAR, COMMON, "CDDAR", 5, 0x4144449AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDDR, COMMON, "CDDDR", 5, 0x4444449AULL, 0, 0, 0 }, { CONSTANT_COMMON_CAAAAR, COMMON, "CAAAAR", 6, 0x4141938AULL, 0, 0, 0 }, { CONSTANT_COMMON_CAAADR, COMMON, "CAAADR", 6, 0x4141938DULL, 0, 0, 0 }, { CONSTANT_COMMON_CAADAR, COMMON, "CAADAR", 6, 0x4441938AULL, 0, 0, 0 }, { CONSTANT_COMMON_CAADDR, COMMON, "CAADDR", 6, 0x4441938DULL, 0, 0, 0 }, { CONSTANT_COMMON_CADAAR, COMMON, "CADAAR", 6, 0x4144938AULL, 0, 0, 0 }, { CONSTANT_COMMON_CADADR, COMMON, "CADADR", 6, 0x4144938DULL, 0, 0, 0 }, { CONSTANT_COMMON_CADDAR, COMMON, "CADDAR", 6, 0x4444938AULL, 0, 0, 0 }, { CONSTANT_COMMON_CADDDR, COMMON, "CADDDR", 6, 0x4444938DULL, 0, 0, 0 }, { CONSTANT_COMMON_CDAAAR, COMMON, "CDAAAR", 6, 0x4141968AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDAADR, COMMON, "CDAADR", 6, 0x4141968DULL, 0, 0, 0 }, { CONSTANT_COMMON_CDADAR, COMMON, "CDADAR", 6, 0x4441968AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDADDR, COMMON, "CDADDR", 6, 0x4441968DULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDAAR, COMMON, "CDDAAR", 6, 0x4144968AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDADR, COMMON, "CDDADR", 6, 0x4144968DULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDDAR, COMMON, "CDDDAR", 6, 0x4444968AULL, 0, 0, 0 }, { CONSTANT_COMMON_CDDDDR, COMMON, "CDDDDR", 6, 0x4444968DULL, 0, 0, 0 }, { CONSTANT_COMMON_CASE, COMMON, "CASE", 4, 0x45534147ULL, 0, 0, 0 }, { CONSTANT_COMMON_CATCH, COMMON, "CATCH", 5, 0x43544190ULL, 0, 0, 0 }, { CONSTANT_COMMON_CCASE, COMMON, "CCASE", 5, 0x5341438DULL, 0, 0, 0 }, { CONSTANT_COMMON_CEILING, COMMON, "CEILING", 7, 0x4C909393ULL, 0, 0, 0 }, { CONSTANT_COMMON_CELL_ERROR, COMMON, "CELL-ERROR", 10, 0x1E9EDCC9ULL, 0, 0, 0 }, { CONSTANT_COMMON_CELL_ERROR_NAME, COMMON, "CELL-ERROR-NAME", 15, 0x6D112A0FULL, 0, 0, 0 }, { CONSTANT_COMMON_CERROR, COMMON, "CERROR", 6, 0x52529798ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR, COMMON, "CHAR", 4, 0x52414847ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHARACTER, COMMON, "CHARACTER", 9, 0x17958BDFULL, 0, 0, 0 }, { CONSTANT_COMMON_CHARACTERP, COMMON, "CHARACTERP", 10, 0x1795DBE0ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_EQL, COMMON, "CHAR=", 5, 0x52414885ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_NOT_EQL, COMMON, "CHAR/=", 6, 0x52418578ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_LESS, COMMON, "CHAR<", 5, 0x52414884ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_GREATER, COMMON, "CHAR>", 5, 0x52414886ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_LESS_EQUAL, COMMON, "CHAR<=", 6, 0x52418585ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_GREATER_EQUAL, COMMON, "CHAR>=", 6, 0x52418587ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_CODE, COMMON, "CHAR-CODE", 9, 0x16908BBEULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_CODE_LIMIT, COMMON, "CHAR-CODE-LIMIT", 15, 0x60310211ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_DOWNCASE, COMMON, "CHAR-DOWNCASE", 13, 0x7CD1D010ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_EQUAL, COMMON, "CHAR-EQUAL", 10, 0x2792D9BBULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_GREATERP, COMMON, "CHAR-GREATERP", 13, 0x69D8E40EULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_INT, COMMON, "CHAR-INT", 8, 0x268F9178ULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_LESSP, COMMON, "CHAR-LESSP", 10, 0x2586E4CDULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_NAME, COMMON, "CHAR-NAME", 9, 0x1F8296BEULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_NOT_EQUAL, COMMON, "CHAR-NOT-EQUAL", 14, 0x7BE227ECULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_NOT_GREATERP, COMMON, "CHAR-NOT-GREATERP", 17, 0x3E28323FULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_NOT_LESSP, COMMON, "CHAR-NOT-LESSP", 14, 0x79D632FEULL, 0, 0, 0 }, { CONSTANT_COMMON_CHAR_UPCASE, COMMON, "CHAR-UPCASE", 11, 0x15D6F0BCULL, 0, 0, 0 }, { CONSTANT_COMMON_CHECK_TYPE, COMMON, "CHECK-TYPE", 10, 0x1C99BAE8ULL, 0, 0, 0 }, { CONSTANT_COMMON_CIS, COMMON, "CIS", 3, 0x00534946ULL, 0, 0, 0 }, { CONSTANT_COMMON_CLASS, COMMON, "CLASS", 5, 0x53414C9BULL, 0, 0, 0 }, { CONSTANT_COMMON_CLASS_OF, COMMON, "CLASS-OF", 8, 0x1990799EULL, 0, 0, 0 }, { CONSTANT_COMMON_CLEAR_INPUT, COMMON, "CLEAR-INPUT", 11, 0x0FE2CEF0ULL, 0, 0, 0 }, { CONSTANT_COMMON_CLEAR_OUTPUT, COMMON, "CLEAR-OUTPUT", 12, 0x6AE9C9F5ULL, 0, 0, 0 }, { CONSTANT_COMMON_CLOSE, COMMON, "CLOSE", 5, 0x534F4C8DULL, 0, 0, 0 }, { CONSTANT_COMMON_CLRHASH, COMMON, "CLRHASH", 7, 0x489A9F8BULL, 0, 0, 0 }, { CONSTANT_COMMON_CODE_CHAR, COMMON, "CODE-CHAR", 9, 0x068C92CBULL, 0, 0, 0 }, { CONSTANT_COMMON_COERCE, COMMON, "COERCE", 6, 0x5245948CULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILATION_SPEED, COMMON, "COMPILATION-SPEED", 17, 0x17223B7DULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILE, COMMON, "COMPILE", 7, 0x50929B93ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILED_FUNCTION, COMMON, "COMPILED-FUNCTION", 17, 0x3231365BULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILED_FUNCTION_P, COMMON, "COMPILED-FUNCTION-P", 19, 0x3281635DULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILER_MACRO, COMMON, "COMPILER-MACRO", 14, 0x65D43819ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILER_MACRO_FUNCTION, COMMON, "COMPILER-MACRO-FUNCTION", 23, 0x0092D5C0ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPLEMENT, COMMON, "COMPLEMENT", 10, 0x159AE8E7ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPLEX, COMMON, "COMPLEX", 7, 0x50A59496ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPLEXP, COMMON, "COMPLEXP", 8, 0x20A59497ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPUTE_APPLICABLE_METHODS, COMMON, "COMPUTE-APPLICABLE-METHODS", 26, 0x289A2411ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPUTE_RESTARTS, COMMON, "COMPUTE-RESTARTS", 16, 0x253A3B3BULL, 0, 0, 0 }, { CONSTANT_COMMON_CONCATENATE, COMMON, "CONCATENATE", 11, 0x11D8F7D0ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONCATENATED_STREAM, COMMON, "CONCATENATED-STREAM", 19, 0x287A8C4AULL, 0, 0, 0 }, { CONSTANT_COMMON_CONCATENATED_STREAM_STREAMS, COMMON, "CONCATENATED-STREAM-STREAMS", 27, 0x1B202DE6ULL, 0, 0, 0 }, { CONSTANT_COMMON_COND, COMMON, "COND", 4, 0x444E4F47ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONDITION, COMMON, "CONDITION", 9, 0x1397A3E3ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONJUGATE, COMMON, "CONJUGATE", 9, 0x1E8F96E6ULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILE_FILE, COMMON, "COMPILE-FILE", 12, 0x42DEE4DEULL, 0, 0, 0 }, { CONSTANT_COMMON_COMPILE_FILE_PATHNAME, COMMON, "COMPILE-FILE-PATHNAME", 21, 0x646183A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONS, COMMON, "CONS", 4, 0x534E4F47ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONSP, COMMON, "CONSP", 5, 0x534E4F98ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONSTANTLY, COMMON, "CONSTANTLY", 10, 0x279CE9EDULL, 0, 0, 0 }, { CONSTANT_COMMON_CONSTANTP, COMMON, "CONSTANTP", 9, 0x279C90F0ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONTINUE, COMMON, "CONTINUE", 8, 0x19A39D94ULL, 0, 0, 0 }, { CONSTANT_COMMON_CONTROL_ERROR, COMMON, "CONTROL-ERROR", 13, 0x50ECF139ULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_ALIST, COMMON, "COPY-ALIST", 10, 0x229CE4CDULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_LIST, COMMON, "COPY-LIST", 9, 0x2C999BCDULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_PPRINT_DISPATCH, COMMON, "COPY-PPRINT-DISPATCH", 20, 0x718B8B52ULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_READTABLE, COMMON, "COPY-READTABLE", 14, 0x5CD73B0EULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_SEQ, COMMON, "COPY-SEQ", 8, 0x2A95A278ULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_STRUCTURE, COMMON, "COPY-STRUCTURE", 14, 0x00F92B25ULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_SYMBOL, COMMON, "COPY-SYMBOL", 11, 0x26F5F1BDULL, 0, 0, 0 }, { CONSTANT_COMMON_COPY_TREE, COMMON, "COPY-TREE", 9, 0x1EA2A3BEULL, 0, 0, 0 }, { CONSTANT_COMMON_COS, COMMON, "COS", 3, 0x00534F46ULL, 0, 0, 0 }, { CONSTANT_COMMON_COSH, COMMON, "COSH", 4, 0x48534F47ULL, 0, 0, 0 }, { CONSTANT_COMMON_COUNT, COMMON, "COUNT", 5, 0x4E554F9CULL, 0, 0, 0 }, { CONSTANT_COMMON_COUNT_IF, COMMON, "COUNT-IF", 8, 0x149E7C9FULL, 0, 0, 0 }, { CONSTANT_COMMON_COUNT_IF_NOT, COMMON, "COUNT-IF-NOT", 12, 0x68EDCAD0ULL, 0, 0, 0 }, { CONSTANT_COMMON_CTYPECASE, COMMON, "CTYPECASE", 9, 0x239A97D6ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEBUG, COMMON, "DEBUG", 5, 0x55424590ULL, 0, 0, 0 }, { CONSTANT_COMMON_DECF, COMMON, "DECF", 4, 0x46434548ULL, 0, 0, 0 }, { CONSTANT_COMMON_DECLARATION, COMMON, "DECLARATION", 11, 0x20D2E6D9ULL, 0, 0, 0 }, { CONSTANT_COMMON_DECLARE, COMMON, "DECLARE", 7, 0x4C88978CULL, 0, 0, 0 }, { CONSTANT_COMMON_DECLAIM, COMMON, "DECLAIM", 7, 0x4C908E8CULL, 0, 0, 0 }, { CONSTANT_COMMON_DECODE_FLOAT, COMMON, "DECODE-FLOAT", 12, 0x69B1D9E0ULL, 0, 0, 0 }, { CONSTANT_COMMON_DECODE_UNIVERSAL_TIME, COMMON, "DECODE-UNIVERSAL-TIME", 21, 0x03517BAFULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFCLASS, COMMON, "DEFCLASS", 8, 0x16998698ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFCONSTANT, COMMON, "DEFCONSTANT", 11, 0x17EDE1DFULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFGENERIC, COMMON, "DEFGENERIC", 10, 0x198BD6DCULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFINE_COMPILER_MACRO, COMMON, "DEFINE-COMPILER-MACRO", 21, 0x55595EDEULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFINE_CONDITION, COMMON, "DEFINE-CONDITION", 16, 0x24072245ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFINE_METHOD_COMBINATION, COMMON, "DEFINE-METHOD-COMBINATION", 25, 0x5291A310ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFINE_MODIFY_MACRO, COMMON, "DEFINE-MODIFY-MACRO", 19, 0x1E594E90ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFINE_SETF_EXPANDER, COMMON, "DEFINE-SETF-EXPANDER", 20, 0x5D4F7B7EULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFINE_SYMBOL_MACRO, COMMON, "DEFINE-SYMBOL-MACRO", 19, 0x2D52578DULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFMACRO, COMMON, "DEFMACRO", 8, 0x1C98888DULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFMETHOD, COMMON, "DEFMETHOD", 9, 0x1C8E99D6ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFPACKAGE, COMMON, "DEFPACKAGE", 10, 0x1191CDD6ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFPARAMETER, COMMON, "DEFPARAMETER", 12, 0x6FCCEBD6ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFSETF, COMMON, "DEFSETF", 7, 0x538C9990ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFSTRUCT, COMMON, "DEFSTRUCT", 9, 0x169B97F5ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFTYPE, COMMON, "DEFTYPE", 7, 0x548B95A4ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFUN, COMMON, "DEFUN", 5, 0x55464597ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEFVAR, COMMON, "DEFVAR", 6, 0x5646978BULL, 0, 0, 0 }, { CONSTANT_COMMON_DELETE, COMMON, "DELETE", 6, 0x454C8A9EULL, 0, 0, 0 }, { CONSTANT_COMMON_DELETE_DUPLICATES, COMMON, "DELETE-DUPLICATES", 17, 0x181A1C94ULL, 0, 0, 0 }, { CONSTANT_COMMON_DELETE_FILE, COMMON, "DELETE-FILE", 11, 0x0BBED6ECULL, 0, 0, 0 }, { CONSTANT_COMMON_DELETE_IF, COMMON, "DELETE-IF", 9, 0x0E798AE7ULL, 0, 0, 0 }, { CONSTANT_COMMON_DELETE_IF_NOT, COMMON, "DELETE-IF-NOT", 13, 0x5DC7B83FULL, 0, 0, 0 }, { CONSTANT_COMMON_DELETE_PACKAGE, COMMON, "DELETE-PACKAGE", 14, 0x56C5132EULL, 0, 0, 0 }, { CONSTANT_COMMON_DENOMINATOR, COMMON, "DENOMINATOR", 11, 0x10EEDDF0ULL, 0, 0, 0 }, { CONSTANT_COMMON_DEPOSIT_FIELD, COMMON, "DEPOSIT-FIELD", 13, 0x48E9D82EULL, 0, 0, 0 }, { CONSTANT_COMMON_DESCRIBE, COMMON, "DESCRIBE", 8, 0x08958E9EULL, 0, 0, 0 }, { CONSTANT_COMMON_DESCRIBE_OBJECT, COMMON, "DESCRIBE-OBJECT", 15, 0x532C2117ULL, 0, 0, 0 }, { CONSTANT_COMMON_DESTRUCTURING_BIND, COMMON, "DESTRUCTURING-BIND", 18, 0x40225E92ULL, 0, 0, 0 }, { CONSTANT_COMMON_DIGIT_CHAR, COMMON, "DIGIT-CHAR", 10, 0x118AC8E3ULL, 0, 0, 0 }, { CONSTANT_COMMON_DIGIT_CHAR_P, COMMON, "DIGIT-CHAR-P", 12, 0x61B7C8E5ULL, 0, 0, 0 }, { CONSTANT_COMMON_DIRECTORY, COMMON, "DIRECTORY", 9, 0x17A19DE9ULL, 0, 0, 0 }, { CONSTANT_COMMON_DIRECTORY_NAMESTRING, COMMON, "DIRECTORY-NAMESTRING", 20, 0x74915993ULL, 0, 0, 0 }, { CONSTANT_COMMON_DISASSEMBLE, COMMON, "DISASSEMBLE", 11, 0x0EDDE8E4ULL, 0, 0, 0 }, { CONSTANT_COMMON_DIVISION_BY_ZERO, COMMON, "DIVISION-BY-ZERO", 16, 0x14511A2EULL, 0, 0, 0 }, { CONSTANT_COMMON_DO, COMMON, "DO", 2, 0x00004F46ULL, 0, 0, 0 }, { CONSTANT_COMMON_DOA, COMMON, "DO*", 3, 0x002A4F47ULL, 0, 0, 0 }, { CONSTANT_COMMON_DOCUMENTATION, COMMON, "DOCUMENTATION", 13, 0x78DAE92DULL, 0, 0, 0 }, { CONSTANT_COMMON_DOLIST, COMMON, "DOLIST", 6, 0x494CA39DULL, 0, 0, 0 }, { CONSTANT_COMMON_DOTIMES, COMMON, "DOTIMES", 7, 0x49A79498ULL, 0, 0, 0 }, { CONSTANT_COMMON_DOUBLE_FLOAT, COMMON, "DOUBLE-FLOAT", 12, 0x5CC3E3E8ULL, 0, 0, 0 }, { CONSTANT_COMMON_DOUBLE_FLOAT_EPSILON, COMMON, "DOUBLE-FLOAT-EPSILON", 20, 0x7E637566ULL, 0, 0, 0 }, { CONSTANT_COMMON_DOUBLE_FLOAT_NEGATIVE_EPSILON, COMMON, "DOUBLE-FLOAT-NEGATIVE-EPSILON", 29, 0x19E3FD4DULL, 0, 0, 0 }, { CONSTANT_COMMON_DO_ALL_SYMBOLS, COMMON, "DO-ALL-SYMBOLS", 14, 0x639D3C43ULL, 0, 0, 0 }, { CONSTANT_COMMON_DO_EXTERNAL_SYMBOLS, COMMON, "DO-EXTERNAL-SYMBOLS", 19, 0x075F8A9FULL, 0, 0, 0 }, { CONSTANT_COMMON_DO_SYMBOLS, COMMON, "DO-SYMBOLS", 10, 0x226FEFF3ULL, 0, 0, 0 }, { CONSTANT_COMMON_DPB, COMMON, "DPB", 3, 0x00425047ULL, 0, 0, 0 }, { CONSTANT_COMMON_DRIBBLE, COMMON, "DRIBBLE", 7, 0x428E9E8DULL, 0, 0, 0 }, { CONSTANT_COMMON_DYNAMIC_EXTENT, COMMON, "DYNAMIC-EXTENT", 14, 0x33E64F32ULL, 0, 0, 0 }, { CONSTANT_COMMON_ECASE, COMMON, "ECASE", 5, 0x5341438FULL, 0, 0, 0 }, { CONSTANT_COMMON_ECHO_STREAM, COMMON, "ECHO-STREAM", 11, 0x21E9D7C2ULL, 0, 0, 0 }, { CONSTANT_COMMON_ECHO_STREAM_INPUT_STREAM, COMMON, "ECHO-STREAM-INPUT-STREAM", 24, 0x45CE98BEULL, 0, 0, 0 }, { CONSTANT_COMMON_ECHO_STREAM_OUTPUT_STREAM, COMMON, "ECHO-STREAM-OUTPUT-STREAM", 25, 0x33B0D415ULL, 0, 0, 0 }, { CONSTANT_COMMON_ED, COMMON, "ED", 2, 0x00004447ULL, 0, 0, 0 }, { CONSTANT_COMMON_EIGHTH, COMMON, "EIGHTH", 6, 0x4847919FULL, 0, 0, 0 }, { CONSTANT_COMMON_ELT, COMMON, "ELT", 3, 0x00544C48ULL, 0, 0, 0 }, { CONSTANT_COMMON_ENCODE_UNIVERSAL_TIME, COMMON, "ENCODE-UNIVERSAL-TIME", 21, 0x035184B0ULL, 0, 0, 0 }, { CONSTANT_COMMON_END_OF_FILE, COMMON, "END-OF-FILE", 11, 0x73B6E0E8ULL, 0, 0, 0 }, { CONSTANT_COMMON_ENDP, COMMON, "ENDP", 4, 0x50444E49ULL, 0, 0, 0 }, { CONSTANT_COMMON_ENOUGH_NAMESTRING, COMMON, "ENOUGH-NAMESTRING", 17, 0x450B3679ULL, 0, 0, 0 }, { CONSTANT_COMMON_ENSURE_DIRECTORIES_EXIST, COMMON, "ENSURE-DIRECTORIES-EXIST", 24, 0x3F98D1E9ULL, 0, 0, 0 }, { CONSTANT_COMMON_EQ, COMMON, "EQ", 2, 0x00005147ULL, 0, 0, 0 }, { CONSTANT_COMMON_EQL, COMMON, "EQL", 3, 0x004C5148ULL, 0, 0, 0 }, { CONSTANT_COMMON_EQUAL, COMMON, "EQUAL", 5, 0x41555196ULL, 0, 0, 0 }, { CONSTANT_COMMON_EQUALP, COMMON, "EQUALP", 6, 0x4155A197ULL, 0, 0, 0 }, { CONSTANT_COMMON_ERROR, COMMON, "ERROR", 5, 0x4F52529CULL, 0, 0, 0 }, { CONSTANT_COMMON_ETYPECASE, COMMON, "ETYPECASE", 9, 0x239A97D8ULL, 0, 0, 0 }, { CONSTANT_COMMON_EVAL, COMMON, "EVAL", 4, 0x4C415649ULL, 0, 0, 0 }, { CONSTANT_COMMON_EVAL_WHEN, COMMON, "EVAL-WHEN", 9, 0x1189ADC9ULL, 0, 0, 0 }, { CONSTANT_COMMON_EVENP, COMMON, "EVENP", 5, 0x4E45569AULL, 0, 0, 0 }, { CONSTANT_COMMON_EVERY, COMMON, "EVERY", 5, 0x524556A3ULL, 0, 0, 0 }, { CONSTANT_COMMON_EXP, COMMON, "EXP", 3, 0x00505848ULL, 0, 0, 0 }, { CONSTANT_COMMON_EXPORT, COMMON, "EXPORT", 6, 0x4F50AC9DULL, 0, 0, 0 }, { CONSTANT_COMMON_EXPT, COMMON, "EXPT", 4, 0x54505849ULL, 0, 0, 0 }, { CONSTANT_COMMON_EXTENDED_CHAR, COMMON, "EXTENDED-CHAR", 13, 0x4AE1E01FULL, 0, 0, 0 }, { CONSTANT_COMMON_FBOUNDP, COMMON, "FBOUNDP", 7, 0x559F869BULL, 0, 0, 0 }, { CONSTANT_COMMON_FCEILING, COMMON, "FCEILING", 8, 0x10938C9AULL, 0, 0, 0 }, { CONSTANT_COMMON_FDEFINITION, COMMON, "FDEFINITION", 11, 0x1ADCE1E3ULL, 0, 0, 0 }, { CONSTANT_COMMON_FFLOOR, COMMON, "FFLOOR", 6, 0x4F4C989BULL, 0, 0, 0 }, { CONSTANT_COMMON_FMAKUNBOUND, COMMON, "FMAKUNBOUND", 11, 0x1AC7E9FBULL, 0, 0, 0 }, { CONSTANT_COMMON_FIFTH, COMMON, "FIFTH", 5, 0x54464993ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_AUTHOR, COMMON, "FILE-AUTHOR", 11, 0x19F3D9C6ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_ERROR, COMMON, "FILE-ERROR", 10, 0x179EE0CCULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_ERROR_PATHNAME, COMMON, "FILE-ERROR-PATHNAME", 19, 0x36598257ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_LENGTH, COMMON, "FILE-LENGTH", 11, 0x13D9E9C5ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_POSITION, COMMON, "FILE-POSITION", 13, 0x67E4EE17ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_NAMESTRING, COMMON, "FILE-NAMESTRING", 15, 0x65293910ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_STREAM, COMMON, "FILE-STREAM", 11, 0x17EDDDC3ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_STRING_LENGTH, COMMON, "FILE-STRING-LENGTH", 18, 0x0C36786EULL, 0, 0, 0 }, { CONSTANT_COMMON_FILE_WRITE_DATE, COMMON, "FILE-WRITE-DATE", 15, 0x53113A17ULL, 0, 0, 0 }, { CONSTANT_COMMON_FILL, COMMON, "FILL", 4, 0x4C4C494AULL, 0, 0, 0 }, { CONSTANT_COMMON_FILL_POINTER, COMMON, "FILL-POINTER", 12, 0x67E0EDCDULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND, COMMON, "FIND", 4, 0x444E494AULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_ALL_SYMBOLS, COMMON, "FIND-ALL-SYMBOLS", 16, 0x31402CF2ULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_CLASS, COMMON, "FIND-CLASS", 10, 0x059ADFD0ULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_IF, COMMON, "FIND-IF", 7, 0x4494927AULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_IF_NOT, COMMON, "FIND-IF-NOT", 11, 0x71E8E1CCULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_METHOD, COMMON, "FIND-METHOD", 11, 0x18D7E5C6ULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_PACKAGE, COMMON, "FIND-PACKAGE", 12, 0x4CD6DACAULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_RESTART, COMMON, "FIND-RESTART", 12, 0x6BE5DCD3ULL, 0, 0, 0 }, { CONSTANT_COMMON_FIND_SYMBOL, COMMON, "FIND-SYMBOL", 11, 0x11F3EBC0ULL, 0, 0, 0 }, { CONSTANT_COMMON_FINISH_OUTPUT, COMMON, "FINISH-OUTPUT", 13, 0x6DCBE64FULL, 0, 0, 0 }, { CONSTANT_COMMON_FIRST, COMMON, "FIRST", 5, 0x5352499FULL, 0, 0, 0 }, { CONSTANT_COMMON_FIXNUM, COMMON, "FIXNUM", 6, 0x4E5896A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_FLET, COMMON, "FLET", 4, 0x54454C4AULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOAT, COMMON, "FLOAT", 5, 0x414F4C9FULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOATP, COMMON, "FLOATP", 6, 0x414F9CA0ULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOATING_POINT_INEXACT, COMMON, "FLOATING-POINT-INEXACT", 22, 0x5C72D3BCULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOATING_POINT_INVALID_OPERATION, COMMON, "FLOATING-POINT-INVALID-OPERATION", 32, 0x462A6370ULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOATING_POINT_OVERFLOW, COMMON, "FLOATING-POINT-OVERFLOW", 23, 0x67C3CECEULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOATING_POINT_UNDERFLOW, COMMON, "FLOATING-POINT-UNDERFLOW", 24, 0x50AECAC1ULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOAT_RADIX, COMMON, "FLOAT-RADIX", 11, 0x02F9C2E9ULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOAT_SIGN, COMMON, "FLOAT-SIGN", 10, 0x0AA2C7EBULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOAT_DIGITS, COMMON, "FLOAT-DIGITS", 12, 0x5DE7C2EDULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOAT_PRECISION, COMMON, "FLOAT-PRECISION", 15, 0x67370C37ULL, 0, 0, 0 }, { CONSTANT_COMMON_FLOOR, COMMON, "FLOOR", 5, 0x4F4F4C9DULL, 0, 0, 0 }, { CONSTANT_COMMON_FORCE_OUTPUT, COMMON, "FORCE-OUTPUT", 12, 0x6CF6CCEBULL, 0, 0, 0 }, { CONSTANT_COMMON_FORMAT, COMMON, "FORMAT", 6, 0x4D52A38DULL, 0, 0, 0 }, { CONSTANT_COMMON_FORMATTER, COMMON, "FORMATTER", 9, 0x12A6A3E2ULL, 0, 0, 0 }, { CONSTANT_COMMON_FOURTH, COMMON, "FOURTH", 6, 0x525597A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_FRESH_LINE, COMMON, "FRESH-LINE", 10, 0x1C91C4E6ULL, 0, 0, 0 }, { CONSTANT_COMMON_FROUND, COMMON, "FROUND", 6, 0x554F969AULL, 0, 0, 0 }, { CONSTANT_COMMON_FUNCALL, COMMON, "FUNCALL", 7, 0x439AA18EULL, 0, 0, 0 }, { CONSTANT_COMMON_FUNCTION, COMMON, "FUNCTION", 8, 0x119D9EA2ULL, 0, 0, 0 }, { CONSTANT_COMMON_FUNCTION_LAMBDA_EXPRESSION, COMMON, "FUNCTION-LAMBDA-EXPRESSION", 26, 0x27C428FCULL, 0, 0, 0 }, { CONSTANT_COMMON_FUNCTIONP, COMMON, "FUNCTIONP", 9, 0x119D9EF3ULL, 0, 0, 0 }, { CONSTANT_COMMON_FTYPE, COMMON, "FTYPE", 5, 0x50595490ULL, 0, 0, 0 }, { CONSTANT_COMMON_FTRUNCATE, COMMON, "FTRUNCATE", 9, 0x299397E2ULL, 0, 0, 0 }, { CONSTANT_COMMON_GCD, COMMON, "GCD", 3, 0x0044434AULL, 0, 0, 0 }, { CONSTANT_COMMON_GENERIC_FUNCTION, COMMON, "GENERIC-FUNCTION", 16, 0x042F2D43ULL, 0, 0, 0 }, { CONSTANT_COMMON_GENSYM, COMMON, "GENSYM", 6, 0x534E92A6ULL, 0, 0, 0 }, { CONSTANT_COMMON_GENTEMP, COMMON, "GENTEMP", 7, 0x549E9293ULL, 0, 0, 0 }, { CONSTANT_COMMON_GET, COMMON, "GET", 3, 0x0054454AULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_DECODED_TIME, COMMON, "GET-DECODED-TIME", 16, 0x6F291933ULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_DISPATCH_MACRO_CHARACTER, COMMON, "GET-DISPATCH-MACRO-CHARACTER", 28, 0x5FF114F2ULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_INTERNAL_REAL_TIME, COMMON, "GET-INTERNAL-REAL-TIME", 22, 0x4983A6BEULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_INTERNAL_RUN_TIME, COMMON, "GET-INTERNAL-RUN-TIME", 21, 0x5A888896ULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_MACRO_CHARACTER, COMMON, "GET-MACRO-CHARACTER", 19, 0x0B6E4B8BULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_OUTPUT_STREAM_STRING, COMMON, "GET-OUTPUT-STREAM-STRING", 24, 0x2DBCB7F6ULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_SETF_EXPANSION, COMMON, "GET-SETF-EXPANSION", 18, 0x0D546C69ULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_UNIVERSAL_TIME, COMMON, "GET-UNIVERSAL-TIME", 18, 0x0E45588CULL, 0, 0, 0 }, { CONSTANT_COMMON_GETF, COMMON, "GETF", 4, 0x4654454BULL, 0, 0, 0 }, { CONSTANT_COMMON_GETHASH, COMMON, "GETHASH", 7, 0x489C988FULL, 0, 0, 0 }, { CONSTANT_COMMON_GET_PROPERTIES, COMMON, "GET-PROPERTIES", 14, 0x46F83D2FULL, 0, 0, 0 }, { CONSTANT_COMMON_GO, COMMON, "GO", 2, 0x00004F49ULL, 0, 0, 0 }, { CONSTANT_COMMON_GRAPHIC_CHAR_P, COMMON, "GRAPHIC-CHAR-P", 14, 0x4FC6340DULL, 0, 0, 0 }, { CONSTANT_COMMON_HANDLER_BIND, COMMON, "HANDLER-BIND", 12, 0x35EECFE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_HANDLER_CASE, COMMON, "HANDLER-CASE", 12, 0x36F3C7E3ULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE, COMMON, "HASH-TABLE", 10, 0x0A94DACBULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE_COUNT, COMMON, "HASH-TABLE-COUNT", 16, 0x22103020ULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE_P, COMMON, "HASH-TABLE-P", 12, 0x5AC1DACDULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE_REHASH_SIZE, COMMON, "HASH-TABLE-REHASH-SIZE", 22, 0x795695BEULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE_REHASH_THRESHOLD, COMMON, "HASH-TABLE-REHASH-THRESHOLD", 27, 0x40EEE20AULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE_SIZE, COMMON, "HASH-TABLE-SIZE", 15, 0x5E073519ULL, 0, 0, 0 }, { CONSTANT_COMMON_HASH_TABLE_TEST, COMMON, "HASH-TABLE-TEST", 15, 0x5F162E15ULL, 0, 0, 0 }, { CONSTANT_COMMON_HOST_NAMESTRING, COMMON, "HOST-NAMESTRING", 15, 0x74303F12ULL, 0, 0, 0 }, { CONSTANT_COMMON_IDENTITY, COMMON, "IDENTITY", 8, 0x27998DA5ULL, 0, 0, 0 }, { CONSTANT_COMMON_IF, COMMON, "IF", 2, 0x0000464BULL, 0, 0, 0 }, { CONSTANT_COMMON_IGNORABLE, COMMON, "IGNORABLE", 9, 0x1B9088E9ULL, 0, 0, 0 }, { CONSTANT_COMMON_IGNORE, COMMON, "IGNORE", 6, 0x4F4E8CA1ULL, 0, 0, 0 }, { CONSTANT_COMMON_IGNORE_ERRORS, COMMON, "IGNORE-ERRORS", 13, 0x66CADF4DULL, 0, 0, 0 }, { CONSTANT_COMMON_IMAGPART, COMMON, "IMAGPART", 8, 0x1B938EA1ULL, 0, 0, 0 }, { CONSTANT_COMMON_IMPORT, COMMON, "IMPORT", 6, 0x4F50A1A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_INCF, COMMON, "INCF", 4, 0x46434E4DULL, 0, 0, 0 }, { CONSTANT_COMMON_INLINE, COMMON, "INLINE", 6, 0x494C939DULL, 0, 0, 0 }, { CONSTANT_COMMON_INPUT_STREAM_P, COMMON, "INPUT-STREAM-P", 14, 0x76E5112AULL, 0, 0, 0 }, { CONSTANT_COMMON_INSPECT, COMMON, "INSPECT", 7, 0x50A79195ULL, 0, 0, 0 }, { CONSTANT_COMMON_INTEGER, COMMON, "INTEGER", 7, 0x45A69397ULL, 0, 0, 0 }, { CONSTANT_COMMON_INTEGERP, COMMON, "INTEGERP", 8, 0x15A69398ULL, 0, 0, 0 }, { CONSTANT_COMMON_INTEGER_DECODE_FLOAT, COMMON, "INTEGER-DECODE-FLOAT", 20, 0x5C586D78ULL, 0, 0, 0 }, { CONSTANT_COMMON_INTEGER_LENGTH, COMMON, "INTEGER-LENGTH", 14, 0x39F5213EULL, 0, 0, 0 }, { CONSTANT_COMMON_INTERACTIVE_STREAM_P, COMMON, "INTERACTIVE-STREAM-P", 20, 0x5C5C878CULL, 0, 0, 0 }, { CONSTANT_COMMON_INTERN, COMMON, "INTERN", 6, 0x45549CA1ULL, 0, 0, 0 }, { CONSTANT_COMMON_INTERNAL_TIME_UNITS_PER_SECOND, COMMON, "INTERNAL-TIME-UNITS-PER-SECOND", 30, 0x571D4165ULL, 0, 0, 0 }, { CONSTANT_COMMON_INTERSECTION, COMMON, "INTERSECTION", 12, 0x56E8EAFBULL, 0, 0, 0 }, { CONSTANT_COMMON_INVALID_METHOD_ERROR, COMMON, "INVALID-METHOD-ERROR", 20, 0x4E6B7397ULL, 0, 0, 0 }, { CONSTANT_COMMON_INVOKE_DEBUGGER, COMMON, "INVOKE-DEBUGGER", 15, 0x5B2B1B2FULL, 0, 0, 0 }, { CONSTANT_COMMON_INVOKE_RESTART, COMMON, "INVOKE-RESTART", 14, 0x62D83B39ULL, 0, 0, 0 }, { CONSTANT_COMMON_INVOKE_RESTART_INTERACTIVELY, COMMON, "INVOKE-RESTART-INTERACTIVELY", 28, 0x20EB182CULL, 0, 0, 0 }, { CONSTANT_COMMON_IN_PACKAGE, COMMON, "IN-PACKAGE", 10, 0x1178D6DBULL, 0, 0, 0 }, { CONSTANT_COMMON_ISQRT, COMMON, "ISQRT", 5, 0x525153A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_KEYWORD, COMMON, "KEYWORD", 7, 0x579D97A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_KEYWORDP, COMMON, "KEYWORDP", 8, 0x279D97A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_LABELS, COMMON, "LABELS", 6, 0x4542949EULL, 0, 0, 0 }, { CONSTANT_COMMON_LAMBDA, COMMON, "LAMBDA", 6, 0x424D8296ULL, 0, 0, 0 }, { CONSTANT_COMMON_LAMBDA_LIST_KEYWORDS, COMMON, "LAMBDA-LIST-KEYWORDS", 20, 0x666C6D87ULL, 0, 0, 0 }, { CONSTANT_COMMON_LAMBDA_PARAMETERS_LIMIT, COMMON, "LAMBDA-PARAMETERS-LIMIT", 23, 0x7BA19FCDULL, 0, 0, 0 }, { CONSTANT_COMMON_LAST, COMMON, "LAST", 4, 0x54534150ULL, 0, 0, 0 }, { CONSTANT_COMMON_LCM, COMMON, "LCM", 3, 0x004D434FULL, 0, 0, 0 }, { CONSTANT_COMMON_LDB, COMMON, "LDB", 3, 0x0042444FULL, 0, 0, 0 }, { CONSTANT_COMMON_LDB_TEST, COMMON, "LDB-TEST", 8, 0x019589A8ULL, 0, 0, 0 }, { CONSTANT_COMMON_LDIFF, COMMON, "LDIFF", 5, 0x46494497ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_DOUBLE_FLOAT, COMMON, "LEAST-NEGATIVE-DOUBLE-FLOAT", 27, 0x3EEDBD3BULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_LONG_FLOAT, COMMON, "LEAST-NEGATIVE-LONG-FLOAT", 25, 0x1CA7943FULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_NORMALIZED_DOUBLE_FLOAT, COMMON, "LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT", 38, 0x1A959F05ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_NORMALIZED_LONG_FLOAT, COMMON, "LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT", 36, 0x207358DAULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_NORMALIZED_SHORT_FLOAT, COMMON, "LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT", 37, 0x6DAF612AULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_NORMALIZED_SINGLE_FLOAT, COMMON, "LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT", 38, 0x14A4A3FEULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_SHORT_FLOAT, COMMON, "LEAST-NEGATIVE-SHORT-FLOAT", 26, 0x58AFE30DULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_NEGATIVE_SINGLE_FLOAT, COMMON, "LEAST-NEGATIVE-SINGLE-FLOAT", 27, 0x4DF2B635ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_DOUBLE_FLOAT, COMMON, "LEAST-POSITIVE-DOUBLE-FLOAT", 27, 0x48EFC547ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_LONG_FLOAT, COMMON, "LEAST-POSITIVE-LONG-FLOAT", 25, 0x26A99C4BULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_NORMALIZED_DOUBLE_FLOAT, COMMON, "LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT", 38, 0x2497A711ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_NORMALIZED_LONG_FLOAT, COMMON, "LEAST-POSITIVE-NORMALIZED-LONG-FLOAT", 36, 0x2A7560E6ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_NORMALIZED_SHORT_FLOAT, COMMON, "LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT", 37, 0x77B16936ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_NORMALIZED_SINGLE_FLOAT, COMMON, "LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT", 38, 0x1EA6AC0AULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_SHORT_FLOAT, COMMON, "LEAST-POSITIVE-SHORT-FLOAT", 26, 0x62B1EB19ULL, 0, 0, 0 }, { CONSTANT_COMMON_LEAST_POSITIVE_SINGLE_FLOAT, COMMON, "LEAST-POSITIVE-SINGLE-FLOAT", 27, 0x57F4BE41ULL, 0, 0, 0 }, { CONSTANT_COMMON_LENGTH, COMMON, "LENGTH", 6, 0x474E8DA6ULL, 0, 0, 0 }, { CONSTANT_COMMON_LET, COMMON, "LET", 3, 0x0054454FULL, 0, 0, 0 }, { CONSTANT_COMMON_LETA, COMMON, "LET*", 4, 0x2A544550ULL, 0, 0, 0 }, { CONSTANT_COMMON_LISP_IMPLEMENTATION_TYPE, COMMON, "LISP-IMPLEMENTATION-TYPE", 24, 0x2CCDD4C8ULL, 0, 0, 0 }, { CONSTANT_COMMON_LISP_IMPLEMENTATION_VERSION, COMMON, "LISP-IMPLEMENTATION-VERSION", 27, 0x3B1E1016ULL, 0, 0, 0 }, { CONSTANT_COMMON_LIST, COMMON, "LIST", 4, 0x54534950ULL, 0, 0, 0 }, { CONSTANT_COMMON_LISTEN, COMMON, "LISTEN", 6, 0x54539797ULL, 0, 0, 0 }, { CONSTANT_COMMON_LISTP, COMMON, "LISTP", 5, 0x545349A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_LISTA, COMMON, "LIST*", 5, 0x5453497BULL, 0, 0, 0 }, { CONSTANT_COMMON_LIST_ALL_PACKAGES, COMMON, "LIST-ALL-PACKAGES", 17, 0x29281C55ULL, 0, 0, 0 }, { CONSTANT_COMMON_LIST_LENGTH, COMMON, "LIST-LENGTH", 11, 0x22E0E9CBULL, 0, 0, 0 }, { CONSTANT_COMMON_LOAD, COMMON, "LOAD", 4, 0x44414F50ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOAD_LOGICAL_PATHNAME_TRANSLATIONS, COMMON, "LOAD-LOGICAL-PATHNAME-TRANSLATIONS", 34, 0x6745A06EULL, 0, 0, 0 }, { CONSTANT_COMMON_LOAD_TIME_VALUE, COMMON, "LOAD-TIME-VALUE", 15, 0x53262619ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOCALLY, COMMON, "LOCALLY", 7, 0x419C9B9FULL, 0, 0, 0 }, { CONSTANT_COMMON_LOG, COMMON, "LOG", 3, 0x00474F4FULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGAND, COMMON, "LOGAND", 6, 0x414793A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGANDC1, COMMON, "LOGANDC1", 8, 0x728A93A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGANDC2, COMMON, "LOGANDC2", 8, 0x738A93A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGBITP, COMMON, "LOGBITP", 7, 0x4297A39CULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGCOUNT, COMMON, "LOGCOUNT", 8, 0x1795A4A3ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGEQV, COMMON, "LOGEQV", 6, 0x4547A5A3ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGICAL_PATHNAME, COMMON, "LOGICAL-PATHNAME", 16, 0x0435133DULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGICAL_PATHNAME_TRANSLATIONS, COMMON, "LOGICAL-PATHNAME-TRANSLATIONS", 29, 0x5523046CULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGIOR, COMMON, "LOGIOR", 6, 0x4947A1A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGNAND, COMMON, "LOGNAND", 7, 0x4E8B9D94ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGNOR, COMMON, "LOGNOR", 6, 0x4E47A1A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGNOT, COMMON, "LOGNOT", 6, 0x4E47A3A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGORC1, COMMON, "LOGORC1", 7, 0x4F7892A5ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGORC2, COMMON, "LOGORC2", 7, 0x4F7992A5ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGTEST, COMMON, "LOGTEST", 7, 0x549BA298ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOGXOR, COMMON, "LOGXOR", 6, 0x5847A1A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_LONG_FLOAT, COMMON, "LONG-FLOAT", 10, 0x169AE9C4ULL, 0, 0, 0 }, { CONSTANT_COMMON_LONG_FLOAT_EPSILON, COMMON, "LONG-FLOAT-EPSILON", 18, 0x28118B6BULL, 0, 0, 0 }, { CONSTANT_COMMON_LONG_FLOAT_NEGATIVE_EPSILON, COMMON, "LONG-FLOAT-NEGATIVE-EPSILON", 27, 0x2FF026F4ULL, 0, 0, 0 }, { CONSTANT_COMMON_LONG_SITE_NAME, COMMON, "LONG-SITE-NAME", 14, 0x5CE61519ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOOP, COMMON, "LOOP", 4, 0x504F4F50ULL, 0, 0, 0 }, { CONSTANT_COMMON_LOOP_FINISH, COMMON, "LOOP-FINISH", 11, 0x1EE0E8CDULL, 0, 0, 0 }, { CONSTANT_COMMON_LOWER_CASE_P, COMMON, "LOWER-CASE-P", 12, 0x56C7C1FDULL, 0, 0, 0 }, { CONSTANT_COMMON_MACHINE_INSTANCE, COMMON, "MACHINE-INSTANCE", 16, 0x0F1F2C30ULL, 0, 0, 0 }, { CONSTANT_COMMON_MACHINE_TYPE, COMMON, "MACHINE-TYPE", 12, 0x3AD8E8F6ULL, 0, 0, 0 }, { CONSTANT_COMMON_MACHINE_VERSION, COMMON, "MACHINE-VERSION", 15, 0x49292444ULL, 0, 0, 0 }, { CONSTANT_COMMON_MACRO_FUNCTION, COMMON, "MACRO-FUNCTION", 14, 0x70DE0047ULL, 0, 0, 0 }, { CONSTANT_COMMON_MACROEXPAND, COMMON, "MACROEXPAND", 11, 0x22DFD4E8ULL, 0, 0, 0 }, { CONSTANT_COMMON_MACROEXPAND_1, COMMON, "MACROEXPAND-1", 13, 0x4FDFD51BULL, 0, 0, 0 }, { CONSTANT_COMMON_MACROLET, COMMON, "MACROLET", 8, 0x26888DA4ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_ARRAY, COMMON, "MAKE-ARRAY", 10, 0x179DDBC5ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_BROADCAST_STREAM, COMMON, "MAKE-BROADCAST-STREAM", 21, 0x6A536EC4ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_CONDITION, COMMON, "MAKE-CONDITION", 14, 0x5CEF1C1BULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_CONCATENATED_STREAM, COMMON, "MAKE-CONCATENATED-STREAM", 24, 0x3FD779B9ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_DISPATCH_MACRO_CHARACTER, COMMON, "MAKE-DISPATCH-MACRO-CHARACTER", 29, 0x621AD248ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_ECHO_STREAM, COMMON, "MAKE-ECHO-STREAM", 16, 0x2F22F92BULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_HASH_TABLE, COMMON, "MAKE-HASH-TABLE", 15, 0x5A260313ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_INSTANCES_OBSOLETE, COMMON, "MAKE-INSTANCES-OBSOLETE", 23, 0x77A9C6B1ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_LIST, COMMON, "MAKE-LIST", 9, 0x18948DD7ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_LOAD_FORM, COMMON, "MAKE-LOAD-FORM", 14, 0x55E1081EULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_LOAD_FORM_SAVING_SLOTS, COMMON, "MAKE-LOAD-FORM-SAVING-SLOTS", 27, 0x43FDE002ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_METHOD, COMMON, "MAKE-METHOD", 11, 0x19D4DDCDULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_PACKAGE, COMMON, "MAKE-PACKAGE", 12, 0x4DD3D2D1ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_PATHNAME, COMMON, "MAKE-PATHNAME", 13, 0x66CDE014ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_RANDOM_STATE, COMMON, "MAKE-RANDOM-STATE", 17, 0x151B3767ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_SEQUENCE, COMMON, "MAKE-SEQUENCE", 13, 0x59DEDA21ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_STRING, COMMON, "MAKE-STRING", 11, 0x17E6E2CEULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_STRING_INPUT_STREAM, COMMON, "MAKE-STRING-INPUT-STREAM", 24, 0x3BCBA3CAULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_STRING_OUTPUT_STREAM, COMMON, "MAKE-STRING-OUTPUT-STREAM", 25, 0x29ADDF21ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_SYMBOL, COMMON, "MAKE-SYMBOL", 11, 0x12F0E3C7ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_SYNONYM_STREAM, COMMON, "MAKE-SYNONYM-STREAM", 19, 0x339F774EULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_TWO_WAY_STREAM, COMMON, "MAKE-TWO-WAY-STREAM", 19, 0x4085812CULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKUNBOUND, COMMON, "MAKUNBOUND", 10, 0x2A9AC7F3ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAP, COMMON, "MAP", 3, 0x00504150ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPC, COMMON, "MAPC", 4, 0x43504151ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPCAR, COMMON, "MAPCAR", 6, 0x43509394ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPCAN, COMMON, "MAPCAN", 6, 0x43508F94ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPHASH, COMMON, "MAPHASH", 7, 0x48989495ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPL, COMMON, "MAPL", 4, 0x4C504151ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPLIST, COMMON, "MAPLIST", 7, 0x4CA4949DULL, 0, 0, 0 }, { CONSTANT_COMMON_MAPCON, COMMON, "MAPCON", 6, 0x43508FA2ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAP_INTO, COMMON, "MAP-INTO", 8, 0x7CA48F9EULL, 0, 0, 0 }, { CONSTANT_COMMON_MASK_FIELD, COMMON, "MASK-FIELD", 10, 0x109CCBD0ULL, 0, 0, 0 }, { CONSTANT_COMMON_MAX, COMMON, "MAX", 3, 0x00584150ULL, 0, 0, 0 }, { CONSTANT_COMMON_MERGE, COMMON, "MERGE", 5, 0x47524597ULL, 0, 0, 0 }, { CONSTANT_COMMON_METHOD, COMMON, "METHOD", 6, 0x485489A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_METHOD_COMBINATION_ERROR, COMMON, "METHOD-COMBINATION-ERROR", 24, 0x3594B8F2ULL, 0, 0, 0 }, { CONSTANT_COMMON_MEMBER, COMMON, "MEMBER", 6, 0x424D9798ULL, 0, 0, 0 }, { CONSTANT_COMMON_MEMBER_IF, COMMON, "MEMBER-IF", 9, 0x0B7A97E1ULL, 0, 0, 0 }, { CONSTANT_COMMON_MEMBER_IF_NOT, COMMON, "MEMBER-IF-NOT", 13, 0x5AC8C539ULL, 0, 0, 0 }, { CONSTANT_COMMON_MERGE_PATHNAMES, COMMON, "MERGE-PATHNAMES", 15, 0x4A440042ULL, 0, 0, 0 }, { CONSTANT_COMMON_METHOD_COMBINATION, COMMON, "METHOD-COMBINATION", 18, 0x1E18669AULL, 0, 0, 0 }, { CONSTANT_COMMON_MIN, COMMON, "MIN", 3, 0x004E4950ULL, 0, 0, 0 }, { CONSTANT_COMMON_MINUSP, COMMON, "MINUSP", 6, 0x554E99A6ULL, 0, 0, 0 }, { CONSTANT_COMMON_MISMATCH, COMMON, "MISMATCH", 8, 0x15969D96ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOD, COMMON, "MOD", 3, 0x00444F50ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_NEGATIVE_DOUBLE_FLOAT, COMMON, "MOST-NEGATIVE-DOUBLE-FLOAT", 26, 0x55BEFBDDULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_NEGATIVE_FIXNUM, COMMON, "MOST-NEGATIVE-FIXNUM", 20, 0x087D6D6CULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_NEGATIVE_LONG_FLOAT, COMMON, "MOST-NEGATIVE-LONG-FLOAT", 24, 0x5B9CB5B2ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_NEGATIVE_SHORT_FLOAT, COMMON, "MOST-NEGATIVE-SHORT-FLOAT", 25, 0x28D8BE02ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_NEGATIVE_SINGLE_FLOAT, COMMON, "MOST-NEGATIVE-SINGLE-FLOAT", 26, 0x4FCE00D6ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_POSITIVE_DOUBLE_FLOAT, COMMON, "MOST-POSITIVE-DOUBLE-FLOAT", 26, 0x61C8FDE5ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_POSITIVE_FIXNUM, COMMON, "MOST-POSITIVE-FIXNUM", 20, 0x14876F74ULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_POSITIVE_LONG_FLOAT, COMMON, "MOST-POSITIVE-LONG-FLOAT", 24, 0x67A6B7BAULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_POSITIVE_SHORT_FLOAT, COMMON, "MOST-POSITIVE-SHORT-FLOAT", 25, 0x34E2C00AULL, 0, 0, 0 }, { CONSTANT_COMMON_MOST_POSITIVE_SINGLE_FLOAT, COMMON, "MOST-POSITIVE-SINGLE-FLOAT", 26, 0x5BD802DEULL, 0, 0, 0 }, { CONSTANT_COMMON_MUFFLE_WARNING, COMMON, "MUFFLE-WARNING", 14, 0x66C23436ULL, 0, 0, 0 }, { CONSTANT_COMMON_MULTIPLE_VALUE_BIND, COMMON, "MULTIPLE-VALUE-BIND", 19, 0x284B8F74ULL, 0, 0, 0 }, { CONSTANT_COMMON_MULTIPLE_VALUE_CALL, COMMON, "MULTIPLE-VALUE-CALL", 19, 0x29538D6CULL, 0, 0, 0 }, { CONSTANT_COMMON_MULTIPLE_VALUE_LIST, COMMON, "MULTIPLE-VALUE-LIST", 19, 0x325B9474ULL, 0, 0, 0 }, { CONSTANT_COMMON_MULTIPLE_VALUE_PROG1, COMMON, "MULTIPLE-VALUE-PROG1", 20, 0x674E907EULL, 0, 0, 0 }, { CONSTANT_COMMON_MULTIPLE_VALUE_SETQ, COMMON, "MULTIPLE-VALUE-SETQ", 19, 0x39589570ULL, 0, 0, 0 }, { CONSTANT_COMMON_MULTIPLE_VALUES_LIMIT, COMMON, "MULTIPLE-VALUES-LIMIT", 21, 0x5C7A8ACDULL, 0, 0, 0 }, { CONSTANT_COMMON_NAME_CHAR, COMMON, "NAME-CHAR", 9, 0x069584D6ULL, 0, 0, 0 }, { CONSTANT_COMMON_NAMESTRING, COMMON, "NAMESTRING", 10, 0x0E9FDCF9ULL, 0, 0, 0 }, { CONSTANT_COMMON_NBUTLAST, COMMON, "NBUTLAST", 8, 0x28A883A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_NCONC, COMMON, "NCONC", 5, 0x4E4F4396ULL, 0, 0, 0 }, { CONSTANT_COMMON_NEXT_METHOD_P, COMMON, "NEXT-METHOD-P", 13, 0x55E1E220ULL, 0, 0, 0 }, { CONSTANT_COMMON_NINTH, COMMON, "NINTH", 5, 0x544E499BULL, 0, 0, 0 }, { CONSTANT_COMMON_NINTERSECTION, COMMON, "NINTERSECTION", 13, 0x68EAF031ULL, 0, 0, 0 }, { CONSTANT_COMMON_NO_APPLICABLE_METHOD, COMMON, "NO-APPLICABLE-METHOD", 20, 0x6058568EULL, 0, 0, 0 }, { CONSTANT_COMMON_NO_NEXT_METHOD, COMMON, "NO-NEXT-METHOD", 14, 0x43D6313DULL, 0, 0, 0 }, { CONSTANT_COMMON_NOT, COMMON, "NOT", 3, 0x00544F51ULL, 0, 0, 0 }, { CONSTANT_COMMON_NOTANY, COMMON, "NOTANY", 6, 0x4154A8A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_NOTEVERY, COMMON, "NOTEVERY", 8, 0x1EA694ACULL, 0, 0, 0 }, { CONSTANT_COMMON_NOTINLINE, COMMON, "NOTINLINE", 9, 0x179D9BEAULL, 0, 0, 0 }, { CONSTANT_COMMON_NRECONC, COMMON, "NRECONC", 7, 0x4388A0A4ULL, 0, 0, 0 }, { CONSTANT_COMMON_NREVERSE, COMMON, "NREVERSE", 8, 0x1B98A49BULL, 0, 0, 0 }, { CONSTANT_COMMON_NSET_DIFFERENCE, COMMON, "NSET-DIFFERENCE", 15, 0x6026201EULL, 0, 0, 0 }, { CONSTANT_COMMON_NSET_EXCLUSIVE_OR, COMMON, "NSET-EXCLUSIVE-OR", 17, 0x301E3380ULL, 0, 0, 0 }, { CONSTANT_COMMON_NSTRING_CAPITALIZE, COMMON, "NSTRING-CAPITALIZE", 18, 0x1238699AULL, 0, 0, 0 }, { CONSTANT_COMMON_NSTRING_DOWNCASE, COMMON, "NSTRING-DOWNCASE", 16, 0x1346322EULL, 0, 0, 0 }, { CONSTANT_COMMON_NSTRING_UPCASE, COMMON, "NSTRING-UPCASE", 14, 0x40DF374DULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBLIS, COMMON, "NSUBLIS", 7, 0x42A89CA1ULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBST, COMMON, "NSUBST", 6, 0x4255A7A7ULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBSTITUTE, COMMON, "NSUBSTITUTE", 11, 0x16E3FC01ULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBSTITUTE_IF, COMMON, "NSUBSTITUTE-IF", 14, 0x43E4424DULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBSTITUTE_IF_NOT, COMMON, "NSUBSTITUTE-IF-NOT", 18, 0x121196A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBST_IF, COMMON, "NSUBST-IF", 9, 0x0B82A7F0ULL, 0, 0, 0 }, { CONSTANT_COMMON_NSUBST_IF_NOT, COMMON, "NSUBST-IF-NOT", 13, 0x5AD0D548ULL, 0, 0, 0 }, { CONSTANT_COMMON_NTH, COMMON, "NTH", 3, 0x00485451ULL, 0, 0, 0 }, { CONSTANT_COMMON_NTH_VALUE, COMMON, "NTH-VALUE", 9, 0x029495F2ULL, 0, 0, 0 }, { CONSTANT_COMMON_NTHCDR, COMMON, "NTHCDR", 6, 0x4348A698ULL, 0, 0, 0 }, { CONSTANT_COMMON_NULL, COMMON, "NULL", 4, 0x4C4C5552ULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBER, COMMON, "NUMBER", 6, 0x424DA799ULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMBERP, COMMON, "NUMBERP", 7, 0x429DA79AULL, 0, 0, 0 }, { CONSTANT_COMMON_NUMERATOR, COMMON, "NUMERATOR", 9, 0x14A196FBULL, 0, 0, 0 }, { CONSTANT_COMMON_NUNION, COMMON, "NUNION", 6, 0x494EA3A3ULL, 0, 0, 0 }, { CONSTANT_COMMON_ODDP, COMMON, "ODDP", 4, 0x50444453ULL, 0, 0, 0 }, { CONSTANT_COMMON_OTHERWISE, COMMON, "OTHERWISE", 9, 0x1891ABEFULL, 0, 0, 0 }, { CONSTANT_COMMON_OPEN, COMMON, "OPEN", 4, 0x4E455053ULL, 0, 0, 0 }, { CONSTANT_COMMON_OPEN_STREAM_P, COMMON, "OPEN-STREAM-P", 13, 0x4DE6E51EULL, 0, 0, 0 }, { CONSTANT_COMMON_OPTIMIZE, COMMON, "OPTIMIZE", 8, 0x0EAE99A4ULL, 0, 0, 0 }, { CONSTANT_COMMON_OR, COMMON, "OR", 2, 0x00005251ULL, 0, 0, 0 }, { CONSTANT_COMMON_OUTPUT_STREAM_P, COMMON, "OUTPUT-STREAM-P", 15, 0x65172954ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE, COMMON, "PACKAGE", 7, 0x4B888898ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGEP, COMMON, "PACKAGEP", 8, 0x1B888899ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_ERROR, COMMON, "PACKAGE-ERROR", 13, 0x47DADB35ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_ERROR_PACKAGE, COMMON, "PACKAGE-ERROR-PACKAGE", 21, 0x506C53C5ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_NAME, COMMON, "PACKAGE-NAME", 12, 0x3DD5C9EBULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_NICKNAMES, COMMON, "PACKAGE-NICKNAMES", 17, 0x09191391ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_SHADOWING_SYMBOLS, COMMON, "PACKAGE-SHADOWING-SYMBOLS", 25, 0x30B59833ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_USE_LIST, COMMON, "PACKAGE-USE-LIST", 16, 0x7A212542ULL, 0, 0, 0 }, { CONSTANT_COMMON_PACKAGE_USED_BY_LIST, COMMON, "PACKAGE-USED-BY-LIST", 20, 0x3E7A6773ULL, 0, 0, 0 }, { CONSTANT_COMMON_PAIRLIS, COMMON, "PAIRLIS", 7, 0x529C8AA3ULL, 0, 0, 0 }, { CONSTANT_COMMON_PARSE_ERROR, COMMON, "PARSE-ERROR", 11, 0x25E9BDF2ULL, 0, 0, 0 }, { CONSTANT_COMMON_PARSE_INTEGER, COMMON, "PARSE-INTEGER", 13, 0x66E2B448ULL, 0, 0, 0 }, { CONSTANT_COMMON_PARSE_NAMESTRING, COMMON, "PARSE-NAMESTRING", 16, 0x3041FD44ULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME, COMMON, "PATHNAME", 8, 0x0DA182A6ULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_HOST, COMMON, "PATHNAME-HOST", 13, 0x60F0CB2CULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_DEVICE, COMMON, "PATHNAME-DEVICE", 15, 0x642C0A23ULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_DIRECTORY, COMMON, "PATHNAME-DIRECTORY", 18, 0x2F3F6374ULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_NAME, COMMON, "PATHNAME-NAME", 13, 0x5AE2D11DULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_MATCH_P, COMMON, "PATHNAME-MATCH-P", 16, 0x3210181EULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_TYPE, COMMON, "PATHNAME-TYPE", 13, 0x5DFAD71DULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAME_VERSION, COMMON, "PATHNAME-VERSION", 16, 0x2E36222EULL, 0, 0, 0 }, { CONSTANT_COMMON_PATHNAMEP, COMMON, "PATHNAMEP", 9, 0x0DA182F7ULL, 0, 0, 0 }, { CONSTANT_COMMON_PEEK_CHAR, COMMON, "PEEK-CHAR", 9, 0x0C8D88D8ULL, 0, 0, 0 }, { CONSTANT_COMMON_PHASE, COMMON, "PHASE", 5, 0x5341489AULL, 0, 0, 0 }, { CONSTANT_COMMON_PI, COMMON, "PI", 2, 0x00004952ULL, 0, 0, 0 }, { CONSTANT_COMMON_PLUSP, COMMON, "PLUSP", 5, 0x53554CA5ULL, 0, 0, 0 }, { CONSTANT_COMMON_POP, COMMON, "POP", 3, 0x00504F53ULL, 0, 0, 0 }, { CONSTANT_COMMON_POSITION, COMMON, "POSITION", 8, 0x17A298ACULL, 0, 0, 0 }, { CONSTANT_COMMON_POSITION_IF, COMMON, "POSITION-IF", 11, 0x17E8E1DCULL, 0, 0, 0 }, { CONSTANT_COMMON_POSITION_IF_NOT, COMMON, "POSITION-IF-NOT", 15, 0x453D312EULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT, COMMON, "PPRINT", 6, 0x4952A4A4ULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_DISPATCH, COMMON, "PPRINT-DISPATCH", 15, 0x4F183B4AULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_EXIT_IF_LIST_EXHAUSTED, COMMON, "PPRINT-EXIT-IF-LIST-EXHAUSTED", 29, 0x3BF23383ULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_FILL, COMMON, "PPRINT-FILL", 11, 0x0FCBF0F2ULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_INDENT, COMMON, "PPRINT-INDENT", 13, 0x60C4E94DULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_LINEAR, COMMON, "PPRINT-LINEAR", 13, 0x56C4F346ULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_LOGICAL_BLOCK, COMMON, "PPRINT-LOGICAL-BLOCK", 20, 0x6639878EULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_NEWLINE, COMMON, "PPRINT-NEWLINE", 14, 0x60CC413FULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_POP, COMMON, "PPRINT-POP", 10, 0x197FF4F7ULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_TAB, COMMON, "PPRINT-TAB", 10, 0x1D7FE6E9ULL, 0, 0, 0 }, { CONSTANT_COMMON_PPRINT_TABULAR, COMMON, "PPRINT-TABULAR", 14, 0x69D5392EULL, 0, 0, 0 }, { CONSTANT_COMMON_PRIN1, COMMON, "PRIN1", 5, 0x4E495286ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRIN1_TO_STRING, COMMON, "PRIN1-TO-STRING", 15, 0x70392106ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINC, COMMON, "PRINC", 5, 0x4E495298ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINC_TO_STRING, COMMON, "PRINC-TO-STRING", 15, 0x70392118ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINT, COMMON, "PRINT", 5, 0x4E4952A9ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINT_NOT_READABLE, COMMON, "PRINT-NOT-READABLE", 18, 0x252B3697ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINT_NOT_READABLE_OBJECT, COMMON, "PRINT-NOT-READABLE-OBJECT", 25, 0x379D8134ULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINT_OBJECT, COMMON, "PRINT-OBJECT", 12, 0x64DBC4FAULL, 0, 0, 0 }, { CONSTANT_COMMON_PRINT_UNREADABLE_OBJECT, COMMON, "PRINT-UNREADABLE-OBJECT", 23, 0x70C299C0ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROBE_FILE, COMMON, "PROBE-FILE", 10, 0x0B95C4EBULL, 0, 0, 0 }, { CONSTANT_COMMON_PROCLAIM, COMMON, "PROCLAIM", 8, 0x109893A4ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROG, COMMON, "PROG", 4, 0x474F5254ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROG1, COMMON, "PROG1", 5, 0x474F5286ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROG2, COMMON, "PROG2", 5, 0x474F5287ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROGA, COMMON, "PROG*", 5, 0x474F527FULL, 0, 0, 0 }, { CONSTANT_COMMON_PROGN, COMMON, "PROGN", 5, 0x474F52A3ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROGV, COMMON, "PROGV", 5, 0x474F52ABULL, 0, 0, 0 }, { CONSTANT_COMMON_PROGRAM_ERROR, COMMON, "PROGRAM-ERROR", 13, 0x43EEE646ULL, 0, 0, 0 }, { CONSTANT_COMMON_PROVIDE, COMMON, "PROVIDE", 7, 0x569496A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_PSETF, COMMON, "PSETF", 5, 0x5445539BULL, 0, 0, 0 }, { CONSTANT_COMMON_PSETQ, COMMON, "PSETQ", 5, 0x544553A6ULL, 0, 0, 0 }, { CONSTANT_COMMON_PUSH, COMMON, "PUSH", 4, 0x48535554ULL, 0, 0, 0 }, { CONSTANT_COMMON_PUSHNEW, COMMON, "PUSHNEW", 7, 0x48AA9AA5ULL, 0, 0, 0 }, { CONSTANT_COMMON_QUOTE, COMMON, "QUOTE", 5, 0x544F559BULL, 0, 0, 0 }, { CONSTANT_COMMON_RANDOM, COMMON, "RANDOM", 6, 0x444E8EA7ULL, 0, 0, 0 }, { CONSTANT_COMMON_RANDOM_STATE, COMMON, "RANDOM-STATE", 12, 0x5CCFD001ULL, 0, 0, 0 }, { CONSTANT_COMMON_RANDOM_STATE_P, COMMON, "RANDOM-STATE-P", 14, 0x5CD02030ULL, 0, 0, 0 }, { CONSTANT_COMMON_RASSOC, COMMON, "RASSOC", 6, 0x535384A7ULL, 0, 0, 0 }, { CONSTANT_COMMON_RASSOC_IF, COMMON, "RASSOC-IF", 9, 0x1C8084F0ULL, 0, 0, 0 }, { CONSTANT_COMMON_RASSOC_IF_NOT, COMMON, "RASSOC-IF-NOT", 13, 0x6BCEB248ULL, 0, 0, 0 }, { CONSTANT_COMMON_RATIO, COMMON, "RATIO", 5, 0x495441A6ULL, 0, 0, 0 }, { CONSTANT_COMMON_RATIONAL, COMMON, "RATIONAL", 8, 0x15958FA9ULL, 0, 0, 0 }, { CONSTANT_COMMON_RATIONALIZE, COMMON, "RATIONALIZE", 11, 0x15DAE9F5ULL, 0, 0, 0 }, { CONSTANT_COMMON_RATIONALP, COMMON, "RATIONALP", 9, 0x15958FFAULL, 0, 0, 0 }, { CONSTANT_COMMON_READ, COMMON, "READ", 4, 0x44414556ULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_BYTE, COMMON, "READ-BYTE", 9, 0x189A87CDULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_CHAR, COMMON, "READ-CHAR", 9, 0x058988DAULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_CHAR_NO_HANG, COMMON, "READ-CHAR-NO-HANG", 17, 0x2318FE56ULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_DELIMITED_LIST, COMMON, "READ-DELIMITED-LIST", 19, 0x31516E69ULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_FROM_STRING, COMMON, "READ-FROM-STRING", 16, 0x2F35022EULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_LINE, COMMON, "READ-LINE", 9, 0x128A91CDULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_PRESERVING_WHITESPACE, COMMON, "READ-PRESERVING-WHITESPACE", 26, 0x22C70A14ULL, 0, 0, 0 }, { CONSTANT_COMMON_READ_SEQUENCE, COMMON, "READ-SEQUENCE", 13, 0x58D4DE26ULL, 0, 0, 0 }, { CONSTANT_COMMON_READER_ERROR, COMMON, "READER-ERROR", 12, 0x5BBDE9F5ULL, 0, 0, 0 }, { CONSTANT_COMMON_READTABLE, COMMON, "READTABLE", 9, 0x108386F4ULL, 0, 0, 0 }, { CONSTANT_COMMON_READTABLE_CASE, COMMON, "READTABLE-CASE", 14, 0x51C6F94CULL, 0, 0, 0 }, { CONSTANT_COMMON_READTABLEP, COMMON, "READTABLEP", 10, 0x1083D6F5ULL, 0, 0, 0 }, { CONSTANT_COMMON_REAL, COMMON, "REAL", 4, 0x4C414556ULL, 0, 0, 0 }, { CONSTANT_COMMON_REALP, COMMON, "REALP", 5, 0x4C4145A7ULL, 0, 0, 0 }, { CONSTANT_COMMON_REALPART, COMMON, "REALPART", 8, 0x209386AAULL, 0, 0, 0 }, { CONSTANT_COMMON_REDUCE, COMMON, "REDUCE", 6, 0x55448A9BULL, 0, 0, 0 }, { CONSTANT_COMMON_REM, COMMON, "REM", 3, 0x004D4555ULL, 0, 0, 0 }, { CONSTANT_COMMON_REMF, COMMON, "REMF", 4, 0x464D4556ULL, 0, 0, 0 }, { CONSTANT_COMMON_REMHASH, COMMON, "REMHASH", 7, 0x4895989AULL, 0, 0, 0 }, { CONSTANT_COMMON_REMOVE, COMMON, "REMOVE", 6, 0x4F4D8AAEULL, 0, 0, 0 }, { CONSTANT_COMMON_REMOVE_DUPLICATES, COMMON, "REMOVE-DUPLICATES", 17, 0x221B1CA4ULL, 0, 0, 0 }, { CONSTANT_COMMON_REMOVE_IF, COMMON, "REMOVE-IF", 9, 0x187A8AF7ULL, 0, 0, 0 }, { CONSTANT_COMMON_REMOVE_IF_NOT, COMMON, "REMOVE-IF-NOT", 13, 0x67C8B84FULL, 0, 0, 0 }, { CONSTANT_COMMON_REMOVE_METHOD, COMMON, "REMOVE-METHOD", 13, 0x6BC2DF3EULL, 0, 0, 0 }, { CONSTANT_COMMON_REMPROP, COMMON, "REMPROP", 7, 0x509D94ABULL, 0, 0, 0 }, { CONSTANT_COMMON_RENAME_FILE, COMMON, "RENAME-FILE", 11, 0x07C0D6F3ULL, 0, 0, 0 }, { CONSTANT_COMMON_RENAME_PACKAGE, COMMON, "RENAME-PACKAGE", 14, 0x52C71335ULL, 0, 0, 0 }, { CONSTANT_COMMON_REPLACE, COMMON, "REPLACE", 7, 0x4C95889AULL, 0, 0, 0 }, { CONSTANT_COMMON_REQUIRE, COMMON, "REQUIRE", 7, 0x559697A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_REST, COMMON, "REST", 4, 0x54534556ULL, 0, 0, 0 }, { CONSTANT_COMMON_RESTART, COMMON, "RESTART", 7, 0x54A7979AULL, 0, 0, 0 }, { CONSTANT_COMMON_RESTART_BIND, COMMON, "RESTART-BIND", 12, 0x45F5E0E1ULL, 0, 0, 0 }, { CONSTANT_COMMON_RESTART_CASE, COMMON, "RESTART-CASE", 12, 0x46FAD8E2ULL, 0, 0, 0 }, { CONSTANT_COMMON_RESTART_NAME, COMMON, "RESTART-NAME", 12, 0x46F4D8EDULL, 0, 0, 0 }, { CONSTANT_COMMON_RETURN, COMMON, "RETURN", 6, 0x555493AAULL, 0, 0, 0 }, { CONSTANT_COMMON_RETURN_FROM, COMMON, "RETURN-FROM", 11, 0x1BCEE301ULL, 0, 0, 0 }, { CONSTANT_COMMON_REVAPPEND, COMMON, "REVAPPEND", 9, 0x0F9B95EFULL, 0, 0, 0 }, { CONSTANT_COMMON_REVERSE, COMMON, "REVERSE", 7, 0x459B98ABULL, 0, 0, 0 }, { CONSTANT_COMMON_ROOM, COMMON, "ROOM", 4, 0x4D4F4F56ULL, 0, 0, 0 }, { CONSTANT_COMMON_ROTATEF, COMMON, "ROTATEF", 7, 0x419A94ADULL, 0, 0, 0 }, { CONSTANT_COMMON_ROUND, COMMON, "ROUND", 5, 0x4E554F9BULL, 0, 0, 0 }, { CONSTANT_COMMON_ROW_MAJOR_AREF, COMMON, "ROW-MAJOR-AREF", 14, 0x4EE30444ULL, 0, 0, 0 }, { CONSTANT_COMMON_RPLACA, COMMON, "RPLACA", 6, 0x414C919BULL, 0, 0, 0 }, { CONSTANT_COMMON_RPLACD, COMMON, "RPLACD", 6, 0x414C949BULL, 0, 0, 0 }, { CONSTANT_COMMON_SAFETY, COMMON, "SAFETY", 6, 0x45469AADULL, 0, 0, 0 }, { CONSTANT_COMMON_SATISFIES, COMMON, "SATISFIES", 9, 0x0E9D8802ULL, 0, 0, 0 }, { CONSTANT_COMMON_SBIT, COMMON, "SBIT", 4, 0x54494257ULL, 0, 0, 0 }, { CONSTANT_COMMON_SCALE_FLOAT, COMMON, "SCALE-FLOAT", 11, 0x18DBB1F2ULL, 0, 0, 0 }, { CONSTANT_COMMON_SCHAR, COMMON, "SCHAR", 5, 0x414843AAULL, 0, 0, 0 }, { CONSTANT_COMMON_SEARCH, COMMON, "SEARCH", 6, 0x52418D9CULL, 0, 0, 0 }, { CONSTANT_COMMON_SECOND, COMMON, "SECOND", 6, 0x4F4389A7ULL, 0, 0, 0 }, { CONSTANT_COMMON_SEQUENCE, COMMON, "SEQUENCE", 8, 0x1A9493A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_SERIOUS_CONDITION, COMMON, "SERIOUS-CONDITION", 17, 0x0A3D3E8DULL, 0, 0, 0 }, { CONSTANT_COMMON_SET, COMMON, "SET", 3, 0x00544556ULL, 0, 0, 0 }, { CONSTANT_COMMON_SET_DISPATCH_MACRO_CHARACTER, COMMON, "SET-DISPATCH-MACRO-CHARACTER", 28, 0x5FF114FEULL, 0, 0, 0 }, { CONSTANT_COMMON_SET_MACRO_CHARACTER, COMMON, "SET-MACRO-CHARACTER", 19, 0x0B6E4B97ULL, 0, 0, 0 }, { CONSTANT_COMMON_SET_PPRINT_DISPATCH, COMMON, "SET-PPRINT-DISPATCH", 19, 0x7C6C80A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_SET_SYNTAX_FROM_CHAR, COMMON, "SET-SYNTAX-FROM-CHAR", 20, 0x475E8E90ULL, 0, 0, 0 }, { CONSTANT_COMMON_SETF, COMMON, "SETF", 4, 0x46544557ULL, 0, 0, 0 }, { CONSTANT_COMMON_SETQ, COMMON, "SETQ", 4, 0x51544557ULL, 0, 0, 0 }, { CONSTANT_COMMON_SET_DIFFERENCE, COMMON, "SET-DIFFERENCE", 14, 0x41E0262DULL, 0, 0, 0 }, { CONSTANT_COMMON_SET_EXCLUSIVE_OR, COMMON, "SET-EXCLUSIVE-OR", 16, 0x22301E42ULL, 0, 0, 0 }, { CONSTANT_COMMON_SEVENTH, COMMON, "SEVENTH", 7, 0x459E99A8ULL, 0, 0, 0 }, { CONSTANT_COMMON_SHADOW, COMMON, "SHADOW", 6, 0x44419FA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_SHADOWING_IMPORT, COMMON, "SHADOWING-IMPORT", 16, 0x34261C49ULL, 0, 0, 0 }, { CONSTANT_COMMON_SHIFTF, COMMON, "SHIFTF", 6, 0x46498EADULL, 0, 0, 0 }, { CONSTANT_COMMON_SHORT_FLOAT, COMMON, "SHORT-FLOAT", 11, 0x1EE9B701ULL, 0, 0, 0 }, { CONSTANT_COMMON_SHORT_FLOAT_EPSILON, COMMON, "SHORT-FLOAT-EPSILON", 19, 0x158B569AULL, 0, 0, 0 }, { CONSTANT_COMMON_SHORT_FLOAT_NEGATIVE_EPSILON, COMMON, "SHORT-FLOAT-NEGATIVE-EPSILON", 28, 0x7426D72AULL, 0, 0, 0 }, { CONSTANT_COMMON_SHORT_SITE_NAME, COMMON, "SHORT-SITE-NAME", 15, 0x6A15084BULL, 0, 0, 0 }, { CONSTANT_COMMON_SIGNAL, COMMON, "SIGNAL", 6, 0x4E47959AULL, 0, 0, 0 }, { CONSTANT_COMMON_SIGNED_BYTE, COMMON, "SIGNED-BYTE", 11, 0x10B9E1FCULL, 0, 0, 0 }, { CONSTANT_COMMON_SIGNUM, COMMON, "SIGNUM", 6, 0x4E4796AEULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_ARRAY, COMMON, "SIMPLE-ARRAY", 12, 0x6ABBE0FDULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_BASE_STRING, COMMON, "SIMPLE-BASE-STRING", 18, 0x09127D93ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_BIT_VECTOR, COMMON, "SIMPLE-BIT-VECTOR", 17, 0x37FC2690ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_BIT_VECTOR_P, COMMON, "SIMPLE-BIT-VECTOR-P", 19, 0x384C5392ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_CONDITION, COMMON, "SIMPLE-CONDITION", 16, 0x2B0E2652ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_CONDITION_FORMAT_CONTROL, COMMON, "SIMPLE-CONDITION-FORMAT-CONTROL", 31, 0x7F4C4C70ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_CONDITION_FORMAT_ARGUMENTS, COMMON, "SIMPLE-CONDITION-FORMAT-ARGUMENTS", 33, 0x544745BEULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_ERROR, COMMON, "SIMPLE-ERROR", 12, 0x67C9E0FDULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_STRING, COMMON, "SIMPLE-STRING", 13, 0x71C3E147ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_STRING_P, COMMON, "SIMPLE-STRING-P", 15, 0x72140E49ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_TYPE_ERROR, COMMON, "SIMPLE-TYPE-ERROR", 17, 0x211231A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_VECTOR, COMMON, "SIMPLE-VECTOR", 13, 0x75CED243ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_VECTOR_P, COMMON, "SIMPLE-VECTOR-P", 15, 0x761EFF45ULL, 0, 0, 0 }, { CONSTANT_COMMON_SIMPLE_WARNING, COMMON, "SIMPLE-WARNING", 14, 0x70C9283CULL, 0, 0, 0 }, { CONSTANT_COMMON_SIN, COMMON, "SIN", 3, 0x004E4956ULL, 0, 0, 0 }, { CONSTANT_COMMON_SINH, COMMON, "SINH", 4, 0x484E4957ULL, 0, 0, 0 }, { CONSTANT_COMMON_SINGLE_FLOAT, COMMON, "SINGLE-FLOAT", 12, 0x61BCDDF7ULL, 0, 0, 0 }, { CONSTANT_COMMON_SINGLE_FLOAT_EPSILON, COMMON, "SINGLE-FLOAT-EPSILON", 20, 0x035C6F75ULL, 0, 0, 0 }, { CONSTANT_COMMON_SINGLE_FLOAT_NEGATIVE_EPSILON, COMMON, "SINGLE-FLOAT-NEGATIVE-EPSILON", 29, 0x1EDCF75CULL, 0, 0, 0 }, { CONSTANT_COMMON_SIXTH, COMMON, "SIXTH", 5, 0x545849A0ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLEEP, COMMON, "SLEEP", 5, 0x45454CA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLOT_BOUNDP, COMMON, "SLOT-BOUNDP", 11, 0x29EED2D9ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLOT_EXISTS_P, COMMON, "SLOT-EXISTS-P", 13, 0x4AFAE630ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLOT_MAKUNBOUND, COMMON, "SLOT-MAKUNBOUND", 15, 0x6F173639ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLOT_VALUE, COMMON, "SLOT-VALUE", 10, 0x2090E7DFULL, 0, 0, 0 }, { CONSTANT_COMMON_SOFTWARE_TYPE, COMMON, "SOFTWARE-TYPE", 13, 0x69F1E529ULL, 0, 0, 0 }, { CONSTANT_COMMON_SOFTWARE_VERSION, COMMON, "SOFTWARE-VERSION", 16, 0x3A2D303AULL, 0, 0, 0 }, { CONSTANT_COMMON_SOME, COMMON, "SOME", 4, 0x454D4F57ULL, 0, 0, 0 }, { CONSTANT_COMMON_SORT, COMMON, "SORT", 4, 0x54524F57ULL, 0, 0, 0 }, { CONSTANT_COMMON_SPACE, COMMON, "SPACE", 5, 0x4341509DULL, 0, 0, 0 }, { CONSTANT_COMMON_SPECIAL, COMMON, "SPECIAL", 7, 0x439191A3ULL, 0, 0, 0 }, { CONSTANT_COMMON_SPECIAL_OPERATOR_P, COMMON, "SPECIAL-OPERATOR-P", 18, 0x1526866BULL, 0, 0, 0 }, { CONSTANT_COMMON_SPEED, COMMON, "SPEED", 5, 0x4545509CULL, 0, 0, 0 }, { CONSTANT_COMMON_SQRT, COMMON, "SQRT", 4, 0x54525157ULL, 0, 0, 0 }, { CONSTANT_COMMON_STABLE_SORT, COMMON, "STABLE-SORT", 11, 0x15C2EBF9ULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD, COMMON, "STANDARD", 8, 0x1293959FULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD_CHAR, COMMON, "STANDARD-CHAR", 13, 0x53DBD923ULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD_CHAR_P, COMMON, "STANDARD-CHAR-P", 15, 0x542C0625ULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD_CLASS, COMMON, "STANDARD-CLASS", 14, 0x53E02C25ULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD_GENERIC_FUNCTION, COMMON, "STANDARD-GENERIC-FUNCTION", 25, 0x41C0C9E0ULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD_METHOD, COMMON, "STANDARD-METHOD", 15, 0x671D321BULL, 0, 0, 0 }, { CONSTANT_COMMON_STANDARD_OBJECT, COMMON, "STANDARD-OBJECT", 15, 0x5D2A2818ULL, 0, 0, 0 }, { CONSTANT_COMMON_STEP, COMMON, "STEP", 4, 0x50455457ULL, 0, 0, 0 }, { CONSTANT_COMMON_STORAGE_CONDITION, COMMON, "STORAGE-CONDITION", 17, 0x132C3F7FULL, 0, 0, 0 }, { CONSTANT_COMMON_STORE_VALUE, COMMON, "STORE-VALUE", 11, 0x13EAD6EFULL, 0, 0, 0 }, { CONSTANT_COMMON_STREAM, COMMON, "STREAM", 6, 0x4552A19AULL, 0, 0, 0 }, { CONSTANT_COMMON_STREAMP, COMMON, "STREAMP", 7, 0x45A2A19BULL, 0, 0, 0 }, { CONSTANT_COMMON_STREAM_ELEMENT_TYPE, COMMON, "STREAM-ELEMENT-TYPE", 19, 0x243F8B9AULL, 0, 0, 0 }, { CONSTANT_COMMON_STREAM_ERROR, COMMON, "STREAM-ERROR", 12, 0x5CCEF3F2ULL, 0, 0, 0 }, { CONSTANT_COMMON_STREAM_ERROR_STREAM, COMMON, "STREAM-ERROR-STREAM", 19, 0x2F70886BULL, 0, 0, 0 }, { CONSTANT_COMMON_STREAM_EXTERNAL_FORMAT, COMMON, "STREAM-EXTERNAL-FORMAT", 22, 0x5763DAD7ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING, COMMON, "STRING", 6, 0x49529BA7ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_EQL, COMMON, "STRING=", 7, 0x498F9BA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_NOT_EQL, COMMON, "STRING/=", 8, 0x06819BA9ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_LESS, COMMON, "STRING<", 7, 0x498E9BA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_GREATER, COMMON, "STRING>", 7, 0x49909BA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_LESS_EQUAL, COMMON, "STRING<=", 8, 0x068E9BA9ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_GREATER_EQUAL, COMMON, "STRING>=", 8, 0x06909BA9ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_CAPITALIZE, COMMON, "STRING-CAPITALIZE", 17, 0x3B123879ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_DOWNCASE, COMMON, "STRING-DOWNCASE", 15, 0x51134640ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_EQUAL, COMMON, "STRING-EQUAL", 12, 0x5AC0F0FEULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_GREATERP, COMMON, "STRING-GREATERP", 15, 0x65113347ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_LEFT_TRIM, COMMON, "STRING-LEFT-TRIM", 16, 0x101D344AULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_LESSP, COMMON, "STRING-LESSP", 12, 0x65D2EEF2ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_NOT_EQUAL, COMMON, "STRING-NOT-EQUAL", 16, 0x28EE4551ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_NOT_GREATERP, COMMON, "STRING-NOT-GREATERP", 19, 0x333E879AULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_NOT_LESSP, COMMON, "STRING-NOT-LESSP", 16, 0x34004345ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_RIGHT_TRIM, COMMON, "STRING-RIGHT-TRIM", 17, 0x391A3775ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_STREAM, COMMON, "STRING-STREAM", 13, 0x5DC4EE4FULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_TRIM, COMMON, "STRING-TRIM", 11, 0x1DCCE4FEULL, 0, 0, 0 }, { CONSTANT_COMMON_STRING_UPCASE, COMMON, "STRING-UPCASE", 13, 0x71C0DF43ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRINGP, COMMON, "STRINGP", 7, 0x49A29BA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRUCTURE, COMMON, "STRUCTURE", 9, 0x27A7A8E4ULL, 0, 0, 0 }, { CONSTANT_COMMON_STRUCTURE_CLASS, COMMON, "STRUCTURE-CLASS", 15, 0x743E292BULL, 0, 0, 0 }, { CONSTANT_COMMON_STRUCTURE_OBJECT, COMMON, "STRUCTURE-OBJECT", 16, 0x3E3A1B35ULL, 0, 0, 0 }, { CONSTANT_COMMON_STYLE_WARNING, COMMON, "STYLE-WARNING", 13, 0x5BF9D03EULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBSETP, COMMON, "SUBSETP", 7, 0x5392A99FULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBSEQ, COMMON, "SUBSEQ", 6, 0x5342A69EULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBLIS, COMMON, "SUBLIS", 6, 0x4C42A8A2ULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBST, COMMON, "SUBST", 5, 0x534255ACULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBSTITUTE, COMMON, "SUBSTITUTE", 10, 0x2896E405ULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBSTITUTE_IF, COMMON, "SUBSTITUTE-IF", 13, 0x71C3E44EULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBSTITUTE_IF_NOT, COMMON, "SUBSTITUTE-IF-NOT", 17, 0x411211A6ULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBST_IF, COMMON, "SUBST-IF", 8, 0x198B82AFULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBST_IF_NOT, COMMON, "SUBST-IF-NOT", 12, 0x6DDAD0E0ULL, 0, 0, 0 }, { CONSTANT_COMMON_SUBTYPEP, COMMON, "SUBTYPEP", 8, 0x2487A5B4ULL, 0, 0, 0 }, { CONSTANT_COMMON_SVREF, COMMON, "SVREF", 5, 0x4552569EULL, 0, 0, 0 }, { CONSTANT_COMMON_SXHASH, COMMON, "SXHASH", 6, 0x4148A0ACULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL, COMMON, "SYMBOL", 6, 0x424DA5A8ULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL_FUNCTION, COMMON, "SYMBOL-FUNCTION", 15, 0x5D0C434FULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL_MACROLET, COMMON, "SYMBOL-MACROLET", 15, 0x5F212E3EULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL_NAME, COMMON, "SYMBOL-NAME", 11, 0x10BFF2EEULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL_PACKAGE, COMMON, "SYMBOL-PACKAGE", 14, 0x53C62E38ULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL_PLIST, COMMON, "SYMBOL-PLIST", 12, 0x66CDEEFAULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOL_VALUE, COMMON, "SYMBOL-VALUE", 12, 0x5DCFF1EFULL, 0, 0, 0 }, { CONSTANT_COMMON_SYMBOLP, COMMON, "SYMBOLP", 7, 0x429DA5A9ULL, 0, 0, 0 }, { CONSTANT_COMMON_SYNONYM_STREAM, COMMON, "SYNONYM-STREAM", 14, 0x41EE5443ULL, 0, 0, 0 }, { CONSTANT_COMMON_SYNONYM_STREAM_SYMBOL, COMMON, "SYNONYM-STREAM-SYMBOL", 21, 0x645DA1EFULL, 0, 0, 0 }, { CONSTANT_COMMON_TAGBODY, COMMON, "TAGBODY", 7, 0x42A085AAULL, 0, 0, 0 }, { CONSTANT_COMMON_TAILP, COMMON, "TAILP", 5, 0x4C4941A9ULL, 0, 0, 0 }, { CONSTANT_COMMON_TAN, COMMON, "TAN", 3, 0x004E4157ULL, 0, 0, 0 }, { CONSTANT_COMMON_TANH, COMMON, "TANH", 4, 0x484E4158ULL, 0, 0, 0 }, { CONSTANT_COMMON_TENTH, COMMON, "TENTH", 5, 0x544E45A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_TERPRI, COMMON, "TERPRI", 6, 0x50528EACULL, 0, 0, 0 }, { CONSTANT_COMMON_THE, COMMON, "THE", 3, 0x00454857ULL, 0, 0, 0 }, { CONSTANT_COMMON_THIRD, COMMON, "THIRD", 5, 0x5249489DULL, 0, 0, 0 }, { CONSTANT_COMMON_THROW, COMMON, "THROW", 5, 0x4F5248B0ULL, 0, 0, 0 }, { CONSTANT_COMMON_TIME, COMMON, "TIME", 4, 0x454D4958ULL, 0, 0, 0 }, { CONSTANT_COMMON_TRACE, COMMON, "TRACE", 5, 0x4341529EULL, 0, 0, 0 }, { CONSTANT_COMMON_TRANSLATE_LOGICAL_PATHNAME, COMMON, "TRANSLATE-LOGICAL-PATHNAME", 26, 0x35B0D03AULL, 0, 0, 0 }, { CONSTANT_COMMON_TRANSLATE_PATHNAME, COMMON, "TRANSLATE-PATHNAME", 18, 0x2521599FULL, 0, 0, 0 }, { CONSTANT_COMMON_TREE_EQUAL, COMMON, "TREE-EQUAL", 10, 0x1A96E3CCULL, 0, 0, 0 }, { CONSTANT_COMMON_TRUENAME, COMMON, "TRUENAME", 8, 0x0AA293AAULL, 0, 0, 0 }, { CONSTANT_COMMON_TRUNCATE, COMMON, "TRUNCATE", 8, 0x13A9939FULL, 0, 0, 0 }, { CONSTANT_COMMON_TWO_WAY_STREAM, COMMON, "TWO-WAY-STREAM", 14, 0x1FFB3A4DULL, 0, 0, 0 }, { CONSTANT_COMMON_TWO_WAY_STREAM_INPUT_STREAM, COMMON, "TWO-WAY-STREAM-INPUT-STREAM", 27, 0x101F1F1AULL, 0, 0, 0 }, { CONSTANT_COMMON_TWO_WAY_STREAM_OUTPUT_STREAM, COMMON, "TWO-WAY-STREAM-OUTPUT-STREAM", 28, 0x660D0156ULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPE, COMMON, "TYPE", 4, 0x45505958ULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPEP, COMMON, "TYPEP", 5, 0x455059A9ULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPE_ERROR, COMMON, "TYPE-ERROR", 10, 0x17A2F0DAULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPE_ERROR_DATUM, COMMON, "TYPE-ERROR-DATUM", 16, 0x29254521ULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPE_ERROR_EXPECTED_TYPE, COMMON, "TYPE-ERROR-EXPECTED-TYPE", 24, 0x12A9DFE8ULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPE_OF, COMMON, "TYPE-OF", 7, 0x4596A888ULL, 0, 0, 0 }, { CONSTANT_COMMON_TYPECASE, COMMON, "TYPECASE", 8, 0x0AA39A9FULL, 0, 0, 0 }, { CONSTANT_COMMON_UNBOUND_SLOT, COMMON, "UNBOUND-SLOT", 12, 0x50D5E909ULL, 0, 0, 0 }, { CONSTANT_COMMON_UNBOUND_SLOT_INSTANCE, COMMON, "UNBOUND-SLOT-INSTANCE", 21, 0x677273D8ULL, 0, 0, 0 }, { CONSTANT_COMMON_UNBOUND_VARIABLE, COMMON, "UNBOUND-VARIABLE", 16, 0x0B252051ULL, 0, 0, 0 }, { CONSTANT_COMMON_UNDEFINED_FUNCTION, COMMON, "UNDEFINED-FUNCTION", 18, 0x292D568EULL, 0, 0, 0 }, { CONSTANT_COMMON_UNEXPORT, COMMON, "UNEXPORT", 8, 0x2C979DADULL, 0, 0, 0 }, { CONSTANT_COMMON_UNINTERN, COMMON, "UNINTERN", 8, 0x1C9B93B1ULL, 0, 0, 0 }, { CONSTANT_COMMON_UNION, COMMON, "UNION", 5, 0x4F494EA8ULL, 0, 0, 0 }, { CONSTANT_COMMON_UNLESS, COMMON, "UNLESS", 6, 0x454CA1AEULL, 0, 0, 0 }, { CONSTANT_COMMON_UNREAD_CHAR, COMMON, "UNREAD-CHAR", 11, 0x08D1D3E9ULL, 0, 0, 0 }, { CONSTANT_COMMON_UNSIGNED_BYTE, COMMON, "UNSIGNED-BYTE", 13, 0x61F1DF1BULL, 0, 0, 0 }, { CONSTANT_COMMON_UNTRACE, COMMON, "UNTRACE", 7, 0x5299919DULL, 0, 0, 0 }, { CONSTANT_COMMON_UNUSE_PACKAGE, COMMON, "UNUSE-PACKAGE", 13, 0x5BE6C72FULL, 0, 0, 0 }, { CONSTANT_COMMON_UNWIND_PROTECT, COMMON, "UNWIND-PROTECT", 14, 0x5ED93646ULL, 0, 0, 0 }, { CONSTANT_COMMON_UPDATE_INSTANCE_FOR_DIFFERENT_CLASS, COMMON, "UPDATE-INSTANCE-FOR-DIFFERENT-CLASS", 35, 0x077F97CCULL, 0, 0, 0 }, { CONSTANT_COMMON_UPDATE_INSTANCE_FOR_REDEFINED_CLASS, COMMON, "UPDATE-INSTANCE-FOR-REDEFINED-CLASS", 35, 0x7D868ACBULL, 0, 0, 0 }, { CONSTANT_COMMON_UPGRADED_ARRAY_ELEMENT_TYPE, COMMON, "UPGRADED-ARRAY-ELEMENT-TYPE", 27, 0x47CC1912ULL, 0, 0, 0 }, { CONSTANT_COMMON_UPGRADED_COMPLEX_PART_TYPE, COMMON, "UPGRADED-COMPLEX-PART-TYPE", 26, 0x67B6E6FEULL, 0, 0, 0 }, { CONSTANT_COMMON_UPPER_CASE_P, COMMON, "UPPER-CASE-P", 12, 0x56C0C306ULL, 0, 0, 0 }, { CONSTANT_COMMON_USE_PACKAGE, COMMON, "USE-PACKAGE", 11, 0x78CDDBF1ULL, 0, 0, 0 }, { CONSTANT_COMMON_USE_VALUE, COMMON, "USE-VALUE", 9, 0x029194F9ULL, 0, 0, 0 }, { CONSTANT_COMMON_USER_HOMEDIR_PATHNAME, COMMON, "USER-HOMEDIR-PATHNAME", 21, 0x13607E96ULL, 0, 0, 0 }, { CONSTANT_COMMON_VALUES, COMMON, "VALUES", 6, 0x554C94A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_VALUES_LIST, COMMON, "VALUES-LIST", 11, 0x21CDE7EFULL, 0, 0, 0 }, { CONSTANT_COMMON_VARIABLE, COMMON, "VARIABLE", 8, 0x0E9E839FULL, 0, 0, 0 }, { CONSTANT_COMMON_VECTOR, COMMON, "VECTOR", 6, 0x544397ABULL, 0, 0, 0 }, { CONSTANT_COMMON_VECTOR_POP, COMMON, "VECTOR-POP", 10, 0x2470E7FEULL, 0, 0, 0 }, { CONSTANT_COMMON_VECTOR_PUSH, COMMON, "VECTOR-PUSH", 11, 0x24B8EB05ULL, 0, 0, 0 }, { CONSTANT_COMMON_VECTOR_PUSH_EXTEND, COMMON, "VECTOR-PUSH-EXTEND", 18, 0x170D879FULL, 0, 0, 0 }, { CONSTANT_COMMON_VECTORP, COMMON, "VECTORP", 7, 0x549397ACULL, 0, 0, 0 }, { CONSTANT_COMMON_WARN, COMMON, "WARN", 4, 0x4E52415BULL, 0, 0, 0 }, { CONSTANT_COMMON_WARNING, COMMON, "WARNING", 7, 0x4E998FA7ULL, 0, 0, 0 }, { CONSTANT_COMMON_WILD_PATHNAME_P, COMMON, "WILD-PATHNAME-P", 15, 0x661F1520ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_ACCESSORS, COMMON, "WITH-ACCESSORS", 14, 0x5AEB3129ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_COMPILATION_UNIT, COMMON, "WITH-COMPILATION-UNIT", 21, 0x6E8D74BEULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_CONDITION_RESTARTS, COMMON, "WITH-CONDITION-RESTARTS", 23, 0x73CCCBC5ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_HASH_TABLE_ITERATOR, COMMON, "WITH-HASH-TABLE-ITERATOR", 24, 0x2EC3B3B0ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_INPUT_FROM_STRING, COMMON, "WITH-INPUT-FROM-STRING", 22, 0x556FD1E2ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_OPEN_FILE, COMMON, "WITH-OPEN-FILE", 14, 0x56EB0B2CULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_OPEN_STREAM, COMMON, "WITH-OPEN-STREAM", 16, 0x2F390B34ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_OUTPUT_TO_STRING, COMMON, "WITH-OUTPUT-TO-STRING", 21, 0x6B748FD8ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_PACKAGE_ITERATOR, COMMON, "WITH-PACKAGE-ITERATOR", 21, 0x658565B5ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_SIMPLE_RESTART, COMMON, "WITH-SIMPLE-RESTART", 19, 0x178A807AULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_SLOTS, COMMON, "WITH-SLOTS", 10, 0x17A0EFE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_WITH_STANDARD_IO_SYNTAX, COMMON, "WITH-STANDARD-IO-SYNTAX", 23, 0x79E4A2AEULL, 0, 0, 0 }, { CONSTANT_COMMON_WHEN, COMMON, "WHEN", 4, 0x4E45485BULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE, COMMON, "WRITE", 5, 0x544952A1ULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE_BYTE, COMMON, "WRITE-BYTE", 10, 0x2D8BC4FAULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE_CHAR, COMMON, "WRITE-CHAR", 10, 0x1C8CD1E7ULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE_LINE, COMMON, "WRITE-LINE", 10, 0x1D95C4F4ULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE_SEQUENCE, COMMON, "WRITE-SEQUENCE", 14, 0x67E21A3EULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE_STRING, COMMON, "WRITE-STRING", 12, 0x6FEAC8FAULL, 0, 0, 0 }, { CONSTANT_COMMON_WRITE_TO_STRING, COMMON, "WRITE-TO-STRING", 15, 0x76392121ULL, 0, 0, 0 }, { CONSTANT_COMMON_YES_OR_NO_P, COMMON, "YES-OR-NO-P", 11, 0x7BD0C502ULL, 0, 0, 0 }, { CONSTANT_COMMON_Y_OR_N_P, COMMON, "Y-OR-N-P", 8, 0x227C7B8EULL, 0, 0, 0 }, { CONSTANT_COMMON_ZEROP, COMMON, "ZEROP", 5, 0x4F5245AFULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DATUM, CLOS, "DATUM", 5, 0x55544196ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_EXPECTED_TYPE, CLOS, "EXPECTED-TYPE", 13, 0x59EF0107ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FORMAT_ARGUMENTS, CLOS, "FORMAT-ARGUMENTS", 16, 0x2F29392EULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FORMAT_CONTROL, CLOS, "FORMAT-CONTROL", 14, 0x62D43E33ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_OPERANDS, CLOS, "OPERANDS", 8, 0x25899E98ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_OPERATION, CLOS, "OPERATION", 9, 0x218EA4E7ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_PACKAGE, CLOS, "PACKAGE", 7, 0x4B888898ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_PATHNAME, CLOS, "PATHNAME", 8, 0x0DA182A6ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STREAM, CLOS, "STREAM", 6, 0x4552A19AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_NAME, CLOS, "NAME", 4, 0x454D4152ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DIRECT_SLOTS, CLOS, "DIRECT-SLOTS", 12, 0x6BD3ECDFULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DIRECT_SUBCLASSES, CLOS, "DIRECT-SUBCLASSES", 17, 0x2A163381ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DIRECT_SUPERCLASSES, CLOS, "DIRECT-SUPERCLASSES", 19, 0x3E597F85ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_PRECEDENCE_LIST, CLOS, "CLASS-PRECEDENCE-LIST", 21, 0x026357B6ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_EFFECTIVE_SLOTS, CLOS, "EFFECTIVE-SLOTS", 15, 0x68361C2BULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FINALIZED_P, CLOS, "FINALIZED-P", 11, 0x06F8BFE1ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_PROTOTYPE, CLOS, "PROTOTYPE", 9, 0x24A8A6EDULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DEFAULT_INITARGS, CLOS, "DEFAULT-INITARGS", 16, 0x162B3233ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DIRECT_DEFAULT_INITARGS, CLOS, "DIRECT-DEFAULT-INITARGS", 23, 0x6995C8CFULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_VERSION, CLOS, "VERSION", 7, 0x53A094A6ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_REDEFINED_CLASS, CLOS, "REDEFINED-CLASS", 15, 0x57290F2CULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_NAME, KEYWORD, "NAME", 4, 0x454D4152ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_DIRECT_SLOTS, KEYWORD, "DIRECT-SLOTS", 12, 0x6BD3ECDFULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_DIRECT_SUBCLASSES, KEYWORD, "DIRECT-SUBCLASSES", 17, 0x2A163381ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_DIRECT_SUPERCLASSES, KEYWORD, "DIRECT-SUPERCLASSES", 19, 0x3E597F85ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_CLASS_PRECEDENCE_LIST, KEYWORD, "CLASS-PRECEDENCE-LIST", 21, 0x026357B6ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_EFFECTIVE_SLOTS, KEYWORD, "EFFECTIVE-SLOTS", 15, 0x68361C2BULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_FINALIZED_P, KEYWORD, "FINALIZED-P", 11, 0x06F8BFE1ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_PROTOTYPE, KEYWORD, "PROTOTYPE", 9, 0x24A8A6EDULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_DEFAULT_INITARGS, KEYWORD, "DEFAULT-INITARGS", 16, 0x162B3233ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_DIRECT_DEFAULT_INITARGS, KEYWORD, "DIRECT-DEFAULT-INITARGS", 23, 0x6995C8CFULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_VERSION, KEYWORD, "VERSION", 7, 0x53A094A6ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_REDEFINED_CLASS, KEYWORD, "REDEFINED-CLASS", 15, 0x57290F2CULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHODS, CLOS, "METHODS", 7, 0x48A789A3ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_LAMBDA_LIST, CLOS, "LAMBDA-LIST", 11, 0x0ECED5E4ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ARGUMENT_PRECEDENCE_ORDER, CLOS, "ARGUMENT-PRECEDENCE-ORDER", 25, 0x26B5C306ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DECLARATIONS, CLOS, "DECLARATIONS", 12, 0x73D2E6DAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_CLASS, CLOS, "METHOD-CLASS", 12, 0x5ED4CAF4ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_COMBINATION, CLOS, "METHOD-COMBINATION", 18, 0x1E18669AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_VECTOR, CLOS, "VECTOR", 6, 0x544397ABULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_REMOVE, CLOS, "REMOVE", 6, 0x4F4D8AAEULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ARGUMENT, CLOS, "ARGUMENT", 8, 0x29959796ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_EQLCHECK, CLOS, "EQLCHECK", 8, 0x0E8F9695ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CACHE, CLOS, "CACHE", 5, 0x4843418DULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CALL, CLOS, "CALL", 4, 0x4C4C4147ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FUNCTION, CLOS, "FUNCTION", 8, 0x119D9EA2ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_PRECEDENCE_INDEX, CLOS, "PRECEDENCE-INDEX", 16, 0x32FD2036ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_METHODS, KEYWORD, "METHODS", 7, 0x48A789A3ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_LAMBDA_LIST, KEYWORD, "LAMBDA-LIST", 11, 0x0ECED5E4ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_ARGUMENT_PRECEDENCE_ORDER, KEYWORD, "ARGUMENT-PRECEDENCE-ORDER", 25, 0x26B5C306ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_DECLARATIONS, KEYWORD, "DECLARATIONS", 12, 0x73D2E6DAULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_METHOD_CLASS, KEYWORD, "METHOD-CLASS", 12, 0x5ED4CAF4ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_METHOD_COMBINATION, KEYWORD, "METHOD-COMBINATION", 18, 0x1E18669AULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_VECTOR, KEYWORD, "VECTOR", 6, 0x544397ABULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_REMOVE, KEYWORD, "REMOVE", 6, 0x4F4D8AAEULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_ARGUMENT, KEYWORD, "ARGUMENT", 8, 0x29959796ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_EQLCHECK, KEYWORD, "EQLCHECK", 8, 0x0E8F9695ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_CACHE, KEYWORD, "CACHE", 5, 0x4843418DULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_CALL, KEYWORD, "CALL", 4, 0x4C4C4147ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_FUNCTION, KEYWORD, "FUNCTION", 8, 0x119D9EA2ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_PRECEDENCE_INDEX, KEYWORD, "PRECEDENCE-INDEX", 16, 0x32FD2036ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION, CLOS, "GENERIC-FUNCTION", 16, 0x042F2D43ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_QUALIFIERS, CLOS, "QUALIFIERS", 10, 0x118AEEF6ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SPECIALIZERS, CLOS, "SPECIALIZERS", 12, 0x5FE3D702ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_LONG_P, CLOS, "LONG-P", 6, 0x474E9F7FULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DOCUMENTATION, CLOS, "DOCUMENTATION", 13, 0x78DAE92DULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_IDENTITY, CLOS, "IDENTITY", 8, 0x27998DA5ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_OPERATOR, CLOS, "OPERATOR", 8, 0x2494A498ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ARGUMENTS, CLOS, "ARGUMENTS", 9, 0x299597EAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC, CLOS, "GENERIC", 7, 0x45918EA0ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FORM, CLOS, "FORM", 4, 0x4D524F4AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DECLARE, CLOS, "DECLARE", 7, 0x4C88978CULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_GENERIC_FUNCTION, KEYWORD, "GENERIC-FUNCTION", 16, 0x042F2D43ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_QUALIFIERS, KEYWORD, "QUALIFIERS", 10, 0x118AEEF6ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_SPECIALIZERS, KEYWORD, "SPECIALIZERS", 12, 0x5FE3D702ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_LONG_P, KEYWORD, "LONG-P", 6, 0x474E9F7FULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_DOCUMENTATION, KEYWORD, "DOCUMENTATION", 13, 0x78DAE92DULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_IDENTITY, KEYWORD, "IDENTITY", 8, 0x27998DA5ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_OPERATOR, KEYWORD, "OPERATOR", 8, 0x2494A498ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_ARGUMENTS, KEYWORD, "ARGUMENTS", 9, 0x299597EAULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_GENERIC, KEYWORD, "GENERIC", 7, 0x45918EA0ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_FORM, KEYWORD, "FORM", 4, 0x4D524F4AULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_DECLARE, KEYWORD, "DECLARE", 7, 0x4C88978CULL, 0, 0, 1 }, { CONSTANT_CLOSNAME_OBJECT, CLOS, "OBJECT", 6, 0x454A9698ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_TYPE, CLOS, "TYPE", 4, 0x45505958ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_OBJECT, KEYWORD, "OBJECT", 6, 0x454A9698ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_TYPE, KEYWORD, "TYPE", 4, 0x45505958ULL, 0, 0, 1 }, { CONSTANT_CLOSNAME_READERS, CLOS, "READERS", 7, 0x4494979EULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_WRITERS, CLOS, "WRITERS", 7, 0x549CA4A3ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ACCESSORS, CLOS, "ACCESSORS", 9, 0x179296F0ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_INITARGS, CLOS, "INITARGS", 8, 0x2790A092ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_INITFORM, CLOS, "INITFORM", 8, 0x219B9D97ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_INITFUNCTION, CLOS, "INITFUNCTION", 12, 0x65E6ECEFULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ALLOCATION, CLOS, "ALLOCATION", 10, 0x18A0DBDDULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_INSTANCE, CLOS, "INSTANCE", 8, 0x19969C92ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS, CLOS, "CLASS", 5, 0x53414C9BULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METACLASS, CLOS, "METACLASS", 9, 0x149591ECULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_BINDING, CLOS, "BINDING", 7, 0x44959792ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ORDER, CLOS, "ORDER", 5, 0x454452A6ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_READERS, KEYWORD, "READERS", 7, 0x4494979EULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_WRITERS, KEYWORD, "WRITERS", 7, 0x549CA4A3ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_ACCESSORS, KEYWORD, "ACCESSORS", 9, 0x179296F0ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_INITARGS, KEYWORD, "INITARGS", 8, 0x2790A092ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_INITFORM, KEYWORD, "INITFORM", 8, 0x219B9D97ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_INITFUNCTION, KEYWORD, "INITFUNCTION", 12, 0x65E6ECEFULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_ALLOCATION, KEYWORD, "ALLOCATION", 10, 0x18A0DBDDULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_INSTANCE, KEYWORD, "INSTANCE", 8, 0x19969C92ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_CLASS, KEYWORD, "CLASS", 5, 0x53414C9BULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_METACLASS, KEYWORD, "METACLASS", 9, 0x149591ECULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_BINDING, KEYWORD, "BINDING", 7, 0x44959792ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_ORDER, KEYWORD, "ORDER", 5, 0x454452A6ULL, 0, 0, 1 }, { CONSTANT_CLOSNAME_SLOTS, CLOS, "SLOTS", 5, 0x544F4CABULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_INCLUDE, CLOS, "INCLUDE", 7, 0x4C8892A5ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_VALUE, CLOS, "VALUE", 5, 0x554C41A0ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_PREDICATE, CLOS, "PREDICATE", 9, 0x188695E7ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ACCESS, CLOS, "ACCESS", 6, 0x4543969AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_COPIER, CLOS, "COPIER", 6, 0x4950A18EULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CONSTRUCTOR, CLOS, "CONSTRUCTOR", 11, 0x16F5F0F6ULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_SLOTS, KEYWORD, "SLOTS", 5, 0x544F4CABULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_INCLUDE, KEYWORD, "INCLUDE", 7, 0x4C8892A5ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_VALUE, KEYWORD, "VALUE", 5, 0x554C41A0ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_PREDICATE, KEYWORD, "PREDICATE", 9, 0x188695E7ULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_ACCESS, KEYWORD, "ACCESS", 6, 0x4543969AULL, 0, 0, 0 }, { CONSTANT_CLOSKEY_COPIER, KEYWORD, "COPIER", 6, 0x4950A18EULL, 0, 0, 1 }, { CONSTANT_CLOSKEY_CONSTRUCTOR, KEYWORD, "CONSTRUCTOR", 11, 0x16F5F0F6ULL, 0, 0, 1 }, { CONSTANT_SYSTEM_VALUE, SYSTEM, "VALUE", 5, 0x554C41A0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FUNCTION, SYSTEM, "FUNCTION", 8, 0x119D9EA2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SETF, SYSTEM, "SETF", 4, 0x46544557ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INLINE_FUNCTION, SYSTEM, "INLINE-FUNCTION", 15, 0x640B3144ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INLINE_SETF, SYSTEM, "INLINE-SETF", 11, 0x1CBFE7E7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TAGBODY, SYSTEM, "TAGBODY", 7, 0x42A085AAULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BLOCK, SYSTEM, "BLOCK", 5, 0x434F4C92ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DECLAIM, SYSTEM, "DECLAIM", 7, 0x4C908E8CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFUN, SYSTEM, "DEFUN", 5, 0x55464597ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFMACRO, SYSTEM, "DEFMACRO", 8, 0x1C98888DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFTYPE, SYSTEM, "DEFTYPE", 7, 0x548B95A4ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFINE_COMPILER_MACRO, SYSTEM, "DEFINE-COMPILER-MACRO", 21, 0x55595EDEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MACRO_LAMBDA, SYSTEM, "MACRO-LAMBDA", 12, 0x54D3B0F5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DESTRUCTURING_BIND, SYSTEM, "DESTRUCTURING-BIND", 18, 0x40225E92ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SPECIAL, SYSTEM, "SPECIAL", 7, 0x439191A3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LEXICAL, SYSTEM, "LEXICAL", 7, 0x49A48696ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOCAL, SYSTEM, "LOCAL", 5, 0x41434F9DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_GLOBAL, SYSTEM, "GLOBAL", 6, 0x424F988EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LAMBDA, SYSTEM, "LAMBDA", 6, 0x424D8296ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SCOPE, SYSTEM, "SCOPE", 5, 0x504F439DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MULTIPLE_VALUE_BIND, SYSTEM, "MULTIPLE-VALUE-BIND", 19, 0x284B8F74ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DECLARATION, SYSTEM, "DECLARATION", 11, 0x20D2E6D9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INLINE, SYSTEM, "INLINE", 6, 0x494C939DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DYNAMIC_VALUE, SYSTEM, "DYNAMIC-VALUE", 13, 0x43DDE439ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DYNAMIC_FUNCTION, SYSTEM, "DYNAMIC-FUNCTION", 16, 0x002F413BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_IGNORE_VALUE, SYSTEM, "IGNORE-VALUE", 12, 0x6AD0D8E8ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_IGNORE_FUNCTION, SYSTEM, "IGNORE-FUNCTION", 15, 0x6A0D2A48ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE, SYSTEM, "TYPE", 4, 0x45505958ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_SPECIAL, SYSTEM, "TYPE-SPECIAL", 12, 0x56E1F5D0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_LEXICAL, SYSTEM, "TYPE-LEXICAL", 12, 0x69D6E8D6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_VALUE, SYSTEM, "TYPE-VALUE", 10, 0x1191F4E0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_FUNCTION, SYSTEM, "TYPE-FUNCTION", 13, 0x62EEF41FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_SETF, SYSTEM, "TYPE-SETF", 9, 0x1995ACD0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FUNCTION_ARGTYPE, SYSTEM, "FUNCTION-ARGTYPE", 16, 0x1E40392BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FUNCTION_RETTYPE, SYSTEM, "FUNCTION-RETTYPE", 16, 0x2B334A2BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_HANDLER, SYSTEM, "HANDLER", 7, 0x44A0869BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_HANDLER_BIND, SYSTEM, "HANDLER-BIND", 12, 0x35EECFE2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_HANDLER_CASE, SYSTEM, "HANDLER-CASE", 12, 0x36F3C7E3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_RESTART, SYSTEM, "RESTART", 7, 0x54A7979AULL, 0, 0, 0 }, { CONSTANT_SYSTEM_RESTART_BIND, SYSTEM, "RESTART-BIND", 12, 0x45F5E0E1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_RESTART_CASE, SYSTEM, "RESTART-CASE", 12, 0x46FAD8E2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_STANDARD, SYSTEM, "STANDARD", 8, 0x1293959FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COMPILED_MACRO_FUNCTION, SYSTEM, "COMPILED-MACRO-FUNCTION", 23, 0x7292D5C0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CONTROL, SYSTEM, "CONTROL", 7, 0x549A9E9CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CODE, SYSTEM, "CODE", 4, 0x45444F47ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CALLNAME, SYSTEM, "CALLNAME", 8, 0x11998299ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_EVAL, SYSTEM, "EVAL", 4, 0x4C415649ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INDEX, SYSTEM, "INDEX", 5, 0x45444EA6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SYSTEM, SYSTEM, "SYSTEM", 6, 0x5453A69EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_QUOTE, SYSTEM, "QUOTE", 5, 0x544F559BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ENVIRONMENT, SYSTEM, "ENVIRONMENT", 11, 0x16F8EBE7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CHARACTER2, SYSTEM, "CHARACTER2", 10, 0x1795BDE0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CHARQUEUE, SYSTEM, "CHARQUEUE", 9, 0x27869DE2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CHARBIT, SYSTEM, "CHARBIT", 7, 0x5295918CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SYMSTACK, SYSTEM, "SYMSTACK", 8, 0x1E909AAFULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BITTYPE, SYSTEM, "BITTYPE", 7, 0x549999A2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_READLABEL, SYSTEM, "READLABEL", 9, 0x098386F3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_READINFO_SYMBOL, SYSTEM, "READINFO", 8, 0x138793A3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_READTYPE, SYSTEM, "READTYPE", 8, 0x09919EAEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BITCONS, SYSTEM, "BITCONS", 7, 0x43A79798ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BITBUFFER, SYSTEM, "BITBUFFER", 9, 0x079A8FF2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_HASHITERATOR, SYSTEM, "HASHITERATOR", 12, 0x6CE7E9DEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PACKAGEITERATOR, SYSTEM, "PACKAGEITERATOR", 15, 0x562D1D48ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TAGINFO, SYSTEM, "TAGINFO", 7, 0x499687A9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ARRAY_DIMENSION, SYSTEM, "ARRAY-DIMENSION", 15, 0x5E33143FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ARRAY_GENERAL, SYSTEM, "ARRAY-GENERAL", 13, 0x47EBC541ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ARRAY_SPECIALIZED, SYSTEM, "ARRAY-SPECIALIZED", 17, 0x18490C80ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UNBOUND, SYSTEM, "UNBOUND", 7, 0x4F869CB1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SPACE, SYSTEM, "SPACE", 5, 0x4341509DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SPACE1, SYSTEM, "SPACE1", 6, 0x4341819EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_RESERVED, SYSTEM, "RESERVED", 8, 0x09989BACULL, 0, 0, 0 }, { CONSTANT_SYSTEM_END, SYSTEM, "END", 3, 0x00444E48ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PROMPT_STREAM, SYSTEM, "PROMPT-STREAM", 13, 0x61C1F94EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PRETTY_STREAM, SYSTEM, "PRETTY-STREAM", 13, 0x68B7FE52ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MEMORY_STREAM, SYSTEM, "MEMORY-STREAM", 13, 0x63BFF14DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PIPE_STREAM, SYSTEM, "PIPE-STREAM", 11, 0x17F1DDCDULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_CONTROL_ERROR, SYSTEM, "SIMPLE-CONTROL-ERROR", 20, 0x7D4B7BA3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_FILE_ERROR, SYSTEM, "SIMPLE-FILE-ERROR", 17, 0x13122D90ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_PACKAGE_ERROR, SYSTEM, "SIMPLE-PACKAGE-ERROR", 20, 0x7942698DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_PARSE_ERROR, SYSTEM, "SIMPLE-PARSE-ERROR", 18, 0x3820786EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_PROGRAM_ERROR, SYSTEM, "SIMPLE-PROGRAM-ERROR", 20, 0x0A3E7D98ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_READER_ERROR, SYSTEM, "SIMPLE-READER-ERROR", 19, 0x3A564C9BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SIMPLE_STYLE_WARNING, SYSTEM, "SIMPLE-STYLE-WARNING", 20, 0x02568882ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_INITIALLY, SYSTEM, "LOOP-INITIALLY", 14, 0x65DF3B27ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FINALLY, SYSTEM, "LOOP-FINALLY", 12, 0x77E4E1C6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_WITH, SYSTEM, "LOOP-WITH", 9, 0x2498A6CAULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS, SYSTEM, "LOOP-FOR-AS", 11, 0x22F1D6B1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_IN_LIST, SYSTEM, "LOOP-FOR-AS-IN-LIST", 19, 0x1C73784BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_ON_LIST, SYSTEM, "LOOP-FOR-AS-ON-LIST", 19, 0x1C737851ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_EQUALS_THEN, SYSTEM, "LOOP-FOR-AS-EQUALS-THEN", 23, 0x65C2C096ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_ACROSS, SYSTEM, "LOOP-FOR-AS-ACROSS", 18, 0x1F446D4CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_HASH, SYSTEM, "LOOP-FOR-AS-HASH", 16, 0x184517FEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_PACKAGE_SYMBOL, SYSTEM, "LOOP-FOR-AS-PACKAGE-SYMBOL", 26, 0x0AC804F3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_PACKAGE_PRESENT, SYSTEM, "LOOP-FOR-AS-PACKAGE-PRESENT", 27, 0x1C13FFE7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_PACKAGE_EXTERNAL, SYSTEM, "LOOP-FOR-AS-PACKAGE-EXTERNAL", 28, 0x5A1005EAULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_ARITHMETIC_UP, SYSTEM, "LOOP-FOR-AS-ARITHMETIC-UP", 25, 0x4DADB9E1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_ARITHMETIC_DOWNTO, SYSTEM, "LOOP-FOR-AS-ARITHMETIC-DOWNTO", 29, 0x10FC1133ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FOR_AS_ARITHMETIC_DOWNFROM, SYSTEM, "LOOP-FOR-AS-ARITHMETIC-DOWNFROM", 31, 0x03496038ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_DO, SYSTEM, "LOOP-DO", 7, 0x509E9380ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_RETURN, SYSTEM, "LOOP-RETURN", 11, 0x24E2F3D9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_IF, SYSTEM, "LOOP-IF", 7, 0x50959880ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_UNLESS, SYSTEM, "LOOP-UNLESS", 11, 0x1CF0F7C9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_COLLECT, SYSTEM, "LOOP-COLLECT", 12, 0x70E1D7D1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_APPEND, SYSTEM, "LOOP-APPEND", 11, 0x20E3DEC9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_NCONC, SYSTEM, "LOOP-NCONC", 10, 0x1F92E0D1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_COUNT, SYSTEM, "LOOP-COUNT", 10, 0x259EE6D1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_SUM, SYSTEM, "LOOP-SUM", 8, 0x1DA4A281ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_MAXIMIZE, SYSTEM, "LOOP-MAXIMIZE", 13, 0x02D9EA14ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_MINIMIZE, SYSTEM, "LOOP-MINIMIZE", 13, 0x78E1EA14ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_WHILE, SYSTEM, "LOOP-WHILE", 10, 0x1997EBCFULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_UNTIL, SYSTEM, "LOOP-UNTIL", 10, 0x249DF0CCULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_REPEAT, SYSTEM, "LOOP-REPEAT", 11, 0x20E8E2C9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_ALWAYS, SYSTEM, "LOOP-ALWAYS", 11, 0x27EEE9C5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_NEVER, SYSTEM, "LOOP-NEVER", 10, 0x2694EFC8ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_THEREIS, SYSTEM, "LOOP-THEREIS", 12, 0x68E0E8D7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_NEXT_LOOP, SYSTEM, "NEXT-LOOP", 9, 0x23A791D4ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_END_LOOP, SYSTEM, "END-LOOP", 8, 0x7D939D99ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_VALUE_LOOP, SYSTEM, "VALUE-LOOP", 10, 0x2498BEF4ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FUNCTION_LOOP, SYSTEM, "FUNCTION-LOOP", 13, 0x60ECEB24ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_IT_LOOP, SYSTEM, "IT-LOOP", 7, 0x4C7DA39FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_STRUCTURE_GENSYM, SYSTEM, "STRUCTURE-GENSYM", 16, 0x3A482939ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_STRUCTURE_NAMED, SYSTEM, "STRUCTURE-NAMED", 15, 0x693A1B37ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CACHE, SYSTEM, "CACHE", 5, 0x4843418DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_DOCUMENTATION, SYSTEM, "TYPE-DOCUMENTATION", 18, 0x20397A8BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COMPILER_MACRO_FUNCTION, SYSTEM, "COMPILER-MACRO-FUNCTION", 23, 0x0092D5C0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SETF_COMPILER_MACRO_FUNCTION, SYSTEM, "SETF-COMPILER-MACRO-FUNCTION", 28, 0x5929F01BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COMPILE_WARNING, SYSTEM, "COMPILE-WARNING", 15, 0x4C2C2B3BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COMPILE_STYLE_WARNING, SYSTEM, "COMPILE-STYLE-WARNING", 21, 0x598C6BD2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_NTH_VALUE, SYSTEM, "NTH-VALUE", 9, 0x029495F2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_OPTIMIZE_CHECK, SYSTEM, "OPTIMIZE-CHECK", 14, 0x53F7281AULL, 0, 1, 0 }, { CONSTANT_SYSTEM_CAST_SINGLE_FLOAT, SYSTEM, "CAST-SINGLE-FLOAT", 17, 0x11312D62ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CAST_DOUBLE_FLOAT, SYSTEM, "CAST-DOUBLE-FLOAT", 17, 0x18371E5DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CAST_LONG_FLOAT, SYSTEM, "CAST-LONG-FLOAT", 15, 0x6F3CFC15ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BYTESPEC, SYSTEM, "BYTESPEC", 8, 0x0899A99DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_SYMBOL, SYSTEM, "TYPE-SYMBOL", 11, 0x12F5FBCEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TYPE_LIST, SYSTEM, "TYPE-LIST", 9, 0x1899A5DEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UNIX, SYSTEM, "UNIX", 4, 0x58494E59ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_WINDOWS, SYSTEM, "WINDOWS", 7, 0x44A1A0ADULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UNIVERSAL, SYSTEM, "UNIVERSAL", 9, 0x179CA0EFULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEVICE, SYSTEM, "DEVICE", 6, 0x49568A8DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOGICAL_PATHNAME, SYSTEM, "LOGICAL-PATHNAME", 16, 0x0435133DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TIME1970, SYSTEM, "TIME1970", 8, 0x7584828DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ASCII, SYSTEM, "ASCII", 5, 0x4943538FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_8, SYSTEM, "UTF-8", 5, 0x2D465492ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_8_BOM, SYSTEM, "UTF-8-BOM", 9, 0x7C8881E3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_16, SYSTEM, "UTF-16", 6, 0x2D468A8CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_16LE, SYSTEM, "UTF-16LE", 8, 0x72928A8EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_16BE, SYSTEM, "UTF-16BE", 8, 0x72888A8EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_16LE_BOM, SYSTEM, "UTF-16LE-BOM", 12, 0x3FE1CCBFULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_16BE_BOM, SYSTEM, "UTF-16BE-BOM", 12, 0x3FD7CCBFULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_32, SYSTEM, "UTF-32", 6, 0x2D46868EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_32LE, SYSTEM, "UTF-32LE", 8, 0x72928690ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_32BE, SYSTEM, "UTF-32BE", 8, 0x72888690ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_32LE_BOM, SYSTEM, "UTF-32LE-BOM", 12, 0x3FE1C8C1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UTF_32BE_BOM, SYSTEM, "UTF-32BE-BOM", 12, 0x3FD7C8C1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CR, SYSTEM, "CR", 2, 0x00005245ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LF, SYSTEM, "LF", 2, 0x0000464EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CRLF, SYSTEM, "CRLF", 4, 0x464C5247ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_AUTO, SYSTEM, "AUTO", 4, 0x4F545545ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CLOSE_ABORT, SYSTEM, "CLOSE-ABORT", 11, 0x15E4CBE2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PRINT_DISPATCH, SYSTEM, "PRINT-DISPATCH", 14, 0x6BCF1848ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_N, SYSTEM, "N", 1, 0x0000004FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_A, SYSTEM, "A", 1, 0x00000042ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_H, SYSTEM, "H", 1, 0x00000049ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_W, SYSTEM, "W", 1, 0x00000058ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_F, SYSTEM, "F", 1, 0x00000047ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_NA, SYSTEM, "NA", 2, 0x00004150ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DISPATCH_VECTOR, SYSTEM, "DISPATCH-VECTOR", 15, 0x5C2E4315ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DISPATCH_QUOTE, SYSTEM, "DISPATCH-QUOTE", 14, 0x67EC3414ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DISPATCH_CALL, SYSTEM, "DISPATCH-CALL", 13, 0x64D7E10BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DISPATCH_DEFUN, SYSTEM, "DISPATCH-DEFUN", 14, 0x5EDC3015ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DISPATCH_LET, SYSTEM, "DISPATCH-LET", 12, 0x6CDBE9BEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DELAY_WARNING, SYSTEM, "DELAY-WARNING", 13, 0x50ECC143ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DOC_TYPE, SYSTEM, "DOC-TYPE", 8, 0x7293A8A0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_OBJECT, SYSTEM, "OBJECT", 6, 0x454A9698ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_STEP, SYSTEM, "STEP", 4, 0x50455457ULL, 0, 0, 0 }, { CONSTANT_CODE_NOP, CODE, "NOP", 3, 0x00504F51ULL, 0, 0, 0 }, { CONSTANT_CODE_BEGIN, CODE, "BEGIN", 5, 0x49474595ULL, 0, 0, 0 }, { CONSTANT_CODE_BEGIN_CALL, CODE, "BEGIN-CALL", 10, 0x0A8ABEE6ULL, 0, 0, 0 }, { CONSTANT_CODE_END, CODE, "END", 3, 0x00444E48ULL, 0, 0, 0 }, { CONSTANT_CODE_ESCAPE, CODE, "ESCAPE", 6, 0x4143989BULL, 0, 0, 0 }, { CONSTANT_CODE_ESCAPE_NOT, CODE, "ESCAPE-NOT", 10, 0x0F70ECEEULL, 0, 0, 0 }, { CONSTANT_CODE_SAVE, CODE, "SAVE", 4, 0x45564157ULL, 0, 0, 0 }, { CONSTANT_CODE_RESTORE, CODE, "RESTORE", 7, 0x549897A8ULL, 0, 0, 0 }, { CONSTANT_CODE_NORMAL, CODE, "NORMAL", 6, 0x4D529B95ULL, 0, 0, 0 }, { CONSTANT_CODE_REVERT, CODE, "REVERT", 6, 0x455699AAULL, 0, 0, 0 }, { CONSTANT_CODE_REVERT_GOTO, CODE, "REVERT-GOTO", 11, 0x0CD2EDFEULL, 0, 0, 0 }, { CONSTANT_CODE_SET, CODE, "SET", 3, 0x00544556ULL, 0, 0, 0 }, { CONSTANT_CODE_PUSH, CODE, "PUSH", 4, 0x48535554ULL, 0, 0, 0 }, { CONSTANT_CODE_PUSH_RESULT, CODE, "PUSH-RESULT", 11, 0x1BECF3DDULL, 0, 0, 0 }, { CONSTANT_CODE_PUSH_VALUES, CODE, "PUSH-VALUES", 11, 0x14E7F0DDULL, 0, 0, 0 }, { CONSTANT_CODE_NIL_SET, CODE, "NIL-SET", 7, 0x2DA08EA8ULL, 0, 0, 0 }, { CONSTANT_CODE_NIL_PUSH, CODE, "NIL-PUSH", 8, 0x759F9EA6ULL, 0, 0, 0 }, { CONSTANT_CODE_T_SET, CODE, "T-SET", 5, 0x45532DADULL, 0, 0, 0 }, { CONSTANT_CODE_T_PUSH, CODE, "T-PUSH", 6, 0x555075ADULL, 0, 0, 0 }, { CONSTANT_CODE_LEXICAL, CODE, "LEXICAL", 7, 0x49A48696ULL, 0, 0, 0 }, { CONSTANT_CODE_LEXICAL_SET, CODE, "LEXICAL-SET", 11, 0x76F8CBEDULL, 0, 0, 0 }, { CONSTANT_CODE_LEXICAL_PUSH, CODE, "LEXICAL-PUSH", 12, 0x3EF7DBEBULL, 0, 0, 0 }, { CONSTANT_CODE_LEXICAL_REM, CODE, "LEXICAL-REM", 11, 0x76F1CBECULL, 0, 0, 0 }, { CONSTANT_CODE_LEXICAL_FREE, CODE, "LEXICAL-FREE", 12, 0x3BE9D8E1ULL, 0, 0, 0 }, { CONSTANT_CODE_SPECIAL, CODE, "SPECIAL", 7, 0x439191A3ULL, 0, 0, 0 }, { CONSTANT_CODE_SPECIAL_SET, CODE, "SPECIAL-SET", 11, 0x70E5D6FAULL, 0, 0, 0 }, { CONSTANT_CODE_SPECIAL_PUSH, CODE, "SPECIAL-PUSH", 12, 0x38E4E6F8ULL, 0, 0, 0 }, { CONSTANT_CODE_SPECIAL_REM, CODE, "SPECIAL-REM", 11, 0x70DED6F9ULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_SPECIAL, CODE, "DECLAIM-SPECIAL", 15, 0x3D222030ULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_TYPE_VALUE, CODE, "DECLAIM-TYPE-VALUE", 18, 0x0B22836DULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_TYPE_FUNCTION, CODE, "DECLAIM-TYPE-FUNCTION", 21, 0x5C7F82ACULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_INLINE, CODE, "DECLAIM-INLINE", 14, 0x42DD222AULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_NOTINLINE, CODE, "DECLAIM-NOTINLINE", 17, 0x112E2A77ULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_COMPILATION, CODE, "DECLAIM-COMPILATION", 19, 0x1E6D796DULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_DEBUG, CODE, "DECLAIM-DEBUG", 13, 0x4ED2D41DULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_SAFETY, CODE, "DECLAIM-SAFETY", 14, 0x3ED7293AULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_SPACE, CODE, "DECLAIM-SPACE", 13, 0x3CD1DF2AULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_SPEED, CODE, "DECLAIM-SPEED", 13, 0x3ED5DF29ULL, 0, 0, 0 }, { CONSTANT_CODE_DECLAIM_DECLARATION, CODE, "DECLAIM-DECLARATION", 19, 0x1A637566ULL, 0, 0, 0 }, { CONSTANT_CODE_TYPE_RESULT, CODE, "TYPE-RESULT", 11, 0x18E9F7E1ULL, 0, 0, 0 }, { CONSTANT_CODE_TYPE_LEXICAL, CODE, "TYPE-LEXICAL", 12, 0x69D6E8D6ULL, 0, 0, 0 }, { CONSTANT_CODE_TYPE_SPECIAL, CODE, "TYPE-SPECIAL", 12, 0x56E1F5D0ULL, 0, 0, 0 }, { CONSTANT_CODE_TYPE_GLOBAL, CODE, "TYPE-GLOBAL", 11, 0x14E8E1CEULL, 0, 0, 0 }, { CONSTANT_CODE_TYPE_FUNCTION, CODE, "TYPE-FUNCTION", 13, 0x62EEF41FULL, 0, 0, 0 }, { CONSTANT_CODE_TYPE_SETF, CODE, "TYPE-SETF", 9, 0x1995ACD0ULL, 0, 0, 0 }, { CONSTANT_CODE_LET_LEXICAL, CODE, "LET-LEXICAL", 11, 0x76F8CBE6ULL, 0, 0, 0 }, { CONSTANT_CODE_LET_SPECIAL, CODE, "LET-SPECIAL", 11, 0x70E5D6F3ULL, 0, 0, 0 }, { CONSTANT_CODE_LETA_SPECIAL, CODE, "LET*-SPECIAL", 12, 0x3BE5E1C8ULL, 0, 0, 0 }, { CONSTANT_CODE_SETQ_LEXICAL, CODE, "SETQ-LEXICAL", 12, 0x75DAD4D5ULL, 0, 0, 0 }, { CONSTANT_CODE_SETQ_SPECIAL, CODE, "SETQ-SPECIAL", 12, 0x62E5E1CFULL, 0, 0, 0 }, { CONSTANT_CODE_SETQ_GLOBAL, CODE, "SETQ-GLOBAL", 11, 0x20ECCDCDULL, 0, 0, 0 }, { CONSTANT_CODE_FUNCTION_SET, CODE, "FUNCTION-SET", 12, 0x65E2F1D3ULL, 0, 0, 0 }, { CONSTANT_CODE_FUNCTION_PUSH, CODE, "FUNCTION-PUSH", 13, 0x64F2EF1CULL, 0, 0, 0 }, { CONSTANT_CODE_SETF_SET, CODE, "SETF-SET", 8, 0x1A999888ULL, 0, 0, 0 }, { CONSTANT_CODE_SETF_PUSH, CODE, "SETF-PUSH", 9, 0x19A995D1ULL, 0, 0, 0 }, { CONSTANT_CODE_DEFMACRO, CODE, "DEFMACRO", 8, 0x1C98888DULL, 0, 0, 0 }, { CONSTANT_CODE_DEFTYPE, CODE, "DEFTYPE", 7, 0x548B95A4ULL, 0, 0, 0 }, { CONSTANT_CODE_DEFINE_COMPILER_MACRO, CODE, "DEFINE-COMPILER-MACRO", 21, 0x55595EDEULL, 0, 0, 0 }, { CONSTANT_CODE_DEFUN, CODE, "DEFUN", 5, 0x55464597ULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_NAME, CODE, "CALL-NAME", 9, 0x198D8FBEULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_RESULT, CODE, "CALL-RESULT", 11, 0x1FE5DFD0ULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_TYPE, CODE, "CALL-TYPE", 9, 0x1CA595BEULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_KEY, CODE, "CALL-KEY", 8, 0x25918C78ULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_FUNCTION, CODE, "CALL-FUNCTION", 13, 0x69EADC0EULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_SETF, CODE, "CALL-SETF", 9, 0x209194BFULL, 0, 0, 0 }, { CONSTANT_CODE_CALL_LEXICAL, CODE, "CALL-LEXICAL", 12, 0x70D2D0C5ULL, 0, 0, 0 }, { CONSTANT_CODE_VALUES_NIL, CODE, "VALUES-NIL", 10, 0x2379E0EEULL, 0, 0, 0 }, { CONSTANT_CODE_VALUES_SET, CODE, "VALUES-SET", 10, 0x2879E8EAULL, 0, 0, 0 }, { CONSTANT_CODE_THE_SET, CODE, "THE-SET", 7, 0x2D998DAEULL, 0, 0, 0 }, { CONSTANT_CODE_THE_PUSH, CODE, "THE-PUSH", 8, 0x75989DACULL, 0, 0, 0 }, { CONSTANT_CODE_IF_UNBOUND, CODE, "IF-UNBOUND", 10, 0x2A7CCCEFULL, 0, 0, 0 }, { CONSTANT_CODE_IF_NIL, CODE, "IF-NIL", 6, 0x4E2D9298ULL, 0, 0, 0 }, { CONSTANT_CODE_IF_T, CODE, "IF-T", 4, 0x542D464DULL, 0, 0, 0 }, { CONSTANT_CODE_GOTO, CODE, "GOTO", 4, 0x4F544F4BULL, 0, 0, 0 }, { CONSTANT_CODE_GO, CODE, "GO", 2, 0x00004F49ULL, 0, 0, 0 }, { CONSTANT_CODE_RETURN_FROM, CODE, "RETURN-FROM", 11, 0x1BCEE301ULL, 0, 0, 0 }, { CONSTANT_CODE_CATCH, CODE, "CATCH", 5, 0x43544190ULL, 0, 0, 0 }, { CONSTANT_CODE_THROW, CODE, "THROW", 5, 0x4F5248B0ULL, 0, 0, 0 }, { CONSTANT_CODE_TAG, CODE, "TAG", 3, 0x00474157ULL, 0, 0, 0 }, { CONSTANT_CODE_TAGINFO, CODE, "TAGINFO", 7, 0x499687A9ULL, 0, 0, 0 }, { CONSTANT_CODE_BLOCKINFO, CODE, "BLOCKINFO", 9, 0x099D95E5ULL, 0, 0, 0 }, { CONSTANT_CODE_HANDLER_BIND, CODE, "HANDLER-BIND", 12, 0x35EECFE2ULL, 0, 0, 0 }, { CONSTANT_CODE_HANDLER_CASE, CODE, "HANDLER-CASE", 12, 0x36F3C7E3ULL, 0, 0, 0 }, { CONSTANT_CODE_RESTART_BIND, CODE, "RESTART-BIND", 12, 0x45F5E0E1ULL, 0, 0, 0 }, { CONSTANT_CODE_RESTART_CASE, CODE, "RESTART-CASE", 12, 0x46FAD8E2ULL, 0, 0, 0 }, { CONSTANT_CODE_RESTART_PROGN, CODE, "RESTART-PROGN", 13, 0x48F6EA3EULL, 0, 0, 0 }, { CONSTANT_CODE_FUNCALL, CODE, "FUNCALL", 7, 0x439AA18EULL, 0, 0, 0 }, { CONSTANT_CODE_NTH_VALUE, CODE, "NTH-VALUE", 9, 0x029495F2ULL, 0, 0, 0 }, { CONSTANT_CODE_PROGV, CODE, "PROGV", 5, 0x474F52ABULL, 0, 0, 0 }, { CONSTANT_CODE_POP, CODE, "POP", 3, 0x00504F53ULL, 0, 0, 0 }, { CONSTANT_CODE_POP_UNBOUND, CODE, "POP-UNBOUND", 11, 0x7CD6EC05ULL, 0, 0, 0 }, { CONSTANT_CODE_GETF, CODE, "GETF", 4, 0x4654454BULL, 0, 0, 0 }, { CONSTANT_CODE_REST_COPY, CODE, "REST_COPY", 9, 0x24A28913ULL, 0, 0, 0 }, { CONSTANT_CODE_REST_BIND, CODE, "REST_BIND", 9, 0x229C87FEULL, 0, 0, 0 }, { CONSTANT_CODE_ALLOW_OTHER_KEYS, CODE, "ALLOW-OTHER-KEYS", 16, 0x2447043BULL, 0, 0, 0 }, { CONSTANT_CODE_REST_NULL, CODE, "REST-NULL", 9, 0x20A893D4ULL, 0, 0, 0 }, { CONSTANT_CODE_WHOLE, CODE, "WHOLE", 5, 0x4C4F48A1ULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA, CODE, "LAMBDA", 6, 0x424D8296ULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_NAME, CODE, "LAMBDA-NAME", 11, 0x10BFCFDCULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_TYPE, CODE, "LAMBDA-TYPE", 11, 0x16BFD2F4ULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_DOC, CODE, "LAMBDA-DOC", 10, 0x067AC5E9ULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_FORM, CODE, "LAMBDA-FORM", 11, 0x08C7D4EAULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_DEFUN, CODE, "LAMBDA-DEFUN", 12, 0x54CFC8E1ULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_CLOSURE, CODE, "LAMBDA-CLOSURE", 14, 0x5ACE173CULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_LEXICAL, CODE, "LAMBDA-LEXICAL", 14, 0x51C42724ULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_CACHE, CODE, "LAMBDA-CACHE", 12, 0x4AC2C5DDULL, 0, 0, 0 }, { CONSTANT_CODE_LAMBDA_CACHE_SET, CODE, "LAMBDA-CACHE-SET", 16, 0x1F08190EULL, 0, 0, 0 }, { CONSTANT_CODE_MACRO, CODE, "MACRO", 5, 0x524341A1ULL, 0, 0, 0 }, { CONSTANT_CODE_MACRO_SPECIAL, CODE, "MACRO-SPECIAL", 13, 0x63DFB23AULL, 0, 0, 0 }, { CONSTANT_CODE_MACRO_ENV, CODE, "MACRO-ENV", 9, 0x20886EFBULL, 0, 0, 0 }, { CONSTANT_CODE_MACRO_WHOLE, CODE, "MACRO-WHOLE", 11, 0x1ADFBAF6ULL, 0, 0, 0 }, { CONSTANT_CODE_LABELS_MAKE, CODE, "LABELS-MAKE", 11, 0x12B4DFE4ULL, 0, 0, 0 }, { CONSTANT_CODE_LABELS_LAMBDA, CODE, "LABELS-LAMBDA", 13, 0x55B1E227ULL, 0, 0, 0 }, { CONSTANT_CODE_BIND1_TYPE, CODE, "BIND1-TYPE", 10, 0x1DA2BBCDULL, 0, 0, 0 }, { CONSTANT_CODE_BIND1_SPECIAL, CODE, "BIND1-SPECIAL", 13, 0x55EABA11ULL, 0, 0, 0 }, { CONSTANT_CODE_BIND1_LEXICAL, CODE, "BIND1-LEXICAL", 13, 0x4ADDC024ULL, 0, 0, 0 }, { CONSTANT_CODE_BIND2_TYPE, CODE, "BIND2-TYPE", 10, 0x1DA2BBCEULL, 0, 0, 0 }, { CONSTANT_CODE_BIND2_SPECIAL, CODE, "BIND2-SPECIAL", 13, 0x55EABA12ULL, 0, 0, 0 }, { CONSTANT_CODE_BIND2_LEXICAL, CODE, "BIND2-LEXICAL", 13, 0x4ADDC025ULL, 0, 0, 0 }, { CONSTANT_CODE_LOAD_ALLOC, CODE, "LOAD-ALLOC", 10, 0x108DD3D2ULL, 0, 0, 0 }, { CONSTANT_CODE_LOAD_GENSYM, CODE, "LOAD-GENSYM", 11, 0x12D3EFD7ULL, 0, 0, 0 }, { CONSTANT_CODE_LOAD_SET, CODE, "LOAD-SET", 8, 0x1886A281ULL, 0, 0, 0 }, { CONSTANT_CODE_REFERENCE_SET, CODE, "REFERENCE-SET", 13, 0x4DE7B84AULL, 0, 0, 0 }, { CONSTANT_CODE_REFERENCE_PUSH, CODE, "REFERENCE-PUSH", 14, 0x5DE5004AULL, 0, 0, 0 }, { CONSTANT_CODE_STEP, CODE, "STEP", 4, 0x50455457ULL, 0, 0, 0 }, { CONSTANT_CODE_STEP_OFF, CODE, "STEP-OFF", 8, 0x168BA388ULL, 0, 0, 0 }, { CONSTANT_CODE_STEP_BEGIN, CODE, "STEP-BEGIN", 10, 0x178AE4D3ULL, 0, 0, 0 }, { CONSTANT_CODE_STEP_END, CODE, "STEP-END", 8, 0x14939988ULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_RESULT_TYPE, CODE, "OPTCODE-RESULT-TYPE", 19, 0x1A5F7EA8ULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CAR0_SET, CODE, "OPTCODE-CAR0-SET", 16, 0x7531291EULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CAR0_PUSH, CODE, "OPTCODE-CAR0-PUSH", 17, 0x74412667ULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CAR1_SET, CODE, "OPTCODE-CAR1-SET", 16, 0x7631291EULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CAR1_PUSH, CODE, "OPTCODE-CAR1-PUSH", 17, 0x75412667ULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CDR0_SET, CODE, "OPTCODE-CDR0-SET", 16, 0x75312C1EULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CDR0_PUSH, CODE, "OPTCODE-CDR0-PUSH", 17, 0x74412967ULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CDR1_SET, CODE, "OPTCODE-CDR1-SET", 16, 0x76312C1EULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CDR1_PUSH, CODE, "OPTCODE-CDR1-PUSH", 17, 0x75412967ULL, 0, 0, 0 }, { CONSTANT_CODE_OPTCODE_CONS, CODE, "OPTCODE-CONS", 12, 0x43E7E3EDULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METAOBJECT, CLOS, "METAOBJECT", 10, 0x069EDBE9ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SPECIALIZER, CLOS, "SPECIALIZER", 11, 0x0CE3D701ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_EQL_SPECIALIZER, CLOS, "EQL-SPECIALIZER", 15, 0x3A30284AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FORWARD_REFERENCED_CLASS, CLOS, "FORWARD-REFERENCED-CLASS", 24, 0x23ABB1D4ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FUNCALLABLE_STANDARD_OBJECT, CLOS, "FUNCALLABLE-STANDARD-OBJECT", 27, 0x0F0A15EDULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FUNCALLABLE_STANDARD_CLASS, CLOS, "FUNCALLABLE-STANDARD-CLASS", 26, 0x05C019FAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STANDARD_READER_METHOD, CLOS, "STANDARD-READER-METHOD", 22, 0x497FB6BAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STANDARD_WRITER_METHOD, CLOS, "STANDARD-WRITER-METHOD", 22, 0x518CBBCAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STANDARD_ACCESSOR_METHOD, CLOS, "STANDARD-ACCESSOR-METHOD", 24, 0x2EC69FC7ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION, CLOS, "SLOT-DEFINITION", 15, 0x6F2C2E21ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DIRECT_SLOT_DEFINITION, CLOS, "DIRECT-SLOT-DEFINITION", 22, 0x586EC9CAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_EFFECTIVE_SLOT_DEFINITION, CLOS, "EFFECTIVE-SLOT-DEFINITION", 25, 0x49A2B711ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STANDARD_SLOT_DEFINITION, CLOS, "STANDARD-SLOT-DEFINITION", 24, 0x3EC1A8CAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STANDARD_DIRECT_SLOT_DEFINITION, CLOS, "STANDARD-DIRECT-SLOT-DEFINITION", 31, 0x015D4B3AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_STANDARD_EFFECTIVE_SLOT_DEFINITION, CLOS, "STANDARD-EFFECTIVE-SLOT-DEFINITION", 34, 0x354A8FAEULL, 0, 0, 0 }, { CONSTANT_COMMON_ALLOCATE_INSTANCE, CLOS, "ALLOCATE-INSTANCE", 17, 0x2B3D185BULL, 0, 0, 0 }, { CONSTANT_COMMON_INITIALIZE_INSTANCE, CLOS, "INITIALIZE-INSTANCE", 19, 0x285C6B9BULL, 0, 0, 0 }, { CONSTANT_COMMON_REINITIALIZE_INSTANCE, CLOS, "REINITIALIZE-INSTANCE", 21, 0x6B896DC2ULL, 0, 0, 0 }, { CONSTANT_COMMON_SHARED_INITIALIZE, CLOS, "SHARED-INITIALIZE", 17, 0x3F0C227DULL, 0, 0, 0 }, { CONSTANT_COMMON_ENSURE_GENERIC_FUNCTION, CLOS, "ENSURE-GENERIC-FUNCTION", 23, 0x0984C2DAULL, 0, 0, 0 }, { CONSTANT_COMMON_MAKE_INSTANCE, CLOS, "MAKE-INSTANCE", 13, 0x5BE7CC20ULL, 0, 0, 0 }, { CONSTANT_COMMON_SLOT_MISSING, CLOS, "SLOT-MISSING", 12, 0x6EE6E2DFULL, 0, 0, 0 }, { CONSTANT_COMMON_SLOT_UNBOUND, CLOS, "SLOT-UNBOUND", 12, 0x5AEBF6DBULL, 0, 0, 0 }, { CONSTANT_COMMON_CHANGE_CLASS, CLOS, "CHANGE-CLASS", 12, 0x64C1CEE2ULL, 0, 0, 0 }, { CONSTANT_COMMON_FUNCTION_KEYWORDS, CLOS, "FUNCTION-KEYWORDS", 17, 0x2F353982ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_REDEFINED, CLOS, "REDEFINED", 9, 0x0A928EE5ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_REFERENCED_CLASS, CLOS, "REFERENCED-CLASS", 16, 0x1F151045ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ENSURE_CLASS, CLOS, "ENSURE-CLASS", 12, 0x6BD3D4EFULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_ENSURE_CLASS_USING_CLASS, CLOS, "ENSURE-CLASS-USING-CLASS", 24, 0x4BA7B2C2ULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_ENSURE_GENERIC_FUNCTION_USING_CLASS, CLOS, "ENSURE-GENERIC-FUNCTION-USING-CLASS", 35, 0x516496C3ULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_ENSURE_METHOD, CLOS, "ENSURE-METHOD", 13, 0x71C8E82DULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_SLOT_BOUNDP_USING_CLASS, CLOS, "SLOT-BOUNDP-USING-CLASS", 23, 0x71CEA6C2ULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_SLOT_EXISTS_P_USING_CLASS, CLOS, "SLOT-EXISTS-P-USING-CLASS", 25, 0x1ED8AE1BULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_SLOT_MAKUNBOUND_USING_CLASS, CLOS, "SLOT-MAKUNBOUND-USING-CLASS", 27, 0x36F70A22ULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_SLOT_VALUE_USING_CLASS, CLOS, "SLOT-VALUE-USING-CLASS", 22, 0x7E58C7BEULL, 0, 1, 0 }, { CONSTANT_CLOSNAME_FLET_METHOD_P, CLOS, "FLET-METHOD-P", 13, 0x55CEE918ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FLET_NEXT_METHOD, CLOS, "FLET-NEXT-METHOD", 16, 0x3627102BULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DEFINE_METHOD_COMBINATION, CLOS, "DEFINE-METHOD-COMBINATION", 25, 0x5291A310ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DEFINE_LONG_METHOD_COMBINATION, CLOS, "DEFINE-LONG-METHOD-COMBINATION", 30, 0x60D33F87ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_DEFINE_SHORT_METHOD_COMBINATION, CLOS, "DEFINE-SHORT-METHOD-COMBINATION", 31, 0x092C6343ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_LONG_METHOD_COMBINATION, CLOS, "LONG-METHOD-COMBINATION", 23, 0x5FB4D8ADULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SHORT_METHOD_COMBINATION, CLOS, "SHORT-METHOD-COMBINATION", 24, 0x38D893D6ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_COMBINATION_INSTANCE, CLOS, "METHOD-COMBINATION-INSTANCE", 27, 0x28DEFD3FULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ENSURE_METHOD_COMBINATION_SHORT, CLOS, "ENSURE-METHOD-COMBINATION-SHORT", 31, 0x27462B6AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ENSURE_METHOD_COMBINATION_LONG, CLOS, "ENSURE-METHOD-COMBINATION-LONG", 30, 0x2DEB2068ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_QUALIFIERS_ELT, CLOS, "QUALIFIERS-ELT", 14, 0x56B84346ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_COMBINATION_BINDING, CLOS, "COMBINATION-BINDING", 19, 0x08728473ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_MACRO_MAKE_METHOD, CLOS, "MACRO-MAKE-METHOD", 17, 0x30060881ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_MACRO_CALL_METHOD, CLOS, "MACRO-CALL-METHOD", 17, 0x2FFC0F82ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_MACRO_METHOD_LAMBDA, CLOS, "MACRO-METHOD-LAMBDA", 19, 0x29624772ULL, 0, 0, 0 }, { CONSTANT_COMMON_CLASS_NAME, CLOS, "CLASS-NAME", 10, 0x148FBEEDULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_SLOTS, CLOS, "CLASS-SLOTS", 11, 0x1FE7CDF0ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_DIRECT_SLOTS, CLOS, "CLASS-DIRECT-SLOTS", 18, 0x4015657BULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_DEFAULT_INITARGS, CLOS, "CLASS-DEFAULT-INITARGS", 22, 0x05658FD6ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_DIRECT_DEFAULT_INITARGS, CLOS, "CLASS-DIRECT-DEFAULT-INITARGS", 29, 0x1BFAE347ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_DIRECT_SUPERCLASSES, CLOS, "CLASS-DIRECT-SUPERCLASSES", 25, 0x52B4B807ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_DIRECT_SUBCLASSES, CLOS, "CLASS-DIRECT-SUBCLASSES", 23, 0x06B2A3C2ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_FINALIZED_P, CLOS, "CLASS-FINALIZED-P", 17, 0x1318009FULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_CLASS_PROTOTYPE, CLOS, "CLASS-PROTOTYPE", 15, 0x7A261E4DULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION_NAME, CLOS, "SLOT-DEFINITION-NAME", 20, 0x61796F74ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION_TYPE, CLOS, "SLOT-DEFINITION-TYPE", 20, 0x617C877AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION_ALLOCATION, CLOS, "SLOT-DEFINITION-ALLOCATION", 26, 0x34CD09FFULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION_INITARGS, CLOS, "SLOT-DEFINITION-INITARGS", 24, 0x43BCCEB4ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION_INITFORM, CLOS, "SLOT-DEFINITION-INITFORM", 24, 0x3DC7CBB9ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_SLOT_DEFINITION_INITFUNCTION, CLOS, "SLOT-DEFINITION-INITFUNCTION", 28, 0x02131B11ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_NAME, CLOS, "GENERIC-FUNCTION-NAME", 21, 0x51707BBAULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_METHODS, CLOS, "GENERIC-FUNCTION-METHODS", 24, 0x2BB8C9C0ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_LAMBDA_LIST, CLOS, "GENERIC-FUNCTION-LAMBDA-LIST", 28, 0x5305070AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_ARGUMENT_PRECEDENCE_ORDER, CLOS, "GENERIC-FUNCTION-ARGUMENT-PRECEDENCE-ORDER", 42, 0x39F21C2FULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_DECLARATIONS, CLOS, "GENERIC-FUNCTION-DECLARATIONS", 29, 0x5715FC70ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_METHOD_CLASS, CLOS, "GENERIC-FUNCTION-METHOD-CLASS", 29, 0x58FA165BULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_GENERIC_FUNCTION_METHOD_COMBINATION, CLOS, "GENERIC-FUNCTION-METHOD-COMBINATION", 35, 0x1C95B6A0ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_FUNCTION, CLOS, "METHOD-FUNCTION", 15, 0x63132749ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_GENERIC_FUNCTION, CLOS, "METHOD-GENERIC-FUNCTION", 23, 0x7C85B8DFULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_LAMBDA_LIST, CLOS, "METHOD-LAMBDA-LIST", 18, 0x22105883ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_METHOD_SPECIALIZERS, CLOS, "METHOD-SPECIALIZERS", 19, 0x3F616D85ULL, 0, 0, 0 }, { CONSTANT_COMMON_METHOD_QUALIFIERS, CLOS, "METHOD-QUALIFIERS", 17, 0x3513149BULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_ACCESSOR_METHOD_SLOT_DEFINITION, CLOS, "ACCESSOR-METHOD-SLOT-DEFINITION", 31, 0x0848613AULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_MAKE_METHOD_LAMBDA, CLOS, "MAKE-METHOD-LAMBDA", 18, 0x09226064ULL, 0, 0, 0 }, { CONSTANT_CLOSNAME_FIND_METHOD_COMBINATION, CLOS, "FIND-METHOD-COMBINATION", 23, 0x5CB4D2A7ULL, 0, 1, 0 }, { CONSTANT_RT_ERROR, RT, "ERROR", 5, 0x4F52529CULL, 0, 0, 0 }, { CONSTANT_RT_PUSH_ENTRIES, RT, "PUSH-ENTRIES", 12, 0x6FE6E3DBULL, 0, 0, 0 }, { CONSTANT_RT_DEFTEST, RT, "DEFTEST", 7, 0x549A9890ULL, 0, 0, 0 }, { CONSTANT_RT_DEFTEST_ERROR, RT, "DEFTEST-ERROR", 13, 0x50ECEB2DULL, 0, 0, 0 }, { CONSTANT_RT_DEFTEST_ERROR_, RT, "DEFTEST-ERROR!", 14, 0x50ED0C2EULL, 0, 0, 0 }, { CONSTANT_RT_DO_TESTS, RT, "DO-TESTS", 8, 0x2781A291ULL, 0, 0, 0 }, { CONSTANT_RT_REM_ALL_TESTS, RT, "REM-ALL-TESTS", 13, 0x2EECD747ULL, 0, 0, 0 }, { CONSTANT_RT_EQUALRT, RT, "EQUALRT", 7, 0x41A9A398ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INPUT, SYSTEM, "INPUT", 5, 0x55504EA2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PROCESS, SYSTEM, "PROCESS", 7, 0x43A2A59CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_READTABLE_DOT, SYSTEM, "READTABLE-DOT", 13, 0x5FC7B44CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DOUBLE_QUOTE_READER, SYSTEM, "DOUBLE-QUOTE-READER", 19, 0x1A6E7B69ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SINGLE_QUOTE_READER, SYSTEM, "SINGLE-QUOTE-READER", 19, 0x1F677578ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PARENSIS_OPEN_READER, SYSTEM, "PARENSIS-OPEN-READER", 20, 0x7583556EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PARENSIS_CLOSE_READER, SYSTEM, "PARENSIS-CLOSE-READER", 21, 0x7F595ECAULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SEMICOLON_READER, SYSTEM, "SEMICOLON-READER", 16, 0x30310635ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BACKQUOTE_READER, SYSTEM, "BACKQUOTE-READER", 16, 0x372A0829ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COMMA_READER, SYSTEM, "COMMA-READER", 12, 0x64E4C0D1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SHARP_READER, SYSTEM, "SHARP-READER", 12, 0x69D8B9F0ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DISPATCH_FUNCTION, SYSTEM, "DISPATCH-FUNCTION", 17, 0x36353854ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ERROR_DISPATCH, SYSTEM, "ERROR-DISPATCH", 14, 0x6CD8183BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_EQUAL_DISPATCH, SYSTEM, "EQUAL-DISPATCH", 14, 0x5EDB1735ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SHARP_DISPATCH, SYSTEM, "SHARP-DISPATCH", 14, 0x6FC70E47ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SINGLE_QUOTE_DISPATCH, SYSTEM, "SINGLE-QUOTE-DISPATCH", 21, 0x746D63CEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PARENSIS_OPEN_DISPATCH, SYSTEM, "PARENSIS-OPEN-DISPATCH", 22, 0x7B71A9C5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PARENSIS_CLOSE_DISPATCH, SYSTEM, "PARENSIS-CLOSE-DISPATCH", 23, 0x6DADB3D2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ASTERISK_DISPATCH, SYSTEM, "ASTERISK-DISPATCH", 17, 0x27452269ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COLON_DISPATCH, SYSTEM, "COLON-DISPATCH", 14, 0x6CD21535ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LESS_DISPATCH, SYSTEM, "LESS-DISPATCH", 13, 0x69F0CB1EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BACKSLASH_DISPATCH, SYSTEM, "BACKSLASH-DISPATCH", 18, 0x3C0A5385ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_OR_DISPATCH, SYSTEM, "OR-DISPATCH", 11, 0x05C5E8F7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PLUS_DISPATCH, SYSTEM, "PLUS-DISPATCH", 13, 0x69F2D222ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MINUS_DISPATCH, SYSTEM, "MINUS-DISPATCH", 14, 0x72D40F44ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DOT_DISPATCH, SYSTEM, "DOT-DISPATCH", 12, 0x45EAECD5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ARRAY_DISPATCH, SYSTEM, "ARRAY-DISPATCH", 14, 0x5ED8183EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BINARY_DISPATCH, SYSTEM, "BINARY-DISPATCH", 15, 0x47143940ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_COMPLEX_DISPATCH, SYSTEM, "COMPLEX-DISPATCH", 16, 0x163C3224ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_OCTAL_DISPATCH, SYSTEM, "OCTAL-DISPATCH", 14, 0x5EDA093FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PATHNAME_DISPATCH, SYSTEM, "PATHNAME-DISPATCH", 17, 0x243F0874ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_RADIX_DISPATCH, SYSTEM, "RADIX-DISPATCH", 14, 0x66CA074EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_STRUCTURE_DISPATCH, SYSTEM, "STRUCTURE-DISPATCH", 18, 0x452D6E83ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_HEXADECIMAL_DISPATCH, SYSTEM, "HEXADECIMAL-DISPATCH", 20, 0x507E6972ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_BACKQUOTE, SYSTEM, "BACKQUOTE", 9, 0x1F9296E1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_UNBOUND_VALUE, SYSTEM, "UNBOUND-VALUE", 13, 0x51D2DE52ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INCLUDE, SYSTEM, "INCLUDE", 7, 0x4C8892A5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_EXCLUDE, SYSTEM, "EXCLUDE", 7, 0x4C889CA1ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INVALID, SYSTEM, "INVALID", 7, 0x419A979CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FALSE, SYSTEM, "FALSE", 5, 0x534C4190ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_ATOMIC, SYSTEM, "SUBTYPEP-ATOMIC", 15, 0x741F3035ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_ATOMIC_NOT, SYSTEM, "SUBTYPEP-ATOMIC-NOT", 19, 0x21737F87ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_COMPOUND, SYSTEM, "SUBTYPEP-COMPOUND", 17, 0x402C387EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_FORCE_NUMBER, SYSTEM, "SUBTYPEP-FORCE-NUMBER", 21, 0x0A467ED8ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_NORMAL, SYSTEM, "SUBTYPEP-NORMAL", 15, 0x77233535ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TERME_INPUT, SYSTEM, "TERME-INPUT", 11, 0x1BEFC7F4ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_OUTPUT, SYSTEM, "TERME-OUTPUT", 12, 0x76F6C2F9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_MOVE, SYSTEM, "TERME-MOVE", 10, 0x1C9FB7F9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_CLEAR, SYSTEM, "TERME-CLEAR", 11, 0x19E7B3E9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_DELETE, SYSTEM, "TERME-DELETE", 12, 0x57EAB7F1ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_FONT, SYSTEM, "TERME-FONT", 10, 0x1C98C6F1ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_SIZE, SYSTEM, "TERME-SIZE", 10, 0x16A5B7FDULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_SCROLL, SYSTEM, "TERME-SCROLL", 12, 0x5CF1C1F7ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_BEGIN, SYSTEM, "TERME-BEGIN", 11, 0x12E2BBEBULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_END, SYSTEM, "TERME-END", 9, 0x1B9772E6ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_ENABLE, SYSTEM, "TERME-ENABLE", 12, 0x60E3B4E6ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_SIGNAL, SYSTEM, "TERME-SIGNAL", 12, 0x62E6C0ECULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_HANG, SYSTEM, "TERME-HANG", 10, 0x0E9AB9F1ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_CODE, SYSTEM, "TERME-CODE", 10, 0x1C95B7E7ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_UP, SYSTEM, "TERME-UP", 8, 0x1DA772A1ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_DOWN, SYSTEM, "TERME-DOWN", 10, 0x1C96C0FAULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_LEFT, SYSTEM, "TERME-LEFT", 10, 0x129EC6E9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_RIGHT, SYSTEM, "TERME-RIGHT", 11, 0x16F8BAEBULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_PAGE_UP, SYSTEM, "TERME-PAGE-UP", 13, 0x63CFB83DULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_PAGE_DOWN, SYSTEM, "TERME-PAGE-DOWN", 15, 0x531E0F3EULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_HOME, SYSTEM, "TERME-HOME", 10, 0x1C9AB7F0ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_INSERT, SYSTEM, "TERME-INSERT", 12, 0x6FEDB7F8ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_FUNCTION, SYSTEM, "TERME-FUNCTION", 14, 0x6BED0444ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME_ESCAPE, SYSTEM, "TERME-ESCAPE", 12, 0x65E7B3E8ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_FP_NAN, SYSTEM, "FP-NAN", 6, 0x4E2D9E8DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FP_INFINITE, SYSTEM, "FP-INFINITE", 11, 0x17BBEAE8ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FP_NORMAL, SYSTEM, "FP-NORMAL", 9, 0x0F7AA2EAULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FP_SUBNORMAL, SYSTEM, "FP-SUBNORMAL", 12, 0x6EBCDFF9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_FP_ZERO, SYSTEM, "FP-ZERO", 7, 0x5A7CA292ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PAPER, SYSTEM, "PAPER", 5, 0x455041A7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFINE_SYMBOL_MACRO, SYSTEM, "DEFINE-SYMBOL-MACRO", 19, 0x2D52578DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SYMBOL_MACRO_EXPANDER, SYSTEM, "SYMBOL-MACRO-EXPANDER", 21, 0x74697CB8ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFCONSTANT, SYSTEM, "DEFCONSTANT", 11, 0x17EDE1DFULL, 0, 0, 0 }, { CONSTANT_SYSTEM_IN_PACKAGE, SYSTEM, "IN-PACKAGE", 10, 0x1178D6DBULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SETPLIST, SYSTEM, "SETPLIST", 8, 0x24A78EA7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_REMPLIST, SYSTEM, "REMPLIST", 8, 0x24A08EA6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MAKE_HASH_ITERATOR, SYSTEM, "MAKE-HASH-ITERATOR", 18, 0x41175B68ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_NEXT_HASH_ITERATOR, SYSTEM, "NEXT-HASH-ITERATOR", 18, 0x50245F69ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MAKE_PACKAGE_ITERATOR, SYSTEM, "MAKE-PACKAGE-ITERATOR", 21, 0x627C5DABULL, 0, 0, 0 }, { CONSTANT_SYSTEM_NEXT_PACKAGE_ITERATOR, SYSTEM, "NEXT-PACKAGE-ITERATOR", 21, 0x718961ACULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFPACKAGE, SYSTEM, "DEFPACKAGE", 10, 0x1191CDD6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DO_SYMBOLS, SYSTEM, "DO-SYMBOLS", 10, 0x226FEFF3ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DO_EXTERNAL_SYMBOLS, SYSTEM, "DO-EXTERNAL-SYMBOLS", 19, 0x075F8A9FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DO_ALL_SYMBOLS, SYSTEM, "DO-ALL-SYMBOLS", 14, 0x639D3C43ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_GETDOC_VARIABLE, SYSTEM, "GETDOC-VARIABLE", 15, 0x5C102728ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SETDOC_VARIABLE, SYSTEM, "SETDOC-VARIABLE", 15, 0x5C102734ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ECASE_ERROR, SYSTEM, "ECASE-ERROR", 11, 0x25D8BFE7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ETYPECASE_ERROR, SYSTEM, "ETYPECASE-ERROR", 15, 0x76321430ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFINE_SETF_EXPANDER, SYSTEM, "DEFINE-SETF-EXPANDER", 20, 0x5D4F7B7EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_END_INPUT_STREAM, SYSTEM, "END-INPUT-STREAM", 16, 0x24290F44ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MAKE_EXTEND_OUTPUT_STREAM, SYSTEM, "MAKE-EXTEND-OUTPUT-STREAM", 25, 0x2BAED11DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PROMPT_FOR, SYSTEM, "PROMPT-FOR", 10, 0x137CF8F9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_PRINT_UNREADABLE_CALL, SYSTEM, "PRINT-UNREADABLE-CALL", 21, 0x726D4AC5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_WRITE_DEFAULT, SYSTEM, "WRITE-DEFAULT", 13, 0x65E2C143ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SYMBOL_DEFTYPE, SYSTEM, "SYMBOL-DEFTYPE", 14, 0x5FCF3145ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DELETE_DEFTYPE, SYSTEM, "DELETE-DEFTYPE", 14, 0x62CE163BULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ENSURE_STRUCTURE, SYSTEM, "ENSURE-STRUCTURE", 16, 0x31283B4FULL, 0, 0, 0 }, { CONSTANT_SYSTEM_STRUCTURE_CONSTRUCTOR, SYSTEM, "STRUCTURE-CONSTRUCTOR", 21, 0x18936CE5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_LOOP_BIND, SYSTEM, "LOOP-BIND", 9, 0x1E9891C6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MAKE_PPRINT_STREAM, SYSTEM, "MAKE-PPRINT-STREAM", 18, 0x0A428169ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PPRINT_GENSYM, SYSTEM, "PPRINT-GENSYM", 13, 0x69D2F33DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PPRINT_EXIT, SYSTEM, "PPRINT-EXIT", 11, 0x0ED3EE01ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PPRINT_POP, SYSTEM, "PPRINT-POP", 10, 0x197FF4F7ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PPRINT_CHECK, SYSTEM, "PPRINT-CHECK", 12, 0x57C2E9F2ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PPRINT_CLOSE, SYSTEM, "PPRINT-CLOSE", 12, 0x51D2F3F6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_PPRINT_PRETTY, SYSTEM, "PPRINT-PRETTY", 13, 0x6DD3EA56ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TIMEINFO, SYSTEM, "TIMEINFO", 8, 0x149397A5ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TRACE_ADD, SYSTEM, "TRACE-ADD", 9, 0x07827FE6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_TRACE_DEL, SYSTEM, "TRACE-DEL", 9, 0x08857FEEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_WITH_COMPILATION_UNIT, SYSTEM, "WITH-COMPILATION-UNIT", 21, 0x6E8D74BEULL, 0, 0, 0 }, { CONSTANT_SYSTEM_SET_SLOTS, SYSTEM, "SET-SLOTS", 9, 0x01A39202ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_INTERN_EQL_SPECIALIZER, SYSTEM, "INTERN-EQL-SPECIALIZER", 22, 0x013BCCD8ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFGENERIC_DEFINE, SYSTEM, "DEFGENERIC-DEFINE", 17, 0x2C021D6DULL, 0, 0, 0 }, { CONSTANT_SYSTEM_DEFGENERIC_METHOD, SYSTEM, "DEFGENERIC-METHOD", 17, 0x36012B6CULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CONDITION_RESTARTS_PUSH, SYSTEM, "CONDITION-RESTARTS-PUSH", 23, 0x7BA0CBEDULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CONDITION_RESTARTS_POP, SYSTEM, "CONDITION-RESTARTS-POP", 22, 0x7B58C8E6ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_CONDITION_RESTARTS_MAKE, SYSTEM, "CONDITION-RESTARTS-MAKE", 23, 0x789DC3D9ULL, 0, 0, 0 }, { CONSTANT_SYSTEM_MAKE_RESTART, SYSTEM, "MAKE-RESTART", 12, 0x6CE2D4DAULL, 0, 0, 0 }, { CONSTANT_SYSTEM_RESTART_PROGN, SYSTEM, "RESTART-PROGN", 13, 0x48F6EA3EULL, 0, 0, 0 }, { CONSTANT_SYSTEM_ABORT_LISP, SYSTEM, "ABORT-LISP", 10, 0x1B9BBFF2ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_HELLO, SYSTEM, "HELLO", 5, 0x4C4C459CULL, 0, 1, 0 }, { CONSTANT_SYSTEM_INFOBIT, SYSTEM, "INFOBIT", 7, 0x4F9A9792ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_INFOPRINT, SYSTEM, "INFOPRINT", 9, 0x1D8FA0F6ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_GC, SYSTEM, "GC", 2, 0x00004349ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SAVECORE, SYSTEM, "SAVECORE", 8, 0x0AA8909EULL, 0, 1, 0 }, { CONSTANT_SYSTEM_LOADCORE, SYSTEM, "LOADCORE", 8, 0x09939E97ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_PACKAGE_EXPORT_LIST, SYSTEM, "PACKAGE-EXPORT-LIST", 19, 0x145A8884ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SPECIALP, SYSTEM, "SPECIALP", 8, 0x139191A4ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_ARRAY_GENERAL_P, SYSTEM, "ARRAY-GENERAL-P", 15, 0x483BF243ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_ARRAY_SPECIALIZED_P, SYSTEM, "ARRAY-SPECIALIZED-P", 19, 0x18993982ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SIMPLE_SORT, SYSTEM, "SIMPLE-SORT", 11, 0x23CEE0F9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_BUBBLE_SORT, SYSTEM, "BUBBLE-SORT", 11, 0x15C3ECE8ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_QUICK_SORT, SYSTEM, "QUICK-SORT", 10, 0x129CD6F8ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MERGE_SORT, SYSTEM, "MERGE-SORT", 10, 0x16A5C6EEULL, 0, 1, 0 }, { CONSTANT_SYSTEM_EXIT, SYSTEM, "EXIT", 4, 0x54495849ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_QUIT, SYSTEM, "QUIT", 4, 0x54495555ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_CLOSP, SYSTEM, "CLOSP", 5, 0x534F4C98ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_FIXNUMP, SYSTEM, "FIXNUMP", 7, 0x4EA896A2ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_BIGNUMP, SYSTEM, "BIGNUMP", 7, 0x4E97969EULL, 0, 1, 0 }, { CONSTANT_SYSTEM_RATIOP, SYSTEM, "RATIOP", 6, 0x495491A7ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SHORT_FLOAT_P, SYSTEM, "SHORT-FLOAT-P", 13, 0x4BE9B753ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SINGLE_FLOAT_P, SYSTEM, "SINGLE-FLOAT-P", 14, 0x61BD2E26ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_DOUBLE_FLOAT_P, SYSTEM, "DOUBLE-FLOAT-P", 14, 0x5CC43417ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_LONG_FLOAT_P, SYSTEM, "LONG-FLOAT-P", 12, 0x66C7E9C6ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_CALLNAMEP, SYSTEM, "CALLNAMEP", 9, 0x119982EAULL, 0, 1, 0 }, { CONSTANT_SYSTEM_LARGE_NUMBER, SYSTEM, "LARGE-NUMBER", 12, 0x6EE5B0EAULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_CHARACTER, SYSTEM, "MAKE-CHARACTER", 14, 0x5AD7181FULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_FIXNUM, SYSTEM, "MAKE-FIXNUM", 11, 0x1DE1DCD3ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_BIGNUM, SYSTEM, "MAKE-BIGNUM", 11, 0x0CE1D8D3ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_RATIO, SYSTEM, "MAKE-RATIO", 10, 0x198CE2CDULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_COMPLEX, SYSTEM, "MAKE-COMPLEX", 12, 0x6ADFD0D6ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_EQUAL_RANDOM_STATE, SYSTEM, "EQUAL-RANDOM-STATE", 18, 0x114B5B72ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_EXTEND, SYSTEM, "SUBTYPEP!", 9, 0x2487A5D6ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_NUMBER, SYSTEM, "SUBTYPEP-NUMBER", 15, 0x722F392AULL, 0, 1, 0 }, { CONSTANT_SYSTEM_EASTASIAN_SET, SYSTEM, "EASTASIAN-SET", 13, 0x5AEFC235ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_EASTASIAN_GET, SYSTEM, "EASTASIAN-GET", 13, 0x5AE3C235ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_EASTASIAN_WIDTH, SYSTEM, "EASTASIAN-WIDTH", 15, 0x5F3C1627ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_RUN_PROGRAM, SYSTEM, "RUN-PROGRAM", 11, 0x74EAE8FFULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_CALLNAME, SYSTEM, "MAKE-CALLNAME", 13, 0x5ECDD318ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_REMOVE_FILE, SYSTEM, "REMOVE-FILE", 11, 0x15BFD6FCULL, 0, 1, 0 }, { CONSTANT_SYSTEM_REMOVE_DIRECTORY, SYSTEM, "REMOVE-DIRECTORY", 16, 0x30122C55ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_DECLARE_PARSE, SYSTEM, "DECLARE-PARSE", 13, 0x4CDAD927ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_PARSE_TYPE, SYSTEM, "PARSE-TYPE", 10, 0x2CA6B3EFULL, 0, 1, 0 }, { CONSTANT_SYSTEM_UPGRADED_OPEN_ELEMENT_TYPE, SYSTEM, "UPGRADED-OPEN-ELEMENT-TYPE", 26, 0x4FBBD114ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_MEMORY_INPUT_STREAM, SYSTEM, "MAKE-MEMORY-INPUT-STREAM", 24, 0x36CEA1D0ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_MEMORY_OUTPUT_STREAM, SYSTEM, "MAKE-MEMORY-OUTPUT-STREAM", 25, 0x24B0DD27ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_MEMORY_IO_STREAM, SYSTEM, "MAKE-MEMORY-IO-STREAM", 21, 0x545C82C8ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_WITH_INPUT_FROM_MEMORY, SYSTEM, "WITH-INPUT-FROM-MEMORY", 22, 0x5B6AD4E0ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_WITH_OUTPUT_TO_MEMORY, SYSTEM, "WITH-OUTPUT-TO-MEMORY", 21, 0x697A8ADBULL, 0, 1, 0 }, { CONSTANT_SYSTEM_GET_OUTPUT_STREAM_MEMORY, SYSTEM, "GET-OUTPUT-STREAM-MEMORY", 24, 0x30BABDF1ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MEMORY_STREAM_P, SYSTEM, "MEMORY-STREAM-P", 15, 0x64101E4FULL, 0, 1, 0 }, { CONSTANT_SYSTEM_BYTE_INTEGER, SYSTEM, "BYTE-INTEGER", 12, 0x6BE7E9C0ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_SYSCTL, SYSTEM, "SYSCTL", 6, 0x4353A5ADULL, 0, 1, 0 }, { CONSTANT_SYSTEM_TERME, SYSTEM, "TERME", 5, 0x4D52459EULL, 0, 1, 0 }, { CONSTANT_SYSTEM_FPCLASSIFY, SYSTEM, "FPCLASSIFY", 10, 0x1596FCD7ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_MAKE_PAPER, SYSTEM, "MAKE-PAPER", 10, 0x158CE3C9ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_INFO_PAPER, SYSTEM, "INFO-PAPER", 10, 0x1F87F0C5ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_ARRAY_PAPER, SYSTEM, "ARRAY-PAPER", 11, 0x02F4C4F5ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_BODY_PAPER, SYSTEM, "BODY-PAPER", 10, 0x2985F1BEULL, 0, 1, 0 }, { CONSTANT_SYSTEM_DLFILE, SYSTEM, "DLFILE", 6, 0x49469196ULL, 0, 1, 0 }, { CONSTANT_SYSTEM_DLCALL, SYSTEM, "DLCALL", 6, 0x41439896ULL, 0, 1, 0 }, { CONSTANT_SPECIAL_BREAK_ON_SIGNALS, COMMON, "*BREAK-ON-SIGNALS*", 18, 0x2A143365ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_COMPILE_FILE_PATHNAME, COMMON, "*COMPILE-FILE-PATHNAME*", 23, 0x61AD8DA4ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_COMPILE_FILE_TRUENAME, COMMON, "*COMPILE-FILE-TRUENAME*", 23, 0x72B18AA5ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_COMPILE_PRINT, COMMON, "*COMPILE-PRINT*", 15, 0x5C183104ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_COMPILE_VERBOSE, COMMON, "*COMPILE-VERBOSE*", 17, 0x2A343224ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_DEBUG_IO, COMMON, "*DEBUG-IO*", 10, 0x0B72B5D8ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_DEBUGGER_HOOK, COMMON, "*DEBUGGER-HOOK*", 15, 0x56FF042FULL, 1, 0, 0 }, { CONSTANT_SPECIAL_DEFAULT_PATHNAME_DEFAULTS, COMMON, "*DEFAULT-PATHNAME-DEFAULTS*", 27, 0x4DD7F9DAULL, 1, 0, 0 }, { CONSTANT_SPECIAL_ERROR_OUTPUT, COMMON, "*ERROR-OUTPUT*", 14, 0x76D01630ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_FEATURES, COMMON, "*FEATURES*", 10, 0x0697C5DBULL, 1, 0, 0 }, { CONSTANT_SPECIAL_GENSYM_COUNTER, COMMON, "*GENSYM-COUNTER*", 16, 0x743A3524ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_LOAD_PATHNAME, COMMON, "*LOAD-PATHNAME*", 15, 0x4418071EULL, 1, 0, 0 }, { CONSTANT_SPECIAL_LOAD_PRINT, COMMON, "*LOAD-PRINT*", 12, 0x3DF3C7C3ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_LOAD_TRUENAME, COMMON, "*LOAD-TRUENAME*", 15, 0x551C041FULL, 1, 0, 0 }, { CONSTANT_SPECIAL_LOAD_VERBOSE, COMMON, "*LOAD-VERBOSE*", 14, 0x59F4E613ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_MACROEXPAND_HOOK, COMMON, "*MACROEXPAND-HOOK*", 18, 0x2F245056ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_MODULES, COMMON, "*MODULES*", 9, 0x179499B2ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PACKAGE, COMMON, "*PACKAGE*", 9, 0x088891A8ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_ARRAY, COMMON, "*PRINT-ARRAY*", 13, 0x63C0F701ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_BASE, COMMON, "*PRINT-BASE*", 12, 0x35C4F7C5ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_CASE, COMMON, "*PRINT-CASE*", 12, 0x36C4F7C5ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_CIRCLE, COMMON, "*PRINT-CIRCLE*", 14, 0x58C32114ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_ESCAPE, COMMON, "*PRINT-ESCAPE*", 14, 0x5EC1121EULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_GENSYM, COMMON, "*PRINT-GENSYM*", 14, 0x69D31D18ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_LENGTH, COMMON, "*PRINT-LENGTH*", 14, 0x69C71D13ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_LEVEL, COMMON, "*PRINT-LEVEL*", 13, 0x61C4FAF4ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_LINES, COMMON, "*PRINT-LINES*", 13, 0x68C4F2F8ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_MISER_WIDTH, COMMON, "*PRINT-MISER-WIDTH*", 19, 0x2D389755ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_PPRINT_DISPATCH, COMMON, "*PRINT-PPRINT-DISPATCH*", 23, 0x0578BCC9ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_PRETTY, COMMON, "*PRINT-PRETTY*", 14, 0x6DD41431ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_RADIX, COMMON, "*PRINT-RADIX*", 13, 0x73C8E8F0ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_READABLY, COMMON, "*PRINT-READABLY*", 16, 0x071D320FULL, 1, 0, 0 }, { CONSTANT_SPECIAL_PRINT_RIGHT_MARGIN, COMMON, "*PRINT-RIGHT-MARGIN*", 20, 0x6C578249ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_QUERY_IO, COMMON, "*QUERY-IO*", 10, 0x0E82D4D5ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_RANDOM_STATE, COMMON, "*RANDOM-STATE*", 14, 0x4FD02014ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_READTABLE, COMMON, "*READTABLE*", 11, 0x03B0EBC5ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_READ_BASE, COMMON, "*READ-BASE*", 11, 0x02B1C4CCULL, 1, 0, 0 }, { CONSTANT_SPECIAL_READ_DEFAULT_FLOAT_FORMAT, COMMON, "*READ-DEFAULT-FLOAT-FORMAT*", 27, 0x19F5D2F9ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_READ_EVAL, COMMON, "*READ-EVAL*", 11, 0x17B4CBBAULL, 1, 0, 0 }, { CONSTANT_SPECIAL_READ_SUPPRESS, COMMON, "*READ-SUPPRESS*", 15, 0x5C152320ULL, 1, 0, 0 }, { CONSTANT_SPECIAL_STANDARD_INPUT, COMMON, "*STANDARD-INPUT*", 16, 0x0C331A1CULL, 1, 0, 0 }, { CONSTANT_SPECIAL_STANDARD_OUTPUT, COMMON, "*STANDARD-OUTPUT*", 17, 0x3D3A154BULL, 1, 0, 0 }, { CONSTANT_SPECIAL_TERMINAL_IO, COMMON, "*TERMINAL-IO*", 13, 0x62DCCAFAULL, 1, 0, 0 }, { CONSTANT_SPECIAL_TRACE_OUTPUT, COMMON, "*TRACE-OUTPUT*", 14, 0x65D01824ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_ENABLE_DEBUGGER, SYSTEM, "*ENABLE-DEBUGGER*", 17, 0x161B1E32ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_INDEX_DEBUGGER, SYSTEM, "*INDEX-DEBUGGER*", 16, 0x7A23290BULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_PARSE_ENVIRONMENT, SYSTEM, "*PARSE-ENVIRONMENT*", 19, 0x2F2F8E7BULL, 1, 0, 0 }, { CONSTANT_SYSTEM_PARSE_DECLARE, SYSTEM, "*PARSE-DECLARE*", 15, 0x57E51E23ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_SCOPE, SYSTEM, "*SCOPE*", 7, 0x4F6D9881ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_SCOPE_GLOBAL, SYSTEM, "*SCOPE-GLOBAL*", 14, 0x57B31220ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_TOPLEVEL, SYSTEM, "*EVAL-TOPLEVEL*", 15, 0x671A0B1AULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_COMPILE_TIME, SYSTEM, "*EVAL-COMPILE-TIME*", 19, 0x26613568ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_COMPILE_TOPLEVEL, SYSTEM, "*EVAL-COMPILE-TOPLEVEL*", 23, 0x02A688B4ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_LOAD_TOPLEVEL, SYSTEM, "*EVAL-LOAD-TOPLEVEL*", 20, 0x54684C70ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_EXECUTE, SYSTEM, "*EVAL-EXECUTE*", 14, 0x6DF0E00EULL, 1, 0, 0 }, { CONSTANT_SYSTEM_SPECIAL_ENVIRONMENT, SYSTEM, "*ENVIRONMENT*", 13, 0x78EBDCF7ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_SPECIAL_ARGUMENTS, SYSTEM, "*ARGUMENTS*", 11, 0x15C1E1DEULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_SIZE, SYSTEM, "*LOAD-SIZE*", 11, 0x0ACCBED3ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_ARRAY, SYSTEM, "*LOAD-ARRAY*", 12, 0x3DE9BACCULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_TABLE, SYSTEM, "*LOAD-TABLE*", 12, 0x2CE8C5BCULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_GENSYM, SYSTEM, "*LOAD-GENSYM*", 13, 0x53EFCCF3ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_DEPEND, SYSTEM, "*LOAD-DEPEND*", 13, 0x4AE1BEF5ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_PUSH, SYSTEM, "*LOAD-PUSH*", 11, 0x16C9C1CCULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DEPEND_LOOP, SYSTEM, "*DEPEND-LOOP*", 13, 0x4DD8E1F2ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DEPEND_PASS, SYSTEM, "*DEPEND-PASS*", 13, 0x50DCD3F6ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DEPEND_ERROR, SYSTEM, "*DEPEND-ERROR*", 14, 0x4CDC0F14ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DEPEND_ROOT, SYSTEM, "*DEPEND-ROOT*", 13, 0x51D8E1F8ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_GCHOLD, SYSTEM, "*GCHOLD*", 8, 0x72879381ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOOP_NAMED, SYSTEM, "*LOOP-NAMED*", 12, 0x3AE1BED3ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOOP_VARS, SYSTEM, "*LOOP-VARS*", 11, 0x10CFCCD7ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOOP_INIT, SYSTEM, "*LOOP-INIT*", 11, 0x1DC2CDCEULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FINAL, SYSTEM, "*LOOP-FINAL*", 12, 0x42E1BAD4ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOOP_FORM, SYSTEM, "*LOOP-FORM*", 11, 0x1EBFC6D7ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOOP_LET, SYSTEM, "*LOOP-LET*", 10, 0x149BA3D8ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_ENABLE_COMPILER_MACRO, SYSTEM, "*ENABLE-COMPILER-MACRO*", 23, 0x5491C98EULL, 1, 0, 0 }, { CONSTANT_SYSTEM_LOAD_LOGICAL_PATHNAME_TRANSLATIONS, SYSTEM, "*LOAD-LOGICAL-PATHNAME-TRANSLATIONS*", 36, 0x6FA04EB3ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EXTERNAL_FORMAT, SYSTEM, "*EXTERNAL-FORMAT*", 17, 0x392E1248ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_END_OF_LINE, SYSTEM, "*END-OF-LINE*", 13, 0x36E2DDDAULL, 1, 0, 0 }, { CONSTANT_SYSTEM_PRINT_WRITE, SYSTEM, "*PRINT-WRITE*", 13, 0x65D3EE01ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DEFAULT_PRINT_DISPATCH, SYSTEM, "*DEFAULT-PRINT-DISPATCH*", 24, 0x13A9D49BULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EMPTY_PRINT_DISPATCH, SYSTEM, "*EMPTY-PRINT-DISPATCH*", 22, 0x0B6697ABULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DELAY_WARNING_LIST, SYSTEM, "*DELAY-WARNING-LIST*", 20, 0x63428A57ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DELAY_WARNING_SWITCH, SYSTEM, "*DELAY-WARNING-SWITCH*", 22, 0x0342AAAFULL, 1, 0, 0 }, { CONSTANT_SYSTEM_MODULE_PROVIDER_FUNCTIONS, SYSTEM, "*MODULE-PROVIDER-FUNCTIONS*", 27, 0x37F21DF1ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_COMPILE_OUTPUT, SYSTEM, "*COMPILE-OUTPUT*", 16, 0x11453107ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_COMPILE_CODE, SYSTEM, "*COMPILE-CODE*", 14, 0x56EAF9FAULL, 1, 0, 0 }, { CONSTANT_SYSTEM_ENCODE_UNIVERSAL_1970, SYSTEM, "*ENCODE-UNIVERSAL-1970*", 23, 0x418B87ADULL, 1, 0, 0 }, { CONSTANT_SYSTEM_ED_FUNCTION, SYSTEM, "*ED-FUNCTION*", 13, 0x3EE1E3FBULL, 1, 0, 0 }, { CONSTANT_SYSTEM_ED_TEMPFILE, SYSTEM, "*ED-TEMPFILE*", 13, 0x42DDD3FBULL, 1, 0, 0 }, { CONSTANT_SYSTEM_ED_PROGRAM, SYSTEM, "*ED-PROGRAM*", 12, 0x1EE0D8D8ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_TRACE_LIST, SYSTEM, "*TRACE-LIST*", 12, 0x37D3ECC2ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_TRACE_DEPTH, SYSTEM, "*TRACE-DEPTH*", 13, 0x4DD3E9E9ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DRIBBLE_FILE, SYSTEM, "*DRIBBLE-FILE*", 14, 0x5AE7F6ECULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DRIBBLE_INPUT, SYSTEM, "*DRIBBLE-INPUT*", 15, 0x5F1723FDULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DRIBBLE_OUTPUT, SYSTEM, "*DRIBBLE-OUTPUT*", 16, 0x0D482AF9ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DRIBBLE_ECHO, SYSTEM, "*DRIBBLE-ECHO*", 14, 0x56E1F5F6ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_DRIBBLE_BROADCAST, SYSTEM, "*DRIBBLE-BROADCAST*", 19, 0x1F5E6140ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_INSPECTED, SYSTEM, "*INSPECTED*", 11, 0x27BBD2CAULL, 1, 0, 0 }, { CONSTANT_SYSTEM_STEP_BEGIN, SYSTEM, "*STEP-BEGIN*", 12, 0x34E4C9CDULL, 1, 0, 0 }, { CONSTANT_RT_RESULT, RT, "*RESULT*", 8, 0x7D999E87ULL, 1, 0, 0 }, { CONSTANT_RT_INDEX, RT, "*INDEX*", 7, 0x4478A176ULL, 1, 0, 0 }, { CONSTANT_RT_ENTRIES, RT, "*ENTRIES*", 9, 0x27938EAFULL, 1, 0, 0 }, { CONSTANT_RT_ENTRIES_TABLE, RT, "*ENTRIES-TABLE*", 15, 0x69FF2804ULL, 1, 0, 0 }, { CONSTANT_RT_ENTRIES_WARNING, RT, "*ENTRIES-WARNING*", 17, 0x41232F32ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_READINFO_SPECIAL, SYSTEM, "*READINFO*", 10, 0x0793C5C7ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_EVAL_LOOP_EXIT, SYSTEM, "*EVAL-LOOP-EXIT*", 16, 0x00240C2DULL, 1, 1, 0 }, { CONSTANT_SYSTEM_PROMPT, SYSTEM, "*PROMPT*", 8, 0x79A6A07FULL, 1, 0, 0 }, { CONSTANT_SYSTEM_PROMPT_READING, SYSTEM, "*PROMPT-READING*", 16, 0x6B2F3422ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_PROMPT_VALUE, SYSTEM, "*PROMPT-VALUE*", 14, 0x51F30C20ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_PROMPT_BRIGHT, SYSTEM, "*PROMPT-BRIGHT*", 15, 0x441A4710ULL, 1, 1, 0 }, { CONSTANT_SYSTEM_PROMPT_COLOR, SYSTEM, "*PROMPT-COLOR*", 14, 0x4BF31A1AULL, 1, 1, 0 }, { CONSTANT_SYSTEM_SPECIAL_TERME, SYSTEM, "*TERME*", 7, 0x526F997EULL, 1, 0, 0 }, { CONSTANT_SYSTEM_SPECIAL_DLFILE, SYSTEM, "*DLFILE*", 8, 0x7091907BULL, 1, 0, 0 }, { CONSTANT_SYSTEM_CORE_INPUT, SYSTEM, "*CORE-INPUT*", 12, 0x4AECC5CBULL, 1, 0, 0 }, { CONSTANT_SYSTEM_CORE_OUTPUT, SYSTEM, "*CORE-OUTPUT*", 13, 0x7BF3C0FAULL, 1, 0, 0 }, { CONSTANT_SYSTEM_SUBTYPEP_VALUE, SYSTEM, "*SUBTYPEP!*", 11, 0x07CFCDD9ULL, 1, 0, 0 }, { CONSTANT_SYSTEM_STANDARD_INPUT, SYSTEM, "*STANDARD-INPUT*", 16, 0x0C331A1CULL, 1, 0, 0 }, { CONSTANT_SYSTEM_STANDARD_OUTPUT, SYSTEM, "*STANDARD-OUTPUT*", 17, 0x3D3A154BULL, 1, 0, 0 }, { CONSTANT_SYSTEM_STANDARD_ERROR, SYSTEM, "*STANDARD-ERROR*", 16, 0x102D141EULL, 1, 0, 0 },
611b35aa5c4285e31b9bd826523831ee517949de
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
55fd92a32208e82d122d6a94a35a55a71377d9df
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause", "OpenSSL" ]
permissive
google/google-ctf
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
df02323eaf945d15e124801c74abaadca2749dc7
refs/heads/master
2023-08-31T14:30:27.548081
2023-08-29T13:04:20
2023-08-29T13:04:20
131,317,137
4,136
607
Apache-2.0
2023-08-30T22:17:02
2018-04-27T15:56:03
Go
UTF-8
C
false
false
2,933
h
AuthenticatedVariableFormat.h
/** @file The variable data structures are related to EDKII-specific implementation of UEFI authenticated variables. AuthenticatedVariableFormat.h defines variable data headers and variable storage region headers that has been moved to VariableFormat.h. Copyright (c) 2009 - 2016, 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. **/ #ifndef __AUTHENTICATED_VARIABLE_FORMAT_H__ #define __AUTHENTICATED_VARIABLE_FORMAT_H__ #include <Guid/VariableFormat.h> #define EFI_SECURE_BOOT_ENABLE_DISABLE \ { 0xf0a30bc7, 0xaf08, 0x4556, { 0x99, 0xc4, 0x0, 0x10, 0x9, 0xc9, 0x3a, 0x44 } } extern EFI_GUID gEfiSecureBootEnableDisableGuid; extern EFI_GUID gEfiCertDbGuid; extern EFI_GUID gEfiCustomModeEnableGuid; extern EFI_GUID gEfiVendorKeysNvGuid; /// /// "SecureBootEnable" variable for the Secure Boot feature enable/disable. /// This variable is used for allowing a physically present user to disable /// Secure Boot via firmware setup without the possession of PKpriv. /// /// GUID: gEfiSecureBootEnableDisableGuid /// /// Format: UINT8 /// #define EFI_SECURE_BOOT_ENABLE_NAME L"SecureBootEnable" #define SECURE_BOOT_ENABLE 1 #define SECURE_BOOT_DISABLE 0 /// /// "CustomMode" variable for two Secure Boot modes feature: "Custom" and "Standard". /// Standard Secure Boot mode is the default mode as UEFI Spec's description. /// Custom Secure Boot mode allows for more flexibility as specified in the following: /// Can enroll or delete PK without existing PK's private key. /// Can enroll or delete KEK without existing PK's private key. /// Can enroll or delete signature from DB/DBX without KEK's private key. /// /// GUID: gEfiCustomModeEnableGuid /// /// Format: UINT8 /// #define EFI_CUSTOM_MODE_NAME L"CustomMode" #define CUSTOM_SECURE_BOOT_MODE 1 #define STANDARD_SECURE_BOOT_MODE 0 /// /// "VendorKeysNv" variable to record the out of band secure boot keys modification. /// This variable is a read-only NV varaible that indicates whether someone other than /// the platform vendor has used a mechanism not defined by the UEFI Specification to /// transition the system to setup mode or to update secure boot keys. /// /// GUID: gEfiVendorKeysNvGuid /// /// Format: UINT8 /// #define EFI_VENDOR_KEYS_NV_VARIABLE_NAME L"VendorKeysNv" #define VENDOR_KEYS_VALID 1 #define VENDOR_KEYS_MODIFIED 0 #endif // __AUTHENTICATED_VARIABLE_FORMAT_H__
0122cc322172559d97dd56f4497b1d996056d491
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/libei/include/rdma/i40iw-abi.h
79890baa6fdbb38431ec297f6ab68fe6c6d4cf4c
[ "BSD-3-Clause", "MIT", "Apache-2.0", "LGPL-2.0-or-later", "GPL-1.0-or-later" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
3,030
h
i40iw-abi.h
/* * Copyright (c) 2006 - 2016 Intel Corporation. All rights reserved. * Copyright (c) 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * 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. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ #ifndef I40IW_ABI_H #define I40IW_ABI_H #include <linux/types.h> #define I40IW_ABI_VER 5 struct i40iw_alloc_ucontext_req { __u32 reserved32; __u8 userspace_ver; __u8 reserved8[3]; }; struct i40iw_alloc_ucontext_resp { __u32 max_pds; /* maximum pds allowed for this user process */ __u32 max_qps; /* maximum qps allowed for this user process */ __u32 wq_size; /* size of the WQs (sq+rq) allocated to the mmaped area */ __u8 kernel_ver; __u8 reserved[3]; }; struct i40iw_alloc_pd_resp { __u32 pd_id; __u8 reserved[4]; }; struct i40iw_create_cq_req { __aligned_u64 user_cq_buffer; __aligned_u64 user_shadow_area; }; struct i40iw_create_qp_req { __aligned_u64 user_wqe_buffers; __aligned_u64 user_compl_ctx; /* UDA QP PHB */ __aligned_u64 user_sq_phb; /* place for VA of the sq phb buff */ __aligned_u64 user_rq_phb; /* place for VA of the rq phb buff */ }; enum i40iw_memreg_type { IW_MEMREG_TYPE_MEM = 0x0000, IW_MEMREG_TYPE_QP = 0x0001, IW_MEMREG_TYPE_CQ = 0x0002, }; struct i40iw_mem_reg_req { __u16 reg_type; /* Memory, QP or CQ */ __u16 cq_pages; __u16 rq_pages; __u16 sq_pages; }; struct i40iw_create_cq_resp { __u32 cq_id; __u32 cq_size; __u32 mmap_db_index; __u32 reserved; }; struct i40iw_create_qp_resp { __u32 qp_id; __u32 actual_sq_size; __u32 actual_rq_size; __u32 i40iw_drv_opt; __u16 push_idx; __u8 lsmm; __u8 rsvd2; }; #endif
4859e275c937d99499b8f36ad7c911980b8b002d
d8c8f4148940cd9c93bb0692af8c5004f47af05e
/xUSL/RcMgr/FabricRcInit.c
2150295d299deeee9559c8c9a8fbb7fb646e5aca
[ "MIT" ]
permissive
openSIL/openSIL
92213cc94dd4c6d6c43fedeaedd96537001e182f
0f39fbc2454af9a67fc84a88093bcd2f2c8dd887
refs/heads/main
2023-08-19T11:48:14.911453
2023-08-07T20:50:54
2023-08-07T20:50:54
652,124,068
233
14
null
2023-06-28T15:55:29
2023-06-11T06:54:24
C
UTF-8
C
false
false
1,408
c
FabricRcInit.c
/** * @file FabricResourceInit.c * @brief OpenSIL DataFabric MMIO and IO resource map initialization. * */ /* Copyright 2021-2023 Advanced Micro Devices, Inc. All rights reserved. */ // SPDX-License-Identifier: MIT #include "RcMgrIp2Ip.h" #include <DF/DfIp2Ip.h> #include <RcMgr/FabricResourceManager.h> RCMGR_IP2IP_API RcMgrApi = { .FabricReserveMmio = FabricReserveMmio }; /** * SilGetPrimaryRb * * @brief Returns primary RB socket number and RB number * * @param[out] SocketNum Primary RB socket number * @param[out] RootBridgeNum Primary RB number * */ void SilGetPrimaryRb ( uint32_t *SocketNum, uint32_t *RootBridgeNum ) { ROOT_BRIDGE_LOCATION Location; DF_IP2IP_API* DfIp2IpApi; SIL_STATUS Status; Status = SilGetIp2IpApi (SilId_DfClass, (void**) &DfIp2IpApi); assert (Status == SilPass); if (DfIp2IpApi->DfGetSystemComponentRootBridgeLocation (PrimaryFch, &Location)) { *SocketNum = Location.Socket; *RootBridgeNum = Location.Index; } else { *SocketNum = 0; *RootBridgeNum = 0; } } /** * InitializeRcMgrApi * * @brief Initialize internal and external APIs for Resource Manager * * @retval SilPass API initialized successfully * @retval SilInvalidParameter Id class is invalid * */ SIL_STATUS InitializeRcMgrApi (void) { return SilInitIp2IpApi (SilId_RcManager, (void *)&RcMgrApi); }
f0f8f44f74752a4767d5251fa4561e4295b6a4f8
06f2e78f4d736c8ac9cb7e98a5abcc28ed4f25b2
/engine/common/host_state.c
a1ffeda9a845b872e295866b390e445e14658a43
[]
no_license
FWGS/xash3d-fwgs
07a1002396f43754b49521681cc771c0d89051ed
435b95fc5ab3fc5b1a79212ffdc901a47769d056
refs/heads/master
2023-09-01T05:20:48.112400
2023-08-31T05:40:24
2023-08-31T05:40:24
127,814,982
1,078
275
null
2023-09-12T17:49:04
2018-04-02T21:33:02
C
UTF-8
C
false
false
4,760
c
host_state.c
/* host_cmd.c - dedicated and normal host Copyright (C) 2017 Uncle Mike This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include "common.h" #include "platform/platform.h" void COM_InitHostState( void ) { memset( GameState, 0, sizeof( game_status_t )); } static void Host_SetState( host_state_t newState, qboolean clearNext ) { if( clearNext ) GameState->nextstate = newState; GameState->curstate = newState; if( clearNext && newState == STATE_RUNFRAME ) { // states finished here GameState->backgroundMap = false; GameState->loadGame = false; GameState->newGame = false; } } static void Host_SetNextState( host_state_t nextState ) { ASSERT( GameState->curstate == STATE_RUNFRAME ); GameState->nextstate = nextState; } void COM_NewGame( char const *pMapName ) { if( GameState->nextstate != STATE_RUNFRAME ) return; if( UI_CreditsActive( )) return; Q_strncpy( GameState->levelName, pMapName, sizeof( GameState->levelName )); Host_SetNextState( STATE_LOAD_LEVEL ); GameState->backgroundMap = false; GameState->landmarkName[0] = 0; GameState->loadGame = false; GameState->newGame = true; } void COM_LoadLevel( char const *pMapName, qboolean background ) { if( GameState->nextstate != STATE_RUNFRAME ) return; if( UI_CreditsActive( )) return; Q_strncpy( GameState->levelName, pMapName, sizeof( GameState->levelName )); Host_SetNextState( STATE_LOAD_LEVEL ); GameState->backgroundMap = background; GameState->landmarkName[0] = 0; GameState->loadGame = false; GameState->newGame = false; } void COM_LoadGame( char const *pMapName ) { if( GameState->nextstate != STATE_RUNFRAME ) return; if( UI_CreditsActive( )) return; Q_strncpy( GameState->levelName, pMapName, sizeof( GameState->levelName )); Host_SetNextState( STATE_LOAD_GAME ); GameState->backgroundMap = false; GameState->newGame = false; GameState->loadGame = true; } void COM_ChangeLevel( char const *pNewLevel, char const *pLandmarkName, qboolean background ) { if( GameState->nextstate != STATE_RUNFRAME ) return; if( UI_CreditsActive( )) return; Q_strncpy( GameState->levelName, pNewLevel, sizeof( GameState->levelName )); GameState->backgroundMap = background; if( COM_CheckString( pLandmarkName )) { Q_strncpy( GameState->landmarkName, pLandmarkName, sizeof( GameState->landmarkName )); GameState->loadGame = true; } else { GameState->landmarkName[0] = 0; GameState->loadGame = false; } Host_SetNextState( STATE_CHANGELEVEL ); GameState->newGame = false; } void Host_ShutdownGame( void ) { SV_ShutdownGame(); switch( GameState->nextstate ) { case STATE_LOAD_GAME: case STATE_LOAD_LEVEL: Host_SetState( GameState->nextstate, true ); break; default: Host_SetState( STATE_RUNFRAME, true ); break; } } void Host_RunFrame( float time ) { // at this time, we don't need to get events from OS on dedicated #if !XASH_DEDICATED Platform_RunEvents(); #endif // XASH_DEDICATED // engine main frame Host_Frame( time ); switch( GameState->nextstate ) { case STATE_RUNFRAME: break; case STATE_LOAD_GAME: case STATE_LOAD_LEVEL: SCR_BeginLoadingPlaque( GameState->backgroundMap ); // intentionally fallthrough case STATE_GAME_SHUTDOWN: Host_SetState( STATE_GAME_SHUTDOWN, false ); break; case STATE_CHANGELEVEL: SCR_BeginLoadingPlaque( GameState->backgroundMap ); Host_SetState( GameState->nextstate, true ); break; default: Host_SetState( STATE_RUNFRAME, true ); break; } } void COM_Frame( float time ) { int loopCount = 0; if( setjmp( host.abortframe )) return; while( 1 ) { int oldState = GameState->curstate; // execute the current state (and transition to the next state if not in STATE_RUNFRAME) switch( GameState->curstate ) { case STATE_LOAD_LEVEL: SV_ExecLoadLevel(); Host_SetState( STATE_RUNFRAME, true ); break; case STATE_LOAD_GAME: SV_ExecLoadGame(); Host_SetState( STATE_RUNFRAME, true ); break; case STATE_CHANGELEVEL: SV_ExecChangeLevel(); Host_SetState( STATE_RUNFRAME, true ); break; case STATE_RUNFRAME: Host_RunFrame( time ); break; case STATE_GAME_SHUTDOWN: Host_ShutdownGame(); break; } if( oldState == STATE_RUNFRAME ) break; if(( GameState->curstate == oldState ) || ( ++loopCount > 8 )) Sys_Error( "state infinity loop!\n" ); } }
ae05c3700f59e834eb5a1dbf33dc306ed2405155
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/lpc55sxx/Libraries/LPC55S6X/LPC55S6X/drivers/fsl_powerquad_data.h
e0bbb5b6757280726139b9884116f1b50f57f666
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
1,341
h
fsl_powerquad_data.h
/* * Copyright 2018-2022 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _FSL_POWERQUAD_DATA_H_ #define _FSL_POWERQUAD_DATA_H_ #include <stdint.h> /******************************************************************************* * Definitions ******************************************************************************/ extern int32_t dct16_twiddle[32]; extern int32_t dct32_twiddle[64]; extern int32_t dct64_twiddle[128]; extern int32_t dct128_twiddle[256]; extern int32_t dct256_twiddle[512]; extern int32_t dct512_twiddle[1024]; extern int32_t idct16_twiddle[32]; extern int32_t idct32_twiddle[64]; extern int32_t idct64_twiddle[128]; extern int32_t idct128_twiddle[256]; extern int32_t idct256_twiddle[512]; extern int32_t idct512_twiddle[1024]; extern int32_t dct16_cosFactor[16]; extern int32_t dct32_cosFactor[32]; extern int32_t dct64_cosFactor[64]; extern int32_t dct128_cosFactor[128]; extern int32_t dct256_cosFactor[256]; extern int32_t dct512_cosFactor[512]; /******************************************************************************* * API ******************************************************************************/ #if defined(__cplusplus) extern "C" { #endif /* __cplusplus */ #if defined(__cplusplus) } #endif /* __cplusplus */ #endif /* _FSL_POWERQUAD_DATA_H_ */
5f98d3cff9b87b92333e04c273e319210e7ae02a
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/libs/clapack/slarrd.c
7670ff9edf9fa5d0c51f1e00e98ed64ef35ba033
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
catboost/catboost
854c1a1f439a96f1ae6b48e16644be20aa04dba2
f5042e35b945aded77b23470ead62d7eacefde92
refs/heads/master
2023-09-01T12:14:14.174108
2023-09-01T10:01:01
2023-09-01T10:22:12
97,556,265
8,012
1,425
Apache-2.0
2023-09-11T03:32:32
2017-07-18T05:29:04
Python
UTF-8
C
false
false
26,071
c
slarrd.c
/* slarrd.f -- translated by f2c (version 20061008). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib; on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */ #include "f2c.h" #include "blaswrap.h" /* Table of constant values */ static integer c__1 = 1; static integer c_n1 = -1; static integer c__3 = 3; static integer c__2 = 2; static integer c__0 = 0; /* Subroutine */ int slarrd_(char *range, char *order, integer *n, real *vl, real *vu, integer *il, integer *iu, real *gers, real *reltol, real * d__, real *e, real *e2, real *pivmin, integer *nsplit, integer * isplit, integer *m, real *w, real *werr, real *wl, real *wu, integer * iblock, integer *indexw, real *work, integer *iwork, integer *info) { /* System generated locals */ integer i__1, i__2, i__3; real r__1, r__2; /* Builtin functions */ double log(doublereal); /* Local variables */ integer i__, j, ib, ie, je, nb; real gl; integer im, in; real gu; integer iw, jee; real eps; integer nwl; real wlu, wul; integer nwu; real tmp1, tmp2; integer iend, jblk, ioff, iout, itmp1, itmp2, jdisc; extern logical lsame_(char *, char *); integer iinfo; real atoli; integer iwoff, itmax; real wkill, rtoli, uflow, tnorm; integer ibegin, irange, idiscl; extern doublereal slamch_(char *); integer idumma[1]; extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *); integer idiscu; extern /* Subroutine */ int slaebz_(integer *, integer *, integer *, integer *, integer *, integer *, real *, real *, real *, real *, real *, real *, integer *, real *, real *, integer *, integer *, real *, integer *, integer *); logical ncnvrg, toofew; /* -- LAPACK auxiliary routine (version 3.2.1) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* -- April 2009 -- */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SLARRD computes the eigenvalues of a symmetric tridiagonal */ /* matrix T to suitable accuracy. This is an auxiliary code to be */ /* called from SSTEMR. */ /* The user may ask for all eigenvalues, all eigenvalues */ /* in the half-open interval (VL, VU], or the IL-th through IU-th */ /* eigenvalues. */ /* To avoid overflow, the matrix must be scaled so that its */ /* largest element is no greater than overflow**(1/2) * */ /* underflow**(1/4) in absolute value, and for greatest */ /* accuracy, it should not be much smaller than that. */ /* See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */ /* Matrix", Report CS41, Computer Science Dept., Stanford */ /* University, July 21, 1966. */ /* Arguments */ /* ========= */ /* RANGE (input) CHARACTER */ /* = 'A': ("All") all eigenvalues will be found. */ /* = 'V': ("Value") all eigenvalues in the half-open interval */ /* (VL, VU] will be found. */ /* = 'I': ("Index") the IL-th through IU-th eigenvalues (of the */ /* entire matrix) will be found. */ /* ORDER (input) CHARACTER */ /* = 'B': ("By Block") the eigenvalues will be grouped by */ /* split-off block (see IBLOCK, ISPLIT) and */ /* ordered from smallest to largest within */ /* the block. */ /* = 'E': ("Entire matrix") */ /* the eigenvalues for the entire matrix */ /* will be ordered from smallest to */ /* largest. */ /* N (input) INTEGER */ /* The order of the tridiagonal matrix T. N >= 0. */ /* VL (input) REAL */ /* VU (input) REAL */ /* If RANGE='V', the lower and upper bounds of the interval to */ /* be searched for eigenvalues. Eigenvalues less than or equal */ /* to VL, or greater than VU, will not be returned. VL < VU. */ /* Not referenced if RANGE = 'A' or 'I'. */ /* IL (input) INTEGER */ /* IU (input) INTEGER */ /* If RANGE='I', the indices (in ascending order) of the */ /* smallest and largest eigenvalues to be returned. */ /* 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */ /* Not referenced if RANGE = 'A' or 'V'. */ /* GERS (input) REAL array, dimension (2*N) */ /* The N Gerschgorin intervals (the i-th Gerschgorin interval */ /* is (GERS(2*i-1), GERS(2*i)). */ /* RELTOL (input) REAL */ /* The minimum relative width of an interval. When an interval */ /* is narrower than RELTOL times the larger (in */ /* magnitude) endpoint, then it is considered to be */ /* sufficiently small, i.e., converged. Note: this should */ /* always be at least radix*machine epsilon. */ /* D (input) REAL array, dimension (N) */ /* The n diagonal elements of the tridiagonal matrix T. */ /* E (input) REAL array, dimension (N-1) */ /* The (n-1) off-diagonal elements of the tridiagonal matrix T. */ /* E2 (input) REAL array, dimension (N-1) */ /* The (n-1) squared off-diagonal elements of the tridiagonal matrix T. */ /* PIVMIN (input) REAL */ /* The minimum pivot allowed in the Sturm sequence for T. */ /* NSPLIT (input) INTEGER */ /* The number of diagonal blocks in the matrix T. */ /* 1 <= NSPLIT <= N. */ /* ISPLIT (input) INTEGER array, dimension (N) */ /* The splitting points, at which T breaks up into submatrices. */ /* The first submatrix consists of rows/columns 1 to ISPLIT(1), */ /* the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */ /* etc., and the NSPLIT-th consists of rows/columns */ /* ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */ /* (Only the first NSPLIT elements will actually be used, but */ /* since the user cannot know a priori what value NSPLIT will */ /* have, N words must be reserved for ISPLIT.) */ /* M (output) INTEGER */ /* The actual number of eigenvalues found. 0 <= M <= N. */ /* (See also the description of INFO=2,3.) */ /* W (output) REAL array, dimension (N) */ /* On exit, the first M elements of W will contain the */ /* eigenvalue approximations. SLARRD computes an interval */ /* I_j = (a_j, b_j] that includes eigenvalue j. The eigenvalue */ /* approximation is given as the interval midpoint */ /* W(j)= ( a_j + b_j)/2. The corresponding error is bounded by */ /* WERR(j) = abs( a_j - b_j)/2 */ /* WERR (output) REAL array, dimension (N) */ /* The error bound on the corresponding eigenvalue approximation */ /* in W. */ /* WL (output) REAL */ /* WU (output) REAL */ /* The interval (WL, WU] contains all the wanted eigenvalues. */ /* If RANGE='V', then WL=VL and WU=VU. */ /* If RANGE='A', then WL and WU are the global Gerschgorin bounds */ /* on the spectrum. */ /* If RANGE='I', then WL and WU are computed by SLAEBZ from the */ /* index range specified. */ /* IBLOCK (output) INTEGER array, dimension (N) */ /* At each row/column j where E(j) is zero or small, the */ /* matrix T is considered to split into a block diagonal */ /* matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which */ /* block (from 1 to the number of blocks) the eigenvalue W(i) */ /* belongs. (SLARRD may use the remaining N-M elements as */ /* workspace.) */ /* INDEXW (output) INTEGER array, dimension (N) */ /* The indices of the eigenvalues within each block (submatrix); */ /* for example, INDEXW(i)= j and IBLOCK(i)=k imply that the */ /* i-th eigenvalue W(i) is the j-th eigenvalue in block k. */ /* WORK (workspace) REAL array, dimension (4*N) */ /* IWORK (workspace) INTEGER array, dimension (3*N) */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* > 0: some or all of the eigenvalues failed to converge or */ /* were not computed: */ /* =1 or 3: Bisection failed to converge for some */ /* eigenvalues; these eigenvalues are flagged by a */ /* negative block number. The effect is that the */ /* eigenvalues may not be as accurate as the */ /* absolute and relative tolerances. This is */ /* generally caused by unexpectedly inaccurate */ /* arithmetic. */ /* =2 or 3: RANGE='I' only: Not all of the eigenvalues */ /* IL:IU were found. */ /* Effect: M < IU+1-IL */ /* Cause: non-monotonic arithmetic, causing the */ /* Sturm sequence to be non-monotonic. */ /* Cure: recalculate, using RANGE='A', and pick */ /* out eigenvalues IL:IU. In some cases, */ /* increasing the PARAMETER "FUDGE" may */ /* make things work. */ /* = 4: RANGE='I', and the Gershgorin interval */ /* initially used was too small. No eigenvalues */ /* were computed. */ /* Probable cause: your machine has sloppy */ /* floating-point arithmetic. */ /* Cure: Increase the PARAMETER "FUDGE", */ /* recompile, and try again. */ /* Internal Parameters */ /* =================== */ /* FUDGE REAL , default = 2 */ /* A "fudge factor" to widen the Gershgorin intervals. Ideally, */ /* a value of 1 should work, but on machines with sloppy */ /* arithmetic, this needs to be larger. The default for */ /* publicly released versions should be large enough to handle */ /* the worst machine around. Note that this has no effect */ /* on accuracy of the solution. */ /* Based on contributions by */ /* W. Kahan, University of California, Berkeley, USA */ /* Beresford Parlett, University of California, Berkeley, USA */ /* Jim Demmel, University of California, Berkeley, USA */ /* Inderjit Dhillon, University of Texas, Austin, USA */ /* Osni Marques, LBNL/NERSC, USA */ /* Christof Voemel, University of California, Berkeley, USA */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ --iwork; --work; --indexw; --iblock; --werr; --w; --isplit; --e2; --e; --d__; --gers; /* Function Body */ *info = 0; /* Decode RANGE */ if (lsame_(range, "A")) { irange = 1; } else if (lsame_(range, "V")) { irange = 2; } else if (lsame_(range, "I")) { irange = 3; } else { irange = 0; } /* Check for Errors */ if (irange <= 0) { *info = -1; } else if (! (lsame_(order, "B") || lsame_(order, "E"))) { *info = -2; } else if (*n < 0) { *info = -3; } else if (irange == 2) { if (*vl >= *vu) { *info = -5; } } else if (irange == 3 && (*il < 1 || *il > max(1,*n))) { *info = -6; } else if (irange == 3 && (*iu < min(*n,*il) || *iu > *n)) { *info = -7; } if (*info != 0) { return 0; } /* Initialize error flags */ *info = 0; ncnvrg = FALSE_; toofew = FALSE_; /* Quick return if possible */ *m = 0; if (*n == 0) { return 0; } /* Simplification: */ if (irange == 3 && *il == 1 && *iu == *n) { irange = 1; } /* Get machine constants */ eps = slamch_("P"); uflow = slamch_("U"); /* Special Case when N=1 */ /* Treat case of 1x1 matrix for quick return */ if (*n == 1) { if (irange == 1 || irange == 2 && d__[1] > *vl && d__[1] <= *vu || irange == 3 && *il == 1 && *iu == 1) { *m = 1; w[1] = d__[1]; /* The computation error of the eigenvalue is zero */ werr[1] = 0.f; iblock[1] = 1; indexw[1] = 1; } return 0; } /* NB is the minimum vector length for vector bisection, or 0 */ /* if only scalar is to be done. */ nb = ilaenv_(&c__1, "SSTEBZ", " ", n, &c_n1, &c_n1, &c_n1); if (nb <= 1) { nb = 0; } /* Find global spectral radius */ gl = d__[1]; gu = d__[1]; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { /* Computing MIN */ r__1 = gl, r__2 = gers[(i__ << 1) - 1]; gl = dmin(r__1,r__2); /* Computing MAX */ r__1 = gu, r__2 = gers[i__ * 2]; gu = dmax(r__1,r__2); /* L5: */ } /* Compute global Gerschgorin bounds and spectral diameter */ /* Computing MAX */ r__1 = dabs(gl), r__2 = dabs(gu); tnorm = dmax(r__1,r__2); gl = gl - tnorm * 2.f * eps * *n - *pivmin * 4.f; gu = gu + tnorm * 2.f * eps * *n + *pivmin * 4.f; /* [JAN/28/2009] remove the line below since SPDIAM variable not use */ /* SPDIAM = GU - GL */ /* Input arguments for SLAEBZ: */ /* The relative tolerance. An interval (a,b] lies within */ /* "relative tolerance" if b-a < RELTOL*max(|a|,|b|), */ rtoli = *reltol; /* Set the absolute tolerance for interval convergence to zero to force */ /* interval convergence based on relative size of the interval. */ /* This is dangerous because intervals might not converge when RELTOL is */ /* small. But at least a very small number should be selected so that for */ /* strongly graded matrices, the code can get relatively accurate */ /* eigenvalues. */ atoli = uflow * 4.f + *pivmin * 4.f; if (irange == 3) { /* RANGE='I': Compute an interval containing eigenvalues */ /* IL through IU. The initial interval [GL,GU] from the global */ /* Gerschgorin bounds GL and GU is refined by SLAEBZ. */ itmax = (integer) ((log(tnorm + *pivmin) - log(*pivmin)) / log(2.f)) + 2; work[*n + 1] = gl; work[*n + 2] = gl; work[*n + 3] = gu; work[*n + 4] = gu; work[*n + 5] = gl; work[*n + 6] = gu; iwork[1] = -1; iwork[2] = -1; iwork[3] = *n + 1; iwork[4] = *n + 1; iwork[5] = *il - 1; iwork[6] = *iu; slaebz_(&c__3, &itmax, n, &c__2, &c__2, &nb, &atoli, &rtoli, pivmin, & d__[1], &e[1], &e2[1], &iwork[5], &work[*n + 1], &work[*n + 5] , &iout, &iwork[1], &w[1], &iblock[1], &iinfo); if (iinfo != 0) { *info = iinfo; return 0; } /* On exit, output intervals may not be ordered by ascending negcount */ if (iwork[6] == *iu) { *wl = work[*n + 1]; wlu = work[*n + 3]; nwl = iwork[1]; *wu = work[*n + 4]; wul = work[*n + 2]; nwu = iwork[4]; } else { *wl = work[*n + 2]; wlu = work[*n + 4]; nwl = iwork[2]; *wu = work[*n + 3]; wul = work[*n + 1]; nwu = iwork[3]; } /* On exit, the interval [WL, WLU] contains a value with negcount NWL, */ /* and [WUL, WU] contains a value with negcount NWU. */ if (nwl < 0 || nwl >= *n || nwu < 1 || nwu > *n) { *info = 4; return 0; } } else if (irange == 2) { *wl = *vl; *wu = *vu; } else if (irange == 1) { *wl = gl; *wu = gu; } /* Find Eigenvalues -- Loop Over blocks and recompute NWL and NWU. */ /* NWL accumulates the number of eigenvalues .le. WL, */ /* NWU accumulates the number of eigenvalues .le. WU */ *m = 0; iend = 0; *info = 0; nwl = 0; nwu = 0; i__1 = *nsplit; for (jblk = 1; jblk <= i__1; ++jblk) { ioff = iend; ibegin = ioff + 1; iend = isplit[jblk]; in = iend - ioff; if (in == 1) { /* 1x1 block */ if (*wl >= d__[ibegin] - *pivmin) { ++nwl; } if (*wu >= d__[ibegin] - *pivmin) { ++nwu; } if (irange == 1 || *wl < d__[ibegin] - *pivmin && *wu >= d__[ ibegin] - *pivmin) { ++(*m); w[*m] = d__[ibegin]; werr[*m] = 0.f; /* The gap for a single block doesn't matter for the later */ /* algorithm and is assigned an arbitrary large value */ iblock[*m] = jblk; indexw[*m] = 1; } /* Disabled 2x2 case because of a failure on the following matrix */ /* RANGE = 'I', IL = IU = 4 */ /* Original Tridiagonal, d = [ */ /* -0.150102010615740E+00 */ /* -0.849897989384260E+00 */ /* -0.128208148052635E-15 */ /* 0.128257718286320E-15 */ /* ]; */ /* e = [ */ /* -0.357171383266986E+00 */ /* -0.180411241501588E-15 */ /* -0.175152352710251E-15 */ /* ]; */ /* ELSE IF( IN.EQ.2 ) THEN */ /* * 2x2 block */ /* DISC = SQRT( (HALF*(D(IBEGIN)-D(IEND)))**2 + E(IBEGIN)**2 ) */ /* TMP1 = HALF*(D(IBEGIN)+D(IEND)) */ /* L1 = TMP1 - DISC */ /* IF( WL.GE. L1-PIVMIN ) */ /* $ NWL = NWL + 1 */ /* IF( WU.GE. L1-PIVMIN ) */ /* $ NWU = NWU + 1 */ /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L1-PIVMIN .AND. WU.GE. */ /* $ L1-PIVMIN ) ) THEN */ /* M = M + 1 */ /* W( M ) = L1 */ /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */ /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */ /* IBLOCK( M ) = JBLK */ /* INDEXW( M ) = 1 */ /* ENDIF */ /* L2 = TMP1 + DISC */ /* IF( WL.GE. L2-PIVMIN ) */ /* $ NWL = NWL + 1 */ /* IF( WU.GE. L2-PIVMIN ) */ /* $ NWU = NWU + 1 */ /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L2-PIVMIN .AND. WU.GE. */ /* $ L2-PIVMIN ) ) THEN */ /* M = M + 1 */ /* W( M ) = L2 */ /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */ /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */ /* IBLOCK( M ) = JBLK */ /* INDEXW( M ) = 2 */ /* ENDIF */ } else { /* General Case - block of size IN >= 2 */ /* Compute local Gerschgorin interval and use it as the initial */ /* interval for SLAEBZ */ gu = d__[ibegin]; gl = d__[ibegin]; tmp1 = 0.f; i__2 = iend; for (j = ibegin; j <= i__2; ++j) { /* Computing MIN */ r__1 = gl, r__2 = gers[(j << 1) - 1]; gl = dmin(r__1,r__2); /* Computing MAX */ r__1 = gu, r__2 = gers[j * 2]; gu = dmax(r__1,r__2); /* L40: */ } /* [JAN/28/2009] */ /* change SPDIAM by TNORM in lines 2 and 3 thereafter */ /* line 1: remove computation of SPDIAM (not useful anymore) */ /* SPDIAM = GU - GL */ /* GL = GL - FUDGE*SPDIAM*EPS*IN - FUDGE*PIVMIN */ /* GU = GU + FUDGE*SPDIAM*EPS*IN + FUDGE*PIVMIN */ gl = gl - tnorm * 2.f * eps * in - *pivmin * 2.f; gu = gu + tnorm * 2.f * eps * in + *pivmin * 2.f; if (irange > 1) { if (gu < *wl) { /* the local block contains none of the wanted eigenvalues */ nwl += in; nwu += in; goto L70; } /* refine search interval if possible, only range (WL,WU] matters */ gl = dmax(gl,*wl); gu = dmin(gu,*wu); if (gl >= gu) { goto L70; } } /* Find negcount of initial interval boundaries GL and GU */ work[*n + 1] = gl; work[*n + in + 1] = gu; slaebz_(&c__1, &c__0, &in, &in, &c__1, &nb, &atoli, &rtoli, pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, & work[*n + 1], &work[*n + (in << 1) + 1], &im, &iwork[1], & w[*m + 1], &iblock[*m + 1], &iinfo); if (iinfo != 0) { *info = iinfo; return 0; } nwl += iwork[1]; nwu += iwork[in + 1]; iwoff = *m - iwork[1]; /* Compute Eigenvalues */ itmax = (integer) ((log(gu - gl + *pivmin) - log(*pivmin)) / log( 2.f)) + 2; slaebz_(&c__2, &itmax, &in, &in, &c__1, &nb, &atoli, &rtoli, pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, & work[*n + 1], &work[*n + (in << 1) + 1], &iout, &iwork[1], &w[*m + 1], &iblock[*m + 1], &iinfo); if (iinfo != 0) { *info = iinfo; return 0; } /* Copy eigenvalues into W and IBLOCK */ /* Use -JBLK for block number for unconverged eigenvalues. */ /* Loop over the number of output intervals from SLAEBZ */ i__2 = iout; for (j = 1; j <= i__2; ++j) { /* eigenvalue approximation is middle point of interval */ tmp1 = (work[j + *n] + work[j + in + *n]) * .5f; /* semi length of error interval */ tmp2 = (r__1 = work[j + *n] - work[j + in + *n], dabs(r__1)) * .5f; if (j > iout - iinfo) { /* Flag non-convergence. */ ncnvrg = TRUE_; ib = -jblk; } else { ib = jblk; } i__3 = iwork[j + in] + iwoff; for (je = iwork[j] + 1 + iwoff; je <= i__3; ++je) { w[je] = tmp1; werr[je] = tmp2; indexw[je] = je - iwoff; iblock[je] = ib; /* L50: */ } /* L60: */ } *m += im; } L70: ; } /* If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU */ /* If NWL+1 < IL or NWU > IU, discard extra eigenvalues. */ if (irange == 3) { idiscl = *il - 1 - nwl; idiscu = nwu - *iu; if (idiscl > 0) { im = 0; i__1 = *m; for (je = 1; je <= i__1; ++je) { /* Remove some of the smallest eigenvalues from the left so that */ /* at the end IDISCL =0. Move all eigenvalues up to the left. */ if (w[je] <= wlu && idiscl > 0) { --idiscl; } else { ++im; w[im] = w[je]; werr[im] = werr[je]; indexw[im] = indexw[je]; iblock[im] = iblock[je]; } /* L80: */ } *m = im; } if (idiscu > 0) { /* Remove some of the largest eigenvalues from the right so that */ /* at the end IDISCU =0. Move all eigenvalues up to the left. */ im = *m + 1; for (je = *m; je >= 1; --je) { if (w[je] >= wul && idiscu > 0) { --idiscu; } else { --im; w[im] = w[je]; werr[im] = werr[je]; indexw[im] = indexw[je]; iblock[im] = iblock[je]; } /* L81: */ } jee = 0; i__1 = *m; for (je = im; je <= i__1; ++je) { ++jee; w[jee] = w[je]; werr[jee] = werr[je]; indexw[jee] = indexw[je]; iblock[jee] = iblock[je]; /* L82: */ } *m = *m - im + 1; } if (idiscl > 0 || idiscu > 0) { /* Code to deal with effects of bad arithmetic. (If N(w) is */ /* monotone non-decreasing, this should never happen.) */ /* Some low eigenvalues to be discarded are not in (WL,WLU], */ /* or high eigenvalues to be discarded are not in (WUL,WU] */ /* so just kill off the smallest IDISCL/largest IDISCU */ /* eigenvalues, by marking the corresponding IBLOCK = 0 */ if (idiscl > 0) { wkill = *wu; i__1 = idiscl; for (jdisc = 1; jdisc <= i__1; ++jdisc) { iw = 0; i__2 = *m; for (je = 1; je <= i__2; ++je) { if (iblock[je] != 0 && (w[je] < wkill || iw == 0)) { iw = je; wkill = w[je]; } /* L90: */ } iblock[iw] = 0; /* L100: */ } } if (idiscu > 0) { wkill = *wl; i__1 = idiscu; for (jdisc = 1; jdisc <= i__1; ++jdisc) { iw = 0; i__2 = *m; for (je = 1; je <= i__2; ++je) { if (iblock[je] != 0 && (w[je] >= wkill || iw == 0)) { iw = je; wkill = w[je]; } /* L110: */ } iblock[iw] = 0; /* L120: */ } } /* Now erase all eigenvalues with IBLOCK set to zero */ im = 0; i__1 = *m; for (je = 1; je <= i__1; ++je) { if (iblock[je] != 0) { ++im; w[im] = w[je]; werr[im] = werr[je]; indexw[im] = indexw[je]; iblock[im] = iblock[je]; } /* L130: */ } *m = im; } if (idiscl < 0 || idiscu < 0) { toofew = TRUE_; } } if (irange == 1 && *m != *n || irange == 3 && *m != *iu - *il + 1) { toofew = TRUE_; } /* If ORDER='B', do nothing the eigenvalues are already sorted by */ /* block. */ /* If ORDER='E', sort the eigenvalues from smallest to largest */ if (lsame_(order, "E") && *nsplit > 1) { i__1 = *m - 1; for (je = 1; je <= i__1; ++je) { ie = 0; tmp1 = w[je]; i__2 = *m; for (j = je + 1; j <= i__2; ++j) { if (w[j] < tmp1) { ie = j; tmp1 = w[j]; } /* L140: */ } if (ie != 0) { tmp2 = werr[ie]; itmp1 = iblock[ie]; itmp2 = indexw[ie]; w[ie] = w[je]; werr[ie] = werr[je]; iblock[ie] = iblock[je]; indexw[ie] = indexw[je]; w[je] = tmp1; werr[je] = tmp2; iblock[je] = itmp1; indexw[je] = itmp2; } /* L150: */ } } *info = 0; if (ncnvrg) { ++(*info); } if (toofew) { *info += 2; } return 0; /* End of SLARRD */ } /* slarrd_ */
314ddb60d2fa254ed566132c78d4822915c49f65
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/devel/libuuid/patches/patch-misc-utils_mcookie.c
f283753a9705d021426e10c22a29ecfc03db524c
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
524
c
patch-misc-utils_mcookie.c
$NetBSD: patch-misc-utils_mcookie.c,v 1.1 2021/07/25 04:00:34 dholland Exp $ Rename random_get_bytes to avoid symbol name conflict on Solaris. --- misc-utils/mcookie.c~ 2018-06-04 07:57:02.810445749 +0000 +++ misc-utils/mcookie.c @@ -180,7 +180,7 @@ int main(int argc, char **argv) randomness_from_files(&ctl); free(ctl.files); - random_get_bytes(&buf, RAND_BYTES); + my_random_get_bytes(&buf, RAND_BYTES); ul_MD5Update(&ctl.ctx, buf, RAND_BYTES); if (ctl.verbose) fprintf(stderr, P_("Got %d byte from %s\n",
bf709c82e9a8416e15942a0da2a6ba9a4bbbcdf3
72e0f1797737a4b73d61f5ffeeb2d6c025326e6f
/SingleSource/UnitTests/testcase-Value-1.c
eab6183bf59acfbc4336d01dfdcf04cc68379c60
[ "NCSA", "Apache-2.0", "LLVM-exception" ]
permissive
llvm/llvm-test-suite
83f4c87b5dc35843aff4e08cf66147ee51dc699a
0e6307a4eb8a1a2126fdb582b3c997cd446034b9
refs/heads/main
2023-09-06T06:57:54.592788
2023-09-05T20:20:32
2023-09-05T20:20:32
164,930,827
116
110
NOASSERTION
2023-09-08T20:37:50
2019-01-09T20:13:14
Logos
UTF-8
C
false
false
603
c
testcase-Value-1.c
/* The test targets function Value::dropDroppableUse(Use &U) in Value.cpp. */ #include <stdint.h> #include <stdio.h> #include <inttypes.h> char a; short b = 1, d = 5, h = 1; char c[6]; int32_t e = 1, f = 20, g = 1, j = 1; int32_t main() { int32_t i = 8; for (; f; f = a) { g = (5); for (; g <= 32; ++g) { i = 6; for (; i < -4; i++) while (7 > d) if (c[b]) { break; } L: if (j) { break; } } } e = 0; for (; e; e = 900) { d++; for (; h;) goto L; } printf("%" PRId32, e); return 0; }
20bc7adadf4e83273e3f4396ff5cb6a8aa75e970
b0f08154e3eebc7d8465efc57597e52d08d69c18
/src/compat/cnvlex.h
58cdf66d2ae8dbf85faa6f663bd8d4a4f7c30b87
[ "BSD-3-Clause", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
CUBRID/cubrid
8f71a0010243b72e43ba887d229210650f4e901e
3b952af33230839a1b561a78ecd4b773374b66f8
refs/heads/develop
2023-08-18T19:16:30.987583
2023-08-18T08:18:05
2023-08-18T08:18:05
52,080,367
287
294
NOASSERTION
2023-09-14T21:29:09
2016-02-19T10:25:32
C
UTF-8
C
false
false
3,031
h
cnvlex.h
/* * Copyright 2008 Search Solution Corporation * Copyright 2016 CUBRID Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /* * cnvlex.h - Lexical scanning interface for string conversion API. */ #ifndef _CNVLEX_H_ #define _CNVLEX_H_ #ident "$Id$" #include "intl_support.h" /* * Lexical scan modes. These correspond directly to start conditions defined * in the scanner definition file. Be sure to update db_fmt_lex_start() to * maintain the correspondence. */ typedef enum { FL_LOCAL_NUMBER = 0, FL_US_ENG_NUMBER = 1, FL_KO_KR_NUMBER = 2, FL_LOCAL_TIME = 3, FL_US_ENG_TIME = 4, FL_KO_KR_TIME = 5, FL_INTEGER_FORMAT = 6, FL_TIME_FORMAT = 7, FL_BIT_STRING_FORMAT = 8, FL_BIT_STRING = 9, FL_VALIDATE_DATE_FORMAT = 10, FL_VALIDATE_FLOAT_FORMAT = 11, FL_VALIDATE_INTEGER_FORMAT = 12, FL_VALIDATE_MONETARY_FORMAT = 13, FL_VALIDATE_TIME_FORMAT = 14, FL_VALIDATE_TIMESTAMP_FORMAT = 15, FL_VALIDATE_BIT_STRING_FORMAT = 16 } FMT_LEX_MODE; typedef enum { FT_NONE = 0, FT_AM_PM = 1, FT_BLANKS = 2, FT_BINARY_DIGITS = 3, FT_BIT_STRING_FORMAT = 4, FT_CURRENCY = 5, FT_DATE = 6, FT_DATE_FORMAT = 7, FT_DATE_SEPARATOR = 8, FT_LOCAL_DATE_SEPARATOR = 9, FT_DECIMAL = 10, FT_FLOAT_FORMAT = 11, FT_HOUR = 12, FT_HEX_DIGITS = 13, FT_INTEGER_FORMAT = 14, FT_MINUS = 15, FT_MINUTE = 16, FT_MONETARY_FORMAT = 17, FT_MONTH = 18, FT_MONTHDAY = 19, FT_MONTH_LONG = 20, FT_NUMBER = 21, FT_PATTERN = 22, FT_PLUS = 23, FT_SECOND = 24, FT_SPACES = 25, FT_STARS = 26, FT_THOUSANDS = 27, FT_TIME = 28, FT_TIME_DIGITS = 29, FT_TIME_DIGITS_ANY = 30, FT_TIME_DIGITS_0 = 31, FT_TIME_DIGITS_BLANK = 32, FT_TIME_FORMAT = 33, FT_TIME_SEPARATOR = 34, FT_LOCAL_TIME_SEPARATOR = 35, FT_UNKNOWN = 36, FT_TIMESTAMP = 37, FT_TIMESTAMP_FORMAT = 38, FT_WEEKDAY = 39, FT_WEEKDAY_LONG = 40, FT_YEAR = 41, FT_ZEROES = 42, FT_ZONE = 43, FT_MILLISECOND = 44 } FMT_TOKEN_TYPE; typedef struct fmt_token FMT_TOKEN; struct fmt_token { FMT_TOKEN_TYPE type; const char *text; int length; const char *raw_text; int value; }; extern void cnv_fmt_analyze (const char *instring, FMT_LEX_MODE mode); extern FMT_TOKEN_TYPE cnv_fmt_lex (FMT_TOKEN * token); extern void cnv_fmt_unlex (void); extern const char *cnv_fmt_next_token (void); extern FMT_LEX_MODE cnv_fmt_number_mode (INTL_ZONE zone); extern FMT_LEX_MODE cnv_fmt_time_mode (INTL_ZONE zone); extern void cnv_fmt_exit (void); #endif /* _CNVLEX_H_ */
dca3923d9f6b03f6543e67d179d18539a7949fb3
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/ffmpeg/libavcodec/hqx.c
6083946550224eb80533837c5a21615338713662
[ "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
18,320
c
hqx.c
/* * Canopus HQX decoder * * 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 <inttypes.h> #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "canopus.h" #include "codec_internal.h" #include "get_bits.h" #include "thread.h" #include "hqx.h" #include "hqxdsp.h" /* HQX has four modes - 422, 444, 422alpha and 444alpha - all 12-bit */ enum HQXFormat { HQX_422 = 0, HQX_444, HQX_422A, HQX_444A, }; #define HQX_HEADER_SIZE 59 /* macroblock selects a group of 4 possible quants and * a block can use any of those four quantisers * one column is powers of 2, the other one is powers of 2 * 3, * then there is the special one, powers of 2 * 5 */ static const int hqx_quants[16][4] = { { 0x1, 0x2, 0x4, 0x8 }, { 0x1, 0x3, 0x6, 0xC }, { 0x2, 0x4, 0x8, 0x10 }, { 0x3, 0x6, 0xC, 0x18 }, { 0x4, 0x8, 0x10, 0x20 }, { 0x6, 0xC, 0x18, 0x30 }, { 0x8, 0x10, 0x20, 0x40 }, { 0xA, 0x14, 0x28, 0x50 }, { 0xC, 0x18, 0x30, 0x60 }, { 0x10, 0x20, 0x40, 0x80 }, { 0x18, 0x30, 0x60, 0xC0 }, { 0x20, 0x40, 0x80, 0x100 }, { 0x30, 0x60, 0xC0, 0x180 }, { 0x40, 0x80, 0x100, 0x200 }, { 0x60, 0xC0, 0x180, 0x300 }, { 0x80, 0x100, 0x200, 0x400 } }; static const uint8_t hqx_quant_luma[64] = { 16, 16, 16, 19, 19, 19, 42, 44, 16, 16, 19, 19, 19, 38, 43, 45, 16, 19, 19, 19, 40, 41, 45, 48, 19, 19, 19, 40, 41, 42, 46, 49, 19, 19, 40, 41, 42, 43, 48, 101, 19, 38, 41, 42, 43, 44, 98, 104, 42, 43, 45, 46, 48, 98, 109, 116, 44, 45, 48, 49, 101, 104, 116, 123, }; static const uint8_t hqx_quant_chroma[64] = { 16, 16, 19, 25, 26, 26, 42, 44, 16, 19, 25, 25, 26, 38, 43, 91, 19, 25, 26, 27, 40, 41, 91, 96, 25, 25, 27, 40, 41, 84, 93, 197, 26, 26, 40, 41, 84, 86, 191, 203, 26, 38, 41, 84, 86, 177, 197, 209, 42, 43, 91, 93, 191, 197, 219, 232, 44, 91, 96, 197, 203, 209, 232, 246, }; static inline void put_blocks(HQXContext *ctx, int plane, int x, int y, int ilace, int16_t *block0, int16_t *block1, const uint8_t *quant) { int fields = ilace ? 2 : 1; int lsize = ctx->pic->linesize[plane]; uint8_t *p = ctx->pic->data[plane] + x * 2; ctx->hqxdsp.idct_put((uint16_t *)(p + y * lsize), lsize * fields, block0, quant); ctx->hqxdsp.idct_put((uint16_t *)(p + (y + (ilace ? 1 : 8)) * lsize), lsize * fields, block1, quant); } static inline void hqx_get_ac(GetBitContext *gb, const HQXAC *ac, int *run, int *lev) { int val; val = show_bits(gb, ac->lut_bits); if (ac->lut[val].bits == -1) { GetBitContext gb2 = *gb; skip_bits(&gb2, ac->lut_bits); val = ac->lut[val].lev + show_bits(&gb2, ac->extra_bits); } *run = ac->lut[val].run; *lev = ac->lut[val].lev; skip_bits(gb, ac->lut[val].bits); } static int decode_block(GetBitContext *gb, VLC *vlc, const int *quants, int dcb, int16_t block[64], int *last_dc) { int q, dc; int ac_idx; int run, lev, pos = 1; memset(block, 0, 64 * sizeof(*block)); dc = get_vlc2(gb, vlc->table, HQX_DC_VLC_BITS, 2); *last_dc += dc; block[0] = sign_extend(*last_dc << (12 - dcb), 12); q = quants[get_bits(gb, 2)]; if (q >= 128) ac_idx = HQX_AC_Q128; else if (q >= 64) ac_idx = HQX_AC_Q64; else if (q >= 32) ac_idx = HQX_AC_Q32; else if (q >= 16) ac_idx = HQX_AC_Q16; else if (q >= 8) ac_idx = HQX_AC_Q8; else ac_idx = HQX_AC_Q0; do { hqx_get_ac(gb, &ff_hqx_ac[ac_idx], &run, &lev); pos += run; if (pos >= 64) break; block[ff_zigzag_direct[pos++]] = lev * q; } while (pos < 64); return 0; } static int hqx_decode_422(HQXContext *ctx, int slice_no, int x, int y) { HQXSlice *slice = &ctx->slice[slice_no]; GetBitContext *gb = &slice->gb; const int *quants; int flag; int last_dc; int i, ret; if (ctx->interlaced) flag = get_bits1(gb); else flag = 0; quants = hqx_quants[get_bits(gb, 4)]; for (i = 0; i < 8; i++) { int vlc_index = ctx->dcb - 9; if (i == 0 || i == 4 || i == 6) last_dc = 0; ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants, ctx->dcb, slice->block[i], &last_dc); if (ret < 0) return ret; } put_blocks(ctx, 0, x, y, flag, slice->block[0], slice->block[2], hqx_quant_luma); put_blocks(ctx, 0, x + 8, y, flag, slice->block[1], slice->block[3], hqx_quant_luma); put_blocks(ctx, 2, x >> 1, y, flag, slice->block[4], slice->block[5], hqx_quant_chroma); put_blocks(ctx, 1, x >> 1, y, flag, slice->block[6], slice->block[7], hqx_quant_chroma); return 0; } static int hqx_decode_422a(HQXContext *ctx, int slice_no, int x, int y) { HQXSlice *slice = &ctx->slice[slice_no]; GetBitContext *gb = &slice->gb; const int *quants; int flag = 0; int last_dc; int i, ret; int cbp; cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1); for (i = 0; i < 12; i++) memset(slice->block[i], 0, sizeof(**slice->block) * 64); for (i = 0; i < 12; i++) slice->block[i][0] = -0x800; if (cbp) { if (ctx->interlaced) flag = get_bits1(gb); quants = hqx_quants[get_bits(gb, 4)]; cbp |= cbp << 4; // alpha CBP if (cbp & 0x3) // chroma CBP - top cbp |= 0x500; if (cbp & 0xC) // chroma CBP - bottom cbp |= 0xA00; for (i = 0; i < 12; i++) { if (i == 0 || i == 4 || i == 8 || i == 10) last_dc = 0; if (cbp & (1 << i)) { int vlc_index = ctx->dcb - 9; ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants, ctx->dcb, slice->block[i], &last_dc); if (ret < 0) return ret; } } } put_blocks(ctx, 3, x, y, flag, slice->block[ 0], slice->block[ 2], hqx_quant_luma); put_blocks(ctx, 3, x + 8, y, flag, slice->block[ 1], slice->block[ 3], hqx_quant_luma); put_blocks(ctx, 0, x, y, flag, slice->block[ 4], slice->block[ 6], hqx_quant_luma); put_blocks(ctx, 0, x + 8, y, flag, slice->block[ 5], slice->block[ 7], hqx_quant_luma); put_blocks(ctx, 2, x >> 1, y, flag, slice->block[ 8], slice->block[ 9], hqx_quant_chroma); put_blocks(ctx, 1, x >> 1, y, flag, slice->block[10], slice->block[11], hqx_quant_chroma); return 0; } static int hqx_decode_444(HQXContext *ctx, int slice_no, int x, int y) { HQXSlice *slice = &ctx->slice[slice_no]; GetBitContext *gb = &slice->gb; const int *quants; int flag; int last_dc; int i, ret; if (ctx->interlaced) flag = get_bits1(gb); else flag = 0; quants = hqx_quants[get_bits(gb, 4)]; for (i = 0; i < 12; i++) { int vlc_index = ctx->dcb - 9; if (i == 0 || i == 4 || i == 8) last_dc = 0; ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants, ctx->dcb, slice->block[i], &last_dc); if (ret < 0) return ret; } put_blocks(ctx, 0, x, y, flag, slice->block[0], slice->block[ 2], hqx_quant_luma); put_blocks(ctx, 0, x + 8, y, flag, slice->block[1], slice->block[ 3], hqx_quant_luma); put_blocks(ctx, 2, x, y, flag, slice->block[4], slice->block[ 6], hqx_quant_chroma); put_blocks(ctx, 2, x + 8, y, flag, slice->block[5], slice->block[ 7], hqx_quant_chroma); put_blocks(ctx, 1, x, y, flag, slice->block[8], slice->block[10], hqx_quant_chroma); put_blocks(ctx, 1, x + 8, y, flag, slice->block[9], slice->block[11], hqx_quant_chroma); return 0; } static int hqx_decode_444a(HQXContext *ctx, int slice_no, int x, int y) { HQXSlice *slice = &ctx->slice[slice_no]; GetBitContext *gb = &slice->gb; const int *quants; int flag = 0; int last_dc; int i, ret; int cbp; cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1); for (i = 0; i < 16; i++) memset(slice->block[i], 0, sizeof(**slice->block) * 64); for (i = 0; i < 16; i++) slice->block[i][0] = -0x800; if (cbp) { if (ctx->interlaced) flag = get_bits1(gb); quants = hqx_quants[get_bits(gb, 4)]; cbp |= cbp << 4; // alpha CBP cbp |= cbp << 8; // chroma CBP for (i = 0; i < 16; i++) { if (i == 0 || i == 4 || i == 8 || i == 12) last_dc = 0; if (cbp & (1 << i)) { int vlc_index = ctx->dcb - 9; ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants, ctx->dcb, slice->block[i], &last_dc); if (ret < 0) return ret; } } } put_blocks(ctx, 3, x, y, flag, slice->block[ 0], slice->block[ 2], hqx_quant_luma); put_blocks(ctx, 3, x + 8, y, flag, slice->block[ 1], slice->block[ 3], hqx_quant_luma); put_blocks(ctx, 0, x, y, flag, slice->block[ 4], slice->block[ 6], hqx_quant_luma); put_blocks(ctx, 0, x + 8, y, flag, slice->block[ 5], slice->block[ 7], hqx_quant_luma); put_blocks(ctx, 2, x, y, flag, slice->block[ 8], slice->block[10], hqx_quant_chroma); put_blocks(ctx, 2, x + 8, y, flag, slice->block[ 9], slice->block[11], hqx_quant_chroma); put_blocks(ctx, 1, x, y, flag, slice->block[12], slice->block[14], hqx_quant_chroma); put_blocks(ctx, 1, x + 8, y, flag, slice->block[13], slice->block[15], hqx_quant_chroma); return 0; } static const int shuffle_16[16] = { 0, 5, 11, 14, 2, 7, 9, 13, 1, 4, 10, 15, 3, 6, 8, 12 }; static int decode_slice(HQXContext *ctx, int slice_no) { int mb_w = (ctx->width + 15) >> 4; int mb_h = (ctx->height + 15) >> 4; int grp_w = (mb_w + 4) / 5; int grp_h = (mb_h + 4) / 5; int grp_h_edge = grp_w * (mb_w / grp_w); int grp_v_edge = grp_h * (mb_h / grp_h); int grp_v_rest = mb_w - grp_h_edge; int grp_h_rest = mb_h - grp_v_edge; int num_mbs = mb_w * mb_h; int num_tiles = (num_mbs + 479) / 480; int std_tile_blocks = num_mbs / (16 * num_tiles); int g_tile = slice_no * num_tiles; int blk_addr, loc_addr, mb_x, mb_y, pos, loc_row, i; int tile_blocks, tile_limit, tile_no; for (tile_no = 0; tile_no < num_tiles; tile_no++, g_tile++) { tile_blocks = std_tile_blocks; tile_limit = -1; if (g_tile < num_mbs - std_tile_blocks * 16 * num_tiles) { tile_limit = num_mbs / (16 * num_tiles); tile_blocks++; } for (i = 0; i < tile_blocks; i++) { if (i == tile_limit) blk_addr = g_tile + 16 * num_tiles * i; else blk_addr = tile_no + 16 * num_tiles * i + num_tiles * shuffle_16[(i + slice_no) & 0xF]; loc_row = grp_h * (blk_addr / (grp_h * mb_w)); loc_addr = blk_addr % (grp_h * mb_w); if (loc_row >= grp_v_edge) { mb_x = grp_w * (loc_addr / (grp_h_rest * grp_w)); pos = loc_addr % (grp_h_rest * grp_w); } else { mb_x = grp_w * (loc_addr / (grp_h * grp_w)); pos = loc_addr % (grp_h * grp_w); } if (mb_x >= grp_h_edge) { mb_x += pos % grp_v_rest; mb_y = loc_row + (pos / grp_v_rest); } else { mb_x += pos % grp_w; mb_y = loc_row + (pos / grp_w); } ctx->decode_func(ctx, slice_no, mb_x * 16, mb_y * 16); } } return 0; } static int decode_slice_thread(AVCodecContext *avctx, void *arg, int slice_no, int threadnr) { HQXContext *ctx = avctx->priv_data; uint32_t *slice_off = ctx->slice_off; int ret; if (slice_off[slice_no] < HQX_HEADER_SIZE || slice_off[slice_no] >= slice_off[slice_no + 1] || slice_off[slice_no + 1] > ctx->data_size) { av_log(avctx, AV_LOG_ERROR, "Invalid slice size %d.\n", ctx->data_size); return AVERROR_INVALIDDATA; } ret = init_get_bits8(&ctx->slice[slice_no].gb, ctx->src + slice_off[slice_no], slice_off[slice_no + 1] - slice_off[slice_no]); if (ret < 0) return ret; return decode_slice(ctx, slice_no); } static int hqx_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_picture_ptr, AVPacket *avpkt) { HQXContext *ctx = avctx->priv_data; const uint8_t *src = avpkt->data; uint32_t info_tag; int data_start; int i, ret; if (avpkt->size < 4 + 4) { av_log(avctx, AV_LOG_ERROR, "Frame is too small %d.\n", avpkt->size); return AVERROR_INVALIDDATA; } info_tag = AV_RL32(src); if (info_tag == MKTAG('I', 'N', 'F', 'O')) { uint32_t info_offset = AV_RL32(src + 4); if (info_offset > INT_MAX || info_offset + 8 > avpkt->size) { av_log(avctx, AV_LOG_ERROR, "Invalid INFO header offset: 0x%08"PRIX32" is too large.\n", info_offset); return AVERROR_INVALIDDATA; } ff_canopus_parse_info_tag(avctx, src + 8, info_offset); info_offset += 8; src += info_offset; } data_start = src - avpkt->data; ctx->data_size = avpkt->size - data_start; ctx->src = src; ctx->pic = frame; if (ctx->data_size < HQX_HEADER_SIZE) { av_log(avctx, AV_LOG_ERROR, "Frame too small.\n"); return AVERROR_INVALIDDATA; } if (src[0] != 'H' || src[1] != 'Q') { av_log(avctx, AV_LOG_ERROR, "Not an HQX frame.\n"); return AVERROR_INVALIDDATA; } ctx->interlaced = !(src[2] & 0x80); ctx->format = src[2] & 7; ctx->dcb = (src[3] & 3) + 8; ctx->width = AV_RB16(src + 4); ctx->height = AV_RB16(src + 6); for (i = 0; i < 17; i++) ctx->slice_off[i] = AV_RB24(src + 8 + i * 3); if (ctx->dcb == 8) { av_log(avctx, AV_LOG_ERROR, "Invalid DC precision %d.\n", ctx->dcb); return AVERROR_INVALIDDATA; } ret = av_image_check_size(ctx->width, ctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid stored dimensions %dx%d.\n", ctx->width, ctx->height); return AVERROR_INVALIDDATA; } avctx->coded_width = FFALIGN(ctx->width, 16); avctx->coded_height = FFALIGN(ctx->height, 16); avctx->width = ctx->width; avctx->height = ctx->height; avctx->bits_per_raw_sample = 10; //The minimum size is 2bit per macroblock // hqx_decode_422 & hqx_decode_444 have a unconditionally stored 4bits hqx_quants index // hqx_decode_422a & hqx_decode_444a use cbp_vlc which has a minimum length of 2 bits for its VLCs // The code rejects slices overlapping in their input data if (avctx->coded_width / 16 * (avctx->coded_height / 16) * (100 - avctx->discard_damaged_percentage) / 100 > 4LL * avpkt->size) return AVERROR_INVALIDDATA; switch (ctx->format) { case HQX_422: avctx->pix_fmt = AV_PIX_FMT_YUV422P16; ctx->decode_func = hqx_decode_422; break; case HQX_444: avctx->pix_fmt = AV_PIX_FMT_YUV444P16; ctx->decode_func = hqx_decode_444; break; case HQX_422A: avctx->pix_fmt = AV_PIX_FMT_YUVA422P16; ctx->decode_func = hqx_decode_422a; break; case HQX_444A: avctx->pix_fmt = AV_PIX_FMT_YUVA444P16; ctx->decode_func = hqx_decode_444a; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid format: %d.\n", ctx->format); return AVERROR_INVALIDDATA; } ret = ff_thread_get_buffer(avctx, frame, 0); if (ret < 0) return ret; avctx->execute2(avctx, decode_slice_thread, NULL, NULL, 16); ctx->pic->key_frame = 1; ctx->pic->pict_type = AV_PICTURE_TYPE_I; *got_picture_ptr = 1; return avpkt->size; } static av_cold int hqx_decode_close(AVCodecContext *avctx) { int i; HQXContext *ctx = avctx->priv_data; ff_free_vlc(&ctx->cbp_vlc); for (i = 0; i < 3; i++) { ff_free_vlc(&ctx->dc_vlc[i]); } return 0; } static av_cold int hqx_decode_init(AVCodecContext *avctx) { HQXContext *ctx = avctx->priv_data; ff_hqxdsp_init(&ctx->hqxdsp); return ff_hqx_init_vlcs(ctx); } const FFCodec ff_hqx_decoder = { .p.name = "hqx", CODEC_LONG_NAME("Canopus HQX"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HQX, .priv_data_size = sizeof(HQXContext), .init = hqx_decode_init, FF_CODEC_DECODE_CB(hqx_decode_frame), .close = hqx_decode_close, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };
23e1b9a1aba97da1f79f29066990cc579ceb719a
a5e8d99c1852ee93743e86cfb109835bbe73a49b
/runtimes/native/src/backend/main_libretro.c
8276a0648e95596fbcec2f55016623da15c37b68
[ "ISC" ]
permissive
aduros/wasm4
5cc114dff2bac17373259c2fe36540c138733e8e
700c2929d1fc9512cf7705ceebb130fb72a29892
refs/heads/main
2023-09-06T00:44:00.487354
2023-08-21T13:09:51
2023-08-21T13:09:51
393,196,822
952
190
ISC
2023-08-21T12:45:07
2021-08-05T23:48:23
TypeScript
UTF-8
C
false
false
16,160
c
main_libretro.c
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <libretro.h> #include "../apu.h" #include "../runtime.h" #include "../wasm.h" #include "../util.h" #define AUDIO_BUFFER_FRAMES_CALLBACK 256 #define AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME 735 static retro_environment_t environ_cb; static retro_video_refresh_t video_cb; static retro_input_poll_t input_poll_cb; static retro_input_state_t input_state_cb; static retro_audio_sample_batch_t audio_batch_cb; static uint8_t* wasmData; static size_t wasmLength; static bool wasmCopy = false; static uint8_t* memory; static enum retro_pixel_format pixel_format = RETRO_PIXEL_FORMAT_UNKNOWN; static int use_audio_callback = 0; static int16_t audio_output[2*AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME]; static w4_Disk disk = { 0 }; static int hold_in_start_value = 10; #if !defined(PSP) && !defined(PS2) static void audio_set_state (bool enable) { } #endif static void fallback_log(enum retro_log_level level, const char *fmt, ...) { va_list args; (void) level; va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); } static retro_log_printf_t log_cb = fallback_log; #if !defined(PSP) && !defined(PS2) static void audio_callback () { w4_apuWriteSamples(audio_output, AUDIO_BUFFER_FRAMES_CALLBACK); audio_batch_cb(audio_output, AUDIO_BUFFER_FRAMES_CALLBACK); } #endif unsigned retro_api_version () { return RETRO_API_VERSION; } static struct retro_variable variables[] = { { "wasm4_pixel_type", #if defined(PS2) "Pixel type; bgr555|xrgb8888", #else "Pixel type; xrgb8888|rgb565", #endif }, #if !defined(PSP) && !defined(PS2) // On PSP callback audio leads to hang // On PS2 it leads to silent audio { "wasm4_audio_type", "Audio type; callback|normal", }, #endif { "wasm4_touchscreen_hold_frames", "Frames to hold touch value; 10|20|30|5" }, { NULL, NULL }, }; void retro_set_environment (retro_environment_t cb) { environ_cb = cb; // Tell libretro we want to persistent_data=true struct retro_system_content_info_override exts[] = { { "wasm", false, true }, { NULL, false, false }, }; struct retro_log_callback logging; environ_cb(RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE, exts); // WASM-4 requires content to run bool no_game = false; environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_game); if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) log_cb = logging.log; cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); } void retro_set_audio_sample (retro_audio_sample_t cb) { // audio_cb = cb; } void retro_set_audio_sample_batch (retro_audio_sample_batch_t cb) { audio_batch_cb = cb; } void retro_set_input_poll (retro_input_poll_t cb) { input_poll_cb = cb; } void retro_set_input_state (retro_input_state_t cb) { input_state_cb = cb; } void retro_set_video_refresh (retro_video_refresh_t cb) { video_cb = cb; } void retro_set_controller_port_device (unsigned port, unsigned device) { } size_t retro_serialize_size () { return w4_runtimeSerializeSize(); } bool retro_serialize (void* dest, size_t size) { if (size < w4_runtimeSerializeSize()) { return false; } w4_runtimeSerialize(dest); return true; } bool retro_unserialize (const void* src, size_t size) { if (size < w4_runtimeSerializeSize()) { return false; } w4_runtimeUnserialize(src); return true; } void retro_cheat_reset () { } void retro_cheat_set (unsigned index, bool enabled, const char *code) { } void* retro_get_memory_data (unsigned id) { switch (id) { case RETRO_MEMORY_SAVE_RAM: return &disk; case RETRO_MEMORY_SYSTEM_RAM: return memory; default: return NULL; } } size_t retro_get_memory_size (unsigned id) { switch (id) { case RETRO_MEMORY_SAVE_RAM: return sizeof(disk); case RETRO_MEMORY_SYSTEM_RAM: return 1 << 16; default: return 0; } } void retro_get_system_info (struct retro_system_info* info) { memset(info, 0, sizeof(*info)); info->library_name = "WASM-4"; #ifndef GIT_VERSION #define GIT_VERSION "" #endif info->library_version = "v1" GIT_VERSION; info->valid_extensions = "wasm"; info->need_fullpath = false; } unsigned retro_get_region () { return RETRO_REGION_NTSC; } void retro_init () { // printf("WASM4 init\n"); } void retro_deinit () { // printf("WASM4 deinit\n"); } static void try_pixel_format(enum retro_pixel_format format) { if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &format)) { log_cb(RETRO_LOG_INFO, "Using pixel format %d\n", format); pixel_format = format; } } static void load_variables(bool startup) { struct retro_variable var; if (startup) { #if !defined(PSP) && !defined(PS2) var.key = "wasm4_audio_type"; var.value = NULL; use_audio_callback = !environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || !var.value || strcmp(var.value, "callback") == 0; #else use_audio_callback = 0; #endif } var.key = "wasm4_touchscreen_hold_frames"; var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { hold_in_start_value = strtoul(var.value, 0, 0); } else { hold_in_start_value = 10; } if (hold_in_start_value < 0 || hold_in_start_value > 120) hold_in_start_value = 10; } bool retro_load_game (const struct retro_game_info* game) { // printf("WASM4 load_game\n"); bool persistent_data = false; struct retro_game_info_ext* ext; enum retro_pixel_format preferredformat = RETRO_PIXEL_FORMAT_XRGB8888; static const enum retro_pixel_format supported_formats[] = {RETRO_PIXEL_FORMAT_XRGB8888, RETRO_PIXEL_FORMAT_RGB565 }; struct retro_variable var; unsigned i; var.key = "wasm4_pixel_type"; var.value = NULL; if (!environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var)) var.value = NULL; if (var.value && (strcmp(var.value, "rgb565") == 0 || strcmp(var.value, "bgr555") == 0)) preferredformat = RETRO_PIXEL_FORMAT_RGB565; else preferredformat = RETRO_PIXEL_FORMAT_XRGB8888; pixel_format = RETRO_PIXEL_FORMAT_UNKNOWN; try_pixel_format(preferredformat); for (i = 0; pixel_format == RETRO_PIXEL_FORMAT_UNKNOWN && i < sizeof(supported_formats) / sizeof(supported_formats[0]); i++) if (supported_formats[i] != preferredformat) // No need to try again try_pixel_format(supported_formats[i]); if (pixel_format == RETRO_PIXEL_FORMAT_UNKNOWN) { log_cb(RETRO_LOG_ERROR, "No supported image format found\n"); pixel_format = RETRO_PIXEL_FORMAT_UNKNOWN; return false; } if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &ext)) { persistent_data = ext->persistent_data; } wasmLength = game->size; if (persistent_data) { // We can use the game data directly if libretro will not free it wasmData = (uint8_t*)game->data; wasmCopy = false; } else { // Otherwise we need to manage our own copy wasmData = xmalloc(wasmLength); wasmCopy = true; memcpy(wasmData, game->data, wasmLength); } // Set input descriptors struct retro_input_descriptor descs[] = { { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "X" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Z" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "X" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Z" }, { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" }, { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" }, { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" }, { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "X" }, { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Z" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "X" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Z" }, { 0 }, }; environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descs); memory = w4_wasmInit(); w4_runtimeInit(memory, &disk); w4_wasmLoadModule(wasmData, wasmLength); load_variables(true); #if !defined(PSP) && !defined(PS2) if (use_audio_callback) { struct retro_audio_callback audio_cb = { audio_callback, audio_set_state }; log_cb(RETRO_LOG_INFO, "Using callback audio\n"); environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK, &audio_cb); } #endif if (!use_audio_callback) { log_cb(RETRO_LOG_INFO, "Using normal audio\n"); } return true; } bool retro_load_game_special (unsigned type, const struct retro_game_info *info, size_t num) { return false; } void retro_unload_game () { w4_wasmDestroy(); if (wasmCopy) { free(wasmData); } } void retro_reset () { w4_runtimeInit(memory, &disk); w4_wasmLoadModule(wasmData, wasmLength); } void retro_get_system_av_info (struct retro_system_av_info* info) { info->timing = (struct retro_system_timing) { .fps = 60.0, .sample_rate = 44100, }; info->geometry = (struct retro_game_geometry) { .base_width = 160, .base_height = 160, .max_width = 160, .max_height = 160, .aspect_ratio = 1, }; } void retro_run () { bool updated = false; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) { load_variables(false); } input_poll_cb(); // Gamepad handling for (int idx = 0; idx < 4; ++idx) { uint8_t gamepad = 0; if (input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) || input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X)) { gamepad |= W4_BUTTON_X; } if (input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) || input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y)) { gamepad |= W4_BUTTON_Z; } if (input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT)) { gamepad |= W4_BUTTON_LEFT; } if (input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT)) { gamepad |= W4_BUTTON_RIGHT; } if (input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP)) { gamepad |= W4_BUTTON_UP; } if (input_state_cb(idx, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN)) { gamepad |= W4_BUTTON_DOWN; } w4_runtimeSetGamepad(idx, gamepad); } // Mouse handling int16_t mouseX; int16_t mouseY; uint8_t mouseButtons = 0; int touchcount = 0; static int hold_position_countdown; static int hold_touch_countdown; static int old_touchcount = 0, held_touchcount = 0; static int hold_position_touchcount = 0; static int holdX = 0; static int holdY = 0; static bool is_mouse = #if defined(ANDROID) || defined(__SWITCH__) || defined(VITA) false #else true #endif ; while (input_state_cb(0, RETRO_DEVICE_POINTER, touchcount, RETRO_DEVICE_ID_POINTER_PRESSED)) touchcount++; if (hold_position_countdown > 0 && touchcount < hold_position_touchcount) { hold_position_countdown--; mouseX = holdX; mouseY = holdY; } else if (touchcount > 0) { int sX = 0, sY = 0, i = 0; for (i = 0; i < touchcount; i++) { sX += input_state_cb(0, RETRO_DEVICE_POINTER, i, RETRO_DEVICE_ID_POINTER_X); sY += input_state_cb(0, RETRO_DEVICE_POINTER, i, RETRO_DEVICE_ID_POINTER_Y); } mouseX = sX / touchcount; mouseY = sY / touchcount; } else if (is_mouse) { mouseX = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); mouseY = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); } else { mouseX = 0x7fff; mouseY = 0x7fff; } if (hold_position_countdown <= 0) hold_position_touchcount = 0; if (touchcount > hold_position_touchcount) { hold_position_countdown = hold_in_start_value; hold_position_touchcount = touchcount; holdX = mouseX; holdY = mouseY; } if (touchcount == held_touchcount && hold_touch_countdown > 0) { hold_touch_countdown--; } else if (touchcount == held_touchcount) { old_touchcount = touchcount; } else { held_touchcount = touchcount; hold_touch_countdown = hold_in_start_value; } bool lbutton = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); bool rbutton = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT); bool mbutton = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE); if (lbutton || old_touchcount == 1) { mouseButtons |= W4_MOUSE_LEFT; } if (rbutton || old_touchcount == 2) { mouseButtons |= W4_MOUSE_RIGHT; } if (mbutton || old_touchcount >= 3) { mouseButtons |= W4_MOUSE_MIDDLE; } w4_runtimeSetMouse(80+80*mouseX/0x7fff, 80+80*mouseY/0x7fff, mouseButtons); w4_runtimeUpdate(); if (!use_audio_callback) { w4_apuWriteSamples(audio_output, AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME); audio_batch_cb(audio_output, AUDIO_BUFFER_FRAMES_PER_VIDEO_FRAME); } } #define do_composite(type, palette) { \ type* out = (type *)dest; \ for (int n = 0; n < 160*160/4; ++n) { \ uint8_t quartet = framebuffer[n]; \ int color1 = (quartet & 0x03) >> 0; \ int color2 = (quartet & 0x0c) >> 2; \ int color3 = (quartet & 0x30) >> 4; \ int color4 = (quartet & 0xc0) >> 6; \ \ *out++ = palette[color1]; \ *out++ = palette[color2]; \ *out++ = palette[color3]; \ *out++ = palette[color4]; \ } \ video_cb(dest, 160, 160, 160*sizeof(type)); \ } void w4_windowComposite (const uint32_t* palette, const uint8_t* framebuffer) { // // Get the write destination // uint32_t* dest; // struct retro_framebuffer info = {0}; // info.width = 160; // info.height = 160; // info.access_flags = RETRO_MEMORY_ACCESS_WRITE; // if (environ_cb(RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER, &info) // && info.format == RETRO_PIXEL_FORMAT_XRGB8888) { // // Write directly to libretro's framebuffer // dest = info.data; // // TODO(2021-10-30): Handle info.pitch? // } else { // // Manage our own intermediate framebuffer // static uint32_t* local = NULL; // if (!local) { // local = malloc(160*160*4); // } // dest = local; // } static uint32_t dest[160*160]; // Convert indexed 2bpp framebuffer to XRGB output if (pixel_format == RETRO_PIXEL_FORMAT_RGB565) { uint16_t transform_palette[4]; int i; for (i = 0; i < 4; i++) { uint32_t c = palette[i]; #if defined(PS2) transform_palette[i] = ((((c) & 0xf8) << 7) | ((c>>6) & 0x3e0) | (((c >> 19) & 0x1f))); #else transform_palette[i] = ((c >> 3) & 0x001f) | ((c >> 5) & 0x07e0) | ((c >> 8) & 0xf800); #endif } do_composite(uint16_t, transform_palette); } else { do_composite(uint32_t, palette); } }
c25a83fb978b7d699460cc8801d6c74f30a8d56b
6ffd23679939f59f0a09c9507a126ba056b239d7
/src/jit/impl/halide/halide_header.h
48cf07c5e7a028b777d3c0e3d7db2d6eec1fff6c
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
MegEngine/MegEngine
74c1c9b6022c858962caf7f27e6f65220739999f
66b79160d35b2710c00befede0c3fd729109e474
refs/heads/master
2023-08-23T20:01:32.476848
2023-08-01T07:12:01
2023-08-11T06:04:12
248,175,118
5,697
585
Apache-2.0
2023-07-19T05:11:07
2020-03-18T08:21:58
C++
UTF-8
C
false
false
360
h
halide_header.h
#pragma once #include "megbrain_build_config.h" #if MGB_JIT_HALIDE #if !MGB_JIT #error "MGB_JIT must be set if MGB_JIT_HALIDE is enabled" #endif #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #include <Halide.h> #pragma GCC diagnostic pop #endif // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
f54068b3a232d9003f917f0ce95e24c74799a32b
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/cbmc-with-incr/equality_through_union2/main.c
70a6acd8cdba1d34795e313de8cc5274e50ae86a
[ "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
335
c
main.c
#include <assert.h> #include <stdint.h> union u { uint32_t x; int32_t y; int8_t z[4]; }; union u pass_through_union (int32_t q) { union u un; un.z[0] = 0; un.y = q; return un; } int main (void) { int32_t q; __CPROVER_assume(q > 0); union u un = pass_through_union(q); assert(q == un.x); return 1; }
08a161204eb5d4294c9e3eeacff054a8293638ee
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/sysutils/xfce4-power-manager/patches/patch-src_xfpm-pm-helper.c
bfbdbceb2c4b3299057fafd39f01e78c6e8af9a9
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
1,047
c
patch-src_xfpm-pm-helper.c
$NetBSD: patch-src_xfpm-pm-helper.c,v 1.2 2021/11/30 14:52:32 gutteridge Exp $ Add NetBSD support. --- src/xfpm-pm-helper.c.orig 2021-11-26 18:17:09.701758792 +0000 +++ src/xfpm-pm-helper.c @@ -77,6 +77,10 @@ #define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/zzz" #define UP_BACKEND_HIBERNATE_COMMAND "/usr/sbin/ZZZ" #endif +#ifdef BACKEND_TYPE_NETBSD +#define UP_BACKEND_SUSPEND_COMMAND "sysctl -w hw.acpi.sleep.state=3" +#define UP_BACKEND_HIBERNATE_COMMAND "sysctl -w hw.acpi.sleep.state=4" +#endif static gboolean @@ -178,22 +182,26 @@ main (int argc, char **argv) /* run the command */ if(suspend) { +#if defined(UP_BACKEND_SUSPEND_COMMAND) if (run (UP_BACKEND_SUSPEND_COMMAND)) { return EXIT_CODE_SUCCESS; } else +#endif { return EXIT_CODE_FAILED; } } else if (hibernate) { +#if defined(UP_BACKEND_HIBERNATE_COMMAND) if(run (UP_BACKEND_HIBERNATE_COMMAND)) { return EXIT_CODE_SUCCESS; } else +#endif { return EXIT_CODE_FAILED; }
0813a16896c5a274b75cc72e0cc8b57f4c82d0fe
88aca3340574f733b9ecd6f76708ecd2d57cb07e
/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.1/ext/fsevent_watch/cli.c
6d36dd13dd57e5d88284f2567d52c3508d430617
[ "MIT", "Apache-2.0" ]
permissive
collabnix/dockerlabs
65c63a8424d34120bddc0fc8d6fd54a688953491
0f2a6b906a8ca0ebc28561236d4d6516f93b184c
refs/heads/master
2023-09-05T07:30:30.601797
2023-09-05T07:25:53
2023-09-05T07:25:53
153,069,455
5,239
1,854
Apache-2.0
2023-09-03T05:51:41
2018-10-15T07:19:18
PHP
UTF-8
C
false
false
5,980
c
cli.c
#include <getopt.h> #include "cli.h" const char* cli_info_purpose = "A flexible command-line interface for the FSEvents API"; const char* cli_info_usage = "Usage: fsevent_watch [OPTIONS]... [PATHS]..."; const char* cli_info_help[] = { " -h, --help you're looking at it", " -V, --version print version number and exit", " -p, --show-plist display the embedded Info.plist values", " -s, --since-when=EventID fire historical events since ID", " -l, --latency=seconds latency period (default='0.5')", " -n, --no-defer enable no-defer latency modifier", " -r, --watch-root watch for when the root path has changed", // " -i, --ignore-self ignore current process", " -F, --file-events provide file level event data", " -f, --format=name output format (classic, niw, \n" " tnetstring, otnetstring)", 0 }; static void default_args (struct cli_info* args_info) { args_info->since_when_arg = kFSEventStreamEventIdSinceNow; args_info->latency_arg = 0.5; args_info->no_defer_flag = false; args_info->watch_root_flag = false; args_info->ignore_self_flag = false; args_info->file_events_flag = false; args_info->mark_self_flag = false; args_info->format_arg = kFSEventWatchOutputFormatOTNetstring; } static void cli_parser_release (struct cli_info* args_info) { unsigned int i; for (i=0; i < args_info->inputs_num; ++i) { free(args_info->inputs[i]); } if (args_info->inputs_num) { free(args_info->inputs); } args_info->inputs_num = 0; } void cli_parser_init (struct cli_info* args_info) { default_args(args_info); args_info->inputs = 0; args_info->inputs_num = 0; } void cli_parser_free (struct cli_info* args_info) { cli_parser_release(args_info); } static void cli_print_info_dict (const void *key, const void *value, void *context) { CFStringRef entry = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@:\n %@"), key, value); if (entry) { CFShow(entry); CFRelease(entry); } } void cli_show_plist (void) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFRetain(mainBundle); CFDictionaryRef mainBundleDict = CFBundleGetInfoDictionary(mainBundle); if (mainBundleDict) { CFRetain(mainBundleDict); printf("Embedded Info.plist metadata:\n\n"); CFDictionaryApplyFunction(mainBundleDict, cli_print_info_dict, NULL); CFRelease(mainBundleDict); } CFRelease(mainBundle); printf("\n"); } void cli_print_version (void) { printf("%s %s\n\n", CLI_NAME, CLI_VERSION); #ifdef COMPILED_AT printf("Compiled at: %s\n", COMPILED_AT); #endif #ifdef COMPILER printf("Compiled with: %s\n", COMPILER); #endif #ifdef TARGET_CPU printf("Compiled for: %s\n", TARGET_CPU); #endif printf("\n"); } void cli_print_help (void) { cli_print_version(); printf("\n%s\n", cli_info_purpose); printf("\n%s\n", cli_info_usage); printf("\n"); int i = 0; while (cli_info_help[i]) { printf("%s\n", cli_info_help[i++]); } } int cli_parser (int argc, const char** argv, struct cli_info* args_info) { static struct option longopts[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "show-plist", no_argument, NULL, 'p' }, { "since-when", required_argument, NULL, 's' }, { "latency", required_argument, NULL, 'l' }, { "no-defer", no_argument, NULL, 'n' }, { "watch-root", no_argument, NULL, 'r' }, { "ignore-self", no_argument, NULL, 'i' }, { "file-events", no_argument, NULL, 'F' }, { "mark-self", no_argument, NULL, 'm' }, { "format", required_argument, NULL, 'f' }, { 0, 0, 0, 0 } }; const char* shortopts = "hVps:l:nriFf:"; int c = -1; while ((c = getopt_long(argc, (char * const*)argv, shortopts, longopts, NULL)) != -1) { switch(c) { case 's': // since-when args_info->since_when_arg = strtoull(optarg, NULL, 0); break; case 'l': // latency args_info->latency_arg = strtod(optarg, NULL); break; case 'n': // no-defer args_info->no_defer_flag = true; break; case 'r': // watch-root args_info->watch_root_flag = true; break; case 'i': // ignore-self args_info->ignore_self_flag = true; break; case 'F': // file-events args_info->file_events_flag = true; break; case 'm': // mark-self args_info->mark_self_flag = true; break; case 'f': // format if (strcmp(optarg, "classic") == 0) { args_info->format_arg = kFSEventWatchOutputFormatClassic; } else if (strcmp(optarg, "niw") == 0) { args_info->format_arg = kFSEventWatchOutputFormatNIW; } else if (strcmp(optarg, "tnetstring") == 0) { args_info->format_arg = kFSEventWatchOutputFormatTNetstring; } else if (strcmp(optarg, "otnetstring") == 0) { args_info->format_arg = kFSEventWatchOutputFormatOTNetstring; } else { fprintf(stderr, "Unknown output format: %s\n", optarg); exit(EXIT_FAILURE); } break; case 'V': // version cli_print_version(); exit(EXIT_SUCCESS); case 'p': // show-plist cli_show_plist(); exit(EXIT_SUCCESS); case 'h': // help case '?': // invalid option case ':': // missing argument cli_print_help(); exit((c == 'h') ? EXIT_SUCCESS : EXIT_FAILURE); } } if (optind < argc) { int i = 0; args_info->inputs_num = (unsigned int)(argc - optind); args_info->inputs = (char**)(malloc ((args_info->inputs_num)*sizeof(char*))); while (optind < argc) if (argv[optind++] != argv[0]) { args_info->inputs[i++] = strdup(argv[optind-1]); } } return EXIT_SUCCESS; }
e137fc01cdef9f95f2c3ffcba4f6b17c683cfc73
6d54a7b26d0eb82152a549a6a9dfde656687752c
/src/app/util/endpoint-config-api.h
2028c9f06d7f07ae39cf91c15496e6092f1b3de1
[ "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
2,517
h
endpoint-config-api.h
/** * Copyright (c) 2023 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. */ #pragma once /** * Declarations of function that can be used to query the endpoint configuration * for the device. */ #include <app/util/af-types.h> /** * Returns the total number of possible endpoints (dynamic and pre-compiled). * Not all those endpoints might be enabled, and the dynamic ones might not even * have an EmberAfEndpointType defined. * * Typically only used for endpoint index iteration. */ uint16_t emberAfEndpointCount(void); /** * @brief Enable/disable endpoints */ bool emberAfEndpointEnableDisable(chip::EndpointId endpoint, bool enable); /** * Returns whether the endpoint at the specified index (which must be less than * emberAfEndpointCount() is enabled. If an endpoint is disabled, it is not * guaranteed to have an EmberAfEndpointType. */ bool emberAfEndpointIndexIsEnabled(uint16_t index); /** * Returns the endpoint id of the endpoint at the given index. Will return * kInvalidEndpointId for endpoints that are not actually configured. */ chip::EndpointId emberAfEndpointFromIndex(uint16_t index); /** * Returns the endpoint descriptor for the given endpoint id if there is an * enabled endpoint with that endpoint id. Otherwise returns null. */ const EmberAfEndpointType * emberAfFindEndpointType(chip::EndpointId endpointId); /** * Returns the cluster descriptor for the given cluster on the given endpoint. * * If the given endpoint does not exist or is disabled, returns null. * * If the given endpoint does not have the given cluster, returns null. */ const EmberAfCluster * emberAfFindServerCluster(chip::EndpointId endpoint, chip::ClusterId clusterId); /** * Returns true if the given endpoint exists, is enabled, has the given cluster, * and that cluster has the given attribute. */ bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId);
0e67002bf16fe9075eed579cca6516dce0e8939f
5a5328c0ad39230779aa52c9ae57ec193b88941e
/tesseract4android/src/main/cpp/leptonica/src/prog/recogtest1.c
6d97be8690aca0af54fb63f5093221d80e14d390
[ "BSD-2-Clause", "CC-BY-2.5", "Apache-2.0" ]
permissive
adaptech-cz/Tesseract4Android
66978579ccc80587b8a0ae3eebe79f152fa382cd
8ae584f54502d5457c8b9d62401eaa99551352c3
refs/heads/master
2023-07-21T16:49:39.617935
2023-07-18T12:13:29
2023-07-18T12:13:29
168,021,668
517
101
Apache-2.0
2021-03-29T11:52:21
2019-01-28T19:21:34
C
UTF-8
C
false
false
6,030
c
recogtest1.c
/*====================================================================* - Copyright (C) 2001 Leptonica. 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 ANY - 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. *====================================================================*/ /* * recogtest1.c * * Tests the recog utility using the bootstrap number set, * for both training and identification * * An example of greedy splitting of touching characters is given. */ #ifdef HAVE_CONFIG_H #include <config_auto.h> #endif /* HAVE_CONFIG_H */ #include "string.h" #include "allheaders.h" static const l_int32 scaledw = 0; static const l_int32 scaledh = 40; static const l_float32 MinScore[] = {0.6f, 0.7f, 0.9f}; static const l_int32 MinTarget[] = {4, 5, 4}; static const l_int32 MinSize[] = {3, 2, 3}; l_int32 main(int argc, char **argv) { l_int32 i, linew, same; BOXA *boxat; PIX *pixd, *pix1, *pix2, *pixdb; PIXA *pixa1, *pixa2, *pixa3; L_RECOG *recog1, *recog2; if (argc != 1) { lept_stderr(" Syntax: recogtest1\n"); return 1; } setLeptDebugOK(1); lept_mkdir("lept/digits"); recog1 = NULL; recog2 = NULL; #if 0 linew = 5; /* for lines */ #else linew = 0; /* scanned image */ #endif #if 1 pixa1 = pixaRead("recog/digits/bootnum1.pa"); recog1 = recogCreateFromPixa(pixa1, scaledw, scaledh, linew, 120, 1); pix1 = pixaDisplayTiledWithText(pixa1, 1400, 1.0, 10, 2, 6, 0xff000000); pixWrite("/tmp/lept/digits/bootnum1.png", pix1, IFF_PNG); pixDisplay(pix1, 800, 800); pixDestroy(&pix1); pixaDestroy(&pixa1); #endif #if 1 lept_stderr("Print Stats 1\n"); recogShowContent(stderr, recog1, 1, 1); #endif #if 1 lept_stderr("AverageSamples\n"); recogAverageSamples(recog1, 1); recogShowAverageTemplates(recog1); pix1 = pixaGetPix(recog1->pixadb_ave, 0, L_CLONE); pixWrite("/tmp/lept/digits/unscaled_ave.png", pix1, IFF_PNG); pixDestroy(&pix1); pix1 = pixaGetPix(recog1->pixadb_ave, 1, L_CLONE); pixWrite("/tmp/lept/digits/scaled_ave.png", pix1, IFF_PNG); pixDestroy(&pix1); #endif #if 1 recogDebugAverages(recog1, 0); recogShowMatchesInRange(recog1, recog1->pixa_tr, 0.65, 1.0, 0); pixWrite("/tmp/lept/digits/match_ave1.png", recog1->pixdb_range, IFF_PNG); recogShowMatchesInRange(recog1, recog1->pixa_tr, 0.0, 1.0, 0); pixWrite("/tmp/lept/digits/match_ave2.png", recog1->pixdb_range, IFF_PNG); #endif #if 1 lept_stderr("Print stats 2\n"); recogShowContent(stderr, recog1, 2, 1); recogWrite("/tmp/lept/digits/rec1.rec", recog1); recog2 = recogRead("/tmp/lept/digits/rec1.rec"); recogShowContent(stderr, recog2, 3, 1); recogWrite("/tmp/lept/digits/rec2.rec", recog2); filesAreIdentical("/tmp/lept/digits/rec1.rec", "/tmp/lept/digits/rec2.rec", &same); if (!same) lept_stderr("Error in serialization!\n"); recogDestroy(&recog2); #endif #if 1 /* Three sets of parameters: * 0.6, 0.3 : removes a few poor matches * 0.8, 0.2 : remove many based on matching; remove some based on * requiring retention of 20% of templates in each class * 0.9, 0.01 : remove most based on matching; saved 1 in each class */ lept_stderr("Remove outliers\n"); pixa2 = recogExtractPixa(recog1); for (i = 0; i < 3; i++) { pixa3 = pixaRemoveOutliers1(pixa2, MinScore[i], MinTarget[i], MinSize[i], &pix1, &pix2); pixDisplay(pix1, 900, 250 * i); pixDisplay(pix2, 1300, 250 * i); pixDestroy(&pix1); pixDestroy(&pix2); pixaDestroy(&pixa3); } pixaDestroy(&pixa2); #endif #if 1 /* Split touching characters */ lept_stderr("Split touching\n"); pixd = pixRead("recog/digits/page.590.png"); /* 590 or 306 */ recogIdentifyMultiple(recog1, pixd, 0, 0, &boxat, &pixa2, &pixdb, 1); pixDisplay(pixdb, 800, 800); boxaWriteStderr(boxat); pix1 = pixaDisplay(pixa2, 0, 0); pixDisplay(pix1, 1200, 800); pixDestroy(&pixdb); pixDestroy(&pix1); pixDestroy(&pixd); pixaDestroy(&pixa2); boxaDestroy(&boxat); #endif #if 1 lept_stderr("Reading new training set and computing averages\n"); lept_stderr("Print stats 3\n"); pixa1 = pixaRead("recog/sets/train03.pa"); recog2 = recogCreateFromPixa(pixa1, 0, 40, 0, 128, 1); recogShowContent(stderr, recog2, 3, 1); recogDebugAverages(recog2, 3); pixWrite("/tmp/lept/digits/averages.png", recog2->pixdb_ave, IFF_PNG); recogShowAverageTemplates(recog2); pixaDestroy(&pixa1); recogDestroy(&recog2); #endif recogDestroy(&recog1); recogDestroy(&recog2); return 0; }
d986687cc204ef7a0e4af7a0d6c2779196184e86
7f6c235b0598353549959c18f69eefd20b766907
/libsrc/target/cpm/fcntl/dir_get_entry_name.c
1e8ca30ea21f95677b009cdaf5a9285385bfb139
[ "ClArtistic" ]
permissive
z88dk/z88dk
46dfd4905f36d99333173cadd0a660839befc9f0
8b07f37cc43c5d9ffe69b563c80763491d8faff7
refs/heads/master
2023-09-04T19:29:49.254958
2023-09-03T20:51:24
2023-09-03T20:51:24
54,035,569
820
263
NOASSERTION
2023-09-05T11:09:04
2016-03-16T13:48:16
Assembly
UTF-8
C
false
false
582
c
dir_get_entry_name.c
/* * CP/M Directory browsing * * Stefano, 5 Jun 2013 * * * $Id: dir_get_entry_name.c,v 1.1 2013-06-06 08:58:32 stefano Exp $ */ #include <cpm.h> char dest[20]; // temp filename buffer int i,j; char * source; patch_chars (int startpos, int endpos) { for (i = startpos; i < endpos; i++) { if (source[i] == ' ') break; dest[j++] = source[i] & 0x7F; } } char *dir_get_entry_name() { source = fc_dirbuf + fc_dirpos * 32; j = 0; i = 1; patch_chars (1, 9); if (source[9] != ' ') dest[j++] = '.'; patch_chars (9, 12); dest[j] = '\0'; return dest; }
b34db587d99a1da97eab2d884ad32ffbc19f09ad
70a3f6e66a374f98f8bd1654e51508b94bf16a8a
/src/DNA/native/src/System.String.c
13952a9e6292be846199be764a6b940fb4e5f18c
[ "MIT" ]
permissive
aspnet/Blazor-Hackathon
e11484af0d5919b293c9ecd501ff818ddbbc2c34
798ec083625654221bb953e2cbc556dc917cc2a6
refs/heads/master
2023-03-16T21:57:54.367985
2020-04-09T19:55:10
2020-04-09T19:55:10
98,215,253
154
34
null
2020-04-09T19:55:12
2017-07-24T17:12:47
C#
UTF-8
C
false
false
10,366
c
System.String.c
// Copyright (c) 2012 DotNetAnywhere // // 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 <string.h> #include "Compat.h" #include "Sys.h" #include "System.String.h" #include "MetaData.h" #include "Types.h" #include "Heap.h" #include "Type.h" #include "System.Array.h" typedef struct tSystemString_ tSystemString; // This structure must tie up with string.cs struct tSystemString_ { // Length in characters (not bytes) U32 length; // The characters U16 chars[0]; }; // length in characters, not bytes static tSystemString* CreateStringHeapObj(U32 len) { tSystemString *pSystemString; U32 totalSize; totalSize = sizeof(tSystemString) + (len << 1); pSystemString = (tSystemString*)Heap_Alloc(types[TYPE_SYSTEM_STRING], totalSize); pSystemString->length = len; return pSystemString; } tAsyncCall* System_String_ctor_CharInt32(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pSystemString; CHAR2 c; U32 i, len; c = (CHAR2)(((U32*)pParams)[0]); len = ((U32*)pParams)[1]; pSystemString = CreateStringHeapObj(len); for (i=0; i<len; i++) { pSystemString->chars[i] = c; } *(HEAP_PTR*)pReturnValue = (HEAP_PTR)pSystemString; return NULL; } tAsyncCall* System_String_ctor_CharAIntInt(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pSystemString; HEAP_PTR charArray; PTR charElements; U32 startIndex, length; charArray = ((HEAP_PTR*)pParams)[0]; startIndex = ((U32*)pParams)[1]; length = ((U32*)pParams)[2]; charElements = SystemArray_GetElements(charArray); pSystemString = CreateStringHeapObj(length); memcpy(pSystemString->chars, charElements + (startIndex << 1), length << 1); *(HEAP_PTR*)pReturnValue = (HEAP_PTR)pSystemString; return NULL; } tAsyncCall* System_String_ctor_StringIntInt(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis, *pStr; U32 startIndex, length; pStr = ((tSystemString**)pParams)[0]; startIndex = ((U32*)pParams)[1]; length = ((U32*)pParams)[2]; pThis = CreateStringHeapObj(length); memcpy(pThis->chars, &pStr->chars[startIndex], length << 1); *(HEAP_PTR*)pReturnValue = (HEAP_PTR)pThis; return NULL; } tAsyncCall* System_String_get_Chars(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis = (tSystemString*)pThis_; U32 index; index = *(U32*)pParams; *(U32*)pReturnValue = pThis->chars[index]; return NULL; } tAsyncCall* System_String_InternalConcat(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *s0, *s1, *ret; s0 = (tSystemString*)(((HEAP_PTR*)pParams)[0]); s1 = (tSystemString*)(((HEAP_PTR*)pParams)[1]); ret = CreateStringHeapObj(s0->length + s1->length); memcpy(ret->chars, s0->chars, s0->length << 1); memcpy(&ret->chars[s0->length], s1->chars, s1->length << 1); *(HEAP_PTR*)pReturnValue = (HEAP_PTR)ret; return NULL; } tAsyncCall* System_String_InternalTrim(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis = (tSystemString*)pThis_; HEAP_PTR pWhiteChars; U32 trimType, i, j, checkCharsLen; U32 ofsStart, ofsEnd; U16 *pCheckChars; U32 isWhiteSpace; tSystemString *pRet; U16 c; pWhiteChars = ((HEAP_PTR*)pParams)[0]; trimType = ((U32*)pParams)[1]; pCheckChars = (U16*)SystemArray_GetElements(pWhiteChars); checkCharsLen = SystemArray_GetLength(pWhiteChars); ofsStart = 0; ofsEnd = pThis->length; if (trimType & 1) { // Trim start for (i=ofsStart; i<ofsEnd; i++) { // Check if each char is in the array isWhiteSpace = 0; c = pThis->chars[i]; for (j=0; j<checkCharsLen; j++) { if (c == pCheckChars[j]) { isWhiteSpace = 1; break; } } if (isWhiteSpace == 0) { ofsStart = i; break; } } } if (trimType & 2) { // Trim end for (i=ofsEnd-1; i>=ofsStart; i--) { // Check if each char is in the array isWhiteSpace = 0; c = pThis->chars[i]; for (j=0; j<checkCharsLen; j++) { if (c == pCheckChars[j]) { isWhiteSpace = 1; break; } } if (isWhiteSpace == 0) { ofsEnd = i + 1; break; } } } pRet = CreateStringHeapObj(ofsEnd - ofsStart); memcpy(pRet->chars, &pThis->chars[ofsStart], (ofsEnd - ofsStart) << 1); *(HEAP_PTR*)pReturnValue = (HEAP_PTR)pRet; return NULL; } tAsyncCall* System_String_Equals(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *a, *b; U32 ret; a = ((tSystemString**)pParams)[0]; b = ((tSystemString**)pParams)[1]; if (a == b) { ret = 1; } else if (a == NULL || b == NULL || a->length != b->length) { ret = 0; } else { ret = (memcmp(a->chars, b->chars, a->length<<1) == 0)?1:0; } *(U32*)pReturnValue = ret; return NULL; } tAsyncCall* System_String_GetHashCode(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis = (tSystemString*)pThis_; U16 *pChar, *pEnd; I32 hash; hash = 0; pChar = pThis->chars; pEnd = pChar + pThis->length - 1; for (; pChar < pEnd; pChar += 2) { hash = (hash << 5) - hash + pChar[0]; hash = (hash << 5) - hash + pChar[1]; } if (pChar <= pEnd) { hash = (hash << 5) - hash + pChar[0]; } *(I32*)pReturnValue = hash; return NULL; } tAsyncCall* System_String_InternalReplace(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis = (tSystemString*)pThis_; tSystemString *pOld = ((tSystemString**)pParams)[0]; tSystemString *pNew = ((tSystemString**)pParams)[1]; tSystemString *pResult; U32 thisLen, oldLen, newLen; U16 *pThisChar0, *pOldChar0, *pNewChar0, *pResultChar0; U32 i, j, replacements, dstIndex; U32 resultLen; // This function (correctly) assumes that the old string is not empty thisLen = pThis->length; oldLen = pOld->length; newLen = pNew->length; pThisChar0 = pThis->chars; pOldChar0 = pOld->chars; pNewChar0 = pNew->chars; replacements = 0; for (i=0; i<thisLen-oldLen+1; i++) { U32 match = 1; for (j=0; j<oldLen; j++) { if (pThisChar0[i+j] != pOldChar0[j]) { match = 0; break; } } if (match) { i += oldLen - 1; replacements++; } } resultLen = thisLen - (oldLen - newLen) * replacements; pResult = CreateStringHeapObj(resultLen); pResultChar0 = pResult->chars; dstIndex = 0; for (i=0; i<thisLen; i++) { U32 match; if (i<thisLen-oldLen+1) { for (j=0; j<oldLen; j++) { match = 1; if (pThisChar0[i+j] != pOldChar0[j]) { match = 0; break; } } } else { match = 0; } if (match) { memcpy(&pResultChar0[dstIndex], pNewChar0, newLen << 1); dstIndex += newLen; i += oldLen - 1; } else { pResultChar0[dstIndex++] = pThisChar0[i]; } } *(HEAP_PTR*)pReturnValue = (HEAP_PTR)pResult; return NULL; } tAsyncCall* System_String_InternalIndexOf(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis = (tSystemString*)pThis_; U16 value = ((U16*)pParams)[0]; I32 startIndex = ((I32*)pParams)[1]; I32 count = ((I32*)pParams)[2]; U32 forwards = ((U32*)pParams)[3]; I32 lastIndex; I32 inc; I32 i; if (forwards) { lastIndex = startIndex + count; inc = 1; i = startIndex; } else { lastIndex = startIndex - 1; inc = -1; i = startIndex + count - 1; } for (; i != lastIndex; i += inc) { if (pThis->chars[i] == value) { *(I32*)pReturnValue = i; return NULL; } } *(I32*)pReturnValue = -1; return NULL; } tAsyncCall* System_String_InternalIndexOfAny(PTR pThis_, PTR pParams, PTR pReturnValue) { tSystemString *pThis = (tSystemString*)pThis_; HEAP_PTR valueArray = ((HEAP_PTR*)pParams)[0]; I32 startIndex = ((I32*)pParams)[1]; I32 count = ((I32*)pParams)[2]; U32 forwards = ((U32*)pParams)[3]; PTR valueChars = SystemArray_GetElements(valueArray); U32 numValueChars = SystemArray_GetLength(valueArray); I32 lastIndex; I32 inc; I32 i, j; if (forwards) { lastIndex = startIndex + count; inc = 1; i = startIndex; } else { lastIndex = startIndex - 1; inc = -1; i = startIndex + count - 1; } for (; i != lastIndex; i += inc) { U16 thisChar = pThis->chars[i]; for (j=numValueChars - 1; j>=0; j--) { if (thisChar == ((U16*)valueChars)[j]) { *(I32*)pReturnValue = i; return NULL; } } } *(I32*)pReturnValue = -1; return NULL; } HEAP_PTR SystemString_FromUserStrings(tMetaData *pMetaData, IDX_USERSTRINGS index) { unsigned int stringLen; STRING2 string; tSystemString *pSystemString; string = MetaData_GetUserString(pMetaData, index, &stringLen); // Note: stringLen is in bytes pSystemString = (tSystemString*)CreateStringHeapObj(stringLen >> 1); memcpy(pSystemString->chars, string, stringLen); return (HEAP_PTR)pSystemString; } HEAP_PTR SystemString_FromCharPtrASCII(U8 *pStr) { int stringLen, i; tSystemString *pSystemString; stringLen = (int)strlen(pStr); pSystemString = CreateStringHeapObj(stringLen); for (i=0; i<stringLen; i++) { pSystemString->chars[i] = pStr[i]; } return (HEAP_PTR)pSystemString; } HEAP_PTR SystemString_FromCharPtrUTF16(U16 *pStr) { tSystemString *pSystemString; int strLen = 0; while (pStr[strLen] != 0) { strLen++; } pSystemString = CreateStringHeapObj(strLen); memcpy(pSystemString->chars, pStr, strLen << 1); return (HEAP_PTR)pSystemString; } STRING2 SystemString_GetString(HEAP_PTR pThis_, U32 *pLength) { tSystemString *pThis = (tSystemString*)pThis_; if (pLength != NULL) { *pLength = pThis->length; } return pThis->chars; } U32 SystemString_GetNumBytes(HEAP_PTR pThis_) { return (((tSystemString*)pThis_)->length << 1) + sizeof(tSystemString); }
c34ca91a4781c61ddcb2ddd9d2c6dffa8d69b798
eecd5e4c50d8b78a769bcc2675250576bed34066
/src/binding/petsc4py/src/lib-petsc/compat/hypre.h
bfa9b72a647150b29404e83ea51dd8abb4f133c9
[ "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,439
h
hypre.h
#ifndef PETSC4PY_COMPAT_HYPRE_H #define PETSC4PY_COMPAT_HYPRE_H #if !defined(PETSC_HAVE_HYPRE) #define PetscPCHYPREError do { \ PetscFunctionBegin; \ SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"%s() requires HYPRE",PETSC_FUNCTION_NAME); \ PetscFunctionReturn(PETSC_ERR_SUP);} while (0) PetscErrorCode PCHYPREGetType(PETSC_UNUSED PC pc,PETSC_UNUSED const char *name[]){PetscPCHYPREError;} PetscErrorCode PCHYPRESetType(PETSC_UNUSED PC pc,PETSC_UNUSED const char name[]){PetscPCHYPREError;} PetscErrorCode PCHYPRESetDiscreteCurl(PETSC_UNUSED PC pc,PETSC_UNUSED Mat C){PetscPCHYPREError;} PetscErrorCode PCHYPRESetDiscreteGradient(PETSC_UNUSED PC pc,PETSC_UNUSED Mat G){PetscPCHYPREError;} PetscErrorCode PCHYPRESetAlphaPoissonMatrix(PETSC_UNUSED PC pc,PETSC_UNUSED Mat A){PetscPCHYPREError;} PetscErrorCode PCHYPRESetBetaPoissonMatrix(PETSC_UNUSED PC pc,PETSC_UNUSED Mat B){PetscPCHYPREError;} PetscErrorCode PCHYPRESetInterpolations(PETSC_UNUSED PC pc,PETSC_UNUSED PetscInt dim,PETSC_UNUSED Mat RT_Pi_Full,PETSC_UNUSED Mat RT_Pi[],PETSC_UNUSED Mat ND_Pi_Full,PETSC_UNUSED Mat ND_Pi[]){PetscPCHYPREError;} PetscErrorCode PCHYPRESetEdgeConstantVectors(PETSC_UNUSED PC pc,PETSC_UNUSED Vec ozz,PETSC_UNUSED Vec zoz,PETSC_UNUSED Vec zzo){PetscPCHYPREError;} PetscErrorCode PCHYPREAMSSetInteriorNodes(PETSC_UNUSED PC pc,PETSC_UNUSED Vec interior){PetscPCHYPREError;} #undef PetscPCHYPREError #endif #endif/*PETSC4PY_COMPAT_HYPRE_H*/
112ffe546959f7f49e89d02aa0b49050d473a9bb
f451e9d1a21891b029320dba3a26e3ab0fa0f09b
/source/usb-support.h
f11a9270e1a02e7e7c9d489811a5ef8b44b406df
[ "Apache-2.0", "CC-BY-NC-ND-4.0" ]
permissive
compuphase/Black-Magic-Probe-Book
ddb55444373f6ec5d7c8615c491ea4b37e8db759
cc1464071fc8fb7b78d63078abc02074960d2136
refs/heads/master
2023-09-04T12:33:49.879643
2023-08-18T19:59:58
2023-08-18T19:59:58
212,651,046
118
22
Apache-2.0
2023-03-22T15:28:26
2019-10-03T18:32:00
C
UTF-8
C
false
false
5,504
h
usb-support.h
/* * Functions for general purpose USB device access in Microsoft Windows, by * dynamically loading & Linking WinUSB. * * Copyright 2020-2023 CompuPhase * * 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 _USB_SUPPORT_H #define _USB_SUPPORT_H #include <windows.h> #include <stdint.h> #if defined __cplusplus extern "C" { #endif /* * General types (for both WinUSB and libusbK) */ typedef enum { PIPETYPE_CONTROL, PIPETYPE_ISOCHRONOUS, PIPETYPE_BULK, PIPETYPE_INTERRUPT } USB_PIPE_TYPE; typedef struct tagUSB_INTERFACE_DESCRIPTOR { uint8_t bLength; /**< length of the descriptor in bytes */ uint8_t bDescriptorType; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; uint8_t bNumEndpoints; /**< number of endpoints excluding the control endpoint */ uint8_t bInterfaceClass; /**< USB-IF class code for this interface */ uint8_t bInterfaceSubClass; /**< USB-IF subclass code for this interface*/ uint8_t bInterfaceProtocol; /**< USB-IF protocol code for this interface */ uint8_t iInterface; /**< index of the string descriptor for this interface */ } USB_INTERFACE_DESCRIPTOR; typedef struct tagUSB_PIPE_INFORMATION { uint32_t PipeType; /**< one of the values of the USB_PIPE_TYPE enumeration */ uint8_t PipeId; uint16_t MaximumPacketSize; /**< in bytes */ uint8_t Interval; /**< in milliseconds */ } USB_PIPE_INFORMATION; typedef void* USB_INTERFACE_HANDLE; /* * Part 1: WinUSB * minimal subset of WinUSB types & functions */ extern BOOL (__stdcall *_WinUsb_Initialize)(HANDLE DeviceHandle, USB_INTERFACE_HANDLE *InterfaceHandle); extern BOOL (__stdcall *_WinUsb_Free)(USB_INTERFACE_HANDLE InterfaceHandle); extern BOOL (__stdcall *_WinUsb_QueryInterfaceSettings)(USB_INTERFACE_HANDLE InterfaceHandle, uint8_t AlternateInterfaceNumber, USB_INTERFACE_DESCRIPTOR *UsbAltInterfaceDescriptor); extern BOOL (__stdcall *_WinUsb_QueryPipe)(USB_INTERFACE_HANDLE InterfaceHandle, uint8_t AlternateInterfaceNumber, uint8_t PipeIndex, USB_PIPE_INFORMATION *PipeInformation); extern BOOL (__stdcall *_WinUsb_ReadPipe)(USB_INTERFACE_HANDLE InterfaceHandle, uint8_t PipeID, uint8_t *Buffer, uint32_t BufferLength, uint32_t *LengthTransferred, LPOVERLAPPED Overlapped); /* WinUSB loading & unloading functions */ BOOL WinUsb_Load(void); BOOL WinUsb_Unload(void); BOOL WinUsb_IsActive(void); /* * Part 2: libusbK */ #define KLST_STRING_MAX_LEN 256 typedef struct tagKLST_DEVINFO { int Vid; int Pid; int MI; /**< interface number, set to -1 for non-composite devices */ char InstanceID[KLST_STRING_MAX_LEN]; /**< uniquely identifies the USB device */ int DriverID; char DeviceInterfaceGUID[KLST_STRING_MAX_LEN]; char DeviceID[KLST_STRING_MAX_LEN]; char ClassGUID[KLST_STRING_MAX_LEN]; char Mfg[KLST_STRING_MAX_LEN]; /**< Manufacturer name */ char DeviceDesc[KLST_STRING_MAX_LEN]; char Service[KLST_STRING_MAX_LEN]; /**< driver/service name */ char SymbolicLink[KLST_STRING_MAX_LEN]; char DevicePath[KLST_STRING_MAX_LEN]; /**< Windows virtual path, as used in CreateFile() */ int LUsb0FilterIndex; /**< libusb-win32 filter index id */ BOOL Connected; long SyncFlags; /**< Synchronization flags (internal use only) */ int BusNumber; INT DeviceAddress; char SerialNumber[KLST_STRING_MAX_LEN]; } KLST_DEVINFO; typedef void* KUSB_HANDLE; typedef void* KLST_HANDLE; typedef BOOL __stdcall KLST_ENUM_DEVINFO_CB(KLST_HANDLE DeviceList, KLST_DEVINFO *DeviceInfo, PVOID Context); extern BOOL (__stdcall *_UsbK_Init)(USB_INTERFACE_HANDLE* InterfaceHandle, const KLST_DEVINFO *DevInfo); extern BOOL (__stdcall *_UsbK_Free)(USB_INTERFACE_HANDLE InterfaceHandle); extern BOOL (__stdcall *_UsbK_QueryInterfaceSettings)(USB_INTERFACE_HANDLE InterfaceHandle, uint8_t AlternateInterfaceNumber, USB_INTERFACE_DESCRIPTOR *UsbAltInterfaceDescriptor); extern BOOL (__stdcall *_UsbK_QueryPipe)(USB_INTERFACE_HANDLE InterfaceHandle, uint8_t AlternateInterfaceNumber, uint8_t PipeIndex, USB_PIPE_INFORMATION *PipeInformation); extern BOOL (__stdcall *_UsbK_ReadPipe)(USB_INTERFACE_HANDLE InterfaceHandle, uint8_t PipeID, uint8_t *Buffer, uint32_t BufferLength, uint32_t *LengthTransferred, LPOVERLAPPED Overlapped); extern BOOL (__stdcall *_LstK_Init)(KLST_DEVINFO **DeviceList, int Flags); extern BOOL (__stdcall *_LstK_Free)(KLST_DEVINFO *DeviceList); extern BOOL (__stdcall *_LstK_Count)(const KLST_DEVINFO *DeviceList, uint32_t *Count); extern BOOL (__stdcall *_LstK_Enumerate)(const KLST_DEVINFO *DeviceList, KLST_ENUM_DEVINFO_CB *EnumDevListCB, void *Context); /* WinUSB loading, unloading & compatibility functions */ BOOL UsbK_Load(void); BOOL UsbK_Unload(void); BOOL UsbK_IsActive(void); #if defined __cplusplus } #endif #endif /* _USB_SUPPORT_H */
9c4a1f8a9881469f626bb5c8e01105a492da0370
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/emulators/tiemu3/files/patch-src_core_uae_newcpu.c
b05692415144d8a654d0b01e098796e502c84c4d
[ "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
527
c
patch-src_core_uae_newcpu.c
--- src/core/uae/newcpu.c.orig 2008-05-25 13:08:41 UTC +++ src/core/uae/newcpu.c @@ -148,7 +148,7 @@ static void build_cpufunctbl (void) if (table68k[opcode].handler != -1) { f = cpufunctbl[table68k[opcode].handler]; if (f == op_illg_1) - abort(); + uae_abort(); cpufunctbl[opcode] = f; } } @@ -1575,7 +1575,7 @@ void m68k_go (int may_quit) { if (in_m68k_go || !may_quit) { write_log ("Bug! m68k_go is not reentrant.\n"); - abort (); + uae_abort (); } reset_frame_rate_hack ();
3bda8056a8b04cfcab92f907920553f2ada3cd19
1f399edf85d995443d01f66d77eca0723886d0ff
/devicemodel/hw/platform/tpm/tpm_emulator.c
3d9da36d363a8ad7a2e382ff81cb449d6a46c864
[ "BSD-3-Clause" ]
permissive
projectacrn/acrn-hypervisor
f9c5864d54929a5d2fa36b5e78c08f19b46b8f98
390740aa1b1e9d62c51f8e3afa0c29e07e43fa23
refs/heads/master
2023-08-18T05:07:01.310327
2023-08-11T07:49:36
2023-08-16T13:20:27
123,983,554
1,059
686
BSD-3-Clause
2023-09-14T09:51:10
2018-03-05T21:52:25
C
UTF-8
C
false
false
17,541
c
tpm_emulator.c
/* * Copyright (C) 2018-2022 Intel Corporation. * Copyright (C) 2014, 2015 IBM Corporation. * * SPDX-License-Identifier: BSD-3-Clause */ #include <sys/un.h> #include <errno.h> #include <sys/wait.h> #include <signal.h> #include <sys/socket.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <strings.h> #include <string.h> #include <stdbool.h> #include <sys/stat.h> #include <fcntl.h> #include "vmmapi.h" #include "tpm_internal.h" #include "log.h" /* According to definition in TPM2 spec */ #define TPM_ORD_ContinueSelfTest 0x53 #define TPM_TAG_RSP_COMMAND 0xc4 #define TPM_FAIL 9 #define PTM_INIT_FLAG_DELETE_VOLATILE (1 << 0) /* To align with definition in SWTPM */ typedef uint32_t ptm_res; struct ptm_est { union { struct { ptm_res tpm_result; unsigned char bit; /* TPM established bit */ } resp; /* response */ } u; }; struct ptm_reset_est { union { struct { uint8_t loc; /* locality to use */ } req; /* request */ struct { ptm_res tpm_result; } resp; /* response */ } u; }; struct ptm_init { union { struct { uint32_t init_flags; /* see definitions below */ } req; /* request */ struct { ptm_res tpm_result; } resp; /* response */ } u; }; struct ptm_loc { union { struct { uint8_t loc; /* locality to set */ } req; /* request */ struct { ptm_res tpm_result; } resp; /* response */ } u; }; struct ptm_getconfig { union { struct { ptm_res tpm_result; uint32_t flags; } resp; /* response */ } u; }; struct ptm_setbuffersize { union { struct { uint32_t buffersize; /* 0 to query for current buffer size */ } req; /* request */ struct { ptm_res tpm_result; uint32_t buffersize; /* buffer size in use */ uint32_t minsize; /* min. supported buffer size */ uint32_t maxsize; /* max. supported buffer size */ } resp; /* response */ } u; }; typedef struct ptm_est ptm_est; typedef struct ptm_reset_est ptm_reset_est; typedef struct ptm_loc ptm_loc; typedef struct ptm_init ptm_init; typedef struct ptm_getconfig ptm_getconfig; typedef struct ptm_setbuffersize ptm_setbuffersize; /* For TPM CRB definition */ #pragma pack(push, 1) typedef struct { uint16_t tag; uint32_t length; uint32_t ordinal; } tpm_input_header; typedef struct { uint16_t tag; uint32_t length; uint32_t return_code; } tpm_output_header; #pragma pack(pop) /* This is the main data structure for tpm emulator, * it will work with one SWTPM instance to * provide TPM functionlity to User VM. * * ctrl_chan_fd: fd to communicate with SWTPM ctrl channel * cmd_chan_fd: fd to communicate with SWTPM cmd channel * cur_locty_number: to store the last set locality * established_flag & established_flag_cached: used in * swtpm_get_tpm_established_flag, to store tpm establish flag. */ typedef struct swtpm_context { int ctrl_chan_fd; int cmd_chan_fd; uint8_t cur_locty_number; /* last set locality */ unsigned int established_flag:1; unsigned int established_flag_cached:1; } swtpm_context; /* Align with definition in SWTPM */ enum { CMD_GET_CAPABILITY = 1, /* 0x01 */ CMD_INIT, /* 0x02 */ CMD_SHUTDOWN, /* 0x03 */ CMD_GET_TPMESTABLISHED, /* 0x04 */ CMD_SET_LOCALITY, /* 0x05 */ CMD_HASH_START, /* 0x06 */ CMD_HASH_DATA, /* 0x07 */ CMD_HASH_END, /* 0x08 */ CMD_CANCEL_TPM_CMD, /* 0x09 */ CMD_STORE_VOLATILE, /* 0x0a */ CMD_RESET_TPMESTABLISHED, /* 0x0b */ CMD_GET_STATEBLOB, /* 0x0c */ CMD_SET_STATEBLOB, /* 0x0d */ CMD_STOP, /* 0x0e */ CMD_GET_CONFIG, /* 0x0f */ CMD_SET_DATAFD, /* 0x10 */ CMD_SET_BUFFERSIZE, /* 0x11 */ CMD_GET_INFO, /* 0x12 */ }; static swtpm_context tpm_context; static inline uint16_t tpm_cmd_get_tag(const void *b) { return __builtin_bswap16(*(uint16_t*)(b)); } static inline uint32_t tpm_cmd_get_size(const void *b) { return __builtin_bswap32(*(uint32_t*)(b + 2)); } static inline uint32_t tpm_cmd_get_ordinal(const void *b) { return __builtin_bswap32(*(uint32_t*)(b + 6)); } static inline uint32_t tpm_cmd_get_errcode(const void *b) { return __builtin_bswap32(*(uint32_t*)(b + 6)); } static inline void tpm_cmd_set_tag(void *b, uint16_t tag) { *(uint16_t*)(b) = __builtin_bswap16(tag); } static inline void tpm_cmd_set_size(void *b, uint32_t size) { *(uint32_t*)(b + 2) = __builtin_bswap32(size); } static inline void tpm_cmd_set_error(void *b, uint32_t error) { *(uint32_t*)(b + 6) = __builtin_bswap32(error); } static bool tpm_is_selftest(const uint8_t *in, uint32_t in_len) { if (in_len >= sizeof(tpm_input_header)) return tpm_cmd_get_ordinal(in) == TPM_ORD_ContinueSelfTest; return false; } static int ctrl_chan_conn(const char *servername) { int clifd; struct sockaddr_un servaddr; int ret; if (!servername) { pr_err("%s error, invalid input\n", __func__); return -1; } if (strnlen(servername, sizeof(servaddr.sun_path)) == (sizeof(servaddr.sun_path))) { pr_err("%s error, length of servername is too long\n", __func__); return -1; } clifd = socket(AF_UNIX, SOCK_STREAM, 0); if (clifd < 0) { pr_err("socket failed.\n"); return -1; } bzero(&servaddr, sizeof(servaddr)); servaddr.sun_family = AF_UNIX; strncpy(servaddr.sun_path, servername, sizeof(servaddr.sun_path)); ret = connect(clifd, (struct sockaddr *)&servaddr, sizeof(servaddr)); if (ret < 0) { pr_err("connect failed.\n"); close(clifd); return -1; } return clifd; } static int ctrl_chan_write(int ctrl_chan_fd, const uint8_t *buf, int len, int *pdatafd, int fd_num) { int ret; struct msghdr msg; struct iovec iov[1]; union { struct cmsghdr cm; char control[CMSG_SPACE(sizeof(int))]; } control_un; struct cmsghdr *pcmsg; if (!buf || (!pdatafd && fd_num)) { pr_err("%s error, invalid input\n", __func__); return -1; } msg.msg_name = NULL; msg.msg_namelen = 0; iov[0].iov_base = (void*)buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1; if (fd_num == 0) { if (pdatafd) return -1; msg.msg_control = NULL; msg.msg_controllen = 0; } else if (fd_num == 1) { msg.msg_control = control_un.control; msg.msg_controllen = sizeof(control_un.control); pcmsg = CMSG_FIRSTHDR(&msg); pcmsg->cmsg_len = CMSG_LEN(sizeof(int)); pcmsg->cmsg_level = SOL_SOCKET; pcmsg->cmsg_type = SCM_RIGHTS; *((int *)CMSG_DATA(pcmsg)) = *pdatafd; } else { pr_err("fd_num failed.\n"); return -1; } do { ret = sendmsg(ctrl_chan_fd, &msg, 0); } while (ret < 0 && errno == EINTR); if (ret < 0) { pr_err("Failed to send msg, reason: %s\n", strerror(errno)); } return ret; } static int ctrl_chan_read(int ctrl_chan_fd, uint8_t *buf, int len) { struct msghdr msg; struct iovec iov[1]; int recvd = 0; int n; if (!buf) { pr_err("%s error, invalid input\n", __func__); return -1; } msg.msg_name = NULL; msg.msg_namelen = 0; iov[0].iov_base = buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1; /* No need to recv fd */ msg.msg_control = NULL; msg.msg_controllen = 0; while (recvd < len) { if (0 == recvd) n = recvmsg(ctrl_chan_fd, &msg, 0); else n = read(ctrl_chan_fd, msg.msg_iov[0].iov_base + recvd, len - recvd); if (n <= 0) return n; recvd += n; } return recvd; } static int cmd_chan_write(int cmd_chan_fd, const uint8_t *buf, int len) { ssize_t nwritten = 0; int buffer_length = len; if (!buf) { pr_err("%s error, invalid input\n", __func__); return -1; } while (buffer_length > 0) { nwritten = write(cmd_chan_fd, buf, buffer_length); if (nwritten >= 0) { buffer_length -= nwritten; buf += nwritten; } else { pr_err("cmd_chan_write: Error, write() %d %s\n", errno, strerror(errno)); return -1; } } return (len - buffer_length); } static int cmd_chan_read(int cmd_chan_fd, uint8_t *buf, int len) { ssize_t nread = 0; size_t nleft = len; if (!buf) { pr_err("%s error, invalid input\n", __func__); return -1; } while (nleft > 0) { nread = read(cmd_chan_fd, buf, nleft); if (nread > 0) { nleft -= nread; buf += nread; } else if (nread < 0) {/* error */ pr_err("cmd_chan_read: Error, read() error %d %s\n", errno, strerror(errno)); return -1; } else if (nread == 0) {/* EOF */ pr_err("cmd_chan_read: Error, read EOF, read %lu bytes\n", (unsigned long)(len - nleft)); return -1; } } return (len - nleft); } /* * Send command to swtpm ctrl channel. * Note: Both msg_len_in & msg_len_out are valid and needed. * It has 2 cases as below: * 1. msg_len_in is equal to msg_len_out, all are valid and bigger than 0. * 2. msg_len_in is 0, while msg_len_out is bigger than 0. * msg_len_out should always >0 because it need to return "ptm_res" * as the return value(which to indicate pass or fail) at least. */ static int swtpm_ctrlcmd(int ctrl_chan_fd, unsigned long cmd, void *msg, size_t msg_len_in, size_t msg_len_out, int *pdatafd, int fd_num) { uint32_t cmd_no = __builtin_bswap32(cmd); ssize_t n = sizeof(uint32_t) + msg_len_in; uint8_t *buf = NULL; int ret = -1; int send_num; int recv_num; if (!msg || (!pdatafd && fd_num)) { pr_err("%s error, invalid input\n", __func__); return -1; } buf = calloc(n, sizeof(char)); if (!buf) return -1; memcpy(buf, &cmd_no, sizeof(cmd_no)); memcpy(buf + sizeof(cmd_no), msg, msg_len_in); send_num = ctrl_chan_write(ctrl_chan_fd, buf, n, pdatafd, fd_num); if ((send_num <= 0) || (send_num != n) ) { pr_err("%s failed to write %d != %ld\n", __func__, send_num, n); goto end; } if (msg_len_out != 0) { recv_num = ctrl_chan_read(ctrl_chan_fd, msg, msg_len_out); if ((recv_num <= 0) || (recv_num != msg_len_out)) { pr_err("%s failed to read %d != %ld\n", __func__, recv_num, msg_len_out); goto end; } } ret = 0; end: free(buf); return ret; } /* * Send command to swtpm cmd channel. * Note: out_len should be needed. * Currently swtpm_cmdcmd will only be called by swtpm_handle_request * to deliver the real tpm2 commands. And in crb_reg_write, we can * find that out_len is set as (4096-0x80) which is the maximum size * according to TPM2 spec. So inside function swtpm_cmdcmd, * it need to Check" tpm_cmd_get_size(out)>out_len". */ static int swtpm_cmdcmd(int cmd_chan_fd, const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t out_len, bool *selftest_done) { ssize_t ret; bool is_selftest = false; if (!in || !out) { pr_err("%s error, invalid input\n", __func__); return -1; } if (selftest_done) { *selftest_done = false; is_selftest = tpm_is_selftest(in, in_len); } ret = cmd_chan_write(cmd_chan_fd, (uint8_t *)in, in_len); if ((ret == -1) || (ret != in_len)) { pr_err("%s failed to write %ld != %d\n", __func__, ret, in_len); return -1; } ret = cmd_chan_read(cmd_chan_fd, (uint8_t *)out, sizeof(tpm_output_header)); if (ret == -1) { pr_err("%s failed to read size\n", __func__); return -1; } if (tpm_cmd_get_size(out) > out_len) { pr_err("%s error, get out size is larger than out_len\n", __func__); return -1; } ret = cmd_chan_read(cmd_chan_fd, (uint8_t *)out + sizeof(tpm_output_header), tpm_cmd_get_size(out) - sizeof(tpm_output_header)); if (ret == -1) { pr_err("%s failed to read data\n", __func__); return -1; } if (is_selftest) { *selftest_done = tpm_cmd_get_errcode(out) == 0; } return 0; } /* * Create ctrl channel. */ static int swtpm_ctrlchan_create(const char *arg_path) { int connfd; if (!arg_path) { pr_err("%s error, invalid input\n", __func__); return -1; } connfd = ctrl_chan_conn(arg_path); if(connfd < 0) { pr_err("Error[%d] when connecting...", errno); return -1; } tpm_context.ctrl_chan_fd = connfd; return connfd; } /* * Create cmd channel. */ static int swtpm_cmdchan_create(void) { ptm_res res = 0; int sv[2] = {-1, -1}; if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0) { pr_err("socketpair failed!\n"); return -1; } if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SET_DATAFD, &res, 0, sizeof(res), &sv[1], 1) < 0 || res != 0) { pr_err("swtpm: Failed to send CMD_SET_DATAFD: %s", strerror(errno)); goto err_exit; } tpm_context.cmd_chan_fd = sv[0]; close(sv[1]); return 0; err_exit: close(sv[0]); close(sv[1]); return -1; } static int swtpm_start(ptm_init *init) { ptm_res res; if (!init) { pr_err("%s error, invalid input\n", __func__); return -1; } if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_INIT, init, sizeof(*init), sizeof(*init), NULL, 0) < 0) { pr_err("swtpm: could not send INIT: %s", strerror(errno)); goto err_exit; } res = __builtin_bswap32(init->u.resp.tpm_result); if (res) { pr_err("swtpm: TPM result for CMD_INIT: 0x%x", res); goto err_exit; } return 0; err_exit: return -1; } static int swtpm_stop(void) { ptm_res res = 0; if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_STOP, &res, 0, sizeof(res), NULL, 0) < 0) { pr_err("swtpm: Could not stop TPM: %s", strerror(errno)); return -1; } res = __builtin_bswap32(res); if (res) { pr_err("swtpm: TPM result for CMD_STOP: 0x%x", res); return -1; } return 0; } /* wanted_size: input, the buffer size which we want to setup. * actual_size: output, the actual buffer size returned after setup. * * Note: To meet swtpm logic, swtpm_stop() must be called before * swtpm_set_buffer_size() */ static int swtpm_set_buffer_size(size_t wanted_size, size_t *actual_size) { ptm_setbuffersize psbs; if (wanted_size == 0) { pr_err("%s error, wanted_size is 0\n", __func__); return -1; } psbs.u.req.buffersize = __builtin_bswap32(wanted_size); if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SET_BUFFERSIZE, &psbs, sizeof(psbs.u.req), sizeof(psbs.u.resp), NULL, 0) < 0) { pr_err("swtpm: Could not set buffer size: %s", strerror(errno)); return -1; } psbs.u.resp.tpm_result = __builtin_bswap32(psbs.u.resp.tpm_result); if (psbs.u.resp.tpm_result != 0) { pr_err("swtpm: TPM result for set buffer size : 0x%x", psbs.u.resp.tpm_result); return -1; } if (actual_size) { *actual_size = __builtin_bswap32(psbs.u.resp.buffersize); } return 0; } static int swtpm_startup_tpm(size_t buffersize, bool is_resume) { ptm_init init = { .u.req.init_flags = 0, }; if (swtpm_stop() < 0) { pr_err("swtpm_stop() failed!\n"); return -1; } if (buffersize != 0 && swtpm_set_buffer_size(buffersize, NULL) < 0) { return -1; } if (is_resume) { init.u.req.init_flags |= __builtin_bswap32(PTM_INIT_FLAG_DELETE_VOLATILE); } return swtpm_start(&init); } static void swtpm_shutdown(void) { ptm_res res = 0; if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SHUTDOWN, &res, 0, sizeof(res), NULL, 0) < 0) { pr_err("swtpm: Could not cleanly shutdown the TPM: %s", strerror(errno)); } else if (res != 0) { pr_err("swtpm: TPM result for sutdown: 0x%x", __builtin_bswap32(res)); } } static int swtpm_set_locality(uint8_t locty_number) { ptm_loc loc; if (tpm_context.cur_locty_number == locty_number) return 0; loc.u.req.loc = locty_number; if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SET_LOCALITY, &loc, sizeof(loc), sizeof(loc), NULL, 0) < 0) { pr_err("swtpm: could not set locality : %s", strerror(errno)); return -1; } loc.u.resp.tpm_result = __builtin_bswap32(loc.u.resp.tpm_result); if (loc.u.resp.tpm_result != 0) { pr_err("swtpm: TPM result for set locality : 0x%x", loc.u.resp.tpm_result); return -1; } tpm_context.cur_locty_number = locty_number; return 0; } static void swtpm_write_fatal_error_response(uint8_t *out, uint32_t out_len) { if (!out) { pr_err("%s error, invalid input.\n", __func__); return; } if (out_len >= sizeof(tpm_output_header)) { tpm_cmd_set_tag(out, TPM_TAG_RSP_COMMAND); tpm_cmd_set_size(out, sizeof(tpm_output_header)); tpm_cmd_set_error(out, TPM_FAIL); } } static void swtpm_cleanup(void) { swtpm_shutdown(); close(tpm_context.cmd_chan_fd); close(tpm_context.ctrl_chan_fd); } int swtpm_startup(size_t buffersize) { return swtpm_startup_tpm(buffersize, false); } int swtpm_handle_request(TPMCommBuffer *cmd) { if (!cmd) { pr_err("%s error, invalid input.\n", __func__); return -1; } if (swtpm_set_locality(cmd->locty) < 0 || swtpm_cmdcmd(tpm_context.cmd_chan_fd, cmd->in, cmd->in_len, cmd->out, cmd->out_len, &cmd->selftest_done) < 0) { swtpm_write_fatal_error_response(cmd->out, cmd->out_len); return -1; } return 0; } bool swtpm_get_tpm_established_flag(void) { ptm_est est; if (tpm_context.established_flag_cached) { return tpm_context.established_flag; } if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_GET_TPMESTABLISHED, &est, 0, sizeof(est), NULL, 0) < 0) { pr_err("swtpm: Could not get the TPM established flag: %s", strerror(errno)); return false; } tpm_context.established_flag_cached = 1; tpm_context.established_flag = (est.u.resp.bit != 0); return tpm_context.established_flag; } void swtpm_cancel_cmd(void) { ptm_res res = 0; if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_CANCEL_TPM_CMD, &res, 0, sizeof(res), NULL, 0) < 0) { pr_err("swtpm: Could not cancel command: %s", strerror(errno)); } else if (res != 0) { pr_err("swtpm: Failed to cancel TPM: 0x%x", __builtin_bswap32(res)); } } int init_tpm_emulator(const char *sock_path) { if (swtpm_ctrlchan_create(sock_path) < 0) { pr_err("error, failed to create ctrl channel.\n"); return -1; } if (swtpm_cmdchan_create() < 0) { pr_err("error, failed to create cmd channel.\n"); return -1; } return 0; } void deinit_tpm_emulator(void) { swtpm_cleanup(); }
7f08d85d8e7282a47b5e439b41970748acbedc68
17227ad12bc0826771ac6ac2b95dddd9517d0117
/Cores/FCEU/FCEU-2.2.3/types.h
498b317e53eeda9e362499a2ce2725eab342bcf7
[ "BSD-2-Clause" ]
permissive
Provenance-Emu/Provenance
e38f7c81e784455d4876f8a2ff999baca0135199
c6f49d7921ee27eb8c0c34ca95ec9dc7baf584c1
refs/heads/develop
2023-08-17T05:04:01.554294
2023-07-01T07:58:33
2023-07-01T07:58:33
12,416,862
2,367
364
NOASSERTION
2023-08-01T07:42:35
2013-08-27T20:34:36
C
UTF-8
C
false
false
3,544
h
types.h
/* FCE Ultra - NES/Famicom Emulator * * Copyright notice for this file: * Copyright (C) 2001 Aaron Oneal * Copyright (C) 2002 Xodnizel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __FCEU_TYPES #define __FCEU_TYPES //enables a hack designed for debugging dragon warrior 3 which treats BRK as a 3-byte opcode //#define BRK_3BYTE_HACK //enables a hack designed for debugging dragon warrior 3 which treats 0F and 1F NL files both as 1F //#define DW3_NL_0F_1F_HACK ///causes the code fragment argument to be compiled in if the build includes debugging #ifdef FCEUDEF_DEBUGGER #define DEBUG(X) X; #else #define DEBUG(X) #endif #ifdef MSVC typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedef signed char int8; typedef signed short int16; typedef signed int int32; #define dup _dup #define stat _stat #define fstat _fstat #define mkdir _mkdir #define alloca _alloca #define snprintf _snprintf #if _MSC_VER < 1500 #define vsnprintf _vsnprintf #endif #define W_OK 2 #define R_OK 2 #define X_OK 1 #define F_OK 0 #define PATH_MAX 260 #else //mingw32 doesnt prototype this for some reason #ifdef __MINGW32__ #define alloca __builtin_alloca #endif #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <inttypes.h> typedef int8_t int8; typedef int16_t int16; typedef int32_t int32; typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; #endif #ifdef __GNUC__ typedef unsigned long long uint64; typedef uint64 u64; typedef long long int64; #define INLINE inline #define GINLINE inline #elif MSVC typedef __int64 int64; typedef unsigned __int64 uint64; #define __restrict__ #define INLINE __inline #define GINLINE /* Can't declare a function INLINE and global in MSVC. Bummer. */ #define PSS_STYLE 2 /* Does MSVC compile for anything other than Windows/DOS targets? */ #if _MSC_VER >= 1300 #pragma warning(disable:4244) //warning C4244: '=' : conversion from 'uint32' to 'uint8', possible loss of data #pragma warning(disable:4996) //'strdup' was declared deprecated #endif #if _MSC_VER < 1400 #define vsnprintf _vsnprintf #endif #endif #if PSS_STYLE==2 #define PSS "\\" #define PS '\\' #elif PSS_STYLE==1 #define PSS "/" #define PS '/' #elif PSS_STYLE==3 #define PSS "\\" #define PS '\\' #elif PSS_STYLE==4 #define PSS ":" #define PS ':' #else #error PSS_STYLE undefined or invalid; see "types.h" for possible values, and add as compile-time option. #endif typedef void (*writefunc)(uint32 A, uint8 V); typedef uint8 (*readfunc)(uint32 A); #ifndef CTASSERT #define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1]; #endif #include "utils/endian.h" #endif
76441182879f5cf627576ec37892a31ca61d28cf
77861deda8b3046bdda221d3cb80b77e84b14523
/linux-cmd/prefixeq.c
02a72815b79c1606ee9283382b0a871cc578bcdb
[ "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++
WINDOWS-1250
C
false
false
2,278
c
prefixeq.c
/* Program check if two file has common prefix. prefixeq file1 file2 size is equivalent to head -b size file1 > /tmp/1 head -b size file2 > /tmp/2 cmp /tmp/1 /tmp/2 Wojciech Muła, 2009-12-25 public domain */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <errno.h> #define BUF_SIZE 1024 int main(int argc, char* argv[]) { FILE* file1; FILE* file2; char buf1[BUF_SIZE]; char buf2[BUF_SIZE]; int size; int read; size_t readed1; size_t readed2; char* err; int result; if (argc < 4) { puts("usage: cmpprefix file2 file1 size"); return EXIT_FAILURE; } size = strtol(argv[3], &err, 0); if (*err != '\0') { fprintf(stderr, "invalid digit '%c' at position %d\n", *err, err - &argv[3][0] ); return EXIT_FAILURE; } else if (size < 0) { fprintf(stderr, "size less then zero\n"); return EXIT_FAILURE; } else if (size == 0) { fprintf(stderr, "size equal zero\n"); return EXIT_FAILURE; } errno = 0; file1 = fopen(argv[1], "rb"); if (errno) { fprintf(stderr, "Can't open file 1 '%s' (err=%d): %s\n", argv[1], errno, strerror(errno) ); return EXIT_FAILURE; } file2 = fopen(argv[2], "rb"); if (errno) { fprintf(stderr, "Can't open file 1 '%s' (err=%d): %s\n", argv[1], errno, strerror(errno) ); fclose(file1); return EXIT_FAILURE; } result = EXIT_SUCCESS; while (size > 0) { read = (size < BUF_SIZE) ? size : BUF_SIZE; readed1 = fread(buf1, 1, read, file1); if (errno) { fprintf(stderr, "Can't read from file 1 '%s' (err=%d): %s\n", argv[1], errno, strerror(errno) ); result = EXIT_FAILURE; goto cleanup; } readed2 = fread(buf2, 1, read, file2); if (errno) { fprintf(stderr, "Can't read from file 2 '%s' (err=%d): %s\n", argv[2], errno, strerror(errno) ); result = EXIT_FAILURE; goto cleanup; } if (readed1 != read || readed2 != read) { /* different sizes */ result = EXIT_FAILURE; goto cleanup; } else if (memcmp(buf1, buf2, read) != 0) { result = EXIT_FAILURE; goto cleanup; } else size -= read; } cleanup: fclose(file1); fclose(file2); return result; } /*------------------------------------------------------------------------*/
b5daa6e3a0c3f9bc155e15fc0f946c872e3e3e83
cff4428975e403e4ef02d75498b78cd1a610a01a
/test/unit/cbus_call.c
11b745756a9eadd0957d511ac24466e0657553e8
[ "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,403
c
cbus_call.c
#include "exception.h" #include "memory.h" #include "cbus.h" #define UNIT_TAP_COMPATIBLE 1 #include "unit.h" static struct fiber *caller_fiber; static struct cpipe pipe_to_callee; static struct cpipe pipe_to_caller; static int func(struct cbus_call_msg *msg) { usleep(100000); return 0; } /** Check ordinary cbus_call, nothing special. */ static void test_cbus_call(void) { struct cbus_call_msg msg; int rc = cbus_call(&pipe_to_callee, &pipe_to_caller, &msg, func); is(rc, 0, "cbus_call ordinary"); } static int empty(struct cbus_call_msg *msg) { return 0; } /** Block until previously called func have been completed. */ static void barrier(void) { struct cbus_call_msg msg; int rc = cbus_call(&pipe_to_callee, &pipe_to_caller, &msg, empty); fail_if(rc != 0); } struct test_msg { struct cbus_call_msg base; bool was_freed; }; static int free_cb(struct cbus_call_msg *msg) { struct test_msg *m = (struct test_msg *)msg; m->was_freed = true; return 0; } /** Set cbus_call timeout to 10 ms, while func runs for 100 ms. */ static void test_cbus_call_timeout(void) { plan(3); struct test_msg msg; msg.was_freed = false; int rc = cbus_call_timeout(&pipe_to_callee, &pipe_to_caller, &msg.base, func, free_cb, 0.01); struct error *err = diag_last_error(diag_get()); bool pass = (rc == -1) && err && (err->type == &type_TimedOut); ok(pass, "cbus_call timeout"); ok(!msg.was_freed, "free_cb doesn't fire on timeout"); barrier(); ok(msg.was_freed, "free_cb executed on message return"); check_plan(); } static void test_cbus_call_async(void) { plan(3); struct test_msg msg; msg.was_freed = false; int csw = fiber()->csw; cbus_call_async(&pipe_to_callee, &pipe_to_caller, &msg.base, func, free_cb); is(fiber()->csw, csw, "no context switch"); ok(!msg.was_freed, "free_cb doesn't fire on async call"); barrier(); ok(msg.was_freed, "free_cb executed on message return"); check_plan(); } static int waker_fn(va_list ap) { fiber_sleep(0.05); fiber_wakeup(caller_fiber); return 0; } /** Check that cbus_call is not interrupted by fiber_wakeup. */ static void test_cbus_call_wakeup(void) { struct fiber *waker_fiber = fiber_new("waker", waker_fn); fail_if(waker_fiber == NULL); fiber_wakeup(waker_fiber); struct cbus_call_msg msg; int rc = cbus_call(&pipe_to_callee, &pipe_to_caller, &msg, func); is(rc, 0, "cbus_call wakeup"); barrier(); } static int canceler_fn(va_list ap) { fiber_sleep(0.05); fiber_cancel(caller_fiber); return 0; } /** Check that cbus_call is not interrupted by fiber_cancel. */ static void test_cbus_call_cancel(void) { struct fiber *canceler_fiber = fiber_new("canceler", canceler_fn); fail_if(canceler_fiber == NULL); fiber_wakeup(canceler_fiber); struct cbus_call_msg msg; int rc = cbus_call(&pipe_to_callee, &pipe_to_caller, &msg, func); is(rc, 0, "cbus_call cancel"); barrier(); } static void caller_cb(struct ev_loop *loop, ev_watcher *watcher, int events) { struct cbus_endpoint *endpoint = (struct cbus_endpoint *)watcher->data; cbus_process(endpoint); } static int callee_fn(va_list ap) { struct cbus_endpoint endpoint; cpipe_create(&pipe_to_caller, "caller"); cbus_endpoint_create(&endpoint, "callee", fiber_schedule_cb, fiber()); cbus_loop(&endpoint); cbus_endpoint_destroy(&endpoint, cbus_process); cpipe_destroy(&pipe_to_caller); return 0; } static void callee_start(struct cord *c) { fail_if(cord_costart(c, "callee", callee_fn, NULL) != 0); cpipe_create(&pipe_to_callee, "callee"); } static void callee_stop(struct cord *c) { cbus_stop_loop(&pipe_to_callee); cpipe_destroy(&pipe_to_callee); fail_if(cord_join(c) != 0); } static int caller_fn(va_list ap) { test_cbus_call(); test_cbus_call_timeout(); test_cbus_call_async(); test_cbus_call_wakeup(); test_cbus_call_cancel(); ev_break(loop(), EVBREAK_ALL); return 0; } int main(void) { struct cord callee_cord; struct cbus_endpoint endpoint; header(); plan(5); memory_init(); fiber_init(fiber_c_invoke); cbus_init(); cbus_endpoint_create(&endpoint, "caller", caller_cb, &endpoint); callee_start(&callee_cord); caller_fiber = fiber_new("caller", caller_fn); fail_if(caller_fiber == NULL); fiber_wakeup(caller_fiber); ev_run(loop(), 0); callee_stop(&callee_cord); cbus_endpoint_destroy(&endpoint, cbus_process); cbus_free(); fiber_free(); memory_free(); int rc = check_plan(); footer(); return rc; }
24852d15ac12ad662418f62acc62332acbcc651d
e61d085f74b9fc33f3211af8056932c2807a5446
/pager/test/test_mueller_muller.c
9e251fbf1dd81ab4b21c7133d7e46ff490ce9ca5
[]
no_license
pvachon/tsl-sdr
8ab592019356f749785acea2fb84795ce20acac6
b2e935f3e0a957ba55d8c522edd3b90c38f7df20
refs/heads/master
2022-09-24T21:51:55.087025
2020-08-16T23:37:32
2020-08-16T23:37:32
78,375,956
123
12
null
2022-09-20T02:23:21
2017-01-08T22:56:05
C
UTF-8
C
false
false
4,583
c
test_mueller_muller.c
#include <pager/mueller_muller.h> #include <test/assert.h> #include <test/framework.h> #include <tsl/safe_string.h> #include <tsl/safe_alloc.h> #include <tsl/assert.h> #include <stdlib.h> #include <stdio.h> static const int16_t *samples = NULL; static size_t nr_samples = 0; static aresult_t test_mueller_muller_setup(void) { aresult_t ret = A_OK; const char *test_data_dir = ".", *env_dir = NULL; char *file_path = NULL; size_t file_len = 0; FILE *fp = NULL; if (NULL != (env_dir = getenv("PAGER_TEST_DATA_DIR"))) { test_data_dir = env_dir; } TEST_INF("Retrieving MM test data from directory '%s'", test_data_dir); TSL_BUG_IF_FAILED(tasprintf(&file_path, "%s/%s", test_data_dir, "pocsag_hospital_25khz_long.raw")); if (NULL == (fp = fopen(file_path, "r"))) { TEST_ERR("Failed to open file %s, aborting.", file_path); ret = A_E_INVAL; goto done; } fseek(fp, 0, SEEK_END); file_len = ftell(fp); fseek(fp, 0, SEEK_SET); if (FAILED(ret = TCALLOC((void **)&samples, 1, file_len))) { goto done; } if (1 != fread((int16_t *)samples, file_len, 1, fp)) { TEST_ERR("Failed to read %zu bytes from file %s, aborting.", file_len, file_path); ret = A_E_INVAL; goto done; } nr_samples = file_len / sizeof(int16_t); done: if (FAILED(ret)) { TEST_ERR("Make sure PAGER_TEST_DATA_DIR is set to point to where we can find pocsag_single_burst_25khz.raw"); if (NULL != samples) { TFREE(samples); } } if (NULL != fp) { fclose(fp); fp = NULL; } if (NULL != file_path) { TFREE(file_path); } return ret; } static aresult_t test_mueller_muller_cleanup(void) { aresult_t ret = A_OK; if (NULL != samples) { TFREE(samples); } nr_samples = 0; return ret; } #define TEST_KW 0.0001 #define TEST_KM 0.000004 #define TEST_SAMPLES_PER_BIT (25000.0f/1200.0f) #define TEST_ERROR_MARGIN 0.05f #define TEST_MAX_NR_DECISIONS (1 << 8) #define POCSAG_SYNC_CODEWORD 0x7cd215d8ul TEST_DECLARE_UNIT(test_sample_process, mueller_muller) { int16_t decisions[2 * TEST_MAX_NR_DECISIONS]; size_t nr_decisions = 0, total_decisions = 0, samples_off = 0, nr_syncs = 0, last_sync = 0; struct mueller_muller mm; const size_t samples_per_iter = TEST_MAX_NR_DECISIONS * TEST_SAMPLES_PER_BIT; uint32_t shr = 0; /* * Use the samples that were read in to test the Mueller-Muller clock recovery */ TEST_ASSERT_OK(mm_init(&mm, TEST_KW, TEST_KM, TEST_SAMPLES_PER_BIT, TEST_SAMPLES_PER_BIT - TEST_ERROR_MARGIN, TEST_SAMPLES_PER_BIT + TEST_ERROR_MARGIN)); while (samples_off < nr_samples) { size_t iter_samples = samples_per_iter > nr_samples - samples_off ? nr_samples - samples_off : samples_per_iter; TEST_ASSERT_OK(mm_process(&mm, samples + samples_off, iter_samples, decisions, 2 * TEST_MAX_NR_DECISIONS, &nr_decisions)); samples_off += iter_samples; //TEST_INF("Iteration complete, got %zu samples, next = %f", nr_decisions, (double)mm.next_offset); for (size_t i = 0; i < nr_decisions; i++) { shr <<= 1; shr |= decisions[i] > 0 ? 0 : 1; if (__builtin_popcount(POCSAG_SYNC_CODEWORD ^ shr) < 4) { TEST_INF("Found sync word (decision %zu, delta %zu, block_offs %zu)!", total_decisions + i, total_decisions + i - last_sync, i); nr_syncs++; last_sync = total_decisions + i; } else if (0 != last_sync && total_decisions + i - last_sync == 544) { TEST_INF("Was expecting a sync word, got %08x", shr); } } total_decisions += nr_decisions; } TEST_INF("Total sync words: %zu", nr_syncs); TEST_INF("Total decisions: %zu", total_decisions); TEST_INF("Total samples: %zu", samples_off); TEST_ASSERT_EQUALS(nr_syncs, 9); return A_OK; } TEST_DECLARE_UNIT(test_smoke, mueller_muller) { struct mueller_muller mm; /* Simple smoke test to test the init function */ TEST_ASSERT_OK(mm_init(&mm, TEST_KW, TEST_KM, TEST_SAMPLES_PER_BIT, TEST_SAMPLES_PER_BIT - TEST_ERROR_MARGIN, TEST_SAMPLES_PER_BIT + TEST_ERROR_MARGIN)); return A_OK; } TEST_DECLARE_SUITE(mueller_muller, test_mueller_muller_cleanup, test_mueller_muller_setup, NULL, NULL);
3dc7c4212353177a347f6109beb02f9e1b0d8a39
67305fcba68fdf469862aed2959ad1dd5b22a536
/rt-thread/libcpu/mips/loongson_1c/stackframe_fpu.h
93b8ef10c3072d751b0af8f92853bb3af5040989
[ "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
RT-Thread/IoT_Board
cdabf100a8d515fbcaa65ab0b72ec67acb0d2c9a
2d218a4e06f06dbb356ec00767904f91d00db7cc
refs/heads/master
2023-09-04T16:51:34.485240
2022-01-19T01:26:16
2022-01-19T01:26:16
161,133,933
344
238
Apache-2.0
2023-06-06T04:10:57
2018-12-10T07:21:46
C
GB18030
C
false
false
3,096
h
stackframe_fpu.h
/* * ls1c FPU's stackframe * 最开始本想,将代码加入到stackframe.h中的SAVE_ALL, RESTORE_ALL和RESTORE_ALL_AND_RET中, * 但考虑到源文件"stackframe.h"位于目录"libcpu\mips\common"内,怕影响到其它mips cpu * 所以,另外新建本源文件 */ #ifndef __OPENLOONGSON_STACKFRAME_FPU_H #define __OPENLOONGSON_STACKFRAME_FPU_H #include "../common/asm.h" #include "../common/mipsregs.h" #include "../common/stackframe.h" #define PT_FPU_R0 (0) #define PT_FPU_R2 ((PT_FPU_R0) + 2*LONGSIZE) #define PT_FPU_R4 ((PT_FPU_R2) + 2*LONGSIZE) #define PT_FPU_R6 ((PT_FPU_R4) + 2*LONGSIZE) #define PT_FPU_R8 ((PT_FPU_R6) + 2*LONGSIZE) #define PT_FPU_R10 ((PT_FPU_R8) + 2*LONGSIZE) #define PT_FPU_R12 ((PT_FPU_R10) + 2*LONGSIZE) #define PT_FPU_R14 ((PT_FPU_R12) + 2*LONGSIZE) #define PT_FPU_R16 ((PT_FPU_R14) + 2*LONGSIZE) #define PT_FPU_R18 ((PT_FPU_R16) + 2*LONGSIZE) #define PT_FPU_R20 ((PT_FPU_R18) + 2*LONGSIZE) #define PT_FPU_R22 ((PT_FPU_R20) + 2*LONGSIZE) #define PT_FPU_R24 ((PT_FPU_R22) + 2*LONGSIZE) #define PT_FPU_R26 ((PT_FPU_R24) + 2*LONGSIZE) #define PT_FPU_R28 ((PT_FPU_R26) + 2*LONGSIZE) #define PT_FPU_R30 ((PT_FPU_R28) + 2*LONGSIZE) #define PT_FPU_SIZE ((((PT_FPU_R30) + 2*LONGSIZE) + (2*PTRSIZE-1)) & ~(2*PTRSIZE-1)) .macro SAVE_FPU .set push .set noreorder #ifdef RT_USING_FPU move k1, sp /* 保存现场 */ and k0, k1, 0xFFFFFFF8 /* 8字节对齐 */ PTR_SUBU sp, k0, PT_FPU_SIZE /* 计算栈底 */ s.d $f0, PT_FPU_R0(sp) s.d $f2, PT_FPU_R2(sp) s.d $f4, PT_FPU_R4(sp) s.d $f6, PT_FPU_R6(sp) s.d $f8, PT_FPU_R8(sp) s.d $f10, PT_FPU_R10(sp) s.d $f12, PT_FPU_R12(sp) s.d $f14, PT_FPU_R14(sp) s.d $f16, PT_FPU_R16(sp) s.d $f18, PT_FPU_R18(sp) s.d $f20, PT_FPU_R20(sp) s.d $f22, PT_FPU_R22(sp) s.d $f24, PT_FPU_R24(sp) s.d $f26, PT_FPU_R26(sp) s.d $f28, PT_FPU_R28(sp) s.d $f30, PT_FPU_R30(sp) move sp, k1 /* 恢复现场 */ #endif .set reorder .set pop .endm .macro RESTORE_FPU .set push .set noreorder #ifdef RT_USING_FPU move k1, sp /* 保存现场 */ and k0, k1, 0xFFFFFFF8 /* 8字节对齐 */ PTR_SUBU sp, k0, PT_FPU_SIZE /* 计算栈底*/ l.d $f0, PT_FPU_R0(sp) l.d $f2, PT_FPU_R2(sp) l.d $f4, PT_FPU_R4(sp) l.d $f6, PT_FPU_R6(sp) l.d $f8, PT_FPU_R8(sp) l.d $f10, PT_FPU_R10(sp) l.d $f12, PT_FPU_R12(sp) l.d $f14, PT_FPU_R14(sp) l.d $f16, PT_FPU_R16(sp) l.d $f18, PT_FPU_R18(sp) l.d $f20, PT_FPU_R20(sp) l.d $f22, PT_FPU_R22(sp) l.d $f24, PT_FPU_R24(sp) l.d $f26, PT_FPU_R26(sp) l.d $f28, PT_FPU_R28(sp) l.d $f30, PT_FPU_R30(sp) move sp, k1 /* 恢复现场 */ #endif .set reorder .set pop .endm #endif
28a7443bcbf095ef7e90951bab631fec4abf99f3
fae867d62224cdf27ceb85654525a311fb8c4226
/scpi-server/src/uart.h
e535c6d66619f1e4232e056cdd429026855a5fb0
[ "BSD-3-Clause" ]
permissive
RedPitaya/RedPitaya
a4a9b0bda0d1806e39b90ee9f3164e2e0dee0ab6
69826707f78c764e5835f3197e61f68ced90f77b
refs/heads/master
2023-09-01T12:25:51.370133
2023-07-26T03:51:31
2023-07-26T03:51:31
17,261,658
447
601
NOASSERTION
2023-07-27T04:07:43
2014-02-27T19:38:52
C
UTF-8
C
false
false
990
h
uart.h
/** * $Id: $ * * @brief Red Pitaya Scpi server UART SCPI commands interface * * @Author Red Pitaya * * (c) Red Pitaya http://www.redpitaya.com * */ #ifndef SCPI_UART_H_ #define SCPI_UART_H_ #include "scpi/types.h" scpi_result_t RP_Uart_Init(scpi_t * context); scpi_result_t RP_Uart_Release(scpi_t * context); scpi_result_t RP_Uart_SetSettings(scpi_t * context); scpi_result_t RP_Uart_BIT_Size(scpi_t *context); scpi_result_t RP_Uart_BIT_SizeQ(scpi_t *context); scpi_result_t RP_Uart_Speed(scpi_t *context); scpi_result_t RP_Uart_SpeedQ(scpi_t *context); scpi_result_t RP_Uart_STOP_Bit(scpi_t *context); scpi_result_t RP_Uart_STOP_BitQ(scpi_t *context); scpi_result_t RP_Uart_PARITY(scpi_t *context); scpi_result_t RP_Uart_PARITYQ(scpi_t *context); scpi_result_t RP_Uart_Timeout(scpi_t *context); scpi_result_t RP_Uart_TimeoutQ(scpi_t *context); scpi_result_t RP_Uart_SendBuffer(scpi_t * context); scpi_result_t RP_Uart_ReadBuffer(scpi_t * context); #endif /* SCPI_UART_H_ */
433a17994363683626b84282fc6dde74427eb9df
1ba0d12bf8b853f48dbd8cb7b702a48e4fdbfd97
/bare-metal/hello-world/kprintf.h
331f2e51db0e4dead2f99c6719752d4ef97041d4
[]
no_license
eugene-tarassov/vivado-risc-v
47cf44eeaa4232571a5d7de6e667531865479045
c76a8613a177b3a04face2cb8e15dd07a8d2fc40
refs/heads/master
2023-09-04T09:44:41.122100
2023-07-17T06:38:36
2023-07-17T06:38:36
240,625,745
556
154
null
2023-02-06T04:17:55
2020-02-15T01:12:54
C
UTF-8
C
false
false
180
h
kprintf.h
#ifndef _BOOT_KPRINTF_H #define _BOOT_KPRINTF_H extern void kputc(char ch); extern void kputs(const char *); extern void kprintf(const char *, ...); #endif /* _BOOT_KPRINTF_H */
50b336c55f581e996cc53656bce0e3443033ee64
ca79f4e1655df123bde091a102825b2845764a1d
/include/steam/steamnetworkingsockets.h
62ec17e18adab1b4ee3e1324ccd7a032f4df20fb
[ "BSD-3-Clause" ]
permissive
ValveSoftware/GameNetworkingSockets
d288783e8ff9ab9830d7880264557434b0818062
af2aff89038ccd8e960e4be77da4fe35c6882f14
refs/heads/master
2023-08-29T06:50:08.485869
2023-08-05T12:08:33
2023-08-05T12:08:33
126,225,160
7,656
651
BSD-3-Clause
2023-08-16T22:04:02
2018-03-21T18:43:20
C++
UTF-8
C
false
false
2,272
h
steamnetworkingsockets.h
//====== Copyright Valve Corporation, All rights reserved. ==================== // // High level interface to GameNetworkingSockets library. // //============================================================================= #ifndef STEAMNETWORKINGSOCKETS_H #define STEAMNETWORKINGSOCKETS_H #ifdef _WIN32 #pragma once #endif #include "isteamnetworkingsockets.h" extern "C" { // Initialize the library. Optionally, you can set an initial identity for the default // interface that is returned by SteamNetworkingSockets(). // // On failure, false is returned, and a non-localized diagnostic message is returned. STEAMNETWORKINGSOCKETS_INTERFACE bool GameNetworkingSockets_Init( const SteamNetworkingIdentity *pIdentity, SteamNetworkingErrMsg &errMsg ); // Close all connections and listen sockets and free all resources STEAMNETWORKINGSOCKETS_INTERFACE void GameNetworkingSockets_Kill(); /// Custom memory allocation methods. If you call this, you MUST call it exactly once, /// before calling any other API function. *Most* allocations will pass through these, /// especially all allocations that are per-connection. A few allocations /// might still go to the default CRT malloc and operator new. /// To use this, you must compile the library with STEAMNETWORKINGSOCKETS_ENABLE_MEM_OVERRIDE STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetCustomMemoryAllocator( void* (*pfn_malloc)( size_t s ), void (*pfn_free)( void *p ), void* (*pfn_realloc)( void *p, size_t s ) ); // // Statistics about the global lock. // STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetLockWaitWarningThreshold( SteamNetworkingMicroseconds usecThreshold ); STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetLockAcquiredCallback( void (*callback)( const char *tags, SteamNetworkingMicroseconds usecWaited ) ); STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetLockHeldCallback( void (*callback)( const char *tags, SteamNetworkingMicroseconds usecWaited ) ); /// Called from the service thread at initialization time. /// Use this to customize its priority / affinity, etc STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetServiceThreadInitCallback( void (*callback)() ); } #endif // STEAMNETWORKINGSOCKETS_H
420f31df3eaa3a19feed980d16173480b65bd167
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/synwit/swm320/libraries/SWM320_StdPeriph_Driver/SWM320_timr.c
925bced8356d27de3044241bc01176d04d3f7a0c
[ "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
16,447
c
SWM320_timr.c
/****************************************************************************************************************************************** * 文件名称: SWM320_timr.c * 功能说明: SWM320单片机的计数器/定时器功能驱动库 * 技术支持: http://www.synwit.com.cn/e/tool/gbook/?bid=1 * 注意事项: * 版本日期: V1.1.0 2017年10月25日 * 升级记录: * * ******************************************************************************************************************************************* * @attention * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION * REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE * FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN- * -ECTION WITH THEIR PRODUCTS. * * COPYRIGHT 2012 Synwit Technology *******************************************************************************************************************************************/ #include "SWM320.h" #include "SWM320_timr.h" /****************************************************************************************************************************************** * 函数名称: TIMR_Init() * 功能说明: TIMR定时器/计数器初始化 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,有效值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * uint32_t mode TIMR_MODE_TIMER 定时器模式 TIMR_MODE_COUNTER 计数器模式 * uint32_t period 定时/计数周期 * uint32_t int_en 中断使能 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_Init(TIMR_TypeDef * TIMRx, uint32_t mode, uint32_t period, uint32_t int_en) { SYS->CLKEN |= (0x01 << SYS_CLKEN_TIMR_Pos); TIMR_Stop(TIMRx); //一些关键寄存器只能在定时器停止时设置 TIMRx->CTRL &= ~TIMR_CTRL_CLKSRC_Msk; TIMRx->CTRL |= mode << TIMR_CTRL_CLKSRC_Pos; TIMRx->LDVAL = period; switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): TIMRG->IF = (1 << TIMRG_IF_TIMR0_Pos); //使能中断前清除中断标志 TIMRG->IE &= ~TIMRG_IE_TIMR0_Msk; TIMRG->IE |= (int_en << TIMRG_IE_TIMR0_Pos); if(int_en) NVIC_EnableIRQ(TIMR0_IRQn); break; case ((uint32_t)TIMR1): TIMRG->IF = (1 << TIMRG_IF_TIMR1_Pos); TIMRG->IE &= ~TIMRG_IE_TIMR1_Msk; TIMRG->IE |= (int_en << TIMRG_IE_TIMR1_Pos); if(int_en) NVIC_EnableIRQ(TIMR1_IRQn); break; case ((uint32_t)TIMR2): TIMRG->IF = (1 << TIMRG_IF_TIMR2_Pos); TIMRG->IE &= ~TIMRG_IE_TIMR2_Msk; TIMRG->IE |= (int_en << TIMRG_IE_TIMR2_Pos); if(int_en) NVIC_EnableIRQ(TIMR2_IRQn); break; case ((uint32_t)TIMR3): TIMRG->IF = (1 << TIMRG_IF_TIMR3_Pos); TIMRG->IE &= ~TIMRG_IE_TIMR3_Msk; TIMRG->IE |= (int_en << TIMRG_IE_TIMR3_Pos); if(int_en) NVIC_EnableIRQ(TIMR3_IRQn); break; case ((uint32_t)TIMR4): TIMRG->IF = (1 << TIMRG_IF_TIMR4_Pos); TIMRG->IE &= ~TIMRG_IE_TIMR4_Msk; TIMRG->IE |= (int_en << TIMRG_IE_TIMR4_Pos); if(int_en) NVIC_EnableIRQ(TIMR4_IRQn); break; case ((uint32_t)TIMR5): TIMRG->IF = (1 << TIMRG_IF_TIMR5_Pos); TIMRG->IE &= ~TIMRG_IE_TIMR5_Msk; TIMRG->IE |= (int_en << TIMRG_IE_TIMR5_Pos); if(int_en) NVIC_EnableIRQ(TIMR5_IRQn); break; } } /****************************************************************************************************************************************** * 函数名称: TIMR_Start() * 功能说明: 启动定时器,从初始值开始计时/计数 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_Start(TIMR_TypeDef * TIMRx) { TIMRx->CTRL |= TIMR_CTRL_EN_Msk; } /****************************************************************************************************************************************** * 函数名称: TIMR_Stop() * 功能说明: 停止定时器 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_Stop(TIMR_TypeDef * TIMRx) { TIMRx->CTRL &= ~TIMR_CTRL_EN_Msk; } /****************************************************************************************************************************************** * 函数名称: TIMR_Halt() * 功能说明: 暂停定时器,计数值保持不变 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_Halt(TIMR_TypeDef * TIMRx) { switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): TIMRG->HALT |= (0x01 << TIMRG_HALT_TIMR0_Pos); break; case ((uint32_t)TIMR1): TIMRG->HALT |= (0x01 << TIMRG_HALT_TIMR1_Pos); break; case ((uint32_t)TIMR2): TIMRG->HALT |= (0x01 << TIMRG_HALT_TIMR2_Pos); break; case ((uint32_t)TIMR3): TIMRG->HALT |= (0x01 << TIMRG_HALT_TIMR3_Pos); break; case ((uint32_t)TIMR4): TIMRG->HALT |= (0x01 << TIMRG_HALT_TIMR4_Pos); break; case ((uint32_t)TIMR5): TIMRG->HALT |= (0x01 << TIMRG_HALT_TIMR5_Pos); break; } } /****************************************************************************************************************************************** * 函数名称: TIMR_Resume() * 功能说明: 恢复定时器,从暂停处继续计数 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_Resume(TIMR_TypeDef * TIMRx) { switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): TIMRG->HALT &= ~(0x01 << TIMRG_HALT_TIMR0_Pos); break; case ((uint32_t)TIMR1): TIMRG->HALT &= ~(0x01 << TIMRG_HALT_TIMR1_Pos); break; case ((uint32_t)TIMR2): TIMRG->HALT &= ~(0x01 << TIMRG_HALT_TIMR2_Pos); break; case ((uint32_t)TIMR3): TIMRG->HALT &= ~(0x01 << TIMRG_HALT_TIMR3_Pos); break; case ((uint32_t)TIMR4): TIMRG->HALT &= ~(0x01 << TIMRG_HALT_TIMR4_Pos); break; case ((uint32_t)TIMR5): TIMRG->HALT &= ~(0x01 << TIMRG_HALT_TIMR5_Pos); break; } } /****************************************************************************************************************************************** * 函数名称: TIMR_SetPeriod() * 功能说明: 设置定时/计数周期 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * uint32_t period 定时/计数周期 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_SetPeriod(TIMR_TypeDef * TIMRx, uint32_t period) { TIMRx->LDVAL = period; } /****************************************************************************************************************************************** * 函数名称: TIMR_GetPeriod() * 功能说明: 获取定时/计数周期 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: uint32_t 当前定时/计数周期 * 注意事项: 无 ******************************************************************************************************************************************/ uint32_t TIMR_GetPeriod(TIMR_TypeDef * TIMRx) { return TIMRx->LDVAL; } /****************************************************************************************************************************************** * 函数名称: TIMR_GetCurValue() * 功能说明: 获取当前计数值 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: uint32_t 当前计数值 * 注意事项: 无 ******************************************************************************************************************************************/ uint32_t TIMR_GetCurValue(TIMR_TypeDef * TIMRx) { return TIMRx->CVAL; } /****************************************************************************************************************************************** * 函数名称: TIMR_INTEn() * 功能说明: 使能中断 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_INTEn(TIMR_TypeDef * TIMRx) { switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): TIMRG->IE |= (0x01 << TIMRG_IE_TIMR0_Pos); NVIC_EnableIRQ(TIMR0_IRQn); break; case ((uint32_t)TIMR1): TIMRG->IE |= (0x01 << TIMRG_IE_TIMR1_Pos); NVIC_EnableIRQ(TIMR1_IRQn); break; case ((uint32_t)TIMR2): TIMRG->IE |= (0x01 << TIMRG_IE_TIMR2_Pos); NVIC_EnableIRQ(TIMR2_IRQn); break; case ((uint32_t)TIMR3): TIMRG->IE |= (0x01 << TIMRG_IE_TIMR3_Pos); NVIC_EnableIRQ(TIMR3_IRQn); break; case ((uint32_t)TIMR4): TIMRG->IE |= (0x01 << TIMRG_IE_TIMR4_Pos); NVIC_EnableIRQ(TIMR4_IRQn); break; case ((uint32_t)TIMR5): TIMRG->IE |= (0x01 << TIMRG_IE_TIMR5_Pos); NVIC_EnableIRQ(TIMR5_IRQn); break; } } /****************************************************************************************************************************************** * 函数名称: TIMR_INTDis() * 功能说明: 禁能中断 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_INTDis(TIMR_TypeDef * TIMRx) { switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): TIMRG->IE &= ~(0x01 << TIMRG_IE_TIMR0_Pos); break; case ((uint32_t)TIMR1): TIMRG->IE &= ~(0x01 << TIMRG_IE_TIMR1_Pos); break; case ((uint32_t)TIMR2): TIMRG->IE &= ~(0x01 << TIMRG_IE_TIMR2_Pos); break; case ((uint32_t)TIMR3): TIMRG->IE &= ~(0x01 << TIMRG_IE_TIMR3_Pos); break; case ((uint32_t)TIMR4): TIMRG->IE &= ~(0x01 << TIMRG_IE_TIMR4_Pos); break; case ((uint32_t)TIMR5): TIMRG->IE &= ~(0x01 << TIMRG_IE_TIMR5_Pos); break; } } /****************************************************************************************************************************************** * 函数名称: TIMR_INTClr() * 功能说明: 清除中断标志 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void TIMR_INTClr(TIMR_TypeDef * TIMRx) { switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): TIMRG->IF = (0x01 << TIMRG_IF_TIMR0_Pos); break; case ((uint32_t)TIMR1): TIMRG->IF = (0x01 << TIMRG_IF_TIMR1_Pos); break; case ((uint32_t)TIMR2): TIMRG->IF = (0x01 << TIMRG_IF_TIMR2_Pos); break; case ((uint32_t)TIMR3): TIMRG->IF = (0x01 << TIMRG_IF_TIMR3_Pos); break; case ((uint32_t)TIMR4): TIMRG->IF = (0x01 << TIMRG_IF_TIMR4_Pos); break; case ((uint32_t)TIMR5): TIMRG->IF = (0x01 << TIMRG_IF_TIMR5_Pos); break; } } /****************************************************************************************************************************************** * 函数名称: TIMR_INTStat() * 功能说明: 获取中断状态 * 输 入: TIMR_TypeDef * TIMRx 指定要被设置的定时器,可取值包括TIMR0、TIMR1、TIMR2、TIMR3、TIMR4、TIMR5 * 输 出: uint32_t 0 TIMRx未产生中断 1 TIMRx产生了中断 * 注意事项: 无 ******************************************************************************************************************************************/ uint32_t TIMR_INTStat(TIMR_TypeDef * TIMRx) { switch((uint32_t)TIMRx) { case ((uint32_t)TIMR0): return (TIMRG->IF & TIMRG_IF_TIMR0_Msk) ? 1 : 0; case ((uint32_t)TIMR1): return (TIMRG->IF & TIMRG_IF_TIMR1_Msk) ? 1 : 0; case ((uint32_t)TIMR2): return (TIMRG->IF & TIMRG_IF_TIMR2_Msk) ? 1 : 0; case ((uint32_t)TIMR3): return (TIMRG->IF & TIMRG_IF_TIMR3_Msk) ? 1 : 0; case ((uint32_t)TIMR4): return (TIMRG->IF & TIMRG_IF_TIMR4_Msk) ? 1 : 0; case ((uint32_t)TIMR5): return (TIMRG->IF & TIMRG_IF_TIMR5_Msk) ? 1 : 0; } return 0; } /****************************************************************************************************************************************** * 函数名称: Pulse_Init() * 功能说明: 脉宽测量功能初始化 * 输 入: uint32_t pulse PULSE_LOW 测量低脉冲宽度 PULSE_HIGH 测量高脉冲宽度 * uint32_t int_en 是否使能脉冲测量完成中断 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void Pulse_Init(uint32_t pulse, uint32_t int_en) { SYS->CLKEN |= (0x01 << SYS_CLKEN_TIMR_Pos); TIMRG->PCTRL = (0 << TIMRG_PCTRL_CLKSRC_Pos) | // 系统时钟作为时钟源 (pulse << TIMRG_PCTRL_HIGH_Pos) | (0 << TIMRG_PCTRL_EN_Pos); TIMRG->IE |= (1 << TIMRG_IE_PULSE_Pos); //使能才能查询中断标志 if(int_en) NVIC_EnableIRQ(PULSE_IRQn); } /****************************************************************************************************************************************** * 函数名称: Pulse_Start() * 功能说明: 脉宽测量功能启动,测量到脉宽后会自动关闭测量功能 * 输 入: 无 * 输 出: 无 * 注意事项: 无 ******************************************************************************************************************************************/ void Pulse_Start(void) { TIMRG->PCTRL |= (1 << TIMRG_PCTRL_EN_Pos); } /****************************************************************************************************************************************** * 函数名称: Pulse_Done() * 功能说明: 脉宽测量是否完成 * 输 入: 无 * 输 出: uint32_t 1 测量已完成 0 测量未完成 * 注意事项: 无 ******************************************************************************************************************************************/ uint32_t Pulse_Done(void) { if(TIMRG->IF & TIMRG_IF_PULSE_Msk) { TIMRG->IF = TIMRG_IF_PULSE_Msk; // 清除中断标志 return 1; } else { return 0; } }
9b195483bb180d8ac35e14405eb10fe87170a5b3
f367e4b66a1ee42e85830b31df88f63723c36a47
/plugins/out_bigquery/bigquery.h
c48d9ba4101afcb87d8082bdc2e6981ebabd0bb5
[ "Apache-2.0" ]
permissive
fluent/fluent-bit
06873e441162b92941024e9a7e9e8fc934150bf7
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
refs/heads/master
2023-09-05T13:44:55.347372
2023-09-05T10:14:33
2023-09-05T10:14:33
29,933,948
4,907
1,565
Apache-2.0
2023-09-14T10:17:02
2015-01-27T20:41:52
C
UTF-8
C
false
false
4,372
h
bigquery.h
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Fluent Bit * ========== * Copyright (C) 2015-2022 The Fluent Bit Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FLB_OUT_BIGQUERY #define FLB_OUT_BIGQUERY #include <fluent-bit/flb_info.h> #include <fluent-bit/flb_output.h> #include <fluent-bit/flb_oauth2.h> #include <fluent-bit/flb_sds.h> /* refresh token every 50 minutes */ #define FLB_BIGQUERY_TOKEN_REFRESH 3000 /* BigQuery streaming inserts oauth scope */ #define FLB_BIGQUERY_SCOPE "https://www.googleapis.com/auth/bigquery.insertdata" /* BigQuery authorization URL */ #define FLB_BIGQUERY_AUTH_URL "https://oauth2.googleapis.com/token" #define FLB_BIGQUERY_RESOURCE_TEMPLATE "/bigquery/v2/projects/%s/datasets/%s/tables/%s/insertAll" #define FLB_BIGQUERY_URL_BASE "https://www.googleapis.com" #define FLB_BIGQUERY_GOOGLE_STS_URL "https://sts.googleapis.com" #define FLB_BIGQUERY_GOOGLE_IAM_URL "https://iamcredentials.googleapis.com" #define FLB_BIGQUERY_AWS_STS_ENDPOINT "/?Action=GetCallerIdentity&Version=2011-06-15" #define FLB_BIGQUERY_GOOGLE_CLOUD_TARGET_RESOURCE \ "//iam.googleapis.com/projects/%s/locations/global/workloadIdentityPools/%s/providers/%s" #define FLB_BIGQUERY_GOOGLE_STS_TOKEN_GRANT_TYPE "urn:ietf:params:oauth:grant-type:token-exchange" #define FLB_BIGQUERY_GOOGLE_STS_TOKEN_REQUESTED_TOKEN_TYPE "urn:ietf:params:oauth:token-type:access_token" #define FLB_BIGQUERY_GOOGLE_STS_TOKEN_SCOPE "https://www.googleapis.com/auth/cloud-platform" #define FLB_BIGQUERY_GOOGLE_STS_TOKEN_SUBJECT_TOKEN_TYPE "urn:ietf:params:aws:token-type:aws4_request" #define FLB_BIGQUERY_GOOGLE_CLOUD_TOKEN_ENDPOINT "/v1/token" #define FLB_BIGQUERY_GOOGLE_GEN_ACCESS_TOKEN_REQUEST_BODY \ "{\"scope\": [\"https://www.googleapis.com/auth/cloud-platform\"]}" #define FLB_BIGQUERY_GOOGLE_GEN_ACCESS_TOKEN_URL \ "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/%s:generateAccessToken" struct flb_bigquery_oauth_credentials { /* parsed credentials file */ flb_sds_t type; flb_sds_t project_id; flb_sds_t private_key_id; flb_sds_t private_key; flb_sds_t client_email; flb_sds_t client_id; flb_sds_t auth_uri; flb_sds_t token_uri; }; struct flb_bigquery { /* credentials */ flb_sds_t credentials_file; struct flb_bigquery_oauth_credentials *oauth_credentials; /* Workload Identity Federation */ int has_identity_federation; flb_sds_t project_number; flb_sds_t pool_id; flb_sds_t provider_id; flb_sds_t aws_region; flb_sds_t google_service_account; /* AWS IMDS */ struct flb_tls *aws_tls; struct flb_aws_provider *aws_provider; /* AWS STS */ flb_sds_t aws_sts_endpoint; struct flb_tls *aws_sts_tls; struct flb_upstream *aws_sts_upstream; /* Google STS API */ struct flb_tls *google_sts_tls; struct flb_upstream *google_sts_upstream; /* Google Service Account Credentials API */ struct flb_tls *google_iam_tls; struct flb_upstream *google_iam_upstream; /* Google OAuth access token for service account, that was exchanged for AWS credentials */ flb_sds_t sa_token; time_t sa_token_expiry; /* bigquery configuration */ flb_sds_t project_id; flb_sds_t dataset_id; flb_sds_t table_id; int skip_invalid_rows; int ignore_unknown_values; flb_sds_t uri; /* oauth2 context */ struct flb_oauth2 *o; /* mutex for acquiring oauth tokens */ pthread_mutex_t token_mutex; /* Upstream connection to the backend server */ struct flb_upstream *u; /* Fluent Bit context */ struct flb_config *config; /* Plugin output instance reference */ struct flb_output_instance *ins; }; #endif
8fbc004d0cf080d3fedc2129ad5ccd189f69dd11
4ddf82eeb31d46fb67802a4375390eb42a8f23b8
/ports/nrf/mphalport.c
4469adc80d84f5837b6ef7efadb5b0dccf98b4ed
[ "MIT" ]
permissive
pulkin/micropython
1437a507b9e90c8824e80c3553e6209d89e64565
c274c947c611f510fd2b1c4ef6cbd9f4283794fc
refs/heads/master
2023-03-08T02:35:28.208819
2022-04-19T12:38:47
2022-04-19T12:38:47
167,732,676
103
36
MIT
2023-02-25T03:02:36
2019-01-26T19:57:59
C
UTF-8
C
false
false
6,704
c
mphalport.c
/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2015 Glenn Ruben Bakke * * 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 <string.h> #include "py/mpstate.h" #include "py/mphal.h" #include "py/mperrno.h" #include "py/runtime.h" #include "py/stream.h" #include "uart.h" #include "nrfx_errors.h" #include "nrfx_config.h" // this table converts from HAL_StatusTypeDef to POSIX errno const byte mp_hal_status_to_errno_table[4] = { [HAL_OK] = 0, [HAL_ERROR] = MP_EIO, [HAL_BUSY] = MP_EBUSY, [HAL_TIMEOUT] = MP_ETIMEDOUT, }; NORETURN void mp_hal_raise(HAL_StatusTypeDef status) { mp_raise_OSError(mp_hal_status_to_errno_table[status]); } #if !MICROPY_KBD_EXCEPTION void mp_hal_set_interrupt_char(int c) { } #endif #if !MICROPY_PY_BLE_NUS uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { uintptr_t ret = 0; if ((poll_flags & MP_STREAM_POLL_RD) && MP_STATE_PORT(board_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(board_stdio_uart))) { ret |= MP_STREAM_POLL_RD; } return ret; } #endif #if !MICROPY_PY_BLE_NUS && !MICROPY_HW_USB_CDC int mp_hal_stdin_rx_chr(void) { for (;;) { if (MP_STATE_PORT(board_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(board_stdio_uart))) { return uart_rx_char(MP_STATE_PORT(board_stdio_uart)); } __WFI(); } return 0; } void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { if (MP_STATE_PORT(board_stdio_uart) != NULL) { uart_tx_strn(MP_STATE_PORT(board_stdio_uart), str, len); } } void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) { if (MP_STATE_PORT(board_stdio_uart) != NULL) { uart_tx_strn_cooked(MP_STATE_PORT(board_stdio_uart), str, len); } } #endif void mp_hal_stdout_tx_str(const char *str) { mp_hal_stdout_tx_strn(str, strlen(str)); } void mp_hal_delay_us(mp_uint_t us) { if (us == 0) { return; } register uint32_t delay __ASM("r0") = us; __ASM volatile ( "1:\n" #ifdef NRF51 " SUB %0, %0, #1\n" #else " SUBS %0, %0, #1\n" #endif " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" #if defined(NRF52) || defined(NRF9160_XXAA) " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" " NOP\n" #endif " BNE 1b\n" : "+r" (delay)); } void mp_hal_delay_ms(mp_uint_t ms) { for (mp_uint_t i = 0; i < ms; i++) { mp_hal_delay_us(999); } } #if defined(NRFX_LOG_ENABLED) && (NRFX_LOG_ENABLED == 1) static const char nrfx_error_unknown[1] = ""; static const char nrfx_error_success[] = "NRFX_SUCCESS"; static const char nrfx_error_internal[] = "NRFX_ERROR_INTERNAL"; static const char nrfx_error_no_mem[] = "NRFX_ERROR_NO_MEM"; static const char nrfx_error_not_supported[] = "NRFX_ERROR_NOT_SUPPORTED"; static const char nrfx_error_invalid_param[] = "NRFX_ERROR_INVALID_PARAM"; static const char nrfx_error_invalid_state[] = "NRFX_ERROR_INVALID_STATE"; static const char nrfx_error_invalid_length[] = "NRFX_ERROR_INVALID_LENGTH"; static const char nrfx_error_timeout[] = "NRFX_ERROR_TIMEOUT"; static const char nrfx_error_forbidden[] = "NRFX_ERROR_FORBIDDEN"; static const char nrfx_error_null[] = "NRFX_ERROR_NULL"; static const char nrfx_error_invalid_addr[] = "NRFX_ERROR_INVALID_ADDR"; static const char nrfx_error_busy[] = "NRFX_ERROR_BUSY"; static const char nrfx_error_already_initalized[] = "NRFX_ERROR_ALREADY_INITIALIZED"; static const char *nrfx_error_strings[13] = { nrfx_error_success, nrfx_error_internal, nrfx_error_no_mem, nrfx_error_not_supported, nrfx_error_invalid_param, nrfx_error_invalid_state, nrfx_error_invalid_length, nrfx_error_timeout, nrfx_error_forbidden, nrfx_error_null, nrfx_error_invalid_addr, nrfx_error_busy, nrfx_error_already_initalized }; static const char nrfx_drv_error_twi_err_overrun[] = "NRFX_ERROR_DRV_TWI_ERR_OVERRUN"; static const char nrfx_drv_error_twi_err_anack[] = "NRFX_ERROR_DRV_TWI_ERR_ANACK"; static const char nrfx_drv_error_twi_err_dnack[] = "NRFX_ERROR_DRV_TWI_ERR_DNACK"; static const char *nrfx_drv_error_strings[3] = { nrfx_drv_error_twi_err_overrun, nrfx_drv_error_twi_err_anack, nrfx_drv_error_twi_err_dnack }; const char *nrfx_error_code_lookup(uint32_t err_code) { if (err_code >= NRFX_ERROR_BASE_NUM && err_code <= NRFX_ERROR_BASE_NUM + 13) { return nrfx_error_strings[err_code - NRFX_ERROR_BASE_NUM]; } else if (err_code >= NRFX_ERROR_DRIVERS_BASE_NUM && err_code <= NRFX_ERROR_DRIVERS_BASE_NUM + 3) { return nrfx_drv_error_strings[err_code - NRFX_ERROR_DRIVERS_BASE_NUM]; } return nrfx_error_unknown; } #endif // NRFX_LOG_ENABLED
ce9d741bfa929ce1830e99f3dfa8e83799a38029
75f50003ef55a8a151790a4810d5e3d64367f871
/shellcode/linux-x86-basic/shellcode.c
8a7d79d8767caa8fc9e73395ed6a46677ef49575
[]
no_license
nneonneo/pwn-stuff
8d58f6f4bd16234c4e3317dca33fc39e2f38b265
4470be4e33aaf6a8c997297a49c455658533ed36
refs/heads/master
2023-06-12T15:16:13.689216
2023-05-31T23:50:44
2023-05-31T23:50:44
49,756,417
112
17
null
2023-05-31T23:50:45
2016-01-16T02:51:19
Python
UTF-8
C
false
false
368
c
shellcode.c
char shellcode[] = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x89\xe1\x41\x41\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x51\x89\xe1\xb0\x0b\xcd\x80"; #include <sys/mman.h> #include <string.h> int main() { int (*sc)() = mmap(NULL, 4096, PROT_EXEC | PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); memcpy(sc, shellcode, sizeof(shellcode)); return sc(); }
4bcbc6a1e187ab54f7ea00cf68b4b84eb065117e
549270020f6c8724e2ef1b12e38d11b025579f8d
/recipes/spirv-cross/all/test_package/test_package.c
dd59cdcab47b358b542de54dc1a95f46f28e37b6
[ "MIT" ]
permissive
conan-io/conan-center-index
1bcec065ccd65aa38b1fed93fbd94d9d5fe6bc43
3b17e69bb4e5601a850b6e006e44775e690bac33
refs/heads/master
2023-08-31T11:34:45.403978
2023-08-31T11:13:23
2023-08-31T11:13:23
204,671,232
844
1,820
MIT
2023-09-14T21:22:42
2019-08-27T09:43:58
Python
UTF-8
C
false
false
315
c
test_package.c
#include <spirv_cross_c.h> #include <stdio.h> int main() { spvc_context context; spvc_context_create(&context); spvc_context_destroy(context); unsigned major, minor, patch; spvc_get_version(&major, &minor, &patch); printf("SPIRV-Cross: C API version %u.%u.%u\n", major, minor, patch); return 0; }
00ce091da2f0e2fd9c9c3effc43fac8a5e93c869
9f01cf4f599af5ef184b0a0c5ddc9a5ae6e249bf
/engine/source/scriptlib/Stack.h
de1a7055d667ee402302c8e1b78d122d2234440e
[]
permissive
DCurrent/openbor
89f348ce7a93519f420ac6602d1fea615703f4ca
7f6f17507078848be625e6d1c1b4f41823151387
refs/heads/master
2023-09-03T12:41:21.059545
2022-04-22T20:39:58
2022-04-22T20:39:58
86,879,076
817
127
BSD-3-Clause
2023-09-13T11:47:20
2017-04-01T03:06:14
C
UTF-8
C
false
false
493
h
Stack.h
/* * OpenBOR - http://www.chronocrash.com * ----------------------------------------------------------------------- * All rights reserved, see LICENSE in OpenBOR root for details. * * Copyright (c) 2004 - 2014 OpenBOR Team */ #ifndef STACK_H #define STACK_H #include "List.h" typedef List Stack; void Stack_Init(Stack *stack); void Stack_Push( Stack *stack, void *e); void Stack_Pop(Stack *stack ); void *Stack_Top(const Stack *stack); int Stack_IsEmpty(const Stack *stack); #endif
9a2444674aa9482da8dc8ff312efb235a3096a99
161e968aa47d75d925f10e7f35b174f0f8f7d342
/lib/tests/c/print-chip-spec.c
f77f8237bbf00012a9540d1928b152d13ae61cb5
[ "Apache-2.0" ]
permissive
quil-lang/quilc
e0a81017badd4f98db3e5ee4566f0991a6d7aca1
5d55a9f5b24365ae26cdf35867de73f4ff1cc26d
refs/heads/master
2023-08-28T02:32:34.488640
2023-08-23T17:45:45
2023-08-23T17:47:06
158,458,059
117
21
Apache-2.0
2023-08-23T17:47:07
2018-11-20T22:14:40
Common Lisp
UTF-8
C
false
false
569
c
print-chip-spec.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "libquilc.h" void die(char *msg) { printf("%s\n", msg); exit(1); } int main(int argc, char **argv) { init("libquilc.core"); chip_specification chip_spec; if (quilc_build_nq_linear_chip(8, &chip_spec) != ERROR_SUCCESS) die("unable to build chip"); quilc_print_chip_spec(chip_spec); if (quilc_chip_spec_from_isa_descriptor("8Q", &chip_spec) != ERROR_SUCCESS) die("unable to build chip"); quilc_print_chip_spec(chip_spec); lisp_release_handle(chip_spec); return 0; }
41bcc1b7be94c4653d4945aa90ff8d874861abb2
ca414d0345d2d1486da1126960a164a655965968
/src/drivers/pit.h
53cbec82a596500d390859f92a615d383b33a8e6
[]
permissive
Menotdan/DripOS
6d2ee8fbd87145d789fbe5781e2f6ae825a5aba6
2a3110338e84a8a14f1e9217cea2082de888189c
refs/heads/dev
2023-07-20T01:50:26.166067
2023-05-26T02:59:52
2023-05-26T02:59:52
149,795,128
119
15
MIT
2020-03-26T20:43:19
2018-09-21T17:21:05
C
UTF-8
C
false
false
358
h
pit.h
#ifndef PIT_H #define PIT_H #include <stdint.h> #include "sys/int/isr.h" #define sched_period 8 void timer_handler(int_reg_t *r); void set_pit_freq(); void sleep_no_task(uint64_t ticks); uint64_t stopwatch_start(); uint64_t stopwatch_stop(uint64_t start); void time_code(uint64_t *start, char *description); extern volatile uint64_t global_ticks; #endif
5170c9776f9048fde22c30f6e684545016c765f1
0dd85c72c457ac317ecdde7dc40518f7be1a2602
/include/boatkeypair.h
d31493535cc2461007e7985f007280870be007f9
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
aitos-io/BoAT-X-Framework
00072acd6e570b8dda5c3e211103717110303915
92c09bd1ed269903b542b7b39a02137bb0b4f9be
refs/heads/master
2023-07-08T11:20:52.441231
2023-03-08T01:43:57
2023-03-08T01:43:57
249,309,472
2,165
141
Apache-2.0
2023-06-27T03:22:02
2020-03-23T01:39:16
C
UTF-8
C
false
false
10,427
h
boatkeypair.h
/****************************************************************************** * Copyright (C) 2018-2021 aitos.io * * 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. *****************************************************************************/ /*!@brief Boatkeypair SDK header file @file boatkeypair.h is the SDK header file. */ #ifndef __BOATKEYPAIR_H__ #define __BOATKEYPAIR_H__ /*! @defgroup keypair boat keypair API * @{ */ #include "boattypes.h" #define BOAT_TLS_SUPPORT 1 //!< If need client support TLS, set it to 1. #define BOAT_TLS_IDENTIFY_CLIENT 1 //!< If server need identify client, set it to 1. #define BOAT_KEYPAIR_NUM_LEN 4 // AA55+NUM+CRC #define BOAT_KEYPAIR_ALL_LEN_MAX 3 // 82XXXX #define BOAT_KEYPAIR_INDEX_LEN 2 // 01+index #define BOAT_KEYPAIR_NAME_LEN_MAX 65 // L+64 the max len of keypair name is 64 #define BOAT_KEYPAIR_FORMAT_LEN 5 // L + format 0401000000 #define BOAT_KEYPAIR_TYPE_LEN 5 // L + type 0401000000 #define BOAT_KEYPAIR_PUBKEY_LEN 65 // L + pubkey // #define BOAT_KEYPAIR_PRIKEY_LEN 33 // L + prikey #define BOAT_MAX_KEYPAIR_NUM 5 /* * @Description: * store type * @Author: aitos * @Date: 2022-08-19 14:34:52 * @LastEditors: zt222 * @LastEditTime: 2022-08-30 11:06:40 */ //! @brief The generate mode of the used private key typedef enum { BOAT_KEYPAIR_PRIKEY_GENMODE_UNKNOWN = 0, //!< Placeholder for unknown private key format BOAT_KEYPAIR_PRIKEY_GENMODE_EXTERNAL_INJECTION, //!< The private key is injected externally BOAT_KEYPAIR_PRIKEY_GENMODE_INTERNAL_GENERATION, //!< The private key is generated internally } BoatKeypairPriKeyGenMode; //! @brief The format of the externally injected private key //! This field will be actived when BOAT_KEYPAIR_PRIKEY_FORMAT_EXTERN_INJECTION be selected. typedef enum { BOAT_KEYPAIR_PRIKEY_FORMAT_UNKNOWN = 0, //!< Placeholder for unknown prikey format BOAT_KEYPAIR_PRIKEY_FORMAT_PKCS, //!< Contain PEM and DER format BOAT_KEYPAIR_PRIKEY_FORMAT_NATIVE, //!< The 32 bytes format private key BOAT_KEYPAIR_PRIKEY_FORMAT_MNEMONIC, //!< Mnemonic words that meet BIP39 format } BoatKeypairPriKeyFormat; //! Type of private key //! @note For PKCS format private key, the key type is already included in it, //! but it's still suggest to fill this field. typedef enum { BOAT_KEYPAIR_PRIKEY_TYPE_UNKNOWN = 0, //!< Placeholder for unknown ecliptic curve BOAT_KEYPAIR_PRIKEY_TYPE_SECP256K1, //!< secp256k1 ecliptic curve BOAT_KEYPAIR_PRIKEY_TYPE_SECP256R1, //!< secp256r1 ecliptic curve } BoatKeypairPriKeyType; //!@brief The extension field of prikey context //! This field is only used for secret key storage when secure storage environment is not available. //! \n The practice of the security specification is still to store it in TEE/SE. typedef struct TBoatKeypairExtraData { BUINT32 value_len; //!< Length of the stored private key BUINT8 value[512]; //!< Private key content when a secure storage environment is not available } BoatKeypairExtraData; typedef struct TBoatKeypairKeypair { BoatKeypairExtraData prikey; // keypair prikey BoatKeypairExtraData pubkey; // keypair pubkey } BoatKeypairKeypair; //!@brief Boat keypair key context typedef struct TBoatKeypairPriKeyCtx { BUINT8 keypair_index; //!< Index of keypair BCHAR *keypair_name; //!< name of keypair BoatKeypairPriKeyFormat prikey_format; //!< Format of private key BoatKeypairPriKeyType prikey_type; //!< Type of private key, SDK according to this field to execute corresponding signature BUINT8 pubkey_content[64]; //!< Content of public key, current only native format be supported. } BoatKeypairPriKeyCtx; //!@brief Boat keypair config context typedef struct TBoatKeypairPriKeyCtx_config { BoatKeypairPriKeyGenMode prikey_genMode; //!< Generate mode of private key BoatKeypairPriKeyFormat prikey_format; //!< Format of private key BoatKeypairPriKeyType prikey_type; //!< Type of private key BoatFieldVariable prikey_content; //!< The externally injected private key contents. //!< \n A pointer to externally injected private key content, the content of this //!< field point to will be COPYED to the corresponding field of the keypair, //!< if user dynamically allocated space for this pointer, then the user should //!< free it after BoatKeypairCreate invoked. //!< @note For content of type string, such as PEM format data, the length includes //!< the terminating null byte. } BoatKeypairPriKeyCtx_config; //!@brief Boat keypair data context typedef struct TBoatKeypairDataCtx { BoatKeypairPriKeyCtx prikeyCtx; //!< keypair key content , not contain prikey data BoatKeypairExtraData extraData; //!< prikey data , only used for storing keypair data, delete content immediately after storing; //!< this parameter could be used for onetime keypair, } BoatKeypairDataCtx; //!@brief BoAT IoT SDK Context typedef struct TBoatIotKeypairContext { BUINT8 keypairNum; BUINT8 keypairPersistentNum; // Protocol specific properties are defined in protocol specific KeypairInfo structure BoatKeypairDataCtx keypairs[BOAT_MAX_KEYPAIR_NUM + 1]; //!< Keypair Info List } BoatIotKeypairContext; #ifdef __cplusplus extern "C" { #endif /*!**************************************************************************** * @brief Initialize Boat IoT SDK * * @details * This function initialize global context of Boat IoT SDK. * \n BoatIotSdkInit() MUST be called before any use of BoAT IoT SDK per process. * BoatIotSdkInit() MUST be called only once unless BoatIotSdkDeInit() is called. * BoatIotSdkDeInit() MUST be called after use of BoAT IoT SDK. * * @param This function doesn't take any argument. * * @return * This function returns BOAT_SUCCESS if initialization is successful.\n * Otherwise it returns one of the error codes. Refer to header file boaterrcode.h * for details. * @see BoatIotSdkDeInit() ******************************************************************************/ BOAT_RESULT BoatIotSdkInit(void); /*!**************************************************************************** * @brief De-initialize BoAT IoT SDK * * @details * This function de-initialize context of BoAT IoT SDK. * \n BoatIotSdkInit() MUST be called before any use of BoAT IoT SDK per process. * BoatIotSdkDeInit() MUST be called after use of BoAT IoT SDK. * * @return * This function doesn't return anything. * * @see BoatIotSdkInit() ******************************************************************************/ void BoatIotSdkDeInit(void); /** * @description: * This function create keypair * @param[in] {BoatKeypairPriKeyCtx_config} keypairConfig * @param[in] {BCHAR} *keypairName * If keypairName is NULL , BoAT will slect one testing name. * @param[in] {BoatStoreType} storeType * For onetime keypair or test , select store in ram . * For persistent keypair ,slect store in flash. * @return * This function returns keypair index if create keypair successfully.\n * Otherwise it returns one of the error codes. Refer to header file boaterrcode.h * for details. * @author: aitos */ BOAT_RESULT BoatKeypairCreate(BoatKeypairPriKeyCtx_config *keypairConfig, BCHAR *keypairName, BoatStoreType storeType); /** * @description: * This function get persistent keypair list * @param[out] {BoatIotKeypairContext} *keypairList * @return {*} * This function returns BOAT_SUCCESS if successfully executed. * Otherwise it returns one of the error codes. Refer to header file boaterrcode.h * for details. * @author: aitos */ BOAT_RESULT BoATKeypair_GetKeypairList(BoatIotKeypairContext *keypairList); /** * @description: * This function deletes the keypair which keypairIndex equals index. * This function will delete the keypair data in Nvram. * @param {BUINT8} index * the index want to delete * @return {*} * This function returns BOAT_SUCCESS if delete successfully.\n * Otherwise it returns one of the error codes. Refer to header file boaterrcode.h * for details. * @author: aitos */ BOAT_RESULT BoATIotKeypairDelete(BUINT8 index); /** * @description: * This function use to free BoatIotKeypairContext param. * @param[in] {BoatIotKeypairContext} keypairList * @return {*} * This function returns BOAT_SUCCESS if successfully executed. * Otherwise it returns one of the error codes. Refer to header file boaterrcode.h * for details. * @author: aitos */ BOAT_RESULT BoATKeypair_FreeKeypairContext(BoatIotKeypairContext keypairList); /** * @description: * This function read keypair data from Nvram by index. Not read prikey content. * @param {BoatKeypairPriKeyCtx} *PriKeyCtx * @param {BUINT8} index * the keypair index want to read * @return {*} * This function returns BOAT_SUCCESS if successfully executed. * Otherwise it returns one of the error codes. Refer to header file boaterrcode.h * for details. * @author: aitos */ BOAT_RESULT BoATKeypair_GetKeypairByIndex(BoatKeypairPriKeyCtx *PriKeyCtx, BUINT8 index); /*! @}*/ #ifdef __cplusplus } #endif /* end of __cplusplus */ #endif
3024c5b38f64ce713b07e696ce97c7f9b1450f07
73fbb7c1c93f53c9499e83f13c5ed8e4d4ce9d4a
/tests/kvasir-tests/perl/regcomp.c
0762f551d3025b3b72d40cb12897edb8d6ea97ac
[ "MIT" ]
permissive
codespecs/daikon
8cccbaa7cce77d88160ae368054d9ef74043d465
62109d49852676657ce3205283cebbb46456425c
refs/heads/master
2023-09-01T19:45:13.280344
2023-08-22T03:21:40
2023-08-22T03:21:40
37,424,689
183
56
NOASSERTION
2023-08-22T03:21:41
2015-06-14T18:40:55
C
UTF-8
C
false
false
147,052
c
regcomp.c
/* regcomp.c */ /* * "A fair jaw-cracker dwarf-language must be." --Samwise Gamgee */ /* This file contains functions for compiling a regular expression. See * also regexec.c which funnily enough, contains functions for executing * a regular expression. * * This file is also copied at build time to ext/re/re_comp.c, where * it's built with -DPERL_EXT_RE_BUILD -DPERL_EXT_RE_DEBUG -DPERL_EXT. * This causes the main functions to be compiled under new names and with * debugging support added, which makes "use re 'debug'" work. */ /* NOTE: this is derived from Henry Spencer's regexp code, and should not * confused with the original package (see point 3 below). Thanks, Henry! */ /* Additional note: this code is very heavily munged from Henry's version * in places. In some spots I've traded clarity for efficiency, so don't * blame Henry for some of the lack of readability. */ /* The names of the functions have been changed from regcomp and * regexec to pregcomp and pregexec in order to avoid conflicts * with the POSIX routines of the same names. */ #ifdef PERL_EXT_RE_BUILD /* need to replace pregcomp et al, so enable that */ # ifndef PERL_IN_XSUB_RE # define PERL_IN_XSUB_RE # endif /* need access to debugger hooks */ # if defined(PERL_EXT_RE_DEBUG) && !defined(DEBUGGING) # define DEBUGGING # endif #endif #ifdef PERL_IN_XSUB_RE /* We *really* need to overwrite these symbols: */ # define Perl_pregcomp my_regcomp # define Perl_regdump my_regdump # define Perl_regprop my_regprop # define Perl_pregfree my_regfree # define Perl_re_intuit_string my_re_intuit_string /* *These* symbols are masked to allow static link. */ # define Perl_regnext my_regnext # define Perl_save_re_context my_save_re_context # define Perl_reginitcolors my_reginitcolors # define PERL_NO_GET_CONTEXT #endif /*SUPPRESS 112*/ /* * pregcomp and pregexec -- regsub and regerror are not used in perl * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * **** Alterations to Henry's code are... **** **** Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, **** 2000, 2001, 2002, 2003, by Larry Wall and others **** **** You may distribute under the terms of either the GNU General Public **** License or the Artistic License, as specified in the README file. * * Beware that some of this code is subtly aware of the way operator * precedence is structured in regular expressions. Serious changes in * regular-expression syntax might require a total rethink. */ #include "EXTERN.h" #define PERL_IN_REGCOMP_C #include "perl.h" #ifndef PERL_IN_XSUB_RE # include "INTERN.h" #endif #define REG_COMP_C #include "regcomp.h" #ifdef op #undef op #endif /* op */ #ifdef MSDOS # if defined(BUGGY_MSC6) /* MSC 6.00A breaks on op/regexp.t test 85 unless we turn this off */ # pragma optimize("a",off) /* But MSC 6.00A is happy with 'w', for aliases only across function calls*/ # pragma optimize("w",on ) # endif /* BUGGY_MSC6 */ #endif /* MSDOS */ #ifndef STATIC #define STATIC static #endif typedef struct RExC_state_t { U32 flags; /* are we folding, multilining? */ char *precomp; /* uncompiled string. */ regexp *rx; char *start; /* Start of input for compile */ char *end; /* End of input for compile */ char *parse; /* Input-scan pointer. */ I32 whilem_seen; /* number of WHILEM in this expr */ regnode *emit_start; /* Start of emitted-code area */ regnode *emit; /* Code-emit pointer; &regdummy = don't = compiling */ I32 naughty; /* How bad is this pattern? */ I32 sawback; /* Did we see \1, ...? */ U32 seen; I32 size; /* Code size. */ I32 npar; /* () count. */ I32 extralen; I32 seen_zerolen; I32 seen_evals; I32 utf8; #if ADD_TO_REGEXEC char *starttry; /* -Dr: where regtry was called. */ #define RExC_starttry (pRExC_state->starttry) #endif } RExC_state_t; #define RExC_flags (pRExC_state->flags) #define RExC_precomp (pRExC_state->precomp) #define RExC_rx (pRExC_state->rx) #define RExC_start (pRExC_state->start) #define RExC_end (pRExC_state->end) #define RExC_parse (pRExC_state->parse) #define RExC_whilem_seen (pRExC_state->whilem_seen) #define RExC_offsets (pRExC_state->rx->offsets) /* I am not like the others */ #define RExC_emit (pRExC_state->emit) #define RExC_emit_start (pRExC_state->emit_start) #define RExC_naughty (pRExC_state->naughty) #define RExC_sawback (pRExC_state->sawback) #define RExC_seen (pRExC_state->seen) #define RExC_size (pRExC_state->size) #define RExC_npar (pRExC_state->npar) #define RExC_extralen (pRExC_state->extralen) #define RExC_seen_zerolen (pRExC_state->seen_zerolen) #define RExC_seen_evals (pRExC_state->seen_evals) #define RExC_utf8 (pRExC_state->utf8) #define ISMULT1(c) ((c) == '*' || (c) == '+' || (c) == '?') #define ISMULT2(s) ((*s) == '*' || (*s) == '+' || (*s) == '?' || \ ((*s) == '{' && regcurly(s))) #ifdef SPSTART #undef SPSTART /* dratted cpp namespace... */ #endif /* * Flags to be passed up and down. */ #define WORST 0 /* Worst case. */ #define HASWIDTH 0x1 /* Known to match non-null strings. */ #define SIMPLE 0x2 /* Simple enough to be STAR/PLUS operand. */ #define SPSTART 0x4 /* Starts with * or +. */ #define TRYAGAIN 0x8 /* Weeded out a declaration. */ /* Length of a variant. */ typedef struct scan_data_t { I32 len_min; I32 len_delta; I32 pos_min; I32 pos_delta; SV *last_found; I32 last_end; /* min value, <0 unless valid. */ I32 last_start_min; I32 last_start_max; SV **longest; /* Either &l_fixed, or &l_float. */ SV *longest_fixed; I32 offset_fixed; SV *longest_float; I32 offset_float_min; I32 offset_float_max; I32 flags; I32 whilem_c; I32 *last_closep; struct regnode_charclass_class *start_class; } scan_data_t; /* * Forward declarations for pregcomp()'s friends. */ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #define SF_BEFORE_EOL (SF_BEFORE_SEOL|SF_BEFORE_MEOL) #define SF_BEFORE_SEOL 0x1 #define SF_BEFORE_MEOL 0x2 #define SF_FIX_BEFORE_EOL (SF_FIX_BEFORE_SEOL|SF_FIX_BEFORE_MEOL) #define SF_FL_BEFORE_EOL (SF_FL_BEFORE_SEOL|SF_FL_BEFORE_MEOL) #ifdef NO_UNARY_PLUS # define SF_FIX_SHIFT_EOL (0+2) # define SF_FL_SHIFT_EOL (0+4) #else # define SF_FIX_SHIFT_EOL (+2) # define SF_FL_SHIFT_EOL (+4) #endif #define SF_FIX_BEFORE_SEOL (SF_BEFORE_SEOL << SF_FIX_SHIFT_EOL) #define SF_FIX_BEFORE_MEOL (SF_BEFORE_MEOL << SF_FIX_SHIFT_EOL) #define SF_FL_BEFORE_SEOL (SF_BEFORE_SEOL << SF_FL_SHIFT_EOL) #define SF_FL_BEFORE_MEOL (SF_BEFORE_MEOL << SF_FL_SHIFT_EOL) /* 0x20 */ #define SF_IS_INF 0x40 #define SF_HAS_PAR 0x80 #define SF_IN_PAR 0x100 #define SF_HAS_EVAL 0x200 #define SCF_DO_SUBSTR 0x400 #define SCF_DO_STCLASS_AND 0x0800 #define SCF_DO_STCLASS_OR 0x1000 #define SCF_DO_STCLASS (SCF_DO_STCLASS_AND|SCF_DO_STCLASS_OR) #define SCF_WHILEM_VISITED_POS 0x2000 #define UTF (RExC_utf8 != 0) #define LOC ((RExC_flags & PMf_LOCALE) != 0) #define FOLD ((RExC_flags & PMf_FOLD) != 0) #define OOB_UNICODE 12345678 #define OOB_NAMEDCLASS -1 #define CHR_SVLEN(sv) (UTF ? sv_len_utf8(sv) : SvCUR(sv)) #define CHR_DIST(a,b) (UTF ? utf8_distance(a,b) : a - b) /* length of regex to show in messages that don't mark a position within */ #define RegexLengthToShowInErrorMessages 127 /* * If MARKER[12] are adjusted, be sure to adjust the constants at the top * of t/op/regmesg.t, the tests in t/op/re_tests, and those in * op/pragma/warn/regcomp. */ #define MARKER1 "<-- HERE" /* marker as it appears in the description */ #define MARKER2 " <-- HERE " /* marker as it appears within the regex */ #define REPORT_LOCATION " in regex; marked by " MARKER1 " in m/%.*s" MARKER2 "%s/" /* * Calls SAVEDESTRUCTOR_X if needed, then calls Perl_croak with the given * arg. Show regex, up to a maximum length. If it's too long, chop and add * "...". */ #define FAIL(msg) STMT_START { \ char *ellipses = ""; \ IV len = RExC_end - RExC_precomp; \ \ if (!SIZE_ONLY) \ SAVEDESTRUCTOR_X(clear_re,(void*)RExC_rx); \ if (len > RegexLengthToShowInErrorMessages) { \ /* chop 10 shorter than the max, to ensure meaning of "..." */ \ len = RegexLengthToShowInErrorMessages - 10; \ ellipses = "..."; \ } \ Perl_croak(aTHX_ "%s in regex m/%.*s%s/", \ msg, (int)len, RExC_precomp, ellipses); \ } STMT_END /* * Calls SAVEDESTRUCTOR_X if needed, then calls Perl_croak with the given * args. Show regex, up to a maximum length. If it's too long, chop and add * "...". */ #define FAIL2(pat,msg) STMT_START { \ char *ellipses = ""; \ IV len = RExC_end - RExC_precomp; \ \ if (!SIZE_ONLY) \ SAVEDESTRUCTOR_X(clear_re,(void*)RExC_rx); \ if (len > RegexLengthToShowInErrorMessages) { \ /* chop 10 shorter than the max, to ensure meaning of "..." */ \ len = RegexLengthToShowInErrorMessages - 10; \ ellipses = "..."; \ } \ S_re_croak2(aTHX_ pat, " in regex m/%.*s%s/", \ msg, (int)len, RExC_precomp, ellipses); \ } STMT_END /* * Simple_vFAIL -- like FAIL, but marks the current location in the scan */ #define Simple_vFAIL(m) STMT_START { \ IV offset = RExC_parse - RExC_precomp; \ Perl_croak(aTHX_ "%s" REPORT_LOCATION, \ m, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END /* * Calls SAVEDESTRUCTOR_X if needed, then Simple_vFAIL() */ #define vFAIL(m) STMT_START { \ if (!SIZE_ONLY) \ SAVEDESTRUCTOR_X(clear_re,(void*)RExC_rx); \ Simple_vFAIL(m); \ } STMT_END /* * Like Simple_vFAIL(), but accepts two arguments. */ #define Simple_vFAIL2(m,a1) STMT_START { \ IV offset = RExC_parse - RExC_precomp; \ S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, \ (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END /* * Calls SAVEDESTRUCTOR_X if needed, then Simple_vFAIL2(). */ #define vFAIL2(m,a1) STMT_START { \ if (!SIZE_ONLY) \ SAVEDESTRUCTOR_X(clear_re,(void*)RExC_rx); \ Simple_vFAIL2(m, a1); \ } STMT_END /* * Like Simple_vFAIL(), but accepts three arguments. */ #define Simple_vFAIL3(m, a1, a2) STMT_START { \ IV offset = RExC_parse - RExC_precomp; \ S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, \ (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END /* * Calls SAVEDESTRUCTOR_X if needed, then Simple_vFAIL3(). */ #define vFAIL3(m,a1,a2) STMT_START { \ if (!SIZE_ONLY) \ SAVEDESTRUCTOR_X(clear_re,(void*)RExC_rx); \ Simple_vFAIL3(m, a1, a2); \ } STMT_END /* * Like Simple_vFAIL(), but accepts four arguments. */ #define Simple_vFAIL4(m, a1, a2, a3) STMT_START { \ IV offset = RExC_parse - RExC_precomp; \ S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3, \ (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END /* * Like Simple_vFAIL(), but accepts five arguments. */ #define Simple_vFAIL5(m, a1, a2, a3, a4) STMT_START { \ IV offset = RExC_parse - RExC_precomp; \ S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3, a4, \ (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END #define vWARN(loc,m) STMT_START { \ IV offset = loc - RExC_precomp; \ Perl_warner(aTHX_ packWARN(WARN_REGEXP), "%s" REPORT_LOCATION, \ m, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END #define vWARNdep(loc,m) STMT_START { \ IV offset = loc - RExC_precomp; \ Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_REGEXP), \ "%s" REPORT_LOCATION, \ m, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END #define vWARN2(loc, m, a1) STMT_START { \ IV offset = loc - RExC_precomp; \ Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \ a1, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END #define vWARN3(loc, m, a1, a2) STMT_START { \ IV offset = loc - RExC_precomp; \ Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \ a1, a2, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END #define vWARN4(loc, m, a1, a2, a3) STMT_START { \ IV offset = loc - RExC_precomp; \ Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \ a1, a2, a3, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END #define vWARN5(loc, m, a1, a2, a3, a4) STMT_START { \ IV offset = loc - RExC_precomp; \ Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \ a1, a2, a3, a4, (int)offset, RExC_precomp, RExC_precomp + offset); \ } STMT_END /* Allow for side effects in s */ #define REGC(c,s) STMT_START { \ if (!SIZE_ONLY) *(s) = (c); else (void)(s); \ } STMT_END /* Macros for recording node offsets. 20001227 mjd@plover.com * Nodes are numbered 1, 2, 3, 4. Node #n's position is recorded in * element 2*n-1 of the array. Element #2n holds the byte length node #n. * Element 0 holds the number n. */ #define MJD_OFFSET_DEBUG(x) /* #define MJD_OFFSET_DEBUG(x) Perl_warn_nocontext x */ #define Set_Node_Offset_To_R(node,byte) STMT_START { \ if (! SIZE_ONLY) { \ MJD_OFFSET_DEBUG(("** (%d) offset of node %d is %d.\n", \ __LINE__, (node), (byte))); \ if((node) < 0) { \ Perl_croak(aTHX_ "value of node is %d in Offset macro", node); \ } else { \ RExC_offsets[2*(node)-1] = (byte); \ } \ } \ } STMT_END #define Set_Node_Offset(node,byte) \ Set_Node_Offset_To_R((node)-RExC_emit_start, (byte)-RExC_start) #define Set_Cur_Node_Offset Set_Node_Offset(RExC_emit, RExC_parse) #define Set_Node_Length_To_R(node,len) STMT_START { \ if (! SIZE_ONLY) { \ MJD_OFFSET_DEBUG(("** (%d) size of node %d is %d.\n", \ __LINE__, (node), (len))); \ if((node) < 0) { \ Perl_croak(aTHX_ "value of node is %d in Length macro", node); \ } else { \ RExC_offsets[2*(node)] = (len); \ } \ } \ } STMT_END #define Set_Node_Length(node,len) \ Set_Node_Length_To_R((node)-RExC_emit_start, len) #define Set_Cur_Node_Length(len) Set_Node_Length(RExC_emit, len) #define Set_Node_Cur_Length(node) \ Set_Node_Length(node, RExC_parse - parse_start) /* Get offsets and lengths */ #define Node_Offset(n) (RExC_offsets[2*((n)-RExC_emit_start)-1]) #define Node_Length(n) (RExC_offsets[2*((n)-RExC_emit_start)]) static void clear_re(pTHX_ void *r); /* Mark that we cannot extend a found fixed substring at this point. Updata the longest found anchored substring and the longest found floating substrings if needed. */ STATIC void S_scan_commit(pTHX_ RExC_state_t *pRExC_state, scan_data_t *data) { STRLEN l = CHR_SVLEN(data->last_found); STRLEN old_l = CHR_SVLEN(*data->longest); if ((l >= old_l) && ((l > old_l) || (data->flags & SF_BEFORE_EOL))) { SvSetMagicSV(*data->longest, data->last_found); if (*data->longest == data->longest_fixed) { data->offset_fixed = l ? data->last_start_min : data->pos_min; if (data->flags & SF_BEFORE_EOL) data->flags |= ((data->flags & SF_BEFORE_EOL) << SF_FIX_SHIFT_EOL); else data->flags &= ~SF_FIX_BEFORE_EOL; } else { data->offset_float_min = l ? data->last_start_min : data->pos_min; data->offset_float_max = (l ? data->last_start_max : data->pos_min + data->pos_delta); if ((U32)data->offset_float_max > (U32)I32_MAX) data->offset_float_max = I32_MAX; if (data->flags & SF_BEFORE_EOL) data->flags |= ((data->flags & SF_BEFORE_EOL) << SF_FL_SHIFT_EOL); else data->flags &= ~SF_FL_BEFORE_EOL; } } SvCUR_set(data->last_found, 0); { SV * sv = data->last_found; MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL; if (mg && mg->mg_len > 0) mg->mg_len = 0; } data->last_end = -1; data->flags &= ~SF_BEFORE_EOL; } /* Can match anything (initialization) */ STATIC void S_cl_anything(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl) { ANYOF_CLASS_ZERO(cl); ANYOF_BITMAP_SETALL(cl); cl->flags = ANYOF_EOS|ANYOF_UNICODE_ALL; if (LOC) cl->flags |= ANYOF_LOCALE; } /* Can match anything (initialization) */ STATIC int S_cl_is_anything(pTHX_ struct regnode_charclass_class *cl) { int value; for (value = 0; value <= ANYOF_MAX; value += 2) if (ANYOF_CLASS_TEST(cl, value) && ANYOF_CLASS_TEST(cl, value + 1)) return 1; if (!(cl->flags & ANYOF_UNICODE_ALL)) return 0; if (!ANYOF_BITMAP_TESTALLSET(cl)) return 0; return 1; } /* Can match anything (initialization) */ STATIC void S_cl_init(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl) { Zero(cl, 1, struct regnode_charclass_class); cl->type = ANYOF; cl_anything(pRExC_state, cl); } STATIC void S_cl_init_zero(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl) { Zero(cl, 1, struct regnode_charclass_class); cl->type = ANYOF; cl_anything(pRExC_state, cl); if (LOC) cl->flags |= ANYOF_LOCALE; } /* 'And' a given class with another one. Can create false positives */ /* We assume that cl is not inverted */ STATIC void S_cl_and(pTHX_ struct regnode_charclass_class *cl, struct regnode_charclass_class *and_with) { if (!(and_with->flags & ANYOF_CLASS) && !(cl->flags & ANYOF_CLASS) && (and_with->flags & ANYOF_LOCALE) == (cl->flags & ANYOF_LOCALE) && !(and_with->flags & ANYOF_FOLD) && !(cl->flags & ANYOF_FOLD)) { int i; if (and_with->flags & ANYOF_INVERT) for (i = 0; i < ANYOF_BITMAP_SIZE; i++) cl->bitmap[i] &= ~and_with->bitmap[i]; else for (i = 0; i < ANYOF_BITMAP_SIZE; i++) cl->bitmap[i] &= and_with->bitmap[i]; } /* XXXX: logic is complicated otherwise, leave it along for a moment. */ if (!(and_with->flags & ANYOF_EOS)) cl->flags &= ~ANYOF_EOS; if (cl->flags & ANYOF_UNICODE_ALL && and_with->flags & ANYOF_UNICODE && !(and_with->flags & ANYOF_INVERT)) { cl->flags &= ~ANYOF_UNICODE_ALL; cl->flags |= ANYOF_UNICODE; ARG_SET(cl, ARG(and_with)); } if (!(and_with->flags & ANYOF_UNICODE_ALL) && !(and_with->flags & ANYOF_INVERT)) cl->flags &= ~ANYOF_UNICODE_ALL; if (!(and_with->flags & (ANYOF_UNICODE|ANYOF_UNICODE_ALL)) && !(and_with->flags & ANYOF_INVERT)) cl->flags &= ~ANYOF_UNICODE; } /* 'OR' a given class with another one. Can create false positives */ /* We assume that cl is not inverted */ STATIC void S_cl_or(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl, struct regnode_charclass_class *or_with) { if (or_with->flags & ANYOF_INVERT) { /* We do not use * (B1 | CL1) | (!B2 & !CL2) = (B1 | !B2 & !CL2) | (CL1 | (!B2 & !CL2)) * <= (B1 | !B2) | (CL1 | !CL2) * which is wasteful if CL2 is small, but we ignore CL2: * (B1 | CL1) | (!B2 & !CL2) <= (B1 | CL1) | !B2 = (B1 | !B2) | CL1 * XXXX Can we handle case-fold? Unclear: * (OK1(i) | OK1(i')) | !(OK1(i) | OK1(i')) = * (OK1(i) | OK1(i')) | (!OK1(i) & !OK1(i')) */ if ( (or_with->flags & ANYOF_LOCALE) == (cl->flags & ANYOF_LOCALE) && !(or_with->flags & ANYOF_FOLD) && !(cl->flags & ANYOF_FOLD) ) { int i; for (i = 0; i < ANYOF_BITMAP_SIZE; i++) cl->bitmap[i] |= ~or_with->bitmap[i]; } /* XXXX: logic is complicated otherwise */ else { cl_anything(pRExC_state, cl); } } else { /* (B1 | CL1) | (B2 | CL2) = (B1 | B2) | (CL1 | CL2)) */ if ( (or_with->flags & ANYOF_LOCALE) == (cl->flags & ANYOF_LOCALE) && (!(or_with->flags & ANYOF_FOLD) || (cl->flags & ANYOF_FOLD)) ) { int i; /* OR char bitmap and class bitmap separately */ for (i = 0; i < ANYOF_BITMAP_SIZE; i++) cl->bitmap[i] |= or_with->bitmap[i]; if (or_with->flags & ANYOF_CLASS) { for (i = 0; i < ANYOF_CLASSBITMAP_SIZE; i++) cl->classflags[i] |= or_with->classflags[i]; cl->flags |= ANYOF_CLASS; } } else { /* XXXX: logic is complicated, leave it along for a moment. */ cl_anything(pRExC_state, cl); } } if (or_with->flags & ANYOF_EOS) cl->flags |= ANYOF_EOS; if (cl->flags & ANYOF_UNICODE && or_with->flags & ANYOF_UNICODE && ARG(cl) != ARG(or_with)) { cl->flags |= ANYOF_UNICODE_ALL; cl->flags &= ~ANYOF_UNICODE; } if (or_with->flags & ANYOF_UNICODE_ALL) { cl->flags |= ANYOF_UNICODE_ALL; cl->flags &= ~ANYOF_UNICODE; } } /* * There are strange code-generation bugs caused on sparc64 by gcc-2.95.2. * These need to be revisited when a newer toolchain becomes available. */ #if defined(__sparc64__) && defined(__GNUC__) # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) # undef SPARC64_GCC_WORKAROUND # define SPARC64_GCC_WORKAROUND 1 # endif #endif /* REx optimizer. Converts nodes into quickier variants "in place". Finds fixed substrings. */ /* Stops at toplevel WHILEM as well as at `last'. At end *scanp is set to the position after last scanned or to NULL. */ STATIC I32 S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 flags) /* scanp: Start here (read-write). */ /* deltap: Write maxlen-minlen here. */ /* last: Stop before this one. */ { I32 min = 0, pars = 0, code; regnode *scan = *scanp, *next; I32 delta = 0; int is_inf = (flags & SCF_DO_SUBSTR) && (data->flags & SF_IS_INF); int is_inf_internal = 0; /* The studied chunk is infinite */ I32 is_par = OP(scan) == OPEN ? ARG(scan) : 0; scan_data_t data_fake; struct regnode_charclass_class and_with; /* Valid if flags & SCF_DO_STCLASS_OR */ while (scan && OP(scan) != END && scan < last) { /* Peephole optimizer: */ if (PL_regkind[(U8)OP(scan)] == EXACT) { /* Merge several consecutive EXACTish nodes into one. */ regnode *n = regnext(scan); U32 stringok = 1; #ifdef DEBUGGING regnode *stop = scan; #endif next = scan + NODE_SZ_STR(scan); /* Skip NOTHING, merge EXACT*. */ while (n && ( PL_regkind[(U8)OP(n)] == NOTHING || (stringok && (OP(n) == OP(scan)))) && NEXT_OFF(n) && NEXT_OFF(scan) + NEXT_OFF(n) < I16_MAX) { if (OP(n) == TAIL || n > next) stringok = 0; if (PL_regkind[(U8)OP(n)] == NOTHING) { NEXT_OFF(scan) += NEXT_OFF(n); next = n + NODE_STEP_REGNODE; #ifdef DEBUGGING if (stringok) stop = n; #endif n = regnext(n); } else if (stringok) { int oldl = STR_LEN(scan); regnode *nnext = regnext(n); if (oldl + STR_LEN(n) > U8_MAX) break; NEXT_OFF(scan) += NEXT_OFF(n); STR_LEN(scan) += STR_LEN(n); next = n + NODE_SZ_STR(n); /* Now we can overwrite *n : */ Move(STRING(n), STRING(scan) + oldl, STR_LEN(n), char); #ifdef DEBUGGING stop = next - 1; #endif n = nnext; } } if (UTF && OP(scan) == EXACTF && STR_LEN(scan) >= 6) { /* Two problematic code points in Unicode casefolding of EXACT nodes: U+0390 - GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS U+03B0 - GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS which casefold to Unicode UTF-8 U+03B9 U+0308 U+0301 0xCE 0xB9 0xCC 0x88 0xCC 0x81 U+03C5 U+0308 U+0301 0xCF 0x85 0xCC 0x88 0xCC 0x81 This means that in case-insensitive matching (or "loose matching", as Unicode calls it), an EXACTF of length six (the UTF-8 encoded byte length of the above casefolded versions) can match a target string of length two (the byte length of UTF-8 encoded U+0390 or U+03B0). This would rather mess up the minimum length computation. What we'll do is to look for the tail four bytes, and then peek at the preceding two bytes to see whether we need to decrease the minimum length by four (six minus two). Thanks to the design of UTF-8, there cannot be false matches: A sequence of valid UTF-8 bytes cannot be a subsequence of another valid sequence of UTF-8 bytes. */ char *s0 = STRING(scan), *s, *t; char *s1 = s0 + STR_LEN(scan) - 1, *s2 = s1 - 4; char *t0 = "\xcc\x88\xcc\x81"; char *t1 = t0 + 3; for (s = s0 + 2; s < s2 && (t = ninstr(s, s1, t0, t1)); s = t + 4) { if (((U8)t[-1] == 0xB9 && (U8)t[-2] == 0xCE) || ((U8)t[-1] == 0x85 && (U8)t[-2] == 0xCF)) min -= 4; } } #ifdef DEBUGGING /* Allow dumping */ n = scan + NODE_SZ_STR(scan); while (n <= stop) { if (PL_regkind[(U8)OP(n)] != NOTHING || OP(n) == NOTHING) { OP(n) = OPTIMIZED; NEXT_OFF(n) = 0; } n++; } #endif } /* Follow the next-chain of the current node and optimize away all the NOTHINGs from it. */ if (OP(scan) != CURLYX) { int max = (reg_off_by_arg[OP(scan)] ? I32_MAX /* I32 may be smaller than U16 on CRAYs! */ : (I32_MAX < U16_MAX ? I32_MAX : U16_MAX)); int off = (reg_off_by_arg[OP(scan)] ? ARG(scan) : NEXT_OFF(scan)); int noff; regnode *n = scan; /* Skip NOTHING and LONGJMP. */ while ((n = regnext(n)) && ((PL_regkind[(U8)OP(n)] == NOTHING && (noff = NEXT_OFF(n))) || ((OP(n) == LONGJMP) && (noff = ARG(n)))) && off + noff < max) off += noff; if (reg_off_by_arg[OP(scan)]) ARG(scan) = off; else NEXT_OFF(scan) = off; } /* The principal pseudo-switch. Cannot be a switch, since we look into several different things. */ if (OP(scan) == BRANCH || OP(scan) == BRANCHJ || OP(scan) == IFTHEN || OP(scan) == SUSPEND) { next = regnext(scan); code = OP(scan); if (OP(next) == code || code == IFTHEN || code == SUSPEND) { I32 max1 = 0, min1 = I32_MAX, num = 0; struct regnode_charclass_class accum; if (flags & SCF_DO_SUBSTR) /* XXXX Add !SUSPEND? */ scan_commit(pRExC_state, data); /* Cannot merge strings after this. */ if (flags & SCF_DO_STCLASS) cl_init_zero(pRExC_state, &accum); while (OP(scan) == code) { I32 deltanext, minnext, f = 0, fake; struct regnode_charclass_class this_class; num++; data_fake.flags = 0; if (data) { data_fake.whilem_c = data->whilem_c; data_fake.last_closep = data->last_closep; } else data_fake.last_closep = &fake; next = regnext(scan); scan = NEXTOPER(scan); if (code != BRANCH) scan = NEXTOPER(scan); if (flags & SCF_DO_STCLASS) { cl_init(pRExC_state, &this_class); data_fake.start_class = &this_class; f = SCF_DO_STCLASS_AND; } if (flags & SCF_WHILEM_VISITED_POS) f |= SCF_WHILEM_VISITED_POS; /* we suppose the run is continuous, last=next...*/ minnext = study_chunk(pRExC_state, &scan, &deltanext, next, &data_fake, f); if (min1 > minnext) min1 = minnext; if (max1 < minnext + deltanext) max1 = minnext + deltanext; if (deltanext == I32_MAX) is_inf = is_inf_internal = 1; scan = next; if (data_fake.flags & (SF_HAS_PAR|SF_IN_PAR)) pars++; if (data && (data_fake.flags & SF_HAS_EVAL)) data->flags |= SF_HAS_EVAL; if (data) data->whilem_c = data_fake.whilem_c; if (flags & SCF_DO_STCLASS) cl_or(pRExC_state, &accum, &this_class); if (code == SUSPEND) break; } if (code == IFTHEN && num < 2) /* Empty ELSE branch */ min1 = 0; if (flags & SCF_DO_SUBSTR) { data->pos_min += min1; data->pos_delta += max1 - min1; if (max1 != min1 || is_inf) data->longest = &(data->longest_float); } min += min1; delta += max1 - min1; if (flags & SCF_DO_STCLASS_OR) { cl_or(pRExC_state, data->start_class, &accum); if (min1) { cl_and(data->start_class, &and_with); flags &= ~SCF_DO_STCLASS; } } else if (flags & SCF_DO_STCLASS_AND) { if (min1) { cl_and(data->start_class, &accum); flags &= ~SCF_DO_STCLASS; } else { /* Switch to OR mode: cache the old value of * data->start_class */ StructCopy(data->start_class, &and_with, struct regnode_charclass_class); flags &= ~SCF_DO_STCLASS_AND; StructCopy(&accum, data->start_class, struct regnode_charclass_class); flags |= SCF_DO_STCLASS_OR; data->start_class->flags |= ANYOF_EOS; } } } else if (code == BRANCHJ) /* single branch is optimized. */ scan = NEXTOPER(NEXTOPER(scan)); else /* single branch is optimized. */ scan = NEXTOPER(scan); continue; } else if (OP(scan) == EXACT) { I32 l = STR_LEN(scan); UV uc = *((U8*)STRING(scan)); if (UTF) { U8 *s = (U8*)STRING(scan); l = utf8_length(s, s + l); uc = utf8_to_uvchr(s, NULL); } min += l; if (flags & SCF_DO_SUBSTR) { /* Update longest substr. */ /* The code below prefers earlier match for fixed offset, later match for variable offset. */ if (data->last_end == -1) { /* Update the start info. */ data->last_start_min = data->pos_min; data->last_start_max = is_inf ? I32_MAX : data->pos_min + data->pos_delta; } sv_catpvn(data->last_found, STRING(scan), STR_LEN(scan)); { SV * sv = data->last_found; MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL; if (mg && mg->mg_len >= 0) mg->mg_len += utf8_length((U8*)STRING(scan), (U8*)STRING(scan)+STR_LEN(scan)); } if (UTF) SvUTF8_on(data->last_found); data->last_end = data->pos_min + l; data->pos_min += l; /* As in the first entry. */ data->flags &= ~SF_BEFORE_EOL; } if (flags & SCF_DO_STCLASS_AND) { /* Check whether it is compatible with what we know already! */ int compat = 1; if (uc >= 0x100 || (!(data->start_class->flags & (ANYOF_CLASS | ANYOF_LOCALE)) && !ANYOF_BITMAP_TEST(data->start_class, uc) && (!(data->start_class->flags & ANYOF_FOLD) || !ANYOF_BITMAP_TEST(data->start_class, PL_fold[uc]))) ) compat = 0; ANYOF_CLASS_ZERO(data->start_class); ANYOF_BITMAP_ZERO(data->start_class); if (compat) ANYOF_BITMAP_SET(data->start_class, uc); data->start_class->flags &= ~ANYOF_EOS; if (uc < 0x100) data->start_class->flags &= ~ANYOF_UNICODE_ALL; } else if (flags & SCF_DO_STCLASS_OR) { /* false positive possible if the class is case-folded */ if (uc < 0x100) ANYOF_BITMAP_SET(data->start_class, uc); else data->start_class->flags |= ANYOF_UNICODE_ALL; data->start_class->flags &= ~ANYOF_EOS; cl_and(data->start_class, &and_with); } flags &= ~SCF_DO_STCLASS; } else if (PL_regkind[(U8)OP(scan)] == EXACT) { /* But OP != EXACT! */ I32 l = STR_LEN(scan); UV uc = *((U8*)STRING(scan)); /* Search for fixed substrings supports EXACT only. */ if (flags & SCF_DO_SUBSTR) scan_commit(pRExC_state, data); if (UTF) { U8 *s = (U8 *)STRING(scan); l = utf8_length(s, s + l); uc = utf8_to_uvchr(s, NULL); } min += l; if (data && (flags & SCF_DO_SUBSTR)) data->pos_min += l; if (flags & SCF_DO_STCLASS_AND) { /* Check whether it is compatible with what we know already! */ int compat = 1; if (uc >= 0x100 || (!(data->start_class->flags & (ANYOF_CLASS | ANYOF_LOCALE)) && !ANYOF_BITMAP_TEST(data->start_class, uc) && !ANYOF_BITMAP_TEST(data->start_class, PL_fold[uc]))) compat = 0; ANYOF_CLASS_ZERO(data->start_class); ANYOF_BITMAP_ZERO(data->start_class); if (compat) { ANYOF_BITMAP_SET(data->start_class, uc); data->start_class->flags &= ~ANYOF_EOS; data->start_class->flags |= ANYOF_FOLD; if (OP(scan) == EXACTFL) data->start_class->flags |= ANYOF_LOCALE; } } else if (flags & SCF_DO_STCLASS_OR) { if (data->start_class->flags & ANYOF_FOLD) { /* false positive possible if the class is case-folded. Assume that the locale settings are the same... */ if (uc < 0x100) ANYOF_BITMAP_SET(data->start_class, uc); data->start_class->flags &= ~ANYOF_EOS; } cl_and(data->start_class, &and_with); } flags &= ~SCF_DO_STCLASS; } else if (strchr((char*)PL_varies,OP(scan))) { I32 mincount, maxcount, minnext, deltanext, fl = 0; I32 f = flags, pos_before = 0; regnode *oscan = scan; struct regnode_charclass_class this_class; struct regnode_charclass_class *oclass = NULL; I32 next_is_eval = 0; switch (PL_regkind[(U8)OP(scan)]) { case WHILEM: /* End of (?:...)* . */ scan = NEXTOPER(scan); goto finish; case PLUS: if (flags & (SCF_DO_SUBSTR | SCF_DO_STCLASS)) { next = NEXTOPER(scan); if (OP(next) == EXACT || (flags & SCF_DO_STCLASS)) { mincount = 1; maxcount = REG_INFTY; next = regnext(scan); scan = NEXTOPER(scan); goto do_curly; } } if (flags & SCF_DO_SUBSTR) data->pos_min++; min++; /* Fall through. */ case STAR: if (flags & SCF_DO_STCLASS) { mincount = 0; maxcount = REG_INFTY; next = regnext(scan); scan = NEXTOPER(scan); goto do_curly; } is_inf = is_inf_internal = 1; scan = regnext(scan); if (flags & SCF_DO_SUBSTR) { scan_commit(pRExC_state, data); /* Cannot extend fixed substrings */ data->longest = &(data->longest_float); } goto optimize_curly_tail; case CURLY: mincount = ARG1(scan); maxcount = ARG2(scan); next = regnext(scan); if (OP(scan) == CURLYX) { I32 lp = (data ? *(data->last_closep) : 0); scan->flags = ((lp <= U8_MAX) ? lp : U8_MAX); } scan = NEXTOPER(scan) + EXTRA_STEP_2ARGS; next_is_eval = (OP(scan) == EVAL); do_curly: if (flags & SCF_DO_SUBSTR) { if (mincount == 0) scan_commit(pRExC_state,data); /* Cannot extend fixed substrings */ pos_before = data->pos_min; } if (data) { fl = data->flags; data->flags &= ~(SF_HAS_PAR|SF_IN_PAR|SF_HAS_EVAL); if (is_inf) data->flags |= SF_IS_INF; } if (flags & SCF_DO_STCLASS) { cl_init(pRExC_state, &this_class); oclass = data->start_class; data->start_class = &this_class; f |= SCF_DO_STCLASS_AND; f &= ~SCF_DO_STCLASS_OR; } /* These are the cases when once a subexpression fails at a particular position, it cannot succeed even after backtracking at the enclosing scope. XXXX what if minimal match and we are at the initial run of {n,m}? */ if ((mincount != maxcount - 1) && (maxcount != REG_INFTY)) f &= ~SCF_WHILEM_VISITED_POS; /* This will finish on WHILEM, setting scan, or on NULL: */ minnext = study_chunk(pRExC_state, &scan, &deltanext, last, data, mincount == 0 ? (f & ~SCF_DO_SUBSTR) : f); if (flags & SCF_DO_STCLASS) data->start_class = oclass; if (mincount == 0 || minnext == 0) { if (flags & SCF_DO_STCLASS_OR) { cl_or(pRExC_state, data->start_class, &this_class); } else if (flags & SCF_DO_STCLASS_AND) { /* Switch to OR mode: cache the old value of * data->start_class */ StructCopy(data->start_class, &and_with, struct regnode_charclass_class); flags &= ~SCF_DO_STCLASS_AND; StructCopy(&this_class, data->start_class, struct regnode_charclass_class); flags |= SCF_DO_STCLASS_OR; data->start_class->flags |= ANYOF_EOS; } } else { /* Non-zero len */ if (flags & SCF_DO_STCLASS_OR) { cl_or(pRExC_state, data->start_class, &this_class); cl_and(data->start_class, &and_with); } else if (flags & SCF_DO_STCLASS_AND) cl_and(data->start_class, &this_class); flags &= ~SCF_DO_STCLASS; } if (!scan) /* It was not CURLYX, but CURLY. */ scan = next; if (ckWARN(WARN_REGEXP) /* ? quantifier ok, except for (?{ ... }) */ && (next_is_eval || !(mincount == 0 && maxcount == 1)) && (minnext == 0) && (deltanext == 0) && data && !(data->flags & (SF_HAS_PAR|SF_IN_PAR)) && maxcount <= REG_INFTY/3) /* Complement check for big count */ { vWARN(RExC_parse, "Quantifier unexpected on zero-length expression"); } min += minnext * mincount; is_inf_internal |= ((maxcount == REG_INFTY && (minnext + deltanext) > 0) || deltanext == I32_MAX); is_inf |= is_inf_internal; delta += (minnext + deltanext) * maxcount - minnext * mincount; /* Try powerful optimization CURLYX => CURLYN. */ if ( OP(oscan) == CURLYX && data && data->flags & SF_IN_PAR && !(data->flags & SF_HAS_EVAL) && !deltanext && minnext == 1 ) { /* Try to optimize to CURLYN. */ regnode *nxt = NEXTOPER(oscan) + EXTRA_STEP_2ARGS; regnode *nxt1 = nxt; #ifdef DEBUGGING regnode *nxt2; #endif /* Skip open. */ nxt = regnext(nxt); if (!strchr((char*)PL_simple,OP(nxt)) && !(PL_regkind[(U8)OP(nxt)] == EXACT && STR_LEN(nxt) == 1)) goto nogo; #ifdef DEBUGGING nxt2 = nxt; #endif nxt = regnext(nxt); if (OP(nxt) != CLOSE) goto nogo; /* Now we know that nxt2 is the only contents: */ oscan->flags = (U8)ARG(nxt); OP(oscan) = CURLYN; OP(nxt1) = NOTHING; /* was OPEN. */ #ifdef DEBUGGING OP(nxt1 + 1) = OPTIMIZED; /* was count. */ NEXT_OFF(nxt1+ 1) = 0; /* just for consistancy. */ NEXT_OFF(nxt2) = 0; /* just for consistancy with CURLY. */ OP(nxt) = OPTIMIZED; /* was CLOSE. */ OP(nxt + 1) = OPTIMIZED; /* was count. */ NEXT_OFF(nxt+ 1) = 0; /* just for consistancy. */ #endif } nogo: /* Try optimization CURLYX => CURLYM. */ if ( OP(oscan) == CURLYX && data && !(data->flags & SF_HAS_PAR) && !(data->flags & SF_HAS_EVAL) && !deltanext /* atom is fixed width */ && minnext != 0 /* CURLYM can't handle zero width */ ) { /* XXXX How to optimize if data == 0? */ /* Optimize to a simpler form. */ regnode *nxt = NEXTOPER(oscan) + EXTRA_STEP_2ARGS; /* OPEN */ regnode *nxt2; OP(oscan) = CURLYM; while ( (nxt2 = regnext(nxt)) /* skip over embedded stuff*/ && (OP(nxt2) != WHILEM)) nxt = nxt2; OP(nxt2) = SUCCEED; /* Whas WHILEM */ /* Need to optimize away parenths. */ if (data->flags & SF_IN_PAR) { /* Set the parenth number. */ regnode *nxt1 = NEXTOPER(oscan) + EXTRA_STEP_2ARGS; /* OPEN*/ if (OP(nxt) != CLOSE) FAIL("Panic opt close"); oscan->flags = (U8)ARG(nxt); OP(nxt1) = OPTIMIZED; /* was OPEN. */ OP(nxt) = OPTIMIZED; /* was CLOSE. */ #ifdef DEBUGGING OP(nxt1 + 1) = OPTIMIZED; /* was count. */ OP(nxt + 1) = OPTIMIZED; /* was count. */ NEXT_OFF(nxt1 + 1) = 0; /* just for consistancy. */ NEXT_OFF(nxt + 1) = 0; /* just for consistancy. */ #endif #if 0 while ( nxt1 && (OP(nxt1) != WHILEM)) { regnode *nnxt = regnext(nxt1); if (nnxt == nxt) { if (reg_off_by_arg[OP(nxt1)]) ARG_SET(nxt1, nxt2 - nxt1); else if (nxt2 - nxt1 < U16_MAX) NEXT_OFF(nxt1) = nxt2 - nxt1; else OP(nxt) = NOTHING; /* Cannot beautify */ } nxt1 = nnxt; } #endif /* Optimize again: */ study_chunk(pRExC_state, &nxt1, &deltanext, nxt, NULL, 0); } else oscan->flags = 0; } else if ((OP(oscan) == CURLYX) && (flags & SCF_WHILEM_VISITED_POS) /* See the comment on a similar expression above. However, this time it not a subexpression we care about, but the expression itself. */ && (maxcount == REG_INFTY) && data && ++data->whilem_c < 16) { /* This stays as CURLYX, we can put the count/of pair. */ /* Find WHILEM (as in regexec.c) */ regnode *nxt = oscan + NEXT_OFF(oscan); if (OP(PREVOPER(nxt)) == NOTHING) /* LONGJMP */ nxt += ARG(nxt); PREVOPER(nxt)->flags = (U8)(data->whilem_c | (RExC_whilem_seen << 4)); /* On WHILEM */ } if (data && fl & (SF_HAS_PAR|SF_IN_PAR)) pars++; if (flags & SCF_DO_SUBSTR) { SV *last_str = Nullsv; int counted = mincount != 0; if (data->last_end > 0 && mincount != 0) { /* Ends with a string. */ #if defined(SPARC64_GCC_WORKAROUND) I32 b = 0; STRLEN l = 0; char *s = NULL; I32 old = 0; if (pos_before >= data->last_start_min) b = pos_before; else b = data->last_start_min; l = 0; s = SvPV(data->last_found, l); old = b - data->last_start_min; #else I32 b = pos_before >= data->last_start_min ? pos_before : data->last_start_min; STRLEN l; char *s = SvPV(data->last_found, l); I32 old = b - data->last_start_min; #endif if (UTF) old = utf8_hop((U8*)s, old) - (U8*)s; l -= old; /* Get the added string: */ last_str = newSVpvn(s + old, l); if (UTF) SvUTF8_on(last_str); if (deltanext == 0 && pos_before == b) { /* What was added is a constant string */ if (mincount > 1) { SvGROW(last_str, (mincount * l) + 1); repeatcpy(SvPVX(last_str) + l, SvPVX(last_str), l, mincount - 1); SvCUR(last_str) *= mincount; /* Add additional parts. */ SvCUR_set(data->last_found, SvCUR(data->last_found) - l); sv_catsv(data->last_found, last_str); { SV * sv = data->last_found; MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL; if (mg && mg->mg_len >= 0) mg->mg_len += CHR_SVLEN(last_str); } data->last_end += l * (mincount - 1); } } else { /* start offset must point into the last copy */ data->last_start_min += minnext * (mincount - 1); data->last_start_max += is_inf ? I32_MAX : (maxcount - 1) * (minnext + data->pos_delta); } } /* It is counted once already... */ data->pos_min += minnext * (mincount - counted); data->pos_delta += - counted * deltanext + (minnext + deltanext) * maxcount - minnext * mincount; if (mincount != maxcount) { /* Cannot extend fixed substrings found inside the group. */ scan_commit(pRExC_state,data); if (mincount && last_str) { sv_setsv(data->last_found, last_str); data->last_end = data->pos_min; data->last_start_min = data->pos_min - CHR_SVLEN(last_str); data->last_start_max = is_inf ? I32_MAX : data->pos_min + data->pos_delta - CHR_SVLEN(last_str); } data->longest = &(data->longest_float); } SvREFCNT_dec(last_str); } if (data && (fl & SF_HAS_EVAL)) data->flags |= SF_HAS_EVAL; optimize_curly_tail: if (OP(oscan) != CURLYX) { while (PL_regkind[(U8)OP(next = regnext(oscan))] == NOTHING && NEXT_OFF(next)) NEXT_OFF(oscan) += NEXT_OFF(next); } continue; default: /* REF and CLUMP only? */ if (flags & SCF_DO_SUBSTR) { scan_commit(pRExC_state,data); /* Cannot expect anything... */ data->longest = &(data->longest_float); } is_inf = is_inf_internal = 1; if (flags & SCF_DO_STCLASS_OR) cl_anything(pRExC_state, data->start_class); flags &= ~SCF_DO_STCLASS; break; } } else if (strchr((char*)PL_simple,OP(scan))) { int value = 0; if (flags & SCF_DO_SUBSTR) { scan_commit(pRExC_state,data); data->pos_min++; } min++; if (flags & SCF_DO_STCLASS) { data->start_class->flags &= ~ANYOF_EOS; /* No match on empty */ /* Some of the logic below assumes that switching locale on will only add false positives. */ switch (PL_regkind[(U8)OP(scan)]) { case SANY: default: do_default: /* Perl_croak(aTHX_ "panic: unexpected simple REx opcode %d", OP(scan)); */ if (flags & SCF_DO_STCLASS_OR) /* Allow everything */ cl_anything(pRExC_state, data->start_class); break; case REG_ANY: if (OP(scan) == SANY) goto do_default; if (flags & SCF_DO_STCLASS_OR) { /* Everything but \n */ value = (ANYOF_BITMAP_TEST(data->start_class,'\n') || (data->start_class->flags & ANYOF_CLASS)); cl_anything(pRExC_state, data->start_class); } if (flags & SCF_DO_STCLASS_AND || !value) ANYOF_BITMAP_CLEAR(data->start_class,'\n'); break; case ANYOF: if (flags & SCF_DO_STCLASS_AND) cl_and(data->start_class, (struct regnode_charclass_class*)scan); else cl_or(pRExC_state, data->start_class, (struct regnode_charclass_class*)scan); break; case ALNUM: if (flags & SCF_DO_STCLASS_AND) { if (!(data->start_class->flags & ANYOF_LOCALE)) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_NALNUM); for (value = 0; value < 256; value++) if (!isALNUM(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } } else { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_SET(data->start_class,ANYOF_ALNUM); else { for (value = 0; value < 256; value++) if (isALNUM(value)) ANYOF_BITMAP_SET(data->start_class, value); } } break; case ALNUML: if (flags & SCF_DO_STCLASS_AND) { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_CLEAR(data->start_class,ANYOF_NALNUM); } else { ANYOF_CLASS_SET(data->start_class,ANYOF_ALNUM); data->start_class->flags |= ANYOF_LOCALE; } break; case NALNUM: if (flags & SCF_DO_STCLASS_AND) { if (!(data->start_class->flags & ANYOF_LOCALE)) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_ALNUM); for (value = 0; value < 256; value++) if (isALNUM(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } } else { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_SET(data->start_class,ANYOF_NALNUM); else { for (value = 0; value < 256; value++) if (!isALNUM(value)) ANYOF_BITMAP_SET(data->start_class, value); } } break; case NALNUML: if (flags & SCF_DO_STCLASS_AND) { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_CLEAR(data->start_class,ANYOF_ALNUM); } else { data->start_class->flags |= ANYOF_LOCALE; ANYOF_CLASS_SET(data->start_class,ANYOF_NALNUM); } break; case SPACE: if (flags & SCF_DO_STCLASS_AND) { if (!(data->start_class->flags & ANYOF_LOCALE)) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_NSPACE); for (value = 0; value < 256; value++) if (!isSPACE(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } } else { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_SET(data->start_class,ANYOF_SPACE); else { for (value = 0; value < 256; value++) if (isSPACE(value)) ANYOF_BITMAP_SET(data->start_class, value); } } break; case SPACEL: if (flags & SCF_DO_STCLASS_AND) { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_CLEAR(data->start_class,ANYOF_NSPACE); } else { data->start_class->flags |= ANYOF_LOCALE; ANYOF_CLASS_SET(data->start_class,ANYOF_SPACE); } break; case NSPACE: if (flags & SCF_DO_STCLASS_AND) { if (!(data->start_class->flags & ANYOF_LOCALE)) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_SPACE); for (value = 0; value < 256; value++) if (isSPACE(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } } else { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_SET(data->start_class,ANYOF_NSPACE); else { for (value = 0; value < 256; value++) if (!isSPACE(value)) ANYOF_BITMAP_SET(data->start_class, value); } } break; case NSPACEL: if (flags & SCF_DO_STCLASS_AND) { if (data->start_class->flags & ANYOF_LOCALE) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_SPACE); for (value = 0; value < 256; value++) if (!isSPACE(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } } else { data->start_class->flags |= ANYOF_LOCALE; ANYOF_CLASS_SET(data->start_class,ANYOF_NSPACE); } break; case DIGIT: if (flags & SCF_DO_STCLASS_AND) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_NDIGIT); for (value = 0; value < 256; value++) if (!isDIGIT(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } else { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_SET(data->start_class,ANYOF_DIGIT); else { for (value = 0; value < 256; value++) if (isDIGIT(value)) ANYOF_BITMAP_SET(data->start_class, value); } } break; case NDIGIT: if (flags & SCF_DO_STCLASS_AND) { ANYOF_CLASS_CLEAR(data->start_class,ANYOF_DIGIT); for (value = 0; value < 256; value++) if (isDIGIT(value)) ANYOF_BITMAP_CLEAR(data->start_class, value); } else { if (data->start_class->flags & ANYOF_LOCALE) ANYOF_CLASS_SET(data->start_class,ANYOF_NDIGIT); else { for (value = 0; value < 256; value++) if (!isDIGIT(value)) ANYOF_BITMAP_SET(data->start_class, value); } } break; } if (flags & SCF_DO_STCLASS_OR) cl_and(data->start_class, &and_with); flags &= ~SCF_DO_STCLASS; } } else if (PL_regkind[(U8)OP(scan)] == EOL && flags & SCF_DO_SUBSTR) { data->flags |= (OP(scan) == MEOL ? SF_BEFORE_MEOL : SF_BEFORE_SEOL); } else if ( PL_regkind[(U8)OP(scan)] == BRANCHJ /* Lookbehind, or need to calculate parens/evals/stclass: */ && (scan->flags || data || (flags & SCF_DO_STCLASS)) && (OP(scan) == IFMATCH || OP(scan) == UNLESSM)) { /* Lookahead/lookbehind */ I32 deltanext, minnext, fake = 0; regnode *nscan; struct regnode_charclass_class intrnl; int f = 0; data_fake.flags = 0; if (data) { data_fake.whilem_c = data->whilem_c; data_fake.last_closep = data->last_closep; } else data_fake.last_closep = &fake; if ( flags & SCF_DO_STCLASS && !scan->flags && OP(scan) == IFMATCH ) { /* Lookahead */ cl_init(pRExC_state, &intrnl); data_fake.start_class = &intrnl; f |= SCF_DO_STCLASS_AND; } if (flags & SCF_WHILEM_VISITED_POS) f |= SCF_WHILEM_VISITED_POS; next = regnext(scan); nscan = NEXTOPER(NEXTOPER(scan)); minnext = study_chunk(pRExC_state, &nscan, &deltanext, last, &data_fake, f); if (scan->flags) { if (deltanext) { vFAIL("Variable length lookbehind not implemented"); } else if (minnext > U8_MAX) { vFAIL2("Lookbehind longer than %"UVuf" not implemented", (UV)U8_MAX); } scan->flags = (U8)minnext; } if (data && data_fake.flags & (SF_HAS_PAR|SF_IN_PAR)) pars++; if (data && (data_fake.flags & SF_HAS_EVAL)) data->flags |= SF_HAS_EVAL; if (data) data->whilem_c = data_fake.whilem_c; if (f & SCF_DO_STCLASS_AND) { int was = (data->start_class->flags & ANYOF_EOS); cl_and(data->start_class, &intrnl); if (was) data->start_class->flags |= ANYOF_EOS; } } else if (OP(scan) == OPEN) { pars++; } else if (OP(scan) == CLOSE) { if ((I32)ARG(scan) == is_par) { next = regnext(scan); if ( next && (OP(next) != WHILEM) && next < last) is_par = 0; /* Disable optimization */ } if (data) *(data->last_closep) = ARG(scan); } else if (OP(scan) == EVAL) { if (data) data->flags |= SF_HAS_EVAL; } else if (OP(scan) == LOGICAL && scan->flags == 2) { /* Embedded follows */ if (flags & SCF_DO_SUBSTR) { scan_commit(pRExC_state,data); data->longest = &(data->longest_float); } is_inf = is_inf_internal = 1; if (flags & SCF_DO_STCLASS_OR) /* Allow everything */ cl_anything(pRExC_state, data->start_class); flags &= ~SCF_DO_STCLASS; } /* Else: zero-length, ignore. */ scan = regnext(scan); } finish: *scanp = scan; *deltap = is_inf_internal ? I32_MAX : delta; if (flags & SCF_DO_SUBSTR && is_inf) data->pos_delta = I32_MAX - data->pos_min; if (is_par > U8_MAX) is_par = 0; if (is_par && pars==1 && data) { data->flags |= SF_IN_PAR; data->flags &= ~SF_HAS_PAR; } else if (pars && data) { data->flags |= SF_HAS_PAR; data->flags &= ~SF_IN_PAR; } if (flags & SCF_DO_STCLASS_OR) cl_and(data->start_class, &and_with); return min; } STATIC I32 S_add_data(pTHX_ RExC_state_t *pRExC_state, I32 n, char *s) { if (RExC_rx->data) { Renewc(RExC_rx->data, sizeof(*RExC_rx->data) + sizeof(void*) * (RExC_rx->data->count + n - 1), char, struct reg_data); Renew(RExC_rx->data->what, RExC_rx->data->count + n, U8); RExC_rx->data->count += n; } else { Newc(1207, RExC_rx->data, sizeof(*RExC_rx->data) + sizeof(void*) * (n - 1), char, struct reg_data); New(1208, RExC_rx->data->what, n, U8); RExC_rx->data->count = n; } Copy(s, RExC_rx->data->what + RExC_rx->data->count - n, n, U8); return RExC_rx->data->count - n; } void Perl_reginitcolors(pTHX) { int i = 0; char *s = PerlEnv_getenv("PERL_RE_COLORS"); if (s) { PL_colors[0] = s = savepv(s); while (++i < 6) { s = strchr(s, '\t'); if (s) { *s = '\0'; PL_colors[i] = ++s; } else PL_colors[i] = s = ""; } } else { while (i < 6) PL_colors[i++] = ""; } PL_colorset = 1; } /* - pregcomp - compile a regular expression into internal code * * We can't allocate space until we know how big the compiled form will be, * but we can't compile it (and thus know how big it is) until we've got a * place to put the code. So we cheat: we compile it twice, once with code * generation turned off and size counting turned on, and once "for real". * This also means that we don't allocate space until we are sure that the * thing really will compile successfully, and we never have to move the * code and thus invalidate pointers into it. (Note that it has to be in * one piece because free() must be able to free it all.) [NB: not true in perl] * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. [I'll say.] */ regexp * Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) { register regexp *r; regnode *scan; regnode *first; I32 flags; I32 minlen = 0; I32 sawplus = 0; I32 sawopen = 0; scan_data_t data; RExC_state_t RExC_state; RExC_state_t *pRExC_state = &RExC_state; if (exp == NULL) FAIL("NULL regexp argument"); RExC_utf8 = pm->op_pmdynflags & PMdf_CMP_UTF8; RExC_precomp = exp; DEBUG_r({ if (!PL_colorset) reginitcolors(); PerlIO_printf(Perl_debug_log, "%sCompiling REx%s `%s%*s%s'\n", PL_colors[4],PL_colors[5],PL_colors[0], (int)(xend - exp), RExC_precomp, PL_colors[1]); }); RExC_flags = pm->op_pmflags; RExC_sawback = 0; RExC_seen = 0; RExC_seen_zerolen = *exp == '^' ? -1 : 0; RExC_seen_evals = 0; RExC_extralen = 0; /* First pass: determine size, legality. */ RExC_parse = exp; RExC_start = exp; RExC_end = xend; RExC_naughty = 0; RExC_npar = 1; RExC_size = 0L; RExC_emit = &PL_regdummy; RExC_whilem_seen = 0; #if 0 /* REGC() is (currently) a NOP at the first pass. * Clever compilers notice this and complain. --jhi */ REGC((U8)REG_MAGIC, (char*)RExC_emit); #endif if (reg(pRExC_state, 0, &flags) == NULL) { RExC_precomp = Nullch; return(NULL); } DEBUG_r(PerlIO_printf(Perl_debug_log, "size %"IVdf" ", (IV)RExC_size)); /* Small enough for pointer-storage convention? If extralen==0, this means that we will not need long jumps. */ if (RExC_size >= 0x10000L && RExC_extralen) RExC_size += RExC_extralen; else RExC_extralen = 0; if (RExC_whilem_seen > 15) RExC_whilem_seen = 15; /* Allocate space and initialize. */ Newc(1001, r, sizeof(regexp) + (unsigned)RExC_size * sizeof(regnode), char, regexp); if (r == NULL) FAIL("Regexp out of space"); #ifdef DEBUGGING /* avoid reading uninitialized memory in DEBUGGING code in study_chunk() */ Zero(r, sizeof(regexp) + (unsigned)RExC_size * sizeof(regnode), char); #endif r->refcnt = 1; r->prelen = xend - exp; r->precomp = savepvn(RExC_precomp, r->prelen); r->subbeg = NULL; r->reganch = pm->op_pmflags & PMf_COMPILETIME; r->nparens = RExC_npar - 1; /* set early to validate backrefs */ r->substrs = 0; /* Useful during FAIL. */ r->startp = 0; /* Useful during FAIL. */ r->endp = 0; /* Useful during FAIL. */ Newz(1304, r->offsets, 2*RExC_size+1, U32); /* MJD 20001228 */ if (r->offsets) { r->offsets[0] = RExC_size; } DEBUG_r(PerlIO_printf(Perl_debug_log, "%s %"UVuf" bytes for offset annotations.\n", r->offsets ? "Got" : "Couldn't get", (UV)((2*RExC_size+1) * sizeof(U32)))); RExC_rx = r; /* Second pass: emit code. */ RExC_flags = pm->op_pmflags; /* don't let top level (?i) bleed */ RExC_parse = exp; RExC_end = xend; RExC_naughty = 0; RExC_npar = 1; RExC_emit_start = r->program; RExC_emit = r->program; /* Store the count of eval-groups for security checks: */ RExC_emit->next_off = (U16)((RExC_seen_evals > U16_MAX) ? U16_MAX : RExC_seen_evals); REGC((U8)REG_MAGIC, (char*) RExC_emit++); r->data = 0; if (reg(pRExC_state, 0, &flags) == NULL) return(NULL); /* Dig out information for optimizations. */ r->reganch = pm->op_pmflags & PMf_COMPILETIME; /* Again? */ pm->op_pmflags = RExC_flags; if (UTF) r->reganch |= ROPT_UTF8; /* Unicode in it? */ r->regstclass = NULL; if (RExC_naughty >= 10) /* Probably an expensive pattern. */ r->reganch |= ROPT_NAUGHTY; scan = r->program + 1; /* First BRANCH. */ /* XXXX To minimize changes to RE engine we always allocate 3-units-long substrs field. */ Newz(1004, r->substrs, 1, struct reg_substr_data); StructCopy(&zero_scan_data, &data, scan_data_t); /* XXXX Should not we check for something else? Usually it is OPEN1... */ if (OP(scan) != BRANCH) { /* Only one top-level choice. */ I32 fake; STRLEN longest_float_length, longest_fixed_length; struct regnode_charclass_class ch_class; int stclass_flag; I32 last_close = 0; first = scan; /* Skip introductions and multiplicators >= 1. */ while ((OP(first) == OPEN && (sawopen = 1)) || /* An OR of *one* alternative - should not happen now. */ (OP(first) == BRANCH && OP(regnext(first)) != BRANCH) || (OP(first) == PLUS) || (OP(first) == MINMOD) || /* An {n,m} with n>0 */ (PL_regkind[(U8)OP(first)] == CURLY && ARG1(first) > 0) ) { if (OP(first) == PLUS) sawplus = 1; else first += regarglen[(U8)OP(first)]; first = NEXTOPER(first); } /* Starting-point info. */ again: if (PL_regkind[(U8)OP(first)] == EXACT) { if (OP(first) == EXACT) ; /* Empty, get anchored substr later. */ else if ((OP(first) == EXACTF || OP(first) == EXACTFL)) r->regstclass = first; } else if (strchr((char*)PL_simple,OP(first))) r->regstclass = first; else if (PL_regkind[(U8)OP(first)] == BOUND || PL_regkind[(U8)OP(first)] == NBOUND) r->regstclass = first; else if (PL_regkind[(U8)OP(first)] == BOL) { r->reganch |= (OP(first) == MBOL ? ROPT_ANCH_MBOL : (OP(first) == SBOL ? ROPT_ANCH_SBOL : ROPT_ANCH_BOL)); first = NEXTOPER(first); goto again; } else if (OP(first) == GPOS) { r->reganch |= ROPT_ANCH_GPOS; first = NEXTOPER(first); goto again; } else if (!sawopen && (OP(first) == STAR && PL_regkind[(U8)OP(NEXTOPER(first))] == REG_ANY) && !(r->reganch & ROPT_ANCH) ) { /* turn .* into ^.* with an implied $*=1 */ int type = OP(NEXTOPER(first)); if (type == REG_ANY) type = ROPT_ANCH_MBOL; else type = ROPT_ANCH_SBOL; r->reganch |= type | ROPT_IMPLICIT; first = NEXTOPER(first); goto again; } if (sawplus && (!sawopen || !RExC_sawback) && !(RExC_seen & REG_SEEN_EVAL)) /* May examine pos and $& */ /* x+ must match at the 1st pos of run of x's */ r->reganch |= ROPT_SKIP; /* Scan is after the zeroth branch, first is atomic matcher. */ DEBUG_r(PerlIO_printf(Perl_debug_log, "first at %"IVdf"\n", (IV)(first - scan + 1))); /* * If there's something expensive in the r.e., find the * longest literal string that must appear and make it the * regmust. Resolve ties in favor of later strings, since * the regstart check works with the beginning of the r.e. * and avoiding duplication strengthens checking. Not a * strong reason, but sufficient in the absence of others. * [Now we resolve ties in favor of the earlier string if * it happens that c_offset_min has been invalidated, since the * earlier string may buy us something the later one won't.] */ minlen = 0; data.longest_fixed = newSVpvn("",0); data.longest_float = newSVpvn("",0); data.last_found = newSVpvn("",0); data.longest = &(data.longest_fixed); first = scan; if (!r->regstclass) { cl_init(pRExC_state, &ch_class); data.start_class = &ch_class; stclass_flag = SCF_DO_STCLASS_AND; } else /* XXXX Check for BOUND? */ stclass_flag = 0; data.last_closep = &last_close; minlen = study_chunk(pRExC_state, &first, &fake, scan + RExC_size, /* Up to end */ &data, SCF_DO_SUBSTR | SCF_WHILEM_VISITED_POS | stclass_flag); if ( RExC_npar == 1 && data.longest == &(data.longest_fixed) && data.last_start_min == 0 && data.last_end > 0 && !RExC_seen_zerolen && (!(RExC_seen & REG_SEEN_GPOS) || (r->reganch & ROPT_ANCH_GPOS))) r->reganch |= ROPT_CHECK_ALL; scan_commit(pRExC_state, &data); SvREFCNT_dec(data.last_found); longest_float_length = CHR_SVLEN(data.longest_float); if (longest_float_length || (data.flags & SF_FL_BEFORE_EOL && (!(data.flags & SF_FL_BEFORE_MEOL) || (RExC_flags & PMf_MULTILINE)))) { int t; if (SvCUR(data.longest_fixed) /* ok to leave SvCUR */ && data.offset_fixed == data.offset_float_min && SvCUR(data.longest_fixed) == SvCUR(data.longest_float)) goto remove_float; /* As in (a)+. */ if (SvUTF8(data.longest_float)) { r->float_utf8 = data.longest_float; r->float_substr = Nullsv; } else { r->float_substr = data.longest_float; r->float_utf8 = Nullsv; } r->float_min_offset = data.offset_float_min; r->float_max_offset = data.offset_float_max; t = (data.flags & SF_FL_BEFORE_EOL /* Can't have SEOL and MULTI */ && (!(data.flags & SF_FL_BEFORE_MEOL) || (RExC_flags & PMf_MULTILINE))); fbm_compile(data.longest_float, t ? FBMcf_TAIL : 0); } else { remove_float: r->float_substr = r->float_utf8 = Nullsv; SvREFCNT_dec(data.longest_float); longest_float_length = 0; } longest_fixed_length = CHR_SVLEN(data.longest_fixed); if (longest_fixed_length || (data.flags & SF_FIX_BEFORE_EOL /* Cannot have SEOL and MULTI */ && (!(data.flags & SF_FIX_BEFORE_MEOL) || (RExC_flags & PMf_MULTILINE)))) { int t; if (SvUTF8(data.longest_fixed)) { r->anchored_utf8 = data.longest_fixed; r->anchored_substr = Nullsv; } else { r->anchored_substr = data.longest_fixed; r->anchored_utf8 = Nullsv; } r->anchored_offset = data.offset_fixed; t = (data.flags & SF_FIX_BEFORE_EOL /* Can't have SEOL and MULTI */ && (!(data.flags & SF_FIX_BEFORE_MEOL) || (RExC_flags & PMf_MULTILINE))); fbm_compile(data.longest_fixed, t ? FBMcf_TAIL : 0); } else { r->anchored_substr = r->anchored_utf8 = Nullsv; SvREFCNT_dec(data.longest_fixed); longest_fixed_length = 0; } if (r->regstclass && (OP(r->regstclass) == REG_ANY || OP(r->regstclass) == SANY)) r->regstclass = NULL; if ((!(r->anchored_substr || r->anchored_utf8) || r->anchored_offset) && stclass_flag && !(data.start_class->flags & ANYOF_EOS) && !cl_is_anything(data.start_class)) { I32 n = add_data(pRExC_state, 1, "f"); New(1006, RExC_rx->data->data[n], 1, struct regnode_charclass_class); StructCopy(data.start_class, (struct regnode_charclass_class*)RExC_rx->data->data[n], struct regnode_charclass_class); r->regstclass = (regnode*)RExC_rx->data->data[n]; r->reganch &= ~ROPT_SKIP; /* Used in find_byclass(). */ PL_regdata = r->data; /* for regprop() */ DEBUG_r({ SV *sv = sv_newmortal(); regprop(sv, (regnode*)data.start_class); PerlIO_printf(Perl_debug_log, "synthetic stclass `%s'.\n", SvPVX(sv));}); } /* A temporary algorithm prefers floated substr to fixed one to dig more info. */ if (longest_fixed_length > longest_float_length) { r->check_substr = r->anchored_substr; r->check_utf8 = r->anchored_utf8; r->check_offset_min = r->check_offset_max = r->anchored_offset; if (r->reganch & ROPT_ANCH_SINGLE) r->reganch |= ROPT_NOSCAN; } else { r->check_substr = r->float_substr; r->check_utf8 = r->float_utf8; r->check_offset_min = data.offset_float_min; r->check_offset_max = data.offset_float_max; } /* XXXX Currently intuiting is not compatible with ANCH_GPOS. This should be changed ASAP! */ if ((r->check_substr || r->check_utf8) && !(r->reganch & ROPT_ANCH_GPOS)) { r->reganch |= RE_USE_INTUIT; if (SvTAIL(r->check_substr ? r->check_substr : r->check_utf8)) r->reganch |= RE_INTUIT_TAIL; } } else { /* Several toplevels. Best we can is to set minlen. */ I32 fake; struct regnode_charclass_class ch_class; I32 last_close = 0; DEBUG_r(PerlIO_printf(Perl_debug_log, "\n")); scan = r->program + 1; cl_init(pRExC_state, &ch_class); data.start_class = &ch_class; data.last_closep = &last_close; minlen = study_chunk(pRExC_state, &scan, &fake, scan + RExC_size, &data, SCF_DO_STCLASS_AND|SCF_WHILEM_VISITED_POS); r->check_substr = r->check_utf8 = r->anchored_substr = r->anchored_utf8 = r->float_substr = r->float_utf8 = Nullsv; if (!(data.start_class->flags & ANYOF_EOS) && !cl_is_anything(data.start_class)) { I32 n = add_data(pRExC_state, 1, "f"); New(1006, RExC_rx->data->data[n], 1, struct regnode_charclass_class); StructCopy(data.start_class, (struct regnode_charclass_class*)RExC_rx->data->data[n], struct regnode_charclass_class); r->regstclass = (regnode*)RExC_rx->data->data[n]; r->reganch &= ~ROPT_SKIP; /* Used in find_byclass(). */ DEBUG_r({ SV* sv = sv_newmortal(); regprop(sv, (regnode*)data.start_class); PerlIO_printf(Perl_debug_log, "synthetic stclass `%s'.\n", SvPVX(sv));}); } } r->minlen = minlen; if (RExC_seen & REG_SEEN_GPOS) r->reganch |= ROPT_GPOS_SEEN; if (RExC_seen & REG_SEEN_LOOKBEHIND) r->reganch |= ROPT_LOOKBEHIND_SEEN; if (RExC_seen & REG_SEEN_EVAL) r->reganch |= ROPT_EVAL_SEEN; if (RExC_seen & REG_SEEN_CANY) r->reganch |= ROPT_CANY_SEEN; Newz(1002, r->startp, RExC_npar, I32); Newz(1002, r->endp, RExC_npar, I32); PL_regdata = r->data; /* for regprop() */ DEBUG_r(regdump(r)); return(r); } /* - reg - regular expression, i.e. main body or parenthesized thing * * Caller must absorb opening parenthesis. * * Combining parenthesis handling with the base level of regular expression * is a trifle forced, but the need to tie the tails of the branches to what * follows makes it hard to avoid. */ STATIC regnode * S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp) /* paren: Parenthesized? 0=top, 1=(, inside: changed to letter. */ { register regnode *ret; /* Will be the head of the group. */ register regnode *br; register regnode *lastbr; register regnode *ender = 0; register I32 parno = 0; I32 flags, oregflags = RExC_flags, have_branch = 0, open = 0; /* for (?g), (?gc), and (?o) warnings; warning about (?c) will warn about (?g) -- japhy */ I32 wastedflags = 0x00, wasted_o = 0x01, wasted_g = 0x02, wasted_gc = 0x02 | 0x04, wasted_c = 0x04; char * parse_start = RExC_parse; /* MJD */ char *oregcomp_parse = RExC_parse; char c; *flagp = 0; /* Tentatively. */ /* Make an OPEN node, if parenthesized. */ if (paren) { if (*RExC_parse == '?') { /* (?...) */ U32 posflags = 0, negflags = 0; U32 *flagsp = &posflags; int logical = 0; char *seqstart = RExC_parse; RExC_parse++; paren = *RExC_parse++; ret = NULL; /* For look-ahead/behind. */ switch (paren) { case '<': /* (?<...) */ RExC_seen |= REG_SEEN_LOOKBEHIND; if (*RExC_parse == '!') paren = ','; if (*RExC_parse != '=' && *RExC_parse != '!') goto unknown; RExC_parse++; case '=': /* (?=...) */ case '!': /* (?!...) */ RExC_seen_zerolen++; case ':': /* (?:...) */ case '>': /* (?>...) */ break; case '$': /* (?$...) */ case '@': /* (?@...) */ vFAIL2("Sequence (?%c...) not implemented", (int)paren); break; case '#': /* (?#...) */ while (*RExC_parse && *RExC_parse != ')') RExC_parse++; if (*RExC_parse != ')') FAIL("Sequence (?#... not terminated"); nextchar(pRExC_state); *flagp = TRYAGAIN; return NULL; case 'p': /* (?p...) */ if (SIZE_ONLY && ckWARN2(WARN_DEPRECATED, WARN_REGEXP)) vWARNdep(RExC_parse, "(?p{}) is deprecated - use (??{})"); /* FALL THROUGH*/ case '?': /* (??...) */ logical = 1; if (*RExC_parse != '{') goto unknown; paren = *RExC_parse++; /* FALL THROUGH */ case '{': /* (?{...}) */ { I32 count = 1, n = 0; char c; char *s = RExC_parse; SV *sv; OP_4tree *sop, *rop; RExC_seen_zerolen++; RExC_seen |= REG_SEEN_EVAL; while (count && (c = *RExC_parse)) { if (c == '\\' && RExC_parse[1]) RExC_parse++; else if (c == '{') count++; else if (c == '}') count--; RExC_parse++; } if (*RExC_parse != ')') { RExC_parse = s; vFAIL("Sequence (?{...}) not terminated or not {}-balanced"); } if (!SIZE_ONLY) { PAD *pad; if (RExC_parse - 1 - s) sv = newSVpvn(s, RExC_parse - 1 - s); else sv = newSVpvn("", 0); ENTER; Perl_save_re_context(aTHX); rop = sv_compile_2op(sv, &sop, "re", &pad); sop->op_private |= OPpREFCOUNTED; /* re_dup will OpREFCNT_inc */ OpREFCNT_set(sop, 1); LEAVE; n = add_data(pRExC_state, 3, "nop"); RExC_rx->data->data[n] = (void*)rop; RExC_rx->data->data[n+1] = (void*)sop; RExC_rx->data->data[n+2] = (void*)pad; SvREFCNT_dec(sv); } else { /* First pass */ if (PL_reginterp_cnt < ++RExC_seen_evals && IN_PERL_RUNTIME) /* No compiled RE interpolated, has runtime components ===> unsafe. */ FAIL("Eval-group not allowed at runtime, use re 'eval'"); if (PL_tainting && PL_tainted) FAIL("Eval-group in insecure regular expression"); } nextchar(pRExC_state); if (logical) { ret = reg_node(pRExC_state, LOGICAL); if (!SIZE_ONLY) ret->flags = 2; regtail(pRExC_state, ret, reganode(pRExC_state, EVAL, n)); /* deal with the length of this later - MJD */ return ret; } ret = reganode(pRExC_state, EVAL, n); Set_Node_Length(ret, RExC_parse - parse_start + 1); Set_Node_Offset(ret, parse_start); return ret; } case '(': /* (?(?{...})...) and (?(?=...)...) */ { if (RExC_parse[0] == '?') { /* (?(?...)) */ if (RExC_parse[1] == '=' || RExC_parse[1] == '!' || RExC_parse[1] == '<' || RExC_parse[1] == '{') { /* Lookahead or eval. */ I32 flag; ret = reg_node(pRExC_state, LOGICAL); if (!SIZE_ONLY) ret->flags = 1; regtail(pRExC_state, ret, reg(pRExC_state, 1, &flag)); goto insert_if; } } else if (RExC_parse[0] >= '1' && RExC_parse[0] <= '9' ) { /* (?(1)...) */ parno = atoi(RExC_parse++); while (isDIGIT(*RExC_parse)) RExC_parse++; ret = reganode(pRExC_state, GROUPP, parno); if ((c = *nextchar(pRExC_state)) != ')') vFAIL("Switch condition not recognized"); insert_if: regtail(pRExC_state, ret, reganode(pRExC_state, IFTHEN, 0)); br = regbranch(pRExC_state, &flags, 1); if (br == NULL) br = reganode(pRExC_state, LONGJMP, 0); else regtail(pRExC_state, br, reganode(pRExC_state, LONGJMP, 0)); c = *nextchar(pRExC_state); if (flags&HASWIDTH) *flagp |= HASWIDTH; if (c == '|') { lastbr = reganode(pRExC_state, IFTHEN, 0); /* Fake one for optimizer. */ regbranch(pRExC_state, &flags, 1); regtail(pRExC_state, ret, lastbr); if (flags&HASWIDTH) *flagp |= HASWIDTH; c = *nextchar(pRExC_state); } else lastbr = NULL; if (c != ')') vFAIL("Switch (?(condition)... contains too many branches"); ender = reg_node(pRExC_state, TAIL); regtail(pRExC_state, br, ender); if (lastbr) { regtail(pRExC_state, lastbr, ender); regtail(pRExC_state, NEXTOPER(NEXTOPER(lastbr)), ender); } else regtail(pRExC_state, ret, ender); return ret; } else { vFAIL2("Unknown switch condition (?(%.2s", RExC_parse); } } case 0: RExC_parse--; /* for vFAIL to print correctly */ vFAIL("Sequence (? incomplete"); break; default: --RExC_parse; parse_flags: /* (?i) */ while (*RExC_parse && strchr("iogcmsx", *RExC_parse)) { /* (?g), (?gc) and (?o) are useless here and must be globally applied -- japhy */ if (*RExC_parse == 'o' || *RExC_parse == 'g') { if (SIZE_ONLY && ckWARN(WARN_REGEXP)) { I32 wflagbit = *RExC_parse == 'o' ? wasted_o : wasted_g; if (! (wastedflags & wflagbit) ) { wastedflags |= wflagbit; vWARN5( RExC_parse + 1, "Useless (%s%c) - %suse /%c modifier", flagsp == &negflags ? "?-" : "?", *RExC_parse, flagsp == &negflags ? "don't " : "", *RExC_parse ); } } } else if (*RExC_parse == 'c') { if (SIZE_ONLY && ckWARN(WARN_REGEXP)) { if (! (wastedflags & wasted_c) ) { wastedflags |= wasted_gc; vWARN3( RExC_parse + 1, "Useless (%sc) - %suse /gc modifier", flagsp == &negflags ? "?-" : "?", flagsp == &negflags ? "don't " : "" ); } } } else { pmflag(flagsp, *RExC_parse); } ++RExC_parse; } if (*RExC_parse == '-') { flagsp = &negflags; wastedflags = 0; /* reset so (?g-c) warns twice */ ++RExC_parse; goto parse_flags; } RExC_flags |= posflags; RExC_flags &= ~negflags; if (*RExC_parse == ':') { RExC_parse++; paren = ':'; break; } unknown: if (*RExC_parse != ')') { RExC_parse++; vFAIL3("Sequence (%.*s...) not recognized", RExC_parse-seqstart, seqstart); } nextchar(pRExC_state); *flagp = TRYAGAIN; return NULL; } } else { /* (...) */ parno = RExC_npar; RExC_npar++; ret = reganode(pRExC_state, OPEN, parno); Set_Node_Length(ret, 1); /* MJD */ Set_Node_Offset(ret, RExC_parse); /* MJD */ open = 1; } } else /* ! paren */ ret = NULL; /* Pick up the branches, linking them together. */ parse_start = RExC_parse; /* MJD */ br = regbranch(pRExC_state, &flags, 1); /* branch_len = (paren != 0); */ if (br == NULL) return(NULL); if (*RExC_parse == '|') { if (!SIZE_ONLY && RExC_extralen) { reginsert(pRExC_state, BRANCHJ, br); } else { /* MJD */ reginsert(pRExC_state, BRANCH, br); Set_Node_Length(br, paren != 0); Set_Node_Offset_To_R(br-RExC_emit_start, parse_start-RExC_start); } have_branch = 1; if (SIZE_ONLY) RExC_extralen += 1; /* For BRANCHJ-BRANCH. */ } else if (paren == ':') { *flagp |= flags&SIMPLE; } if (open) { /* Starts with OPEN. */ regtail(pRExC_state, ret, br); /* OPEN -> first. */ } else if (paren != '?') /* Not Conditional */ ret = br; *flagp |= flags & (SPSTART | HASWIDTH); lastbr = br; while (*RExC_parse == '|') { if (!SIZE_ONLY && RExC_extralen) { ender = reganode(pRExC_state, LONGJMP,0); regtail(pRExC_state, NEXTOPER(NEXTOPER(lastbr)), ender); /* Append to the previous. */ } if (SIZE_ONLY) RExC_extralen += 2; /* Account for LONGJMP. */ nextchar(pRExC_state); br = regbranch(pRExC_state, &flags, 0); if (br == NULL) return(NULL); regtail(pRExC_state, lastbr, br); /* BRANCH -> BRANCH. */ lastbr = br; if (flags&HASWIDTH) *flagp |= HASWIDTH; *flagp |= flags&SPSTART; } if (have_branch || paren != ':') { /* Make a closing node, and hook it on the end. */ switch (paren) { case ':': ender = reg_node(pRExC_state, TAIL); break; case 1: ender = reganode(pRExC_state, CLOSE, parno); Set_Node_Offset(ender,RExC_parse+1); /* MJD */ Set_Node_Length(ender,1); /* MJD */ break; case '<': case ',': case '=': case '!': *flagp &= ~HASWIDTH; /* FALL THROUGH */ case '>': ender = reg_node(pRExC_state, SUCCEED); break; case 0: ender = reg_node(pRExC_state, END); break; } regtail(pRExC_state, lastbr, ender); if (have_branch) { /* Hook the tails of the branches to the closing node. */ for (br = ret; br != NULL; br = regnext(br)) { regoptail(pRExC_state, br, ender); } } } { char *p; static char parens[] = "=!<,>"; if (paren && (p = strchr(parens, paren))) { U8 node = ((p - parens) % 2) ? UNLESSM : IFMATCH; int flag = (p - parens) > 1; if (paren == '>') node = SUSPEND, flag = 0; reginsert(pRExC_state, node,ret); Set_Node_Cur_Length(ret); Set_Node_Offset(ret, parse_start + 1); ret->flags = flag; regtail(pRExC_state, ret, reg_node(pRExC_state, TAIL)); } } /* Check for proper termination. */ if (paren) { RExC_flags = oregflags; if (RExC_parse >= RExC_end || *nextchar(pRExC_state) != ')') { RExC_parse = oregcomp_parse; vFAIL("Unmatched ("); } } else if (!paren && RExC_parse < RExC_end) { if (*RExC_parse == ')') { RExC_parse++; vFAIL("Unmatched )"); } else FAIL("Junk on end of regexp"); /* "Can't happen". */ /* NOTREACHED */ } return(ret); } /* - regbranch - one alternative of an | operator * * Implements the concatenation operator. */ STATIC regnode * S_regbranch(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, I32 first) { register regnode *ret; register regnode *chain = NULL; register regnode *latest; I32 flags = 0, c = 0; if (first) ret = NULL; else { if (!SIZE_ONLY && RExC_extralen) ret = reganode(pRExC_state, BRANCHJ,0); else { ret = reg_node(pRExC_state, BRANCH); Set_Node_Length(ret, 1); } } if (!first && SIZE_ONLY) RExC_extralen += 1; /* BRANCHJ */ *flagp = WORST; /* Tentatively. */ RExC_parse--; nextchar(pRExC_state); while (RExC_parse < RExC_end && *RExC_parse != '|' && *RExC_parse != ')') { flags &= ~TRYAGAIN; latest = regpiece(pRExC_state, &flags); if (latest == NULL) { if (flags & TRYAGAIN) continue; return(NULL); } else if (ret == NULL) ret = latest; *flagp |= flags&HASWIDTH; if (chain == NULL) /* First piece. */ *flagp |= flags&SPSTART; else { RExC_naughty++; regtail(pRExC_state, chain, latest); } chain = latest; c++; } if (chain == NULL) { /* Loop ran zero times. */ chain = reg_node(pRExC_state, NOTHING); if (ret == NULL) ret = chain; } if (c == 1) { *flagp |= flags&SIMPLE; } return(ret); } /* - regpiece - something followed by possible [*+?] * * Note that the branching code sequences used for ? and the general cases * of * and + are somewhat optimized: they use the same NOTHING node as * both the endmarker for their branch list and the body of the last branch. * It might seem that this node could be dispensed with entirely, but the * endmarker role is not redundant. */ STATIC regnode * S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp) { register regnode *ret; register char op; register char *next; I32 flags; char *origparse = RExC_parse; char *maxpos; I32 min; I32 max = REG_INFTY; char *parse_start; ret = regatom(pRExC_state, &flags); if (ret == NULL) { if (flags & TRYAGAIN) *flagp |= TRYAGAIN; return(NULL); } op = *RExC_parse; if (op == '{' && regcurly(RExC_parse)) { parse_start = RExC_parse; /* MJD */ next = RExC_parse + 1; maxpos = Nullch; while (isDIGIT(*next) || *next == ',') { if (*next == ',') { if (maxpos) break; else maxpos = next; } next++; } if (*next == '}') { /* got one */ if (!maxpos) maxpos = next; RExC_parse++; min = atoi(RExC_parse); if (*maxpos == ',') maxpos++; else maxpos = RExC_parse; max = atoi(maxpos); if (!max && *maxpos != '0') max = REG_INFTY; /* meaning "infinity" */ else if (max >= REG_INFTY) vFAIL2("Quantifier in {,} bigger than %d", REG_INFTY - 1); RExC_parse = next; nextchar(pRExC_state); do_curly: if ((flags&SIMPLE)) { RExC_naughty += 2 + RExC_naughty / 2; reginsert(pRExC_state, CURLY, ret); Set_Node_Offset(ret, parse_start+1); /* MJD */ Set_Node_Cur_Length(ret); } else { regnode *w = reg_node(pRExC_state, WHILEM); w->flags = 0; regtail(pRExC_state, ret, w); if (!SIZE_ONLY && RExC_extralen) { reginsert(pRExC_state, LONGJMP,ret); reginsert(pRExC_state, NOTHING,ret); NEXT_OFF(ret) = 3; /* Go over LONGJMP. */ } reginsert(pRExC_state, CURLYX,ret); /* MJD hk */ Set_Node_Offset(ret, parse_start+1); Set_Node_Length(ret, op == '{' ? (RExC_parse - parse_start) : 1); if (!SIZE_ONLY && RExC_extralen) NEXT_OFF(ret) = 3; /* Go over NOTHING to LONGJMP. */ regtail(pRExC_state, ret, reg_node(pRExC_state, NOTHING)); if (SIZE_ONLY) RExC_whilem_seen++, RExC_extralen += 3; RExC_naughty += 4 + RExC_naughty; /* compound interest */ } ret->flags = 0; if (min > 0) *flagp = WORST; if (max > 0) *flagp |= HASWIDTH; if (max && max < min) vFAIL("Can't do {n,m} with n > m"); if (!SIZE_ONLY) { ARG1_SET(ret, (U16)min); ARG2_SET(ret, (U16)max); } goto nest_check; } } if (!ISMULT1(op)) { *flagp = flags; return(ret); } #if 0 /* Now runtime fix should be reliable. */ /* if this is reinstated, don't forget to put this back into perldiag: =item Regexp *+ operand could be empty at {#} in regex m/%s/ (F) The part of the regexp subject to either the * or + quantifier could match an empty string. The {#} shows in the regular expression about where the problem was discovered. */ if (!(flags&HASWIDTH) && op != '?') vFAIL("Regexp *+ operand could be empty"); #endif parse_start = RExC_parse; nextchar(pRExC_state); *flagp = (op != '+') ? (WORST|SPSTART|HASWIDTH) : (WORST|HASWIDTH); if (op == '*' && (flags&SIMPLE)) { reginsert(pRExC_state, STAR, ret); ret->flags = 0; RExC_naughty += 4; } else if (op == '*') { min = 0; goto do_curly; } else if (op == '+' && (flags&SIMPLE)) { reginsert(pRExC_state, PLUS, ret); ret->flags = 0; RExC_naughty += 3; } else if (op == '+') { min = 1; goto do_curly; } else if (op == '?') { min = 0; max = 1; goto do_curly; } nest_check: if (ckWARN(WARN_REGEXP) && !SIZE_ONLY && !(flags&HASWIDTH) && max > REG_INFTY/3) { vWARN3(RExC_parse, "%.*s matches null string many times", RExC_parse - origparse, origparse); } if (*RExC_parse == '?') { nextchar(pRExC_state); reginsert(pRExC_state, MINMOD, ret); regtail(pRExC_state, ret, ret + NODE_STEP_REGNODE); } if (ISMULT2(RExC_parse)) { RExC_parse++; vFAIL("Nested quantifiers"); } return(ret); } /* - regatom - the lowest level * * Optimization: gobbles an entire sequence of ordinary characters so that * it can turn them into a single node, which is smaller to store and * faster to run. Backslashed characters are exceptions, each becoming a * separate node; the code is simpler that way and it's not worth fixing. * * [Yes, it is worth fixing, some scripts can run twice the speed.] */ STATIC regnode * S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp) { register regnode *ret = 0; I32 flags; char *parse_start = RExC_parse; *flagp = WORST; /* Tentatively. */ tryagain: switch (*RExC_parse) { case '^': RExC_seen_zerolen++; nextchar(pRExC_state); if (RExC_flags & PMf_MULTILINE) ret = reg_node(pRExC_state, MBOL); else if (RExC_flags & PMf_SINGLELINE) ret = reg_node(pRExC_state, SBOL); else ret = reg_node(pRExC_state, BOL); Set_Node_Length(ret, 1); /* MJD */ break; case '$': nextchar(pRExC_state); if (*RExC_parse) RExC_seen_zerolen++; if (RExC_flags & PMf_MULTILINE) ret = reg_node(pRExC_state, MEOL); else if (RExC_flags & PMf_SINGLELINE) ret = reg_node(pRExC_state, SEOL); else ret = reg_node(pRExC_state, EOL); Set_Node_Length(ret, 1); /* MJD */ break; case '.': nextchar(pRExC_state); if (RExC_flags & PMf_SINGLELINE) ret = reg_node(pRExC_state, SANY); else ret = reg_node(pRExC_state, REG_ANY); *flagp |= HASWIDTH|SIMPLE; RExC_naughty++; Set_Node_Length(ret, 1); /* MJD */ break; case '[': { char *oregcomp_parse = ++RExC_parse; ret = regclass(pRExC_state); if (*RExC_parse != ']') { RExC_parse = oregcomp_parse; vFAIL("Unmatched ["); } nextchar(pRExC_state); *flagp |= HASWIDTH|SIMPLE; Set_Node_Length(ret, RExC_parse - oregcomp_parse + 1); /* MJD */ break; } case '(': nextchar(pRExC_state); ret = reg(pRExC_state, 1, &flags); if (ret == NULL) { if (flags & TRYAGAIN) { if (RExC_parse == RExC_end) { /* Make parent create an empty node if needed. */ *flagp |= TRYAGAIN; return(NULL); } goto tryagain; } return(NULL); } *flagp |= flags&(HASWIDTH|SPSTART|SIMPLE); break; case '|': case ')': if (flags & TRYAGAIN) { *flagp |= TRYAGAIN; return NULL; } vFAIL("Internal urp"); /* Supposed to be caught earlier. */ break; case '{': if (!regcurly(RExC_parse)) { RExC_parse++; goto defchar; } /* FALL THROUGH */ case '?': case '+': case '*': RExC_parse++; vFAIL("Quantifier follows nothing"); break; case '\\': switch (*++RExC_parse) { case 'A': RExC_seen_zerolen++; ret = reg_node(pRExC_state, SBOL); *flagp |= SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'G': ret = reg_node(pRExC_state, GPOS); RExC_seen |= REG_SEEN_GPOS; *flagp |= SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'Z': ret = reg_node(pRExC_state, SEOL); *flagp |= SIMPLE; RExC_seen_zerolen++; /* Do not optimize RE away */ nextchar(pRExC_state); break; case 'z': ret = reg_node(pRExC_state, EOS); *flagp |= SIMPLE; RExC_seen_zerolen++; /* Do not optimize RE away */ nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'C': ret = reg_node(pRExC_state, CANY); RExC_seen |= REG_SEEN_CANY; *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'X': ret = reg_node(pRExC_state, CLUMP); *flagp |= HASWIDTH; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'w': ret = reg_node(pRExC_state, (U8)(LOC ? ALNUML : ALNUM)); *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'W': ret = reg_node(pRExC_state, (U8)(LOC ? NALNUML : NALNUM)); *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'b': RExC_seen_zerolen++; RExC_seen |= REG_SEEN_LOOKBEHIND; ret = reg_node(pRExC_state, (U8)(LOC ? BOUNDL : BOUND)); *flagp |= SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'B': RExC_seen_zerolen++; RExC_seen |= REG_SEEN_LOOKBEHIND; ret = reg_node(pRExC_state, (U8)(LOC ? NBOUNDL : NBOUND)); *flagp |= SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 's': ret = reg_node(pRExC_state, (U8)(LOC ? SPACEL : SPACE)); *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'S': ret = reg_node(pRExC_state, (U8)(LOC ? NSPACEL : NSPACE)); *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'd': ret = reg_node(pRExC_state, DIGIT); *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'D': ret = reg_node(pRExC_state, NDIGIT); *flagp |= HASWIDTH|SIMPLE; nextchar(pRExC_state); Set_Node_Length(ret, 2); /* MJD */ break; case 'p': case 'P': { char* oldregxend = RExC_end; char* parse_start = RExC_parse - 2; if (RExC_parse[1] == '{') { /* a lovely hack--pretend we saw [\pX] instead */ RExC_end = strchr(RExC_parse, '}'); if (!RExC_end) { U8 c = (U8)*RExC_parse; RExC_parse += 2; RExC_end = oldregxend; vFAIL2("Missing right brace on \\%c{}", c); } RExC_end++; } else { RExC_end = RExC_parse + 2; if (RExC_end > oldregxend) RExC_end = oldregxend; } RExC_parse--; ret = regclass(pRExC_state); RExC_end = oldregxend; RExC_parse--; Set_Node_Offset(ret, parse_start + 2); Set_Node_Cur_Length(ret); nextchar(pRExC_state); *flagp |= HASWIDTH|SIMPLE; } break; case 'n': case 'r': case 't': case 'f': case 'e': case 'a': case 'x': case 'c': case '0': goto defchar; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { I32 num = atoi(RExC_parse); if (num > 9 && num >= RExC_npar) goto defchar; else { char * parse_start = RExC_parse - 1; /* MJD */ while (isDIGIT(*RExC_parse)) RExC_parse++; if (!SIZE_ONLY && num > (I32)RExC_rx->nparens) vFAIL("Reference to nonexistent group"); RExC_sawback = 1; ret = reganode(pRExC_state, (U8)(FOLD ? (LOC ? REFFL : REFF) : REF), num); *flagp |= HASWIDTH; /* override incorrect value set in reganode MJD */ Set_Node_Offset(ret, parse_start+1); Set_Node_Cur_Length(ret); /* MJD */ RExC_parse--; nextchar(pRExC_state); } } break; case '\0': if (RExC_parse >= RExC_end) FAIL("Trailing \\"); /* FALL THROUGH */ default: /* Do not generate `unrecognized' warnings here, we fall back into the quick-grab loop below */ parse_start--; goto defchar; } break; case '#': if (RExC_flags & PMf_EXTENDED) { while (RExC_parse < RExC_end && *RExC_parse != '\n') RExC_parse++; if (RExC_parse < RExC_end) goto tryagain; } /* FALL THROUGH */ default: { register STRLEN len; register UV ender; register char *p; char *oldp, *s; STRLEN numlen; STRLEN foldlen; U8 tmpbuf[UTF8_MAXLEN_FOLD+1], *foldbuf; parse_start = RExC_parse - 1; RExC_parse++; defchar: ender = 0; ret = reg_node(pRExC_state, (U8)(FOLD ? (LOC ? EXACTFL : EXACTF) : EXACT)); s = STRING(ret); for (len = 0, p = RExC_parse - 1; len < 127 && p < RExC_end; len++) { oldp = p; if (RExC_flags & PMf_EXTENDED) p = regwhite(p, RExC_end); switch (*p) { case '^': case '$': case '.': case '[': case '(': case ')': case '|': goto loopdone; case '\\': switch (*++p) { case 'A': case 'C': case 'X': case 'G': case 'Z': case 'z': case 'w': case 'W': case 'b': case 'B': case 's': case 'S': case 'd': case 'D': case 'p': case 'P': --p; goto loopdone; case 'n': ender = '\n'; p++; break; case 'r': ender = '\r'; p++; break; case 't': ender = '\t'; p++; break; case 'f': ender = '\f'; p++; break; case 'e': ender = ASCII_TO_NATIVE('\033'); p++; break; case 'a': ender = ASCII_TO_NATIVE('\007'); p++; break; case 'x': if (*++p == '{') { char* e = strchr(p, '}'); if (!e) { RExC_parse = p + 1; vFAIL("Missing right brace on \\x{}"); } else { I32 flags = PERL_SCAN_ALLOW_UNDERSCORES | PERL_SCAN_DISALLOW_PREFIX; numlen = e - p - 1; ender = grok_hex(p + 1, &numlen, &flags, NULL); if (ender > 0xff) RExC_utf8 = 1; p = e + 1; } } else { I32 flags = PERL_SCAN_DISALLOW_PREFIX; numlen = 2; ender = grok_hex(p, &numlen, &flags, NULL); p += numlen; } break; case 'c': p++; ender = UCHARAT(p++); ender = toCTRL(ender); break; case '0': case '1': case '2': case '3':case '4': case '5': case '6': case '7': case '8':case '9': if (*p == '0' || (isDIGIT(p[1]) && atoi(p) >= RExC_npar) ) { I32 flags = 0; numlen = 3; ender = grok_oct(p, &numlen, &flags, NULL); p += numlen; } else { --p; goto loopdone; } break; case '\0': if (p >= RExC_end) FAIL("Trailing \\"); /* FALL THROUGH */ default: if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(*p)) vWARN2(p + 1, "Unrecognized escape \\%c passed through", UCHARAT(p)); goto normal_default; } break; default: normal_default: if (UTF8_IS_START(*p) && UTF) { ender = utf8n_to_uvchr((U8*)p, RExC_end - p, &numlen, 0); p += numlen; } else ender = *p++; break; } if (RExC_flags & PMf_EXTENDED) p = regwhite(p, RExC_end); if (UTF && FOLD) { /* Prime the casefolded buffer. */ ender = toFOLD_uni(ender, tmpbuf, &foldlen); } if (ISMULT2(p)) { /* Back off on ?+*. */ if (len) p = oldp; else if (UTF) { STRLEN unilen; if (FOLD) { /* Emit all the Unicode characters. */ for (foldbuf = tmpbuf; foldlen; foldlen -= numlen) { ender = utf8_to_uvchr(foldbuf, &numlen); if (numlen > 0) { reguni(pRExC_state, ender, s, &unilen); s += unilen; len += unilen; /* In EBCDIC the numlen * and unilen can differ. */ foldbuf += numlen; if (numlen >= foldlen) break; } else break; /* "Can't happen." */ } } else { reguni(pRExC_state, ender, s, &unilen); if (unilen > 0) { s += unilen; len += unilen; } } } else { len++; REGC((char)ender, s++); } break; } if (UTF) { STRLEN unilen; if (FOLD) { /* Emit all the Unicode characters. */ for (foldbuf = tmpbuf; foldlen; foldlen -= numlen) { ender = utf8_to_uvchr(foldbuf, &numlen); if (numlen > 0) { reguni(pRExC_state, ender, s, &unilen); len += unilen; s += unilen; /* In EBCDIC the numlen * and unilen can differ. */ foldbuf += numlen; if (numlen >= foldlen) break; } else break; } } else { reguni(pRExC_state, ender, s, &unilen); if (unilen > 0) { s += unilen; len += unilen; } } len--; } else REGC((char)ender, s++); } loopdone: RExC_parse = p - 1; Set_Node_Cur_Length(ret); /* MJD */ nextchar(pRExC_state); { /* len is STRLEN which is unsigned, need to copy to signed */ IV iv = len; if (iv < 0) vFAIL("Internal disaster"); } if (len > 0) *flagp |= HASWIDTH; if (len == 1 && UNI_IS_INVARIANT(ender)) *flagp |= SIMPLE; if (!SIZE_ONLY) STR_LEN(ret) = len; if (SIZE_ONLY) RExC_size += STR_SZ(len); else RExC_emit += STR_SZ(len); } break; } /* If the encoding pragma is in effect recode the text of * any EXACT-kind nodes. */ if (PL_encoding && PL_regkind[(U8)OP(ret)] == EXACT) { STRLEN oldlen = STR_LEN(ret); SV *sv = sv_2mortal(newSVpvn(STRING(ret), oldlen)); if (RExC_utf8) SvUTF8_on(sv); if (sv_utf8_downgrade(sv, TRUE)) { char *s = sv_recode_to_utf8(sv, PL_encoding); STRLEN newlen = SvCUR(sv); if (SvUTF8(sv)) RExC_utf8 = 1; if (!SIZE_ONLY) { DEBUG_r(PerlIO_printf(Perl_debug_log, "recode %*s to %*s\n", (int)oldlen, STRING(ret), (int)newlen, s)); Copy(s, STRING(ret), newlen, char); STR_LEN(ret) += newlen - oldlen; RExC_emit += STR_SZ(newlen) - STR_SZ(oldlen); } else RExC_size += STR_SZ(newlen) - STR_SZ(oldlen); } } return(ret); } STATIC char * S_regwhite(pTHX_ char *p, char *e) { while (p < e) { if (isSPACE(*p)) ++p; else if (*p == '#') { do { p++; } while (p < e && *p != '\n'); } else break; } return p; } /* Parse POSIX character classes: [[:foo:]], [[=foo=]], [[.foo.]]. Character classes ([:foo:]) can also be negated ([:^foo:]). Returns a named class id (ANYOF_XXX) if successful, -1 otherwise. Equivalence classes ([=foo=]) and composites ([.foo.]) are parsed, but trigger failures because they are currently unimplemented. */ #define POSIXCC_DONE(c) ((c) == ':') #define POSIXCC_NOTYET(c) ((c) == '=' || (c) == '.') #define POSIXCC(c) (POSIXCC_DONE(c) || POSIXCC_NOTYET(c)) STATIC I32 S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value) { char *posixcc = 0; I32 namedclass = OOB_NAMEDCLASS; if (value == '[' && RExC_parse + 1 < RExC_end && /* I smell either [: or [= or [. -- POSIX has been here, right? */ POSIXCC(UCHARAT(RExC_parse))) { char c = UCHARAT(RExC_parse); char* s = RExC_parse++; while (RExC_parse < RExC_end && UCHARAT(RExC_parse) != c) RExC_parse++; if (RExC_parse == RExC_end) /* Grandfather lone [:, [=, [. */ RExC_parse = s; else { char* t = RExC_parse++; /* skip over the c */ if (UCHARAT(RExC_parse) == ']') { RExC_parse++; /* skip over the ending ] */ posixcc = s + 1; if (*s == ':') { I32 complement = *posixcc == '^' ? *posixcc++ : 0; I32 skip = 5; /* the most common skip */ switch (*posixcc) { case 'a': if (strnEQ(posixcc, "alnum", 5)) namedclass = complement ? ANYOF_NALNUMC : ANYOF_ALNUMC; else if (strnEQ(posixcc, "alpha", 5)) namedclass = complement ? ANYOF_NALPHA : ANYOF_ALPHA; else if (strnEQ(posixcc, "ascii", 5)) namedclass = complement ? ANYOF_NASCII : ANYOF_ASCII; break; case 'b': if (strnEQ(posixcc, "blank", 5)) namedclass = complement ? ANYOF_NBLANK : ANYOF_BLANK; break; case 'c': if (strnEQ(posixcc, "cntrl", 5)) namedclass = complement ? ANYOF_NCNTRL : ANYOF_CNTRL; break; case 'd': if (strnEQ(posixcc, "digit", 5)) namedclass = complement ? ANYOF_NDIGIT : ANYOF_DIGIT; break; case 'g': if (strnEQ(posixcc, "graph", 5)) namedclass = complement ? ANYOF_NGRAPH : ANYOF_GRAPH; break; case 'l': if (strnEQ(posixcc, "lower", 5)) namedclass = complement ? ANYOF_NLOWER : ANYOF_LOWER; break; case 'p': if (strnEQ(posixcc, "print", 5)) namedclass = complement ? ANYOF_NPRINT : ANYOF_PRINT; else if (strnEQ(posixcc, "punct", 5)) namedclass = complement ? ANYOF_NPUNCT : ANYOF_PUNCT; break; case 's': if (strnEQ(posixcc, "space", 5)) namedclass = complement ? ANYOF_NPSXSPC : ANYOF_PSXSPC; break; case 'u': if (strnEQ(posixcc, "upper", 5)) namedclass = complement ? ANYOF_NUPPER : ANYOF_UPPER; break; case 'w': /* this is not POSIX, this is the Perl \w */ if (strnEQ(posixcc, "word", 4)) { namedclass = complement ? ANYOF_NALNUM : ANYOF_ALNUM; skip = 4; } break; case 'x': if (strnEQ(posixcc, "xdigit", 6)) { namedclass = complement ? ANYOF_NXDIGIT : ANYOF_XDIGIT; skip = 6; } break; } if (namedclass == OOB_NAMEDCLASS || posixcc[skip] != ':' || posixcc[skip+1] != ']') { Simple_vFAIL3("POSIX class [:%.*s:] unknown", t - s - 1, s + 1); } } else if (!SIZE_ONLY) { /* [[=foo=]] and [[.foo.]] are still future. */ /* adjust RExC_parse so the warning shows after the class closes */ while (UCHARAT(RExC_parse) && UCHARAT(RExC_parse) != ']') RExC_parse++; Simple_vFAIL3("POSIX syntax [%c %c] is reserved for future extensions", c, c); } } else { /* Maternal grandfather: * "[:" ending in ":" but not in ":]" */ RExC_parse = s; } } } return namedclass; } STATIC void S_checkposixcc(pTHX_ RExC_state_t *pRExC_state) { if (!SIZE_ONLY && POSIXCC(UCHARAT(RExC_parse))) { char *s = RExC_parse; char c = *s++; while(*s && isALNUM(*s)) s++; if (*s && c == *s && s[1] == ']') { if (ckWARN(WARN_REGEXP)) vWARN3(s+2, "POSIX syntax [%c %c] belongs inside character classes", c, c); /* [[=foo=]] and [[.foo.]] are still future. */ if (POSIXCC_NOTYET(c)) { /* adjust RExC_parse so the error shows after the class closes */ while (UCHARAT(RExC_parse) && UCHARAT(RExC_parse++) != ']') ; Simple_vFAIL3("POSIX syntax [%c %c] is reserved for future extensions", c, c); } } } } STATIC regnode * S_regclass(pTHX_ RExC_state_t *pRExC_state) { register UV value; register UV nextvalue; register IV prevvalue = OOB_UNICODE; register IV range = 0; register regnode *ret; STRLEN numlen; IV namedclass; char *rangebegin = 0; bool need_class = 0; SV *listsv = Nullsv; register char *e; UV n; bool optimize_invert = TRUE; AV* unicode_alternate = 0; #ifdef EBCDIC UV literal_endpoint = 0; #endif ret = reganode(pRExC_state, ANYOF, 0); if (!SIZE_ONLY) ANYOF_FLAGS(ret) = 0; if (UCHARAT(RExC_parse) == '^') { /* Complement of range. */ RExC_naughty++; RExC_parse++; if (!SIZE_ONLY) ANYOF_FLAGS(ret) |= ANYOF_INVERT; } if (SIZE_ONLY) RExC_size += ANYOF_SKIP; else { RExC_emit += ANYOF_SKIP; if (FOLD) ANYOF_FLAGS(ret) |= ANYOF_FOLD; if (LOC) ANYOF_FLAGS(ret) |= ANYOF_LOCALE; ANYOF_BITMAP_ZERO(ret); listsv = newSVpvn("# comment\n", 10); } nextvalue = RExC_parse < RExC_end ? UCHARAT(RExC_parse) : 0; if (!SIZE_ONLY && POSIXCC(nextvalue)) checkposixcc(pRExC_state); /* allow 1st char to be ] (allowing it to be - is dealt with later) */ if (UCHARAT(RExC_parse) == ']') goto charclassloop; while (RExC_parse < RExC_end && UCHARAT(RExC_parse) != ']') { charclassloop: namedclass = OOB_NAMEDCLASS; /* initialize as illegal */ if (!range) rangebegin = RExC_parse; if (UTF) { value = utf8n_to_uvchr((U8*)RExC_parse, RExC_end - RExC_parse, &numlen, 0); RExC_parse += numlen; } else value = UCHARAT(RExC_parse++); nextvalue = RExC_parse < RExC_end ? UCHARAT(RExC_parse) : 0; if (value == '[' && POSIXCC(nextvalue)) namedclass = regpposixcc(pRExC_state, value); else if (value == '\\') { if (UTF) { value = utf8n_to_uvchr((U8*)RExC_parse, RExC_end - RExC_parse, &numlen, 0); RExC_parse += numlen; } else value = UCHARAT(RExC_parse++); /* Some compilers cannot handle switching on 64-bit integer * values, therefore value cannot be an UV. Yes, this will * be a problem later if we want switch on Unicode. * A similar issue a little bit later when switching on * namedclass. --jhi */ switch ((I32)value) { case 'w': namedclass = ANYOF_ALNUM; break; case 'W': namedclass = ANYOF_NALNUM; break; case 's': namedclass = ANYOF_SPACE; break; case 'S': namedclass = ANYOF_NSPACE; break; case 'd': namedclass = ANYOF_DIGIT; break; case 'D': namedclass = ANYOF_NDIGIT; break; case 'p': case 'P': if (RExC_parse >= RExC_end) vFAIL2("Empty \\%c{}", (U8)value); if (*RExC_parse == '{') { U8 c = (U8)value; e = strchr(RExC_parse++, '}'); if (!e) vFAIL2("Missing right brace on \\%c{}", c); while (isSPACE(UCHARAT(RExC_parse))) RExC_parse++; if (e == RExC_parse) vFAIL2("Empty \\%c{}", c); n = e - RExC_parse; while (isSPACE(UCHARAT(RExC_parse + n - 1))) n--; } else { e = RExC_parse; n = 1; } if (!SIZE_ONLY) { if (UCHARAT(RExC_parse) == '^') { RExC_parse++; n--; value = value == 'p' ? 'P' : 'p'; /* toggle */ while (isSPACE(UCHARAT(RExC_parse))) { RExC_parse++; n--; } } if (value == 'p') Perl_sv_catpvf(aTHX_ listsv, "+utf8::%.*s\n", (int)n, RExC_parse); else Perl_sv_catpvf(aTHX_ listsv, "!utf8::%.*s\n", (int)n, RExC_parse); } RExC_parse = e + 1; ANYOF_FLAGS(ret) |= ANYOF_UNICODE; namedclass = ANYOF_MAX; /* no official name, but it's named */ break; case 'n': value = '\n'; break; case 'r': value = '\r'; break; case 't': value = '\t'; break; case 'f': value = '\f'; break; case 'b': value = '\b'; break; case 'e': value = ASCII_TO_NATIVE('\033');break; case 'a': value = ASCII_TO_NATIVE('\007');break; case 'x': if (*RExC_parse == '{') { I32 flags = PERL_SCAN_ALLOW_UNDERSCORES | PERL_SCAN_DISALLOW_PREFIX; e = strchr(RExC_parse++, '}'); if (!e) vFAIL("Missing right brace on \\x{}"); numlen = e - RExC_parse; value = grok_hex(RExC_parse, &numlen, &flags, NULL); RExC_parse = e + 1; } else { I32 flags = PERL_SCAN_DISALLOW_PREFIX; numlen = 2; value = grok_hex(RExC_parse, &numlen, &flags, NULL); RExC_parse += numlen; } break; case 'c': value = UCHARAT(RExC_parse++); value = toCTRL(value); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { I32 flags = 0; numlen = 3; value = grok_oct(--RExC_parse, &numlen, &flags, NULL); RExC_parse += numlen; break; } default: if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(value)) vWARN2(RExC_parse, "Unrecognized escape \\%c in character class passed through", (int)value); break; } } /* end of \blah */ #ifdef EBCDIC else literal_endpoint++; #endif if (namedclass > OOB_NAMEDCLASS) { /* this is a named class \blah */ if (!SIZE_ONLY && !need_class) ANYOF_CLASS_ZERO(ret); need_class = 1; /* a bad range like a-\d, a-[:digit:] ? */ if (range) { if (!SIZE_ONLY) { if (ckWARN(WARN_REGEXP)) vWARN4(RExC_parse, "False [] range \"%*.*s\"", RExC_parse - rangebegin, RExC_parse - rangebegin, rangebegin); if (prevvalue < 256) { ANYOF_BITMAP_SET(ret, prevvalue); ANYOF_BITMAP_SET(ret, '-'); } else { ANYOF_FLAGS(ret) |= ANYOF_UNICODE; Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n%04"UVxf"\n", (UV)prevvalue, (UV) '-'); } } range = 0; /* this was not a true range */ } if (!SIZE_ONLY) { if (namedclass > OOB_NAMEDCLASS) optimize_invert = FALSE; /* Possible truncation here but in some 64-bit environments * the compiler gets heartburn about switch on 64-bit values. * A similar issue a little earlier when switching on value. * --jhi */ switch ((I32)namedclass) { case ANYOF_ALNUM: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_ALNUM); else { for (value = 0; value < 256; value++) if (isALNUM(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsWord\n"); break; case ANYOF_NALNUM: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NALNUM); else { for (value = 0; value < 256; value++) if (!isALNUM(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsWord\n"); break; case ANYOF_ALNUMC: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_ALNUMC); else { for (value = 0; value < 256; value++) if (isALNUMC(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsAlnum\n"); break; case ANYOF_NALNUMC: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NALNUMC); else { for (value = 0; value < 256; value++) if (!isALNUMC(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsAlnum\n"); break; case ANYOF_ALPHA: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_ALPHA); else { for (value = 0; value < 256; value++) if (isALPHA(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsAlpha\n"); break; case ANYOF_NALPHA: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NALPHA); else { for (value = 0; value < 256; value++) if (!isALPHA(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsAlpha\n"); break; case ANYOF_ASCII: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_ASCII); else { #ifndef EBCDIC for (value = 0; value < 128; value++) ANYOF_BITMAP_SET(ret, value); #else /* EBCDIC */ for (value = 0; value < 256; value++) { if (isASCII(value)) ANYOF_BITMAP_SET(ret, value); } #endif /* EBCDIC */ } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsASCII\n"); break; case ANYOF_NASCII: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NASCII); else { #ifndef EBCDIC for (value = 128; value < 256; value++) ANYOF_BITMAP_SET(ret, value); #else /* EBCDIC */ for (value = 0; value < 256; value++) { if (!isASCII(value)) ANYOF_BITMAP_SET(ret, value); } #endif /* EBCDIC */ } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsASCII\n"); break; case ANYOF_BLANK: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_BLANK); else { for (value = 0; value < 256; value++) if (isBLANK(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsBlank\n"); break; case ANYOF_NBLANK: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NBLANK); else { for (value = 0; value < 256; value++) if (!isBLANK(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsBlank\n"); break; case ANYOF_CNTRL: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_CNTRL); else { for (value = 0; value < 256; value++) if (isCNTRL(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsCntrl\n"); break; case ANYOF_NCNTRL: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NCNTRL); else { for (value = 0; value < 256; value++) if (!isCNTRL(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsCntrl\n"); break; case ANYOF_DIGIT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_DIGIT); else { /* consecutive digits assumed */ for (value = '0'; value <= '9'; value++) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsDigit\n"); break; case ANYOF_NDIGIT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NDIGIT); else { /* consecutive digits assumed */ for (value = 0; value < '0'; value++) ANYOF_BITMAP_SET(ret, value); for (value = '9' + 1; value < 256; value++) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsDigit\n"); break; case ANYOF_GRAPH: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_GRAPH); else { for (value = 0; value < 256; value++) if (isGRAPH(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsGraph\n"); break; case ANYOF_NGRAPH: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NGRAPH); else { for (value = 0; value < 256; value++) if (!isGRAPH(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsGraph\n"); break; case ANYOF_LOWER: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_LOWER); else { for (value = 0; value < 256; value++) if (isLOWER(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsLower\n"); break; case ANYOF_NLOWER: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NLOWER); else { for (value = 0; value < 256; value++) if (!isLOWER(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsLower\n"); break; case ANYOF_PRINT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_PRINT); else { for (value = 0; value < 256; value++) if (isPRINT(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsPrint\n"); break; case ANYOF_NPRINT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NPRINT); else { for (value = 0; value < 256; value++) if (!isPRINT(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsPrint\n"); break; case ANYOF_PSXSPC: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_PSXSPC); else { for (value = 0; value < 256; value++) if (isPSXSPC(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsSpace\n"); break; case ANYOF_NPSXSPC: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NPSXSPC); else { for (value = 0; value < 256; value++) if (!isPSXSPC(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsSpace\n"); break; case ANYOF_PUNCT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_PUNCT); else { for (value = 0; value < 256; value++) if (isPUNCT(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsPunct\n"); break; case ANYOF_NPUNCT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NPUNCT); else { for (value = 0; value < 256; value++) if (!isPUNCT(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsPunct\n"); break; case ANYOF_SPACE: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_SPACE); else { for (value = 0; value < 256; value++) if (isSPACE(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsSpacePerl\n"); break; case ANYOF_NSPACE: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NSPACE); else { for (value = 0; value < 256; value++) if (!isSPACE(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsSpacePerl\n"); break; case ANYOF_UPPER: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_UPPER); else { for (value = 0; value < 256; value++) if (isUPPER(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsUpper\n"); break; case ANYOF_NUPPER: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NUPPER); else { for (value = 0; value < 256; value++) if (!isUPPER(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsUpper\n"); break; case ANYOF_XDIGIT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_XDIGIT); else { for (value = 0; value < 256; value++) if (isXDIGIT(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "+utf8::IsXDigit\n"); break; case ANYOF_NXDIGIT: if (LOC) ANYOF_CLASS_SET(ret, ANYOF_NXDIGIT); else { for (value = 0; value < 256; value++) if (!isXDIGIT(value)) ANYOF_BITMAP_SET(ret, value); } Perl_sv_catpvf(aTHX_ listsv, "!utf8::IsXDigit\n"); break; case ANYOF_MAX: /* this is to handle \p and \P */ break; default: vFAIL("Invalid [::] class"); break; } if (LOC) ANYOF_FLAGS(ret) |= ANYOF_CLASS; continue; } } /* end of namedclass \blah */ if (range) { if (prevvalue > (IV)value) /* b-a */ { Simple_vFAIL4("Invalid [] range \"%*.*s\"", RExC_parse - rangebegin, RExC_parse - rangebegin, rangebegin); range = 0; /* not a valid range */ } } else { prevvalue = value; /* save the beginning of the range */ if (*RExC_parse == '-' && RExC_parse+1 < RExC_end && RExC_parse[1] != ']') { RExC_parse++; /* a bad range like \w-, [:word:]- ? */ if (namedclass > OOB_NAMEDCLASS) { if (ckWARN(WARN_REGEXP)) vWARN4(RExC_parse, "False [] range \"%*.*s\"", RExC_parse - rangebegin, RExC_parse - rangebegin, rangebegin); if (!SIZE_ONLY) ANYOF_BITMAP_SET(ret, '-'); } else range = 1; /* yeah, it's a range! */ continue; /* but do it the next time */ } } /* now is the next time */ if (!SIZE_ONLY) { IV i; if (prevvalue < 256) { IV ceilvalue = value < 256 ? value : 255; #ifdef EBCDIC /* In EBCDIC [\x89-\x91] should include * the \x8e but [i-j] should not. */ if (literal_endpoint == 2 && ((isLOWER(prevvalue) && isLOWER(ceilvalue)) || (isUPPER(prevvalue) && isUPPER(ceilvalue)))) { if (isLOWER(prevvalue)) { for (i = prevvalue; i <= ceilvalue; i++) if (isLOWER(i)) ANYOF_BITMAP_SET(ret, i); } else { for (i = prevvalue; i <= ceilvalue; i++) if (isUPPER(i)) ANYOF_BITMAP_SET(ret, i); } } else #endif for (i = prevvalue; i <= ceilvalue; i++) ANYOF_BITMAP_SET(ret, i); } if (value > 255 || UTF) { UV prevnatvalue = NATIVE_TO_UNI(prevvalue); UV natvalue = NATIVE_TO_UNI(value); ANYOF_FLAGS(ret) |= ANYOF_UNICODE; if (prevnatvalue < natvalue) { /* what about > ? */ Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\t%04"UVxf"\n", prevnatvalue, natvalue); } else if (prevnatvalue == natvalue) { Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", natvalue); if (FOLD) { U8 foldbuf[UTF8_MAXLEN_FOLD+1]; STRLEN foldlen; UV f = to_uni_fold(natvalue, foldbuf, &foldlen); /* If folding and foldable and a single * character, insert also the folded version * to the charclass. */ if (f != value) { if (foldlen == (STRLEN)UNISKIP(f)) Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", f); else { /* Any multicharacter foldings * require the following transform: * [ABCDEF] -> (?:[ABCabcDEFd]|pq|rst) * where E folds into "pq" and F folds * into "rst", all other characters * fold to single characters. We save * away these multicharacter foldings, * to be later saved as part of the * additional "s" data. */ SV *sv; if (!unicode_alternate) unicode_alternate = newAV(); sv = newSVpvn((char*)foldbuf, foldlen); SvUTF8_on(sv); av_push(unicode_alternate, sv); } } /* If folding and the value is one of the Greek * sigmas insert a few more sigmas to make the * folding rules of the sigmas to work right. * Note that not all the possible combinations * are handled here: some of them are handled * by the standard folding rules, and some of * them (literal or EXACTF cases) are handled * during runtime in regexec.c:S_find_byclass(). */ if (value == UNICODE_GREEK_SMALL_LETTER_FINAL_SIGMA) { Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", (UV)UNICODE_GREEK_CAPITAL_LETTER_SIGMA); Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", (UV)UNICODE_GREEK_SMALL_LETTER_SIGMA); } else if (value == UNICODE_GREEK_CAPITAL_LETTER_SIGMA) Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", (UV)UNICODE_GREEK_SMALL_LETTER_SIGMA); } } } #ifdef EBCDIC literal_endpoint = 0; #endif } range = 0; /* this range (if it was one) is done now */ } if (need_class) { ANYOF_FLAGS(ret) |= ANYOF_LARGE; if (SIZE_ONLY) RExC_size += ANYOF_CLASS_ADD_SKIP; else RExC_emit += ANYOF_CLASS_ADD_SKIP; } /* optimize case-insensitive simple patterns (e.g. /[a-z]/i) */ if (!SIZE_ONLY && /* If the only flag is folding (plus possibly inversion). */ ((ANYOF_FLAGS(ret) & (ANYOF_FLAGS_ALL ^ ANYOF_INVERT)) == ANYOF_FOLD) ) { for (value = 0; value < 256; ++value) { if (ANYOF_BITMAP_TEST(ret, value)) { UV fold = PL_fold[value]; if (fold != value) ANYOF_BITMAP_SET(ret, fold); } } ANYOF_FLAGS(ret) &= ~ANYOF_FOLD; } /* optimize inverted simple patterns (e.g. [^a-z]) */ if (!SIZE_ONLY && optimize_invert && /* If the only flag is inversion. */ (ANYOF_FLAGS(ret) & ANYOF_FLAGS_ALL) == ANYOF_INVERT) { for (value = 0; value < ANYOF_BITMAP_SIZE; ++value) ANYOF_BITMAP(ret)[value] ^= ANYOF_FLAGS_ALL; ANYOF_FLAGS(ret) = ANYOF_UNICODE_ALL; } if (!SIZE_ONLY) { AV *av = newAV(); SV *rv; /* The 0th element stores the character class description * in its textual form: used later (regexec.c:Perl_regclass_swash()) * to initialize the appropriate swash (which gets stored in * the 1st element), and also useful for dumping the regnode. * The 2nd element stores the multicharacter foldings, * used later (regexec.c:S_reginclass()). */ av_store(av, 0, listsv); av_store(av, 1, NULL); av_store(av, 2, (SV*)unicode_alternate); rv = newRV_noinc((SV*)av); n = add_data(pRExC_state, 1, "s"); RExC_rx->data->data[n] = (void*)rv; ARG_SET(ret, n); } return ret; } STATIC char* S_nextchar(pTHX_ RExC_state_t *pRExC_state) { char* retval = RExC_parse++; for (;;) { if (*RExC_parse == '(' && RExC_parse[1] == '?' && RExC_parse[2] == '#') { while (*RExC_parse != ')') { if (RExC_parse == RExC_end) FAIL("Sequence (?#... not terminated"); RExC_parse++; } RExC_parse++; continue; } if (RExC_flags & PMf_EXTENDED) { if (isSPACE(*RExC_parse)) { RExC_parse++; continue; } else if (*RExC_parse == '#') { while (RExC_parse < RExC_end) if (*RExC_parse++ == '\n') break; continue; } } return retval; } } /* - reg_node - emit a node */ STATIC regnode * /* Location. */ S_reg_node(pTHX_ RExC_state_t *pRExC_state, U8 op) { register regnode *ret; register regnode *ptr; ret = RExC_emit; if (SIZE_ONLY) { SIZE_ALIGN(RExC_size); RExC_size += 1; return(ret); } NODE_ALIGN_FILL(ret); ptr = ret; FILL_ADVANCE_NODE(ptr, op); if (RExC_offsets) { /* MJD */ MJD_OFFSET_DEBUG(("%s:%u: (op %s) %s %u <- %u (len %u) (max %u).\n", "reg_node", __LINE__, reg_name[op], RExC_emit - RExC_emit_start > RExC_offsets[0] ? "Overwriting end of array!\n" : "OK", RExC_emit - RExC_emit_start, RExC_parse - RExC_start, RExC_offsets[0])); Set_Node_Offset(RExC_emit, RExC_parse + (op == END)); } RExC_emit = ptr; return(ret); } /* - reganode - emit a node with an argument */ STATIC regnode * /* Location. */ S_reganode(pTHX_ RExC_state_t *pRExC_state, U8 op, U32 arg) { register regnode *ret; register regnode *ptr; ret = RExC_emit; if (SIZE_ONLY) { SIZE_ALIGN(RExC_size); RExC_size += 2; return(ret); } NODE_ALIGN_FILL(ret); ptr = ret; FILL_ADVANCE_NODE_ARG(ptr, op, arg); if (RExC_offsets) { /* MJD */ MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s %u <- %u (max %u).\n", "reganode", __LINE__, reg_name[op], RExC_emit - RExC_emit_start > RExC_offsets[0] ? "Overwriting end of array!\n" : "OK", RExC_emit - RExC_emit_start, RExC_parse - RExC_start, RExC_offsets[0])); Set_Cur_Node_Offset; } RExC_emit = ptr; return(ret); } /* - reguni - emit (if appropriate) a Unicode character */ STATIC void S_reguni(pTHX_ RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp) { *lenp = SIZE_ONLY ? UNISKIP(uv) : (uvchr_to_utf8((U8*)s, uv) - (U8*)s); } /* - reginsert - insert an operator in front of already-emitted operand * * Means relocating the operand. */ STATIC void S_reginsert(pTHX_ RExC_state_t *pRExC_state, U8 op, regnode *opnd) { register regnode *src; register regnode *dst; register regnode *place; register int offset = regarglen[(U8)op]; /* (PL_regkind[(U8)op] == CURLY ? EXTRA_STEP_2ARGS : 0); */ if (SIZE_ONLY) { RExC_size += NODE_STEP_REGNODE + offset; return; } src = RExC_emit; RExC_emit += NODE_STEP_REGNODE + offset; dst = RExC_emit; while (src > opnd) { StructCopy(--src, --dst, regnode); if (RExC_offsets) { /* MJD 20010112 */ MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s copy %u -> %u (max %u).\n", "reg_insert", __LINE__, reg_name[op], dst - RExC_emit_start > RExC_offsets[0] ? "Overwriting end of array!\n" : "OK", src - RExC_emit_start, dst - RExC_emit_start, RExC_offsets[0])); Set_Node_Offset_To_R(dst-RExC_emit_start, Node_Offset(src)); Set_Node_Length_To_R(dst-RExC_emit_start, Node_Length(src)); } } place = opnd; /* Op node, where operand used to be. */ if (RExC_offsets) { /* MJD */ MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s %u <- %u (max %u).\n", "reginsert", __LINE__, reg_name[op], place - RExC_emit_start > RExC_offsets[0] ? "Overwriting end of array!\n" : "OK", place - RExC_emit_start, RExC_parse - RExC_start, RExC_offsets[0])); Set_Node_Offset(place, RExC_parse); Set_Node_Length(place, 1); } src = NEXTOPER(place); FILL_ADVANCE_NODE(place, op); Zero(src, offset, regnode); } /* - regtail - set the next-pointer at the end of a node chain of p to val. */ STATIC void S_regtail(pTHX_ RExC_state_t *pRExC_state, regnode *p, regnode *val) { register regnode *scan; register regnode *temp; if (SIZE_ONLY) return; /* Find last node. */ scan = p; for (;;) { temp = regnext(scan); if (temp == NULL) break; scan = temp; } if (reg_off_by_arg[OP(scan)]) { ARG_SET(scan, val - scan); } else { NEXT_OFF(scan) = val - scan; } } /* - regoptail - regtail on operand of first argument; nop if operandless */ STATIC void S_regoptail(pTHX_ RExC_state_t *pRExC_state, regnode *p, regnode *val) { /* "Operandless" and "op != BRANCH" are synonymous in practice. */ if (p == NULL || SIZE_ONLY) return; if (PL_regkind[(U8)OP(p)] == BRANCH) { regtail(pRExC_state, NEXTOPER(p), val); } else if ( PL_regkind[(U8)OP(p)] == BRANCHJ) { regtail(pRExC_state, NEXTOPER(NEXTOPER(p)), val); } else return; } /* - regcurly - a little FSA that accepts {\d+,?\d*} */ STATIC I32 S_regcurly(pTHX_ register char *s) { if (*s++ != '{') return FALSE; if (!isDIGIT(*s)) return FALSE; while (isDIGIT(*s)) s++; if (*s == ',') s++; while (isDIGIT(*s)) s++; if (*s != '}') return FALSE; return TRUE; } #ifdef DEBUGGING STATIC regnode * S_dumpuntil(pTHX_ regnode *start, regnode *node, regnode *last, SV* sv, I32 l) { register U8 op = EXACT; /* Arbitrary non-END op. */ register regnode *next; while (op != END && (!last || node < last)) { /* While that wasn't END last time... */ NODE_ALIGN(node); op = OP(node); if (op == CLOSE) l--; next = regnext(node); /* Where, what. */ if (OP(node) == OPTIMIZED) goto after_print; regprop(sv, node); PerlIO_printf(Perl_debug_log, "%4"IVdf":%*s%s", (IV)(node - start), (int)(2*l + 1), "", SvPVX(sv)); if (next == NULL) /* Next ptr. */ PerlIO_printf(Perl_debug_log, "(0)"); else PerlIO_printf(Perl_debug_log, "(%"IVdf")", (IV)(next - start)); (void)PerlIO_putc(Perl_debug_log, '\n'); after_print: if (PL_regkind[(U8)op] == BRANCHJ) { register regnode *nnode = (OP(next) == LONGJMP ? regnext(next) : next); if (last && nnode > last) nnode = last; node = dumpuntil(start, NEXTOPER(NEXTOPER(node)), nnode, sv, l + 1); } else if (PL_regkind[(U8)op] == BRANCH) { node = dumpuntil(start, NEXTOPER(node), next, sv, l + 1); } else if ( op == CURLY) { /* `next' might be very big: optimizer */ node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS, NEXTOPER(node) + EXTRA_STEP_2ARGS + 1, sv, l + 1); } else if (PL_regkind[(U8)op] == CURLY && op != CURLYX) { node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS, next, sv, l + 1); } else if ( op == PLUS || op == STAR) { node = dumpuntil(start, NEXTOPER(node), NEXTOPER(node) + 1, sv, l + 1); } else if (op == ANYOF) { /* arglen 1 + class block */ node += 1 + ((ANYOF_FLAGS(node) & ANYOF_LARGE) ? ANYOF_CLASS_SKIP : ANYOF_SKIP); node = NEXTOPER(node); } else if (PL_regkind[(U8)op] == EXACT) { /* Literal string, where present. */ node += NODE_SZ_STR(node) - 1; node = NEXTOPER(node); } else { node = NEXTOPER(node); node += regarglen[(U8)op]; } if (op == CURLYX || op == OPEN) l++; else if (op == WHILEM) l--; } return node; } #endif /* DEBUGGING */ /* - regdump - dump a regexp onto Perl_debug_log in vaguely comprehensible form */ void Perl_regdump(pTHX_ regexp *r) { #ifdef DEBUGGING SV *sv = sv_newmortal(); (void)dumpuntil(r->program, r->program + 1, NULL, sv, 0); /* Header fields of interest. */ if (r->anchored_substr) PerlIO_printf(Perl_debug_log, "anchored `%s%.*s%s'%s at %"IVdf" ", PL_colors[0], (int)(SvCUR(r->anchored_substr) - (SvTAIL(r->anchored_substr)!=0)), SvPVX(r->anchored_substr), PL_colors[1], SvTAIL(r->anchored_substr) ? "$" : "", (IV)r->anchored_offset); else if (r->anchored_utf8) PerlIO_printf(Perl_debug_log, "anchored utf8 `%s%.*s%s'%s at %"IVdf" ", PL_colors[0], (int)(SvCUR(r->anchored_utf8) - (SvTAIL(r->anchored_utf8)!=0)), SvPVX(r->anchored_utf8), PL_colors[1], SvTAIL(r->anchored_utf8) ? "$" : "", (IV)r->anchored_offset); if (r->float_substr) PerlIO_printf(Perl_debug_log, "floating `%s%.*s%s'%s at %"IVdf"..%"UVuf" ", PL_colors[0], (int)(SvCUR(r->float_substr) - (SvTAIL(r->float_substr)!=0)), SvPVX(r->float_substr), PL_colors[1], SvTAIL(r->float_substr) ? "$" : "", (IV)r->float_min_offset, (UV)r->float_max_offset); else if (r->float_utf8) PerlIO_printf(Perl_debug_log, "floating utf8 `%s%.*s%s'%s at %"IVdf"..%"UVuf" ", PL_colors[0], (int)(SvCUR(r->float_utf8) - (SvTAIL(r->float_utf8)!=0)), SvPVX(r->float_utf8), PL_colors[1], SvTAIL(r->float_utf8) ? "$" : "", (IV)r->float_min_offset, (UV)r->float_max_offset); if (r->check_substr || r->check_utf8) PerlIO_printf(Perl_debug_log, r->check_substr == r->float_substr && r->check_utf8 == r->float_utf8 ? "(checking floating" : "(checking anchored"); if (r->reganch & ROPT_NOSCAN) PerlIO_printf(Perl_debug_log, " noscan"); if (r->reganch & ROPT_CHECK_ALL) PerlIO_printf(Perl_debug_log, " isall"); if (r->check_substr || r->check_utf8) PerlIO_printf(Perl_debug_log, ") "); if (r->regstclass) { regprop(sv, r->regstclass); PerlIO_printf(Perl_debug_log, "stclass `%s' ", SvPVX(sv)); } if (r->reganch & ROPT_ANCH) { PerlIO_printf(Perl_debug_log, "anchored"); if (r->reganch & ROPT_ANCH_BOL) PerlIO_printf(Perl_debug_log, "(BOL)"); if (r->reganch & ROPT_ANCH_MBOL) PerlIO_printf(Perl_debug_log, "(MBOL)"); if (r->reganch & ROPT_ANCH_SBOL) PerlIO_printf(Perl_debug_log, "(SBOL)"); if (r->reganch & ROPT_ANCH_GPOS) PerlIO_printf(Perl_debug_log, "(GPOS)"); PerlIO_putc(Perl_debug_log, ' '); } if (r->reganch & ROPT_GPOS_SEEN) PerlIO_printf(Perl_debug_log, "GPOS "); if (r->reganch & ROPT_SKIP) PerlIO_printf(Perl_debug_log, "plus "); if (r->reganch & ROPT_IMPLICIT) PerlIO_printf(Perl_debug_log, "implicit "); PerlIO_printf(Perl_debug_log, "minlen %ld ", (long) r->minlen); if (r->reganch & ROPT_EVAL_SEEN) PerlIO_printf(Perl_debug_log, "with eval "); PerlIO_printf(Perl_debug_log, "\n"); if (r->offsets) { U32 i; U32 len = r->offsets[0]; PerlIO_printf(Perl_debug_log, "Offsets: [%"UVuf"]\n\t", (UV)r->offsets[0]); for (i = 1; i <= len; i++) PerlIO_printf(Perl_debug_log, "%"UVuf"[%"UVuf"] ", (UV)r->offsets[i*2-1], (UV)r->offsets[i*2]); PerlIO_printf(Perl_debug_log, "\n"); } #endif /* DEBUGGING */ } #ifdef DEBUGGING STATIC void S_put_byte(pTHX_ SV *sv, int c) { if (isCNTRL(c) || c == 255 || !isPRINT(c)) Perl_sv_catpvf(aTHX_ sv, "\\%o", c); else if (c == '-' || c == ']' || c == '\\' || c == '^') Perl_sv_catpvf(aTHX_ sv, "\\%c", c); else Perl_sv_catpvf(aTHX_ sv, "%c", c); } #endif /* DEBUGGING */ /* - regprop - printable representation of opcode */ void Perl_regprop(pTHX_ SV *sv, regnode *o) { #ifdef DEBUGGING register int k; sv_setpvn(sv, "", 0); if (OP(o) >= reg_num) /* regnode.type is unsigned */ /* It would be nice to FAIL() here, but this may be called from regexec.c, and it would be hard to supply pRExC_state. */ Perl_croak(aTHX_ "Corrupted regexp opcode"); sv_catpv(sv, (char*)reg_name[OP(o)]); /* Take off const! */ k = PL_regkind[(U8)OP(o)]; if (k == EXACT) { SV *dsv = sv_2mortal(newSVpvn("", 0)); /* Using is_utf8_string() is a crude hack but it may * be the best for now since we have no flag "this EXACTish * node was UTF-8" --jhi */ bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o)); char *s = do_utf8 ? pv_uni_display(dsv, (U8*)STRING(o), STR_LEN(o), 60, UNI_DISPLAY_REGEX) : STRING(o); int len = do_utf8 ? strlen(s) : STR_LEN(o); Perl_sv_catpvf(aTHX_ sv, " <%s%.*s%s>", PL_colors[0], len, s, PL_colors[1]); } else if (k == CURLY) { if (OP(o) == CURLYM || OP(o) == CURLYN || OP(o) == CURLYX) Perl_sv_catpvf(aTHX_ sv, "[%d]", o->flags); /* Parenth number */ Perl_sv_catpvf(aTHX_ sv, " {%d,%d}", ARG1(o), ARG2(o)); } else if (k == WHILEM && o->flags) /* Ordinal/of */ Perl_sv_catpvf(aTHX_ sv, "[%d/%d]", o->flags & 0xf, o->flags>>4); else if (k == REF || k == OPEN || k == CLOSE || k == GROUPP ) Perl_sv_catpvf(aTHX_ sv, "%d", (int)ARG(o)); /* Parenth number */ else if (k == LOGICAL) Perl_sv_catpvf(aTHX_ sv, "[%d]", o->flags); /* 2: embedded, otherwise 1 */ else if (k == ANYOF) { int i, rangestart = -1; U8 flags = ANYOF_FLAGS(o); const char * const anyofs[] = { /* Should be synchronized with * ANYOF_ #xdefines in regcomp.h */ "\\w", "\\W", "\\s", "\\S", "\\d", "\\D", "[:alnum:]", "[:^alnum:]", "[:alpha:]", "[:^alpha:]", "[:ascii:]", "[:^ascii:]", "[:ctrl:]", "[:^ctrl:]", "[:graph:]", "[:^graph:]", "[:lower:]", "[:^lower:]", "[:print:]", "[:^print:]", "[:punct:]", "[:^punct:]", "[:upper:]", "[:^upper:]", "[:xdigit:]", "[:^xdigit:]", "[:space:]", "[:^space:]", "[:blank:]", "[:^blank:]" }; if (flags & ANYOF_LOCALE) sv_catpv(sv, "{loc}"); if (flags & ANYOF_FOLD) sv_catpv(sv, "{i}"); Perl_sv_catpvf(aTHX_ sv, "[%s", PL_colors[0]); if (flags & ANYOF_INVERT) sv_catpv(sv, "^"); for (i = 0; i <= 256; i++) { if (i < 256 && ANYOF_BITMAP_TEST(o,i)) { if (rangestart == -1) rangestart = i; } else if (rangestart != -1) { if (i <= rangestart + 3) for (; rangestart < i; rangestart++) put_byte(sv, rangestart); else { put_byte(sv, rangestart); sv_catpv(sv, "-"); put_byte(sv, i - 1); } rangestart = -1; } } if (o->flags & ANYOF_CLASS) for (i = 0; i < sizeof(anyofs)/sizeof(char*); i++) if (ANYOF_CLASS_TEST(o,i)) sv_catpv(sv, anyofs[i]); if (flags & ANYOF_UNICODE) sv_catpv(sv, "{unicode}"); else if (flags & ANYOF_UNICODE_ALL) sv_catpv(sv, "{unicode_all}"); { SV *lv; SV *sw = regclass_swash(o, FALSE, &lv, 0); if (lv) { if (sw) { U8 s[UTF8_MAXLEN+1]; for (i = 0; i <= 256; i++) { /* just the first 256 */ U8 *e = uvchr_to_utf8(s, i); if (i < 256 && swash_fetch(sw, s, TRUE)) { if (rangestart == -1) rangestart = i; } else if (rangestart != -1) { U8 *p; if (i <= rangestart + 3) for (; rangestart < i; rangestart++) { for(e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++) put_byte(sv, *p); } else { for (e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++) put_byte(sv, *p); sv_catpv(sv, "-"); for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++) put_byte(sv, *p); } rangestart = -1; } } sv_catpv(sv, "..."); /* et cetera */ } { char *s = savepv(SvPVX(lv)); char *origs = s; while(*s && *s != '\n') s++; if (*s == '\n') { char *t = ++s; while (*s) { if (*s == '\n') *s = ' '; s++; } if (s[-1] == ' ') s[-1] = 0; sv_catpv(sv, t); } Safefree(origs); } } } Perl_sv_catpvf(aTHX_ sv, "%s]", PL_colors[1]); } else if (k == BRANCHJ && (OP(o) == UNLESSM || OP(o) == IFMATCH)) Perl_sv_catpvf(aTHX_ sv, "[-%d]", o->flags); #endif /* DEBUGGING */ } SV * Perl_re_intuit_string(pTHX_ regexp *prog) { /* Assume that RE_INTUIT is set */ DEBUG_r( { STRLEN n_a; char *s = SvPV(prog->check_substr ? prog->check_substr : prog->check_utf8, n_a); if (!PL_colorset) reginitcolors(); PerlIO_printf(Perl_debug_log, "%sUsing REx %ssubstr:%s `%s%.60s%s%s'\n", PL_colors[4], prog->check_substr ? "" : "utf8 ", PL_colors[5],PL_colors[0], s, PL_colors[1], (strlen(s) > 60 ? "..." : "")); } ); return prog->check_substr ? prog->check_substr : prog->check_utf8; } void Perl_pregfree(pTHX_ struct regexp *r) { #ifdef DEBUGGING SV *dsv = PERL_DEBUG_PAD_ZERO(0); #endif if (!r || (--r->refcnt > 0)) return; DEBUG_r({ int len; char *s; s = (r->reganch & ROPT_UTF8) ? pv_uni_display(dsv, (U8*)r->precomp, r->prelen, 60, UNI_DISPLAY_REGEX) : pv_display(dsv, r->precomp, r->prelen, 0, 60); len = SvCUR(dsv); if (!PL_colorset) reginitcolors(); PerlIO_printf(Perl_debug_log, "%sFreeing REx:%s `%s%*.*s%s%s'\n", PL_colors[4],PL_colors[5],PL_colors[0], len, len, s, PL_colors[1], len > 60 ? "..." : ""); }); if (r->precomp) Safefree(r->precomp); if (r->offsets) /* 20010421 MJD */ Safefree(r->offsets); if (RX_MATCH_COPIED(r)) Safefree(r->subbeg); if (r->substrs) { if (r->anchored_substr) SvREFCNT_dec(r->anchored_substr); if (r->anchored_utf8) SvREFCNT_dec(r->anchored_utf8); if (r->float_substr) SvREFCNT_dec(r->float_substr); if (r->float_utf8) SvREFCNT_dec(r->float_utf8); Safefree(r->substrs); } if (r->data) { int n = r->data->count; PAD* new_comppad = NULL; PAD* old_comppad; while (--n >= 0) { /* If you add a ->what type here, update the comment in regcomp.h */ switch (r->data->what[n]) { case 's': SvREFCNT_dec((SV*)r->data->data[n]); break; case 'f': Safefree(r->data->data[n]); break; case 'p': new_comppad = (AV*)r->data->data[n]; break; case 'o': if (new_comppad == NULL) Perl_croak(aTHX_ "panic: pregfree comppad"); PAD_SAVE_LOCAL(old_comppad, /* Watch out for global destruction's random ordering. */ (SvTYPE(new_comppad) == SVt_PVAV) ? new_comppad : Null(PAD *) ); if (!OpREFCNT_dec((OP_4tree*)r->data->data[n])) { op_free((OP_4tree*)r->data->data[n]); } PAD_RESTORE_LOCAL(old_comppad); SvREFCNT_dec((SV*)new_comppad); new_comppad = NULL; break; case 'n': break; default: Perl_croak(aTHX_ "panic: regfree data code '%c'", r->data->what[n]); } } Safefree(r->data->what); Safefree(r->data); } Safefree(r->startp); Safefree(r->endp); Safefree(r); } /* - regnext - dig the "next" pointer out of a node * * [Note, when REGALIGN is defined there are two places in regmatch() * that bypass this code for speed.] */ regnode * Perl_regnext(pTHX_ register regnode *p) { register I32 offset; if (p == &PL_regdummy) return(NULL); offset = (reg_off_by_arg[OP(p)] ? ARG(p) : NEXT_OFF(p)); if (offset == 0) return(NULL); return(p+offset); } STATIC void S_re_croak2(pTHX_ const char* pat1,const char* pat2,...) { va_list args; STRLEN l1 = strlen(pat1); STRLEN l2 = strlen(pat2); char buf[512]; SV *msv; char *message; if (l1 > 510) l1 = 510; if (l1 + l2 > 510) l2 = 510 - l1; Copy(pat1, buf, l1 , char); Copy(pat2, buf + l1, l2 , char); buf[l1 + l2] = '\n'; buf[l1 + l2 + 1] = '\0'; #ifdef I_STDARG /* ANSI variant takes additional second argument */ va_start(args, pat2); #else va_start(args); #endif msv = vmess(buf, &args); va_end(args); message = SvPV(msv,l1); if (l1 > 512) l1 = 512; Copy(message, buf, l1 , char); buf[l1-1] = '\0'; /* Overwrite \n */ Perl_croak(aTHX_ "%s", buf); } /* XXX Here's a total kludge. But we need to re-enter for swash routines. */ void Perl_save_re_context(pTHX) { SAVEI32(PL_reg_flags); /* from regexec.c */ SAVEPPTR(PL_bostr); SAVEPPTR(PL_reginput); /* String-input pointer. */ SAVEPPTR(PL_regbol); /* Beginning of input, for ^ check. */ SAVEPPTR(PL_regeol); /* End of input, for $ check. */ SAVEVPTR(PL_regstartp); /* Pointer to startp array. */ SAVEVPTR(PL_regendp); /* Ditto for endp. */ SAVEVPTR(PL_reglastparen); /* Similarly for lastparen. */ SAVEVPTR(PL_reglastcloseparen); /* Similarly for lastcloseparen. */ SAVEPPTR(PL_regtill); /* How far we are required to go. */ SAVEGENERICPV(PL_reg_start_tmp); /* from regexec.c */ PL_reg_start_tmp = 0; SAVEI32(PL_reg_start_tmpl); /* from regexec.c */ PL_reg_start_tmpl = 0; SAVEVPTR(PL_regdata); SAVEI32(PL_reg_eval_set); /* from regexec.c */ SAVEI32(PL_regnarrate); /* from regexec.c */ SAVEVPTR(PL_regprogram); /* from regexec.c */ SAVEINT(PL_regindent); /* from regexec.c */ SAVEVPTR(PL_regcc); /* from regexec.c */ SAVEVPTR(PL_curcop); SAVEVPTR(PL_reg_call_cc); /* from regexec.c */ SAVEVPTR(PL_reg_re); /* from regexec.c */ SAVEPPTR(PL_reg_ganch); /* from regexec.c */ SAVESPTR(PL_reg_sv); /* from regexec.c */ SAVEBOOL(PL_reg_match_utf8); /* from regexec.c */ SAVEVPTR(PL_reg_magic); /* from regexec.c */ SAVEI32(PL_reg_oldpos); /* from regexec.c */ SAVEVPTR(PL_reg_oldcurpm); /* from regexec.c */ SAVEVPTR(PL_reg_curpm); /* from regexec.c */ SAVEPPTR(PL_reg_oldsaved); /* old saved substr during match */ PL_reg_oldsaved = Nullch; SAVEI32(PL_reg_oldsavedlen); /* old length of saved substr during match */ PL_reg_oldsavedlen = 0; SAVEI32(PL_reg_maxiter); /* max wait until caching pos */ PL_reg_maxiter = 0; SAVEI32(PL_reg_leftiter); /* wait until caching pos */ PL_reg_leftiter = 0; SAVEGENERICPV(PL_reg_poscache); /* cache of pos of WHILEM */ PL_reg_poscache = Nullch; SAVEI32(PL_reg_poscache_size); /* size of pos cache of WHILEM */ PL_reg_poscache_size = 0; SAVEPPTR(PL_regprecomp); /* uncompiled string. */ SAVEI32(PL_regnpar); /* () count. */ SAVEI32(PL_regsize); /* from regexec.c */ { /* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */ U32 i; GV *mgv; REGEXP *rx; char digits[16]; if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { for (i = 1; i <= rx->nparens; i++) { sprintf(digits, "%lu", (long)i); if ((mgv = gv_fetchpv(digits, FALSE, SVt_PV))) save_scalar(mgv); } } } #ifdef DEBUGGING SAVEPPTR(PL_reg_starttry); /* from regexec.c */ #endif } static void clear_re(pTHX_ void *r) { ReREFCNT_dec((regexp *)r); }
f6019ddfb2f13d11b664bc21b6b41bb3dc1ca3b6
52c8ed39b32ccc7c0673278c1adea3638797c9ff
/src/arch/arm32/mach-raspi2/include/bcm2836-mbox.h
5b2034721d55391e948e3ae949cfe1b32ad6dfcf
[ "MIT" ]
permissive
xboot/xboot
0cab7b440b612aa0a4c366025598a53a7ec3adf1
6d6b93947b7fcb8c3924fedb0715c23877eedd5e
refs/heads/master
2023-08-20T05:56:25.149388
2023-07-12T07:38:29
2023-07-12T07:38:29
471,539
765
296
MIT
2023-05-25T09:39:01
2010-01-14T08:25:12
C
UTF-8
C
false
false
2,000
h
bcm2836-mbox.h
#ifndef __BCM2836_MBOX_H__ #define __BCM2836_MBOX_H__ #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /* Mbox videocore */ int bcm2836_mbox_vc_get_firmware_revison(void); /* Mbox hardware */ int bcm2836_mbox_hardware_get_model(void); int bcm2836_mbox_hardware_get_revison(void); int bcm2836_mbox_hardware_get_mac_address(uint8_t * mac); int bcm2836_mbox_hardware_get_serial(uint64_t * sn); int bcm2836_mbox_hardware_get_arm_memory(uint32_t * base, uint32_t * size); int bcm2836_mbox_hardware_get_vc_memory(uint32_t * base, uint32_t * size); /* Mbox clock */ enum { MBOX_CLOCK_ID_EMMC = 1, MBOX_CLOCK_ID_UART = 2, MBOX_CLOCK_ID_ARM = 3, MBOX_CLOCK_ID_CORE = 4, MBOX_CLOCK_ID_V3D = 5, MBOX_CLOCK_ID_H264 = 6, MBOX_CLOCK_ID_ISP = 7, MBOX_CLOCK_ID_SDRAM = 8, MBOX_CLOCK_ID_PIXEL = 9, MBOX_CLOCK_ID_PWM = 10, }; int bcm2836_mbox_clock_get_turbo(void); int bcm2836_mbox_clock_set_turbo(int level); int bcm2836_mbox_clock_get_state(int id); int bcm2836_mbox_clock_set_state(int id, int state); int bcm2836_mbox_clock_get_rate(int id); int bcm2836_mbox_clock_set_rate(int id, int rate); int bcm2836_mbox_clock_get_max_rate(int id); int bcm2836_mbox_clock_get_min_rate(int id); /* Mbox power */ enum { MBOX_POWER_ID_SDCARD = 0, MBOX_POWER_ID_UART0 = 1, MBOX_POWER_ID_UART1 = 2, MBOX_POWER_ID_USBHCD = 3, MBOX_POWER_ID_I2C0 = 4, MBOX_POWER_ID_I2C1 = 5, MBOX_POWER_ID_I2C2 = 6, MBOX_POWER_ID_SPI = 7, MBOX_POWER_ID_CCP2TX = 8, }; int bcm2836_mbox_power_get_state(int id); int bcm2836_mbox_power_set_state(int id, int state); /* Mbox temperature */ int bcm2836_mbox_temp_get(void); int bcm2836_mbox_temp_get_max(void); /* Mbox framebuffer */ uint32_t bcm2836_mbox_fb_get_gpiovirt(void); void * bcm2836_mbox_fb_alloc(int width, int height, int bpp, int nrender); int bcm2836_mbox_fb_present(int xoffset, int yoffset); #ifdef __cplusplus } #endif #endif /* __BCM2836_MBOX_H__ */
50dc633f6ab9ddd62c586d637948d9f3128cdf77
c26d7b0ed875357278e61627da2da0650da77986
/src/libtcl/tclbasic.c
268fe88507f5926f0cb206335b8850479a5ca649
[ "BSD-3-Clause" ]
permissive
RetroBSD/retrobsd
5343d9e3c424637fc3ad5b03fe720b2744490025
486f81f6abff01c7dcc207235cd2979b226a95ff
refs/heads/master
2023-09-02T23:12:05.110883
2023-07-07T18:41:40
2023-07-07T18:41:40
18,598,087
282
59
BSD-3-Clause
2023-07-18T07:35:36
2014-04-09T13:25:46
C
UTF-8
C
false
false
29,010
c
tclbasic.c
/* * tclBasic.c -- * * Contains the basic facilities for TCL command interpretation, * including interpreter creation and deletion, command creation * and deletion, and command parsing and execution. * * Copyright 1987-1992 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include <stdarg.h> /* * The following structure defines all of the commands in the Tcl core, * and the C procedures that execute them. */ typedef struct { unsigned char *name; /* Name of command. */ Tcl_CmdProc *proc; /* Procedure that executes command. */ } CmdInfo; /* * Built-in commands, and the procedures associated with them: */ static CmdInfo builtin_cmds[] = { /* * Commands in the generic core: */ {(unsigned char*) "append", Tcl_AppendCmd}, {(unsigned char*) "array", Tcl_ArrayCmd}, {(unsigned char*) "break", Tcl_BreakCmd}, {(unsigned char*) "case", Tcl_CaseCmd}, {(unsigned char*) "catch", Tcl_CatchCmd}, {(unsigned char*) "concat", Tcl_ConcatCmd}, {(unsigned char*) "continue", Tcl_ContinueCmd}, {(unsigned char*) "error", Tcl_ErrorCmd}, {(unsigned char*) "eval", Tcl_EvalCmd}, {(unsigned char*) "expr", Tcl_ExprCmd}, {(unsigned char*) "for", Tcl_ForCmd}, {(unsigned char*) "foreach", Tcl_ForeachCmd}, {(unsigned char*) "format", Tcl_FormatCmd}, {(unsigned char*) "global", Tcl_GlobalCmd}, {(unsigned char*) "if", Tcl_IfCmd}, {(unsigned char*) "incr", Tcl_IncrCmd}, {(unsigned char*) "info", Tcl_InfoCmd}, {(unsigned char*) "join", Tcl_JoinCmd}, {(unsigned char*) "lappend", Tcl_LappendCmd}, {(unsigned char*) "lindex", Tcl_LindexCmd}, {(unsigned char*) "linsert", Tcl_LinsertCmd}, {(unsigned char*) "list", Tcl_ListCmd}, {(unsigned char*) "llength", Tcl_LlengthCmd}, {(unsigned char*) "lrange", Tcl_LrangeCmd}, {(unsigned char*) "lreplace", Tcl_LreplaceCmd}, {(unsigned char*) "lsearch", Tcl_LsearchCmd}, {(unsigned char*) "lsort", Tcl_LsortCmd}, {(unsigned char*) "proc", Tcl_ProcCmd}, {(unsigned char*) "regexp", Tcl_RegexpCmd}, {(unsigned char*) "regsub", Tcl_RegsubCmd}, {(unsigned char*) "rename", Tcl_RenameCmd}, {(unsigned char*) "return", Tcl_ReturnCmd}, {(unsigned char*) "scan", Tcl_ScanCmd}, {(unsigned char*) "set", Tcl_SetCmd}, {(unsigned char*) "split", Tcl_SplitCmd}, {(unsigned char*) "string", Tcl_StringCmd}, {(unsigned char*) "trace", Tcl_TraceCmd}, {(unsigned char*) "unset", Tcl_UnsetCmd}, {(unsigned char*) "uplevel", Tcl_UplevelCmd}, {(unsigned char*) "upvar", Tcl_UpvarCmd}, {(unsigned char*) "while", Tcl_WhileCmd}, /* * Commands in the UNIX core: */ #ifdef TCL_FILE_CMDS {(unsigned char*) "glob", Tcl_GlobCmd}, {(unsigned char*) "cd", Tcl_CdCmd}, {(unsigned char*) "close", Tcl_CloseCmd}, {(unsigned char*) "eof", Tcl_EofCmd}, {(unsigned char*) "exit", Tcl_ExitCmd}, {(unsigned char*) "file", Tcl_FileCmd}, {(unsigned char*) "flush", Tcl_FlushCmd}, {(unsigned char*) "gets", Tcl_GetsCmd}, {(unsigned char*) "open", Tcl_OpenCmd}, {(unsigned char*) "puts", Tcl_PutsCmd}, {(unsigned char*) "pwd", Tcl_PwdCmd}, {(unsigned char*) "read", Tcl_ReadCmd}, {(unsigned char*) "seek", Tcl_SeekCmd}, {(unsigned char*) "source", Tcl_SourceCmd}, {(unsigned char*) "tell", Tcl_TellCmd}, #endif {0, 0} }; /* *---------------------------------------------------------------------- * * Tcl_CreateInterp -- * * Create a new TCL command interpreter. * * Results: * The return value is a token for the interpreter, which may be * used in calls to procedures like Tcl_CreateCmd, Tcl_Eval, or * Tcl_DeleteInterp. * * Side effects: * The command interpreter is initialized with an empty variable * table and the built-in commands. * *---------------------------------------------------------------------- */ Tcl_Interp * Tcl_CreateInterp () { Interp *iPtr; Command *c; CmdInfo *ci; int i; iPtr = (Interp*) malloc (sizeof(Interp)); iPtr->result = iPtr->resultSpace; iPtr->freeProc = 0; iPtr->errorLine = 0; Tcl_InitHashTable (&iPtr->commandTable, TCL_STRING_KEYS); Tcl_InitHashTable (&iPtr->globalTable, TCL_STRING_KEYS); iPtr->numLevels = 0; iPtr->framePtr = 0; iPtr->varFramePtr = 0; iPtr->activeTracePtr = 0; iPtr->numEvents = 0; iPtr->events = 0; iPtr->curEvent = 0; iPtr->curEventNum = 0; iPtr->revPtr = 0; iPtr->historyFirst = 0; iPtr->revDisables = 1; iPtr->evalFirst = iPtr->evalLast = 0; iPtr->appendResult = 0; iPtr->appendAvl = 0; iPtr->appendUsed = 0; iPtr->numFiles = 0; iPtr->filePtrArray = 0; for (i = 0; i < NUM_REGEXPS; i++) { iPtr->patterns[i] = 0; iPtr->patLengths[i] = -1; iPtr->regexps[i] = 0; } iPtr->cmdCount = 0; iPtr->noEval = 0; iPtr->scriptFile = 0; iPtr->flags = 0; iPtr->tracePtr = 0; iPtr->resultSpace[0] = 0; /* * Create the built-in commands. Do it here, rather than calling * Tcl_CreateCommand, because it's faster (there's no need to * check for a pre-existing command by the same name). */ for (ci = builtin_cmds; ci->name != 0; ci++) { int new; Tcl_HashEntry *he; he = Tcl_CreateHashEntry (&iPtr->commandTable, ci->name, &new); if (new) { c = (Command*) malloc (sizeof(Command)); c->proc = ci->proc; c->clientData = (void*) 0; c->deleteProc = 0; Tcl_SetHashValue (he, c); } } #ifdef TCL_ENV_CMDS TclSetupEnv ((Tcl_Interp *) iPtr); #endif return (Tcl_Interp *) iPtr; } /* *---------------------------------------------------------------------- * * Tcl_DeleteInterp -- * * Delete an interpreter and free up all of the resources associated * with it. * * Results: * None. * * Side effects: * The interpreter is destroyed. The caller should never again * use the interp token. * *---------------------------------------------------------------------- */ void Tcl_DeleteInterp(interp) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ { Interp *iPtr = (Interp *) interp; Tcl_HashEntry *he; Tcl_HashSearch search; register Command *c; int i; /* * If the interpreter is in use, delay the deletion until later. */ iPtr->flags |= DELETED; if (iPtr->numLevels != 0) { return; } /* * Free up any remaining resources associated with the * interpreter. */ for (he = Tcl_FirstHashEntry(&iPtr->commandTable, &search); he != 0; he = Tcl_NextHashEntry(&search)) { c = (Command *) Tcl_GetHashValue(he); if (c->deleteProc != 0) { (*c->deleteProc)(c->clientData); } free (c); } Tcl_DeleteHashTable(&iPtr->commandTable); TclDeleteVars(iPtr, &iPtr->globalTable); if (iPtr->events != 0) { int i; for (i = 0; i < iPtr->numEvents; i++) { free(iPtr->events[i].command); } free (iPtr->events); } while (iPtr->revPtr != 0) { HistoryRev *nextPtr = iPtr->revPtr->nextPtr; free (iPtr->revPtr); iPtr->revPtr = nextPtr; } if (iPtr->appendResult != 0) { free(iPtr->appendResult); } #ifdef TCL_FILE_CMDS if (iPtr->numFiles > 0) { for (i = 0; i < iPtr->numFiles; i++) { OpenFile *filePtr; filePtr = iPtr->filePtrArray[i]; if (filePtr == 0) { continue; } if (i >= 3) { fclose(filePtr->f); if (filePtr->f2 != 0) { fclose(filePtr->f2); } if (filePtr->numPids > 0) { /* Tcl_DetachPids(filePtr->numPids, filePtr->pidPtr); */ free (filePtr->pidPtr); } } free (filePtr); } free (iPtr->filePtrArray); } #endif for (i = 0; i < NUM_REGEXPS; i++) { if (iPtr->patterns[i] == 0) { break; } free (iPtr->patterns[i]); free (iPtr->regexps[i]); } while (iPtr->tracePtr != 0) { Trace *nextPtr = iPtr->tracePtr->nextPtr; free (iPtr->tracePtr); iPtr->tracePtr = nextPtr; } free (iPtr); } /* *---------------------------------------------------------------------- * * Tcl_CreateCommand -- * * Define a new command in a command table. * * Results: * None. * * Side effects: * If a command named cmdName already exists for interp, it is * deleted. In the future, when cmdName is seen as the name of * a command by Tcl_Eval, proc will be called. When the command * is deleted from the table, deleteProc will be called. See the * manual entry for details on the calling sequence. * *---------------------------------------------------------------------- */ void Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ unsigned char *cmdName; /* Name of command. */ Tcl_CmdProc *proc; /* Command procedure to associate with * cmdName. */ void *clientData; /* Arbitrary one-word value to pass to proc. */ Tcl_CmdDeleteProc *deleteProc; /* If not NULL, gives a procedure to call when * this command is deleted. */ { Interp *iPtr = (Interp *) interp; register Command *c; Tcl_HashEntry *he; int new; he = Tcl_CreateHashEntry(&iPtr->commandTable, cmdName, &new); if (!new) { /* * Command already exists: delete the old one. */ c = (Command *) Tcl_GetHashValue(he); if (c->deleteProc != 0) { (*c->deleteProc)(c->clientData); } } else { c = (Command*) malloc (sizeof(Command)); Tcl_SetHashValue(he, c); } c->proc = proc; c->clientData = clientData; c->deleteProc = deleteProc; } /* *---------------------------------------------------------------------- * * Tcl_DeleteCommand -- * * Remove the given command from the given interpreter. * * Results: * 0 is returned if the command was deleted successfully. * -1 is returned if there didn't exist a command by that * name. * * Side effects: * CmdName will no longer be recognized as a valid command for * interp. * *---------------------------------------------------------------------- */ int Tcl_DeleteCommand(interp, cmdName) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ unsigned char *cmdName; /* Name of command to remove. */ { Interp *iPtr = (Interp *) interp; Tcl_HashEntry *he; Command *c; he = Tcl_FindHashEntry(&iPtr->commandTable, cmdName); if (he == 0) { return -1; } c = (Command *) Tcl_GetHashValue(he); if (c->deleteProc != 0) { (*c->deleteProc)(c->clientData); } free (c); Tcl_DeleteHashEntry(he); return 0; } /* *----------------------------------------------------------------- * * Tcl_Eval -- * * Parse and execute a command in the Tcl language. * * Results: * The return value is one of the return codes defined in tcl.hd * (such as TCL_OK), and interp->result contains a string value * to supplement the return code. The value of interp->result * will persist only until the next call to Tcl_Eval: copy it or * lose it! *TermPtr is filled in with the character just after * the last one that was part of the command (usually a NULL * character or a closing bracket). * * Side effects: * Almost certainly; depends on the command. * *----------------------------------------------------------------- */ int Tcl_Eval(interp, cmd, flags, termPtr) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ unsigned char *cmd; /* Pointer to TCL command to interpret. */ int flags; /* OR-ed combination of flags like * TCL_BRACKET_TERM and TCL_RECORD_BOUNDS. */ unsigned char **termPtr; /* If non-NULL, fill in the address it points * to with the address of the char. just after * the last one that was part of cmd. See * the man page for details on this. */ { /* * The storage immediately below is used to generate a copy * of the command, after all argument substitutions. Pv will * contain the argv values passed to the command procedure. */ # define NUM_CHARS 200 unsigned char copyStorage[NUM_CHARS]; ParseValue pv; unsigned char *oldBuffer; /* * This procedure generates an (argv, argc) array for the command, * It starts out with stack-allocated space but uses dynamically- * allocated storage to increase it if needed. */ # define NUM_ARGS 10 unsigned char *(argStorage[NUM_ARGS]); unsigned char **argv = argStorage; int argc; int argSize = NUM_ARGS; register unsigned char *src; /* Points to current character * in cmd. */ char termChar; /* Return when this character is found * (either ']' or '\0'). Zero means * that newlines terminate commands. */ int result; /* Return value. */ register Interp *iPtr = (Interp *) interp; Tcl_HashEntry *he; Command *c; unsigned char *dummy; /* Make termPtr point here if it was * originally NULL. */ unsigned char *cmdStart; /* Points to first non-blank char. in * command (used in calling trace * procedures). */ unsigned char *ellipsis = (unsigned char*) ""; /* Used in setting errorInfo variable; * set to "..." to indicate that not * all of offending command is included * in errorInfo. "" means that the * command is all there. */ register Trace *tracePtr; /* * Initialize the result to an empty string and clear out any * error information. This makes sure that we return an empty * result if there are no commands in the command string. */ Tcl_FreeResult((Tcl_Interp *) iPtr); iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = 0; result = TCL_OK; /* * Check depth of nested calls to Tcl_Eval: if this gets too large, * it's probably because of an infinite loop somewhere. */ iPtr->numLevels++; if (iPtr->numLevels > MAX_NESTING_DEPTH) { iPtr->numLevels--; iPtr->result = (unsigned char*) "too many nested calls to Tcl_Eval (infinite loop?)"; return TCL_ERROR; } /* * Initialize the area in which command copies will be assembled. */ pv.buffer = copyStorage; pv.end = copyStorage + NUM_CHARS - 1; pv.expandProc = TclExpandParseValue; pv.clientData = (void*) 0; src = cmd; if (flags & TCL_BRACKET_TERM) { termChar = ']'; } else { termChar = 0; } if (termPtr == 0) { termPtr = &dummy; } *termPtr = src; cmdStart = src; /* * There can be many sub-commands (separated by semi-colons or * newlines) in one command string. This outer loop iterates over * individual commands. */ while (*src != termChar) { iPtr->flags &= ~(ERR_IN_PROGRESS | ERROR_CODE_SET); /* * Skim off leading white space and semi-colons, and skip * comments. */ while (1) { switch (*src) { case '\t': case '\v': case '\f': case '\r': case '\n': case ' ': case ':': ++src; continue; } break; } if (*src == '#') { for (src++; *src != 0; src++) { if ((*src == '\n') && (src[-1] != '\\')) { src++; break; } } continue; } cmdStart = src; /* * Parse the words of the command, generating the argc and * argv for the command procedure. May have to call * TclParseWords several times, expanding the argv array * between calls. */ pv.next = oldBuffer = pv.buffer; argc = 0; while (1) { int newArgs, maxArgs; unsigned char **newArgv; int i; /* * Note: the "- 2" below guarantees that we won't use the * last two argv slots here. One is for a NULL pointer to * mark the end of the list, and the other is to leave room * for inserting the command name "unknown" as the first * argument (see below). */ maxArgs = argSize - argc - 2; result = TclParseWords((Tcl_Interp *) iPtr, src, flags, maxArgs, termPtr, &newArgs, &argv[argc], &pv); src = *termPtr; if (result != TCL_OK) { ellipsis = (unsigned char*) "..."; goto done; } /* * Careful! Buffer space may have gotten reallocated while * parsing words. If this happened, be sure to update all * of the older argv pointers to refer to the new space. */ if (oldBuffer != pv.buffer) { int i; for (i = 0; i < argc; i++) { argv[i] = pv.buffer + (argv[i] - oldBuffer); } oldBuffer = pv.buffer; } argc += newArgs; if (newArgs < maxArgs) { argv[argc] = 0; break; } /* * Args didn't all fit in the current array. Make it bigger. */ argSize *= 2; newArgv = (unsigned char**) malloc ((unsigned) argSize * sizeof(char *)); for (i = 0; i < argc; i++) { newArgv[i] = argv[i]; } if (argv != argStorage) { free (argv); } argv = newArgv; } /* * If this is an empty command (or if we're just parsing * commands without evaluating them), then just skip to the * next command. */ if ((argc == 0) || iPtr->noEval) { continue; } argv[argc] = 0; /* * Save information for the history module, if needed. */ if (flags & TCL_RECORD_BOUNDS) { iPtr->evalFirst = cmdStart; iPtr->evalLast = src-1; } /* * Find the procedure to execute this command. If there isn't * one, then see if there is a command "unknown". If so, * invoke it instead, passing it the words of the original * command as arguments. */ he = Tcl_FindHashEntry(&iPtr->commandTable, argv[0]); if (he == 0) { int i; he = Tcl_FindHashEntry(&iPtr->commandTable, (unsigned char*) "unknown"); if (he == 0) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "invalid command name: \"", argv[0], "\"", 0); result = TCL_ERROR; goto done; } for (i = argc; i >= 0; i--) { argv[i+1] = argv[i]; } argv[0] = (unsigned char*) "unknown"; argc++; } c = (Command *) Tcl_GetHashValue(he); /* * Call trace procedures, if any. */ for (tracePtr = iPtr->tracePtr; tracePtr != 0; tracePtr = tracePtr->nextPtr) { char saved; if (tracePtr->level < iPtr->numLevels) { continue; } saved = *src; *src = 0; (*tracePtr->proc)(tracePtr->clientData, interp, iPtr->numLevels, cmdStart, c->proc, c->clientData, argc, argv); *src = saved; } /* * At long last, invoke the command procedure. Reset the * result to its default empty value first (it could have * gotten changed by earlier commands in the same command * string). */ iPtr->cmdCount++; Tcl_FreeResult ((Tcl_Interp*) iPtr); iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = 0; result = (*c->proc)(c->clientData, interp, argc, argv); if (result != TCL_OK) { break; } } /* * Free up any extra resources that were allocated. */ done: if (pv.buffer != copyStorage) { free (pv.buffer); } if (argv != argStorage) { free (argv); } iPtr->numLevels--; if (iPtr->numLevels == 0) { if (result == TCL_RETURN) { result = TCL_OK; } if ((result != TCL_OK) && (result != TCL_ERROR)) { Tcl_ResetResult(interp); if (result == TCL_BREAK) { iPtr->result = (unsigned char*) "invoked \"break\" outside of a loop"; } else if (result == TCL_CONTINUE) { iPtr->result = (unsigned char*) "invoked \"continue\" outside of a loop"; } else { iPtr->result = iPtr->resultSpace; sprintf(iPtr->resultSpace, "command returned bad code: %d", result); } result = TCL_ERROR; } if (iPtr->flags & DELETED) { Tcl_DeleteInterp(interp); } } /* * If an error occurred, record information about what was being * executed when the error occurred. */ if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) { int numChars; register unsigned char *p; /* * Compute the line number where the error occurred. */ iPtr->errorLine = 1; for (p = cmd; p != cmdStart; p++) { if (*p == '\n') { iPtr->errorLine++; } } for ( ; isspace(*p) || (*p == ';'); p++) { if (*p == '\n') { iPtr->errorLine++; } } /* * Figure out how much of the command to print in the error * message (up to a certain number of characters, or up to * the first new-line). */ numChars = src - cmdStart; if (numChars > (NUM_CHARS-50)) { numChars = NUM_CHARS-50; ellipsis = (unsigned char*) " ..."; } if (!(iPtr->flags & ERR_IN_PROGRESS)) { sprintf(copyStorage, "\n while executing\n\"%.*s%s\"", numChars, cmdStart, ellipsis); } else { sprintf(copyStorage, "\n invoked from within\n\"%.*s%s\"", numChars, cmdStart, ellipsis); } Tcl_AddErrorInfo(interp, copyStorage); iPtr->flags &= ~ERR_ALREADY_LOGGED; } else { iPtr->flags &= ~ERR_ALREADY_LOGGED; } return result; } /* *---------------------------------------------------------------------- * * Tcl_CreateTrace -- * * Arrange for a procedure to be called to trace command execution. * * Results: * The return value is a token for the trace, which may be passed * to Tcl_DeleteTrace to eliminate the trace. * * Side effects: * From now on, proc will be called just before a command procedure * is called to execute a Tcl command. Calls to proc will have the * following form: * * void * proc(clientData, interp, level, command, cmdProc, cmdClientData, * argc, argv) * void *clientData; * Tcl_Interp *interp; * int level; * unsigned char *command; * int (*cmdProc)(); * void *cmdClientData; * int argc; * unsigned char **argv; * { * } * * The clientData and interp arguments to proc will be the same * as the corresponding arguments to this procedure. Level gives * the nesting level of command interpretation for this interpreter * (0 corresponds to top level). Command gives the ASCII text of * the raw command, cmdProc and cmdClientData give the procedure that * will be called to process the command and the ClientData value it * will receive, and argc and argv give the arguments to the * command, after any argument parsing and substitution. Proc * does not return a value. * *---------------------------------------------------------------------- */ Tcl_Trace Tcl_CreateTrace(interp, level, proc, clientData) Tcl_Interp *interp; /* Interpreter in which to create the trace. */ int level; /* Only call proc for commands at nesting level * <= level (1 => top level). */ Tcl_CmdTraceProc *proc; /* Procedure to call before executing each * command. */ void *clientData; /* Arbitrary one-word value to pass to proc. */ { register Trace *tracePtr; register Interp *iPtr = (Interp *) interp; tracePtr = (Trace*) malloc (sizeof(Trace)); tracePtr->level = level; tracePtr->proc = proc; tracePtr->clientData = clientData; tracePtr->nextPtr = iPtr->tracePtr; iPtr->tracePtr = tracePtr; return (Tcl_Trace) tracePtr; } /* *---------------------------------------------------------------------- * * Tcl_DeleteTrace -- * * Remove a trace. * * Results: * None. * * Side effects: * From now on there will be no more calls to the procedure given * in trace. * *---------------------------------------------------------------------- */ void Tcl_DeleteTrace(interp, trace) Tcl_Interp *interp; /* Interpreter that contains trace. */ Tcl_Trace trace; /* Token for trace (returned previously by * Tcl_CreateTrace). */ { register Interp *iPtr = (Interp *) interp; register Trace *tracePtr = (Trace *) trace; register Trace *tracePtr2; if (iPtr->tracePtr == tracePtr) { iPtr->tracePtr = tracePtr->nextPtr; free (tracePtr); } else { for (tracePtr2 = iPtr->tracePtr; tracePtr2 != 0; tracePtr2 = tracePtr2->nextPtr) { if (tracePtr2->nextPtr == tracePtr) { tracePtr2->nextPtr = tracePtr->nextPtr; free (tracePtr); return; } } } } /* *---------------------------------------------------------------------- * * Tcl_AddErrorInfo -- * * Add information to a message being accumulated that describes * the current error. * * Results: * None. * * Side effects: * The contents of message are added to the "errorInfo" variable. * If Tcl_Eval has been called since the current value of errorInfo * was set, errorInfo is cleared before adding the new message. * *---------------------------------------------------------------------- */ void Tcl_AddErrorInfo(interp, message) Tcl_Interp *interp; /* Interpreter to which error information * pertains. */ unsigned char *message; /* Message to record. */ { register Interp *iPtr = (Interp *) interp; /* * If an error is already being logged, then the new errorInfo * is the concatenation of the old info and the new message. * If this is the first piece of info for the error, then the * new errorInfo is the concatenation of the message in * interp->result and the new message. */ if (!(iPtr->flags & ERR_IN_PROGRESS)) { Tcl_SetVar2(interp, (unsigned char*) "errorInfo", 0, interp->result, TCL_GLOBAL_ONLY); iPtr->flags |= ERR_IN_PROGRESS; /* * If the errorCode variable wasn't set by the code that generated * the error, set it to "NONE". */ if (!(iPtr->flags & ERROR_CODE_SET)) { Tcl_SetVar2(interp, (unsigned char*) "errorCode", 0, (unsigned char*) "NONE", TCL_GLOBAL_ONLY); } } Tcl_SetVar2(interp, (unsigned char*) "errorInfo", 0, message, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE); } /* *---------------------------------------------------------------------- * * Tcl_VarEval -- * * Given a variable number of string arguments, concatenate them * all together and execute the result as a Tcl command. * * Results: * A standard Tcl return result. An error message or other * result may be left in interp->result. * * Side effects: * Depends on what was done by the command. * *---------------------------------------------------------------------- */ /* VARARGS2 */ /* ARGSUSED */ int Tcl_VarEval (Tcl_Interp *interp,/* Interpreter in which to execute command. */ ...) /* One or more strings to concatenate, * terminated with a NULL string. */ { va_list argList; #define FIXED_SIZE 200 unsigned char fixedSpace[FIXED_SIZE+1]; int spaceAvl, spaceUsed, length; unsigned char *string, *cmd; int result; /* * Copy the strings one after the other into a single larger * string. Use stack-allocated space for small commands, but if * the commands gets too large than call mem_alloc to create the * space. */ va_start(argList, interp); spaceAvl = FIXED_SIZE; spaceUsed = 0; cmd = fixedSpace; while (1) { string = va_arg(argList, unsigned char *); if (string == 0) { break; } length = strlen(string); if ((spaceUsed + length) > spaceAvl) { unsigned char *new; spaceAvl = spaceUsed + length; spaceAvl += spaceAvl/2; new = malloc ((unsigned) spaceAvl); memcpy ((void*) new, (void*) cmd, spaceUsed); if (cmd != fixedSpace) { free(cmd); } cmd = new; } strcpy(cmd + spaceUsed, string); spaceUsed += length; } va_end(argList); cmd[spaceUsed] = '\0'; result = Tcl_Eval(interp, cmd, 0, 0); if (cmd != fixedSpace) { free(cmd); } return result; } /* *---------------------------------------------------------------------- * * Tcl_GlobalEval -- * * Evaluate a command at global level in an interpreter. * * Results: * A standard Tcl result is returned, and interp->result is * modified accordingly. * * Side effects: * The command string is executed in interp, and the execution * is carried out in the variable context of global level (no * procedures active), just as if an "uplevel #0" command were * being executed. * *---------------------------------------------------------------------- */ int Tcl_GlobalEval(interp, command) Tcl_Interp *interp; /* Interpreter in which to evaluate command. */ unsigned char *command; /* Command to evaluate. */ { register Interp *iPtr = (Interp *) interp; int result; CallFrame *savedVarFramePtr; savedVarFramePtr = iPtr->varFramePtr; iPtr->varFramePtr = 0; result = Tcl_Eval(interp, command, 0, 0); iPtr->varFramePtr = savedVarFramePtr; return result; }
5401634add0879a7e6a3826b71267d08d5285689
b4995c17067e4c16e287b4d0d454a9437ed38751
/src/njs.h
69448d1ec8f7d8cbe02b000720a26a9229acf5ae
[ "BSD-2-Clause" ]
permissive
nginx/njs
95f44a9128d26f8ed6a052b2e00dd7cff1410efb
e694d61a94c711b7c48b0ae23909a4cef7c65700
refs/heads/master
2023-08-24T18:52:57.529281
2023-08-23T17:09:22
2023-08-23T17:09:22
43,038,779
742
120
BSD-2-Clause
2023-07-30T09:23:31
2015-09-24T02:03:58
C
UTF-8
C
false
false
22,946
h
njs.h
/* * Copyright (C) Igor Sysoev * Copyright (C) NGINX, Inc. * * njs public header. */ #ifndef _NJS_H_INCLUDED_ #define _NJS_H_INCLUDED_ #include <njs_auto_config.h> #define NJS_VERSION "0.8.1" #define NJS_VERSION_NUMBER 0x000801 #include <string.h> #include <njs_types.h> #include <njs_clang.h> #include <njs_str.h> #include <njs_unicode.h> #include <njs_utf8.h> #include <njs_mp.h> #include <njs_chb.h> #include <njs_sprintf.h> typedef uintptr_t njs_index_t; typedef struct njs_vm_s njs_vm_t; typedef struct njs_mod_s njs_mod_t; typedef union njs_value_s njs_value_t; typedef struct njs_function_s njs_function_t; typedef struct njs_vm_shared_s njs_vm_shared_t; typedef struct njs_object_init_s njs_object_init_t; typedef struct njs_object_prop_s njs_object_prop_t; typedef struct njs_object_type_init_s njs_object_type_init_t; typedef struct njs_external_s njs_external_t; /* * njs_opaque_value_t is the external storage type for native njs_value_t type. * sizeof(njs_opaque_value_t) == sizeof(njs_value_t). */ typedef struct { uint64_t filler[2]; } njs_opaque_value_t; typedef enum { NJS_LOG_LEVEL_ERROR = 4, NJS_LOG_LEVEL_WARN = 5, NJS_LOG_LEVEL_INFO = 7, } njs_log_level_t; /* sizeof(njs_value_t) is 16 bytes. */ #define njs_argument(args, n) \ (njs_value_t *) ((u_char *) args + (n) * 16) extern const njs_value_t njs_value_undefined; #define njs_arg(args, nargs, n) \ ((n < nargs) ? njs_argument(args, n) \ : (njs_value_t *) &njs_value_undefined) #define njs_value_assign(dst, src) \ memcpy(dst, src, sizeof(njs_opaque_value_t)) #define njs_value_arg(val) ((njs_value_t *) val) #define njs_lvalue_arg(lvalue, args, nargs, n) \ ((n < nargs) ? njs_argument(args, n) \ : (njs_value_assign(lvalue, &njs_value_undefined), lvalue)) #define njs_vm_log(vm, fmt, ...) \ njs_vm_logger(vm, NJS_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__) #define njs_vm_warn(vm, fmt, ...) \ njs_vm_logger(vm, NJS_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__) #define njs_vm_err(vm, fmt, ...) \ njs_vm_logger(vm, NJS_LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__) #define njs_vm_error(vm, fmt, ...) \ njs_vm_error2(vm, 0, fmt, ##__VA_ARGS__) #define njs_vm_internal_error(vm, fmt, ...) \ njs_vm_error2(vm, 2, fmt, ##__VA_ARGS__) #define njs_vm_range_error(vm, fmt, ...) \ njs_vm_error2(vm, 3, fmt, ##__VA_ARGS__) #define njs_vm_syntax_error(vm, fmt, ...) \ njs_vm_error2(vm, 5, fmt, ##__VA_ARGS__) #define njs_vm_type_error(vm, fmt, ...) \ njs_vm_error2(vm, 6, fmt, ##__VA_ARGS__) #define njs_deprecated(vm, text) \ do { \ static njs_bool_t reported; \ \ if (!reported) { \ njs_vm_warn(vm, text " is deprecated " \ "and will be removed in the future"); \ reported = 1; \ } \ } while(0) /* * njs_prop_handler_t operates as a property getter/setter or delete handler. * - retval != NULL && setval == NULL - GET context. * - retval != NULL && setval != NULL - SET context. * - retval == NULL - DELETE context. * * njs_prop_handler_t is expected to return: * NJS_OK - handler executed successfully; * NJS_DECLINED - handler was applied to inappropriate object, retval * contains undefined value; * NJS_ERROR - some error, njs_vm_exception_get(vm) can be used to get * the exception value. */ typedef njs_int_t (*njs_prop_handler_t) (njs_vm_t *vm, njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval, njs_value_t *retval); typedef njs_int_t (*njs_exotic_keys_t)(njs_vm_t *vm, njs_value_t *value, njs_value_t *retval); typedef njs_int_t (*njs_function_native_t) (njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t magic8, njs_value_t *retval); typedef enum { NJS_SYMBOL_INVALID, NJS_SYMBOL_ASYNC_ITERATOR, NJS_SYMBOL_HAS_INSTANCE, NJS_SYMBOL_IS_CONCAT_SPREADABLE, NJS_SYMBOL_ITERATOR, NJS_SYMBOL_MATCH, NJS_SYMBOL_MATCH_ALL, NJS_SYMBOL_REPLACE, NJS_SYMBOL_SEARCH, NJS_SYMBOL_SPECIES, NJS_SYMBOL_SPLIT, NJS_SYMBOL_TO_PRIMITIVE, NJS_SYMBOL_TO_STRING_TAG, NJS_SYMBOL_UNSCOPABLES, NJS_SYMBOL_KNOWN_MAX, } njs_wellknown_symbol_t; typedef enum { /* * Extern property type. */ NJS_EXTERN_PROPERTY = 0, NJS_EXTERN_METHOD = 1, NJS_EXTERN_OBJECT = 2, NJS_EXTERN_SELF = 3, #define NJS_EXTERN_TYPE_MASK 3 /* * Extern property flags. */ NJS_EXTERN_SYMBOL = 4, } njs_extern_flag_t; typedef enum { NJS_EXTERN_TYPE_INT = 0, NJS_EXTERN_TYPE_UINT = 1, NJS_EXTERN_TYPE_VALUE = 2, } njs_extern_type_t; struct njs_external_s { njs_extern_flag_t flags; union { njs_str_t string; uint32_t symbol; } name; unsigned writable; unsigned configurable; unsigned enumerable; union { struct { const char value[15]; /* NJS_STRING_SHORT + 1. */ njs_prop_handler_t handler; uint16_t magic16; uint32_t magic32; } property; struct { njs_function_native_t native; uint8_t magic8; uint8_t ctor; } method; struct { njs_external_t *properties; njs_uint_t nproperties; unsigned writable; unsigned configurable; unsigned enumerable; njs_prop_handler_t prop_handler; uint32_t magic32; njs_exotic_keys_t keys; } object; } u; }; /* * NJS and event loops. * * njs_vm_ops_t callbacks are used to interact with the event loop environment. * * Functions get an external object as the first argument. The external * object is provided as the third argument to njs_vm_clone(). * * The callbacks are expected to return to the VM the unique id of an * underlying event. This id will be passed as the second argument to * njs_event_destructor() at the moment the VM wants to destroy it. * * When an underlying events fires njs_vm_post_event() should be invoked with * the value provided as vm_event. * * The events posted by njs_vm_post_event() are processed as soon as * njs_vm_run() is invoked. njs_vm_run() returns NJS_AGAIN until pending events * are present. */ typedef void * njs_vm_event_t; typedef void * njs_host_event_t; typedef void * njs_external_ptr_t; typedef njs_host_event_t (*njs_set_timer_t)(njs_external_ptr_t external, uint64_t delay, njs_vm_event_t vm_event); typedef void (*njs_event_destructor_t)(njs_external_ptr_t external, njs_host_event_t event); typedef njs_mod_t *(*njs_module_loader_t)(njs_vm_t *vm, njs_external_ptr_t external, njs_str_t *name); typedef void (*njs_logger_t)(njs_vm_t *vm, njs_external_ptr_t external, njs_log_level_t level, const u_char *start, size_t length); typedef struct { njs_set_timer_t set_timer; njs_event_destructor_t clear_timer; njs_module_loader_t module_loader; njs_logger_t logger; } njs_vm_ops_t; typedef struct { size_t size; uintptr_t *values; } njs_vm_meta_t; typedef njs_int_t (*njs_addon_init_pt)(njs_vm_t *vm); typedef struct { njs_str_t name; njs_addon_init_pt preinit; njs_addon_init_pt init; } njs_module_t; typedef struct { njs_external_ptr_t external; njs_vm_shared_t *shared; njs_vm_ops_t *ops; njs_vm_meta_t *metas; njs_module_t **addons; njs_str_t file; char **argv; njs_uint_t argc; njs_uint_t max_stack_size; njs_log_level_t log_level; #define NJS_VM_OPT_UNHANDLED_REJECTION_IGNORE 0 #define NJS_VM_OPT_UNHANDLED_REJECTION_THROW 1 /* * interactive - enables "interactive" mode. * (REPL). Allows starting parent VM without cloning. * disassemble - enables disassemble. * backtrace - enables backtraces. * quiet - removes filenames from backtraces. To produce comparable test262 diffs. * sandbox - "sandbox" mode. Disables file access. * unsafe - enables unsafe language features: * - Function constructors. * module - ES6 "module" mode. Script mode is default. * ast - print AST. * unhandled_rejection IGNORE | THROW - tracks unhandled promise rejections: * - throwing inside a Promise without a catch block. * - throwing inside in a finally or catch block. */ uint8_t interactive; /* 1 bit */ uint8_t trailer; /* 1 bit */ uint8_t init; /* 1 bit */ uint8_t disassemble; /* 1 bit */ uint8_t backtrace; /* 1 bit */ uint8_t quiet; /* 1 bit */ uint8_t sandbox; /* 1 bit */ uint8_t unsafe; /* 1 bit */ uint8_t module; /* 1 bit */ uint8_t ast; /* 1 bit */ #ifdef NJS_DEBUG_OPCODE uint8_t opcode_debug; /* 1 bit */ #endif #ifdef NJS_DEBUG_GENERATOR uint8_t generator_debug; /* 1 bit */ #endif uint8_t unhandled_rejection; } njs_vm_opt_t; typedef struct { njs_function_t *function; njs_opaque_value_t argument; njs_opaque_value_t value; void *data; int64_t from; int64_t to; } njs_iterator_args_t; typedef njs_int_t (*njs_iterator_handler_t)(njs_vm_t *vm, njs_iterator_args_t *args, njs_value_t *entry, int64_t n, njs_value_t *retval); NJS_EXPORT void njs_vm_opt_init(njs_vm_opt_t *options); NJS_EXPORT njs_vm_t *njs_vm_create(njs_vm_opt_t *options); NJS_EXPORT void njs_vm_destroy(njs_vm_t *vm); NJS_EXPORT njs_int_t njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end); NJS_EXPORT njs_mod_t *njs_vm_add_module(njs_vm_t *vm, njs_str_t *name, njs_value_t *value); NJS_EXPORT njs_mod_t *njs_vm_compile_module(njs_vm_t *vm, njs_str_t *name, u_char **start, u_char *end); NJS_EXPORT njs_vm_t *njs_vm_clone(njs_vm_t *vm, njs_external_ptr_t external); NJS_EXPORT njs_vm_event_t njs_vm_add_event(njs_vm_t *vm, njs_function_t *function, njs_uint_t once, njs_host_event_t host_ev, njs_event_destructor_t destructor); NJS_EXPORT void njs_vm_del_event(njs_vm_t *vm, njs_vm_event_t vm_event); NJS_EXPORT njs_int_t njs_vm_post_event(njs_vm_t *vm, njs_vm_event_t vm_event, const njs_value_t *args, njs_uint_t nargs); /* * Returns 1 if async events are present. */ NJS_EXPORT njs_int_t njs_vm_waiting(njs_vm_t *vm); /* * Returns 1 if posted events are ready to be executed. */ NJS_EXPORT njs_int_t njs_vm_posted(njs_vm_t *vm); #define njs_vm_pending(vm) (njs_vm_waiting(vm) || njs_vm_posted(vm)) NJS_EXPORT njs_int_t njs_vm_unhandled_rejection(njs_vm_t *vm); NJS_EXPORT void *njs_vm_completions(njs_vm_t *vm, njs_str_t *expression); /* * Runs the specified function with provided arguments. * NJS_OK successful run. * NJS_ERROR some exception or internal error happens. * * njs_vm_exception_get(vm) can be used to get the exception value. */ NJS_EXPORT njs_int_t njs_vm_call(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, njs_uint_t nargs); NJS_EXPORT njs_int_t njs_vm_invoke(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, njs_uint_t nargs, njs_value_t *retval); /* * Runs posted events. * NJS_OK successfully processed all posted events, no more events. * NJS_AGAIN successfully processed all events, some posted events are * still pending. * NJS_ERROR some exception or internal error happens. * njs_vm_exception_get(vm) can be used to get the exception value. */ NJS_EXPORT njs_int_t njs_vm_run(njs_vm_t *vm); /* * Runs the global code. * NJS_OK successful run. * NJS_ERROR some exception or internal error happens. * * njs_vm_exception_get(vm) can be used to get the exception value. */ NJS_EXPORT njs_int_t njs_vm_start(njs_vm_t *vm, njs_value_t *retval); NJS_EXPORT njs_int_t njs_vm_add_path(njs_vm_t *vm, const njs_str_t *path); #define NJS_PROTO_ID_ANY (-1) NJS_EXPORT njs_int_t njs_vm_external_prototype(njs_vm_t *vm, const njs_external_t *definition, njs_uint_t n); NJS_EXPORT njs_int_t njs_vm_external_constructor(njs_vm_t *vm, const njs_str_t *name, njs_function_native_t native, const njs_external_t *ctor_props, njs_uint_t ctor_nprops, const njs_external_t *proto_props, njs_uint_t proto_nprops); NJS_EXPORT njs_int_t njs_vm_external_create(njs_vm_t *vm, njs_value_t *value, njs_int_t proto_id, njs_external_ptr_t external, njs_bool_t shared); NJS_EXPORT njs_external_ptr_t njs_vm_external(njs_vm_t *vm, njs_int_t proto_id, const njs_value_t *value); NJS_EXPORT njs_int_t njs_external_property(njs_vm_t *vm, njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval, njs_value_t *retval); NJS_EXPORT njs_int_t njs_value_property(njs_vm_t *vm, njs_value_t *value, njs_value_t *key, njs_value_t *retval); NJS_EXPORT njs_int_t njs_value_property_set(njs_vm_t *vm, njs_value_t *value, njs_value_t *key, njs_value_t *setval); NJS_EXPORT uintptr_t njs_vm_meta(njs_vm_t *vm, njs_uint_t index); NJS_EXPORT njs_vm_opt_t *njs_vm_options(njs_vm_t *vm); NJS_EXPORT njs_int_t njs_error_constructor(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t type, njs_value_t *retval); NJS_EXPORT njs_int_t njs_object_prototype_create_constructor(njs_vm_t *vm, njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval, njs_value_t *retval); NJS_EXPORT njs_int_t njs_object_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop, njs_value_t *value, njs_value_t *setval, njs_value_t *retval); NJS_EXPORT njs_function_t *njs_vm_function_alloc(njs_vm_t *vm, njs_function_native_t native, njs_bool_t shared, njs_bool_t ctor); NJS_EXPORT void njs_disassembler(njs_vm_t *vm); NJS_EXPORT njs_int_t njs_vm_bind(njs_vm_t *vm, const njs_str_t *var_name, const njs_value_t *value, njs_bool_t shared); njs_int_t njs_vm_bind_handler(njs_vm_t *vm, const njs_str_t *var_name, njs_prop_handler_t handler, uint16_t magic16, uint32_t magic32, njs_bool_t shared); NJS_EXPORT njs_int_t njs_vm_value(njs_vm_t *vm, const njs_str_t *path, njs_value_t *retval); NJS_EXPORT njs_function_t *njs_vm_function(njs_vm_t *vm, const njs_str_t *name); NJS_EXPORT njs_bool_t njs_vm_constructor(njs_vm_t *vm); NJS_EXPORT void njs_vm_throw(njs_vm_t *vm, const njs_value_t *value); NJS_EXPORT void njs_vm_error2(njs_vm_t *vm, unsigned error_type, const char *fmt, ...); NJS_EXPORT void njs_vm_error3(njs_vm_t *vm, unsigned type, const char *fmt, ...); NJS_EXPORT void njs_vm_exception_get(njs_vm_t *vm, njs_value_t *retval); NJS_EXPORT njs_mp_t *njs_vm_memory_pool(njs_vm_t *vm); NJS_EXPORT njs_external_ptr_t njs_vm_external_ptr(njs_vm_t *vm); NJS_EXPORT njs_int_t njs_value_to_integer(njs_vm_t *vm, njs_value_t *value, int64_t *dst); /* Gets string value, no copy. */ NJS_EXPORT void njs_value_string_get(njs_value_t *value, njs_str_t *dst); /* * Sets a byte string value. * start data is not copied and should not be freed. */ NJS_EXPORT njs_int_t njs_vm_value_string_set(njs_vm_t *vm, njs_value_t *value, const u_char *start, uint32_t size); NJS_EXPORT u_char *njs_vm_value_string_alloc(njs_vm_t *vm, njs_value_t *value, uint32_t size); NJS_EXPORT njs_int_t njs_vm_value_string_create(njs_vm_t *vm, njs_value_t *value, const u_char *start, uint32_t size); NJS_EXPORT njs_int_t njs_vm_value_string_create_chb(njs_vm_t *vm, njs_value_t *value, njs_chb_t *chain); NJS_EXPORT njs_int_t njs_vm_value_string_copy(njs_vm_t *vm, njs_str_t *retval, njs_value_t *value, uintptr_t *next); NJS_EXPORT njs_int_t njs_vm_string_compare(const njs_value_t *v1, const njs_value_t *v2); NJS_EXPORT njs_int_t njs_vm_value_array_buffer_set(njs_vm_t *vm, njs_value_t *value, const u_char *start, uint32_t size); NJS_EXPORT njs_int_t njs_value_buffer_get(njs_vm_t *vm, njs_value_t *value, njs_str_t *dst); /* * Sets a Buffer value. * start data is not copied and should not be freed. */ NJS_EXPORT njs_int_t njs_vm_value_buffer_set(njs_vm_t *vm, njs_value_t *value, const u_char *start, uint32_t size); NJS_EXPORT njs_int_t njs_value_to_string(njs_vm_t *vm, njs_value_t *dst, njs_value_t *value); /* * Converts a value to bytes. */ NJS_EXPORT njs_int_t njs_vm_value_to_bytes(njs_vm_t *vm, njs_str_t *dst, njs_value_t *src); /* * Converts a value to string. */ NJS_EXPORT njs_int_t njs_vm_value_to_string(njs_vm_t *vm, njs_str_t *dst, njs_value_t *src); /* * Calls njs_vm_value_to_string(), if exception was thrown adds backtrace. */ NJS_EXPORT njs_int_t njs_vm_value_string(njs_vm_t *vm, njs_str_t *dst, njs_value_t *src); /* * If string value is null-terminated the corresponding C string * is returned as is, otherwise the new copy is allocated with * the terminating zero byte. */ NJS_EXPORT const char *njs_vm_value_to_c_string(njs_vm_t *vm, njs_value_t *value); NJS_EXPORT njs_int_t njs_vm_exception_string(njs_vm_t *vm, njs_str_t *dst); NJS_EXPORT njs_int_t njs_vm_value_dump(njs_vm_t *vm, njs_str_t *dst, njs_value_t *value, njs_uint_t console, njs_uint_t indent); NJS_EXPORT void njs_vm_memory_error(njs_vm_t *vm); NJS_EXPORT void njs_vm_logger(njs_vm_t *vm, njs_log_level_t level, const char *fmt, ...); NJS_EXPORT void njs_value_undefined_set(njs_value_t *value); NJS_EXPORT void njs_value_null_set(njs_value_t *value); NJS_EXPORT void njs_value_invalid_set(njs_value_t *value); NJS_EXPORT void njs_value_boolean_set(njs_value_t *value, int yn); NJS_EXPORT void njs_value_number_set(njs_value_t *value, double num); NJS_EXPORT void njs_value_function_set(njs_value_t *value, njs_function_t *function); NJS_EXPORT uint8_t njs_value_bool(const njs_value_t *value); NJS_EXPORT double njs_value_number(const njs_value_t *value); NJS_EXPORT njs_function_t *njs_value_function(const njs_value_t *value); NJS_EXPORT njs_function_native_t njs_value_native_function( const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_external_tag(const njs_value_t *value); NJS_EXPORT uint16_t njs_vm_prop_magic16(njs_object_prop_t *prop); NJS_EXPORT uint32_t njs_vm_prop_magic32(njs_object_prop_t *prop); NJS_EXPORT njs_int_t njs_vm_prop_name(njs_vm_t *vm, njs_object_prop_t *prop, njs_str_t *dst); NJS_EXPORT njs_int_t njs_value_is_null(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_undefined(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_null_or_undefined(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_valid(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_boolean(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_number(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_valid_number(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_string(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_object(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_error(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_array(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_function(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_buffer(const njs_value_t *value); NJS_EXPORT njs_int_t njs_value_is_data_view(const njs_value_t *value); NJS_EXPORT njs_int_t njs_vm_object_alloc(njs_vm_t *vm, njs_value_t *retval, ...); NJS_EXPORT njs_value_t *njs_vm_object_keys(njs_vm_t *vm, njs_value_t *value, njs_value_t *retval); NJS_EXPORT njs_value_t *njs_vm_object_prop(njs_vm_t *vm, njs_value_t *value, const njs_str_t *key, njs_opaque_value_t *retval); NJS_EXPORT njs_int_t njs_vm_object_prop_set(njs_vm_t *vm, njs_value_t *value, const njs_str_t *prop, njs_opaque_value_t *setval); NJS_EXPORT njs_int_t njs_vm_object_iterate(njs_vm_t *vm, njs_iterator_args_t *args, njs_iterator_handler_t handler, njs_value_t *retval); NJS_EXPORT njs_int_t njs_vm_array_alloc(njs_vm_t *vm, njs_value_t *retval, uint32_t spare); NJS_EXPORT njs_int_t njs_vm_array_length(njs_vm_t *vm, njs_value_t *value, int64_t *length); NJS_EXPORT njs_value_t *njs_vm_array_start(njs_vm_t *vm, njs_value_t *value); NJS_EXPORT njs_value_t *njs_vm_array_prop(njs_vm_t *vm, njs_value_t *value, int64_t index, njs_opaque_value_t *retval); NJS_EXPORT njs_value_t *njs_vm_array_push(njs_vm_t *vm, njs_value_t *value); NJS_EXPORT njs_int_t njs_vm_date_alloc(njs_vm_t *vm, njs_value_t *retval, double time); NJS_EXPORT njs_int_t njs_vm_json_parse(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_value_t *retval); NJS_EXPORT njs_int_t njs_vm_json_stringify(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_value_t *retval); NJS_EXPORT njs_int_t njs_vm_query_string_parse(njs_vm_t *vm, u_char *start, u_char *end, njs_value_t *retval); NJS_EXPORT njs_int_t njs_vm_promise_create(njs_vm_t *vm, njs_value_t *retval, njs_value_t *callbacks); #endif /* _NJS_H_INCLUDED_ */
114a8ff044d6e64e8b86e1d2edff5644704eb315
a1e6be7347de461a4a624a53523345147178920a
/examples/src/lib/fb.c
b9c66914723effed503406b58e22874a23bb6aab
[ "Apache-2.0" ]
permissive
pimoroni/mlx90640-library
2c576795de617e7239e69b87c7efa9f4b2e220fc
93952ef5220fddfba05291f170fe552d2f33c9b5
refs/heads/master
2022-09-29T13:27:50.379125
2022-09-26T14:59:49
2022-09-26T14:59:49
138,606,894
127
95
Apache-2.0
2022-09-26T14:59:50
2018-06-25T14:33:26
C++
UTF-8
C
false
false
4,073
c
fb.c
/* * fbtest7.c * * http://raspberrycompote.blogspot.ie/2013/04/low-level-graphics-on-raspberry-pi-part.html * * Original work by J-P Rosti (a.k.a -rst- and 'Raspberry Compote') * * Licensed under the Creative Commons Attribution 3.0 Unported License * (http://creativecommons.org/licenses/by/3.0/deed.en_US) * * Distributed in the hope that this will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <fcntl.h> #include <linux/fb.h> #include <sys/mman.h> #include <sys/ioctl.h> int fbfd = 0; struct fb_var_screeninfo orig_vinfo; long int screensize = 0; // 'global' variables to store screen info char *fbp = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; void put_pixel_RGB24(int x, int y, int r, int g, int b) { // calculate the pixel's byte offset inside the buffer // note: x * 3 as every pixel is 3 consecutive bytes unsigned int pix_offset = x * 3 + y * finfo.line_length; // now this is about the same as 'fbp[pix_offset] = value' *((char*)(fbp + pix_offset)) = b; *((char*)(fbp + pix_offset + 1)) = g; *((char*)(fbp + pix_offset + 2)) = r; } void put_pixel_RGB565(int x, int y, int r, int g, int b) { // calculate the pixel's byte offset inside the buffer // note: x * 2 as every pixel is 2 consecutive bytes unsigned int pix_offset = x * 2 + y * finfo.line_length; // now this is about the same as 'fbp[pix_offset] = value' // but a bit more complicated for RGB565 //unsigned short c = ((r / 8) << 11) + ((g / 4) << 5) + (b / 8); //unsigned short c = ((r / 8) * 2048) + ((g / 4) * 32) + (b / 8); r = (int)(((double)r) / 8.0); g = (int)(((double)g) / 4.0); b = (int)(((double)b) / 8.0); unsigned short c = (r << 11) | (g << 5) | b; // write 'two bytes at once' *((unsigned short*)(fbp + pix_offset)) = c; } void put_pixel_RGB32(int x, int y, int r, int g, int b) { unsigned int pix_offset = x * 4 + y * finfo.line_length; *((char*)(fbp + pix_offset)) = b; *((char*)(fbp + pix_offset + 1)) = g; *((char*)(fbp + pix_offset + 2)) = r; } void fb_put_pixel(int x, int y, int r, int g, int b) { if (x > vinfo.xres) return; if (y > vinfo.yres) return; if (vinfo.bits_per_pixel == 32) { put_pixel_RGB32(x, y, r, g, b); } else if (vinfo.bits_per_pixel == 16) { put_pixel_RGB565(x, y, r, g, b); } else { put_pixel_RGB24(x, y, r, g, b); } } int fb_init(){ // Open the file for reading and writing fbfd = open("/dev/fb0", O_RDWR); if (fbfd == -1) { printf("Error: cannot open framebuffer device.\n"); return 1; } printf("The framebuffer device was opened successfully.\n"); // Get variable screen information if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { printf("Error reading variable information.\n"); return 1; } printf("Original %dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel ); // Store for reset (copy vinfo to vinfo_orig) memcpy(&orig_vinfo, &vinfo, sizeof(struct fb_var_screeninfo)); // Get fixed screen information if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { printf("Error reading fixed information.\n"); return 1; } // map fb to user mem screensize = finfo.smem_len; fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if (fbp == MAP_FAILED) { printf("Failed to mmap.\n"); return 1; } return 0; } void fb_cleanup(){ // cleanup // unmap fb file from memory munmap(fbp, screensize); // reset the display mode if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_vinfo)) { printf("Error re-setting variable information.\n"); } // close fb file close(fbfd); }
a8ac308c255898dc0241569d7f84a7fabb02f38f
ab016d8a86e2f7c707481f8acdc2016ab7a81522
/src/pci_fbuf.c
705fd6b07d146e33caf84333904b05dbbe97949c
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
machyve/xhyve
060d7f4a3e76465313aab212e8c0ba32231f4e5e
dfbe09b9db0ef9384c993db8e72fb3e96f376e7b
refs/heads/master
2022-02-09T00:25:46.884196
2021-10-02T04:16:50
2021-10-02T04:16:50
37,175,929
1,639
150
NOASSERTION
2023-04-05T10:23:40
2015-06-10T04:45:42
C
UTF-8
C
false
false
10,059
c
pci_fbuf.c
/*- * Copyright (c) 2015 Nahanni Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. * * $FreeBSD$ */ #include <sys/cdefs.h> #include <sys/types.h> #include <sys/mman.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <unistd.h> #include <xhyve/support/misc.h> #include <xhyve/vmm/vmm.h> #include <xhyve/vmm/vmm_api.h> #include <xhyve/bhyvegc.h> #include <xhyve/console.h> #include <xhyve/inout.h> #include <xhyve/pci_emul.h> #include <xhyve/rfb.h> #include <xhyve/vga.h> /* * bhyve Framebuffer device emulation. * BAR0 points to the current mode information. * BAR1 is the 32-bit framebuffer address. * * -s <b>,fbuf,wait,vga=on|io|off,rfb=<ip>:port,w=width,h=height */ static int fbuf_debug = 1; #define DEBUG_INFO 1 #define DEBUG_VERBOSE 4 #define DPRINTF(level, params) if (level <= fbuf_debug) printf params #define KB (1024UL) #define MB (1024UL * KB) #define DMEMSZ 128 #define FB_SIZE (16*MB) #define COLS_MAX 1920 #define ROWS_MAX 1200 #define COLS_DEFAULT 1024 #define ROWS_DEFAULT 768 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-macros" #define COLS_MIN 640 #define ROWS_MIN 480 #pragma clang diagnostic pop #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" struct pci_fbuf_softc { struct pci_devinst *fsc_pi; struct { uint32_t fbsize; uint16_t width; uint16_t height; uint16_t depth; uint16_t refreshrate; uint8_t reserved[116]; } memregs; /* rfb server */ char *rfb_host; char *rfb_password; int rfb_port; int rfb_wait; int vga_enabled; int vga_full; uint64_t fbaddr; char *fb_base; uint16_t gc_width; uint16_t gc_height; void *vgasc; struct bhyvegc_image *gc_image; }; #pragma clang diagnostic pop static struct pci_fbuf_softc *fbuf_sc; #define PCI_FBUF_MSI_MSGS 4 static void pci_fbuf_usage(char *opt) { fprintf(stderr, "Invalid fbuf emulation \"%s\"\r\n", opt); fprintf(stderr, "fbuf: {wait,}{vga=on|io|off,}rfb=<ip>:port\r\n"); } static void pci_fbuf_write(UNUSED int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size, uint64_t value) { struct pci_fbuf_softc *sc; uint8_t *p; assert(baridx == 0); assert(size >= 0); sc = pi->pi_arg; DPRINTF(DEBUG_VERBOSE, ("fbuf wr: offset 0x%llx, size: %d, value: 0x%llx\n", offset, size, value)); if (offset + (unsigned int)size > DMEMSZ) { printf("fbuf: write too large, offset %lld size %d\n", offset, size); return; } p = (uint8_t *)&sc->memregs + offset; switch (size) { case 1: *p = (uint8_t)value; break; case 2: write_uint16_unaligned(p, (uint16_t)value); break; case 4: write_uint32_unaligned(p, (uint32_t)value); break; case 8: write_uint64_unaligned(p, value); break; default: printf("fbuf: write unknown size %d\n", size); break; } if (!sc->gc_image->vgamode && sc->memregs.width == 0 && sc->memregs.height == 0) { DPRINTF(DEBUG_INFO, ("switching to VGA mode\r\n")); sc->gc_image->vgamode = 1; sc->gc_width = 0; sc->gc_height = 0; } else if (sc->gc_image->vgamode && sc->memregs.width != 0 && sc->memregs.height != 0) { DPRINTF(DEBUG_INFO, ("switching to VESA mode\r\n")); sc->gc_image->vgamode = 0; } } static uint64_t pci_fbuf_read(UNUSED int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size) { struct pci_fbuf_softc *sc; uint8_t *p; uint64_t value; assert(baridx == 0); assert(size >= 0); sc = pi->pi_arg; if (offset + (unsigned int)size > DMEMSZ) { printf("fbuf: read too large, offset %lld size %d\n", offset, size); return (0); } p = (uint8_t *)&sc->memregs + offset; value = 0; switch (size) { case 1: value = *p; break; case 2: value = read_uint16_unaligned(p); break; case 4: value = read_uint32_unaligned(p); break; case 8: value = read_uint64_unaligned(p); break; default: printf("fbuf: read unknown size %d\n", size); break; } DPRINTF(DEBUG_VERBOSE, ("fbuf rd: offset 0x%llx, size: %d, value: 0x%llx\n", offset, size, value)); return (value); } static int pci_fbuf_parse_opts(struct pci_fbuf_softc *sc, char *opts) { char *uopts, *xopts, *config; char *tmpstr; int ret; ret = 0; uopts = strdup(opts); for (xopts = strtok(uopts, ","); xopts != NULL; xopts = strtok(NULL, ",")) { if (strcmp(xopts, "wait") == 0) { sc->rfb_wait = 1; continue; } if ((config = strchr(xopts, '=')) == NULL) { pci_fbuf_usage(xopts); ret = -1; goto done; } *config++ = '\0'; DPRINTF(DEBUG_VERBOSE, ("pci_fbuf option %s = %s\r\n", xopts, config)); if (!strcmp(xopts, "tcp") || !strcmp(xopts, "rfb")) { /* parse host-ip:port */ tmpstr = strsep(&config, ":"); if (!config) sc->rfb_port = atoi(tmpstr); else { sc->rfb_port = atoi(config); sc->rfb_host = tmpstr; } } else if (!strcmp(xopts, "vga")) { if (!strcmp(config, "off")) { sc->vga_enabled = 0; } else if (!strcmp(config, "io")) { sc->vga_enabled = 1; sc->vga_full = 0; } else if (!strcmp(config, "on")) { sc->vga_enabled = 1; sc->vga_full = 1; } else { pci_fbuf_usage(opts); ret = -1; goto done; } } else if (!strcmp(xopts, "w")) { sc->memregs.width = (uint16_t)atoi(config); if (sc->memregs.width > COLS_MAX) { pci_fbuf_usage(xopts); ret = -1; goto done; } else if (sc->memregs.width == 0) sc->memregs.width = 1920; } else if (!strcmp(xopts, "h")) { sc->memregs.height = (uint16_t)atoi(config); if (sc->memregs.height > ROWS_MAX) { pci_fbuf_usage(xopts); ret = -1; goto done; } else if (sc->memregs.height == 0) sc->memregs.height = 1080; } else if (!strcmp(xopts, "password")) { sc->rfb_password = config; } else { pci_fbuf_usage(xopts); ret = -1; goto done; } } done: return (ret); } static void pci_fbuf_render(struct bhyvegc *gc, void *arg) { struct pci_fbuf_softc *sc; sc = arg; if (sc->vga_full && sc->gc_image->vgamode) { /* TODO: mode switching to vga and vesa should use the special * EFI-bhyve protocol port. */ vga_render(gc, sc->vgasc); return; } if (sc->gc_width != sc->memregs.width || sc->gc_height != sc->memregs.height) { bhyvegc_resize(gc, sc->memregs.width, sc->memregs.height); sc->gc_width = sc->memregs.width; sc->gc_height = sc->memregs.height; } return; } static int pci_fbuf_init(struct pci_devinst *pi, char *opts) { int error; struct pci_fbuf_softc *sc; if (fbuf_sc != NULL) { fprintf(stderr, "Only one frame buffer device is allowed.\n"); return (-1); } sc = calloc(1, sizeof(struct pci_fbuf_softc)); pi->pi_arg = sc; /* initialize config space */ pci_set_cfgdata16(pi, PCIR_DEVICE, 0x40FB); pci_set_cfgdata16(pi, PCIR_VENDOR, 0xFB5D); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_DISPLAY); pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_DISPLAY_VGA); error = pci_emul_alloc_bar(pi, 0, PCIBAR_MEM32, DMEMSZ); assert(error == 0); error = pci_emul_alloc_bar(pi, 1, PCIBAR_MEM32, FB_SIZE); assert(error == 0); error = pci_emul_add_msicap(pi, PCI_FBUF_MSI_MSGS); assert(error == 0); sc->fbaddr = pi->pi_bar[1].addr; sc->memregs.fbsize = FB_SIZE; sc->memregs.width = COLS_DEFAULT; sc->memregs.height = ROWS_DEFAULT; sc->memregs.depth = 32; sc->vga_enabled = 1; sc->vga_full = 0; sc->fsc_pi = pi; error = pci_fbuf_parse_opts(sc, opts); if (error != 0) goto done; /* XXX until VGA rendering is enabled */ if (sc->vga_full != 0) { fprintf(stderr, "pci_fbuf: VGA rendering not enabled"); goto done; } DPRINTF(DEBUG_INFO, ("fbuf frame buffer base: %p [sz %lu]\r\n", (void *)sc->fb_base, FB_SIZE)); /* * Map the framebuffer into the guest address space. * XXX This may fail if the BAR is different than a prior * run. In this case flag the error. This will be fixed * when a change_memseg api is available. */ if (xh_setup_video_memory(sc->fbaddr, FB_SIZE, (void **)&sc->fb_base) != 0) { fprintf(stderr, "pci_fbuf: mapseg failed - try deleting VM and restarting\n"); error = -1; goto done; } console_init(sc->memregs.width, sc->memregs.height, sc->fb_base); console_fb_register(pci_fbuf_render, sc); if (sc->vga_enabled) sc->vgasc = vga_init(!sc->vga_full); sc->gc_image = console_get_image(); fbuf_sc = sc; memset((void *)sc->fb_base, 0, FB_SIZE); error = rfb_init(sc->rfb_host, sc->rfb_port, sc->rfb_wait, sc->rfb_password); done: if (error) free(sc); return (error); } static struct pci_devemu pci_fbuf = { .pe_emu = "fbuf", .pe_init = pci_fbuf_init, .pe_barwrite = pci_fbuf_write, .pe_barread = pci_fbuf_read }; PCI_EMUL_SET(pci_fbuf);
0d1103d513193d98d78dd669cd110cdcf07f3127
25e99a0af5751865bce1702ee85cc5c080b0715c
/c/src/C语言接口与实现/include/list.h
3d9636a38c22df08110bfe85043b53d708da77ce
[]
no_license
jasonblog/note
215837f6a08d07abe3e3d2be2e1f183e14aa4a30
4471f95736c60969a718d854cab929f06726280a
refs/heads/master
2023-05-31T13:02:27.451743
2022-04-04T11:28:06
2022-04-04T11:28:06
35,311,001
130
67
null
2023-02-10T21:26:36
2015-05-09T02:04:40
C
UTF-8
C
false
false
669
h
list.h
/* $Id: H:/drh/idioms/book/RCS/list.doc,v 1.11 1997/02/21 19:46:01 drh Exp $ */ #ifndef LIST_INCLUDED #define LIST_INCLUDED #define T List_T typedef struct T* T; struct T { T rest; void* first; }; extern T List_append(T list, T tail); extern T List_copy(T list); extern T List_list(void* x, ...); extern T List_pop(T list, void** x); extern T List_push(T list, void* x); extern T List_reverse(T list); extern int List_length(T list); extern void List_free(T* list); extern void List_map(T list, void apply(void** x, void* cl), void* cl); extern void** List_toArray(T list, void* end); #undef T #endif
02e750e93c21eb58b2c5953fe2ba8c7297f09104
bb33f1bb942b058f00a4b765eb5e7ec9286b5b29
/Firmware/vsync.c
a06ae844cf0151518022016b16eb19ba8187f851
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
ikorb/gcvideo
c4f56bff4e52b4478e4c5ab6fe89e4df36ac2223
1638595bd5d575c2d4e63df49767a0945e57c193
refs/heads/main
2023-06-27T09:12:45.934024
2022-01-10T22:27:10
2022-01-10T22:27:10
23,510,303
597
87
null
2022-02-22T08:29:57
2014-08-31T09:29:58
VHDL
UTF-8
C
false
false
2,647
c
vsync.c
/* GCVideo DVI Firmware Copyright (C) 2015-2021, Ingo Korb <ingo@akana.de> 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. vsync.c: System tick and other once-per-frame things */ #include <stdbool.h> #include "pad.h" #include "portdefs.h" #include "reblanker.h" #include "settings.h" #include "vsync.h" #define IRBUTTON_MAX_FRAMES 255 #define IRBUTTON_MIN_FRAMES 2 #define IRBUTTON_LONG_FRAMES 60 volatile tick_t tick_counter; static uint32_t prev_irbutton = IRRX_BUTTON; static uint8_t irbutton_count; void vsync_handler(void) { /* update tick counter */ if (VIDEOIF->flags & VIDEOIF_FLAG_IN_PAL) { tick_counter += TICKS_PER_VSYNC_PAL; } else { tick_counter += TICKS_PER_VSYNC_NTSC; } update_reblanker(); /* read IR button */ uint32_t cur_irbutton = IRRX->pulsedata & IRRX_BUTTON; if (cur_irbutton != prev_irbutton) { /* at edge */ if (cur_irbutton) { /* release */ if (irbutton_count > IRBUTTON_MIN_FRAMES && irbutton_count < IRBUTTON_LONG_FRAMES) { pad_set_irq(IRBUTTON_SHORT); } } else { /* press */ irbutton_count = 0; } } else if (!cur_irbutton) { /* held */ if (irbutton_count < IRBUTTON_MAX_FRAMES) irbutton_count++; if (irbutton_count == IRBUTTON_LONG_FRAMES) { pad_set_irq(IRBUTTON_LONG); } } prev_irbutton = cur_irbutton; }
c42e34f4204c408766fbc9c3d44389b078875115
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/drivers/mmc/sunxi_mmc.h
a79c363681ee1c6e70d7f409e220282fbd5003d6
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "GPL-2.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
5,676
h
sunxi_mmc.h
#ifndef SUNXI_MMC_H #define SUNXI_MMC_H /* speed mode */ #define DS26_SDR12 (0) #define HSSDR52_SDR25 (1) #define HSDDR52_DDR50 (2) #define HS200_SDR104 (3) #define HS400 (4) #define MAX_SPD_MD_NUM (5) /* frequency point */ #define CLK_400K (0) #define CLK_25M (1) #define CLK_50M (2) #define CLK_100M (3) #define CLK_150M (4) #define CLK_200M (5) #define MAX_CLK_FREQ_NUM (8) /* timing mode 1: output and input are both based on phase. 2: output is based on phase, input is based on delay chain except hs400. input of hs400 is based on delay chain. 3: output is based on phase, input is based on delay chain. 4: output is based on phase, input is based on delay chain. it also support to use delay chain on data strobe signal. */ #define SUNXI_MMC_TIMING_MODE_1 1U #define SUNXI_MMC_TIMING_MODE_2 2U #define SUNXI_MMC_TIMING_MODE_3 3U #define SUNXI_MMC_TIMING_MODE_4 4U #define MMC_CLK_SAMPLE_POINIT_MODE_1 3U #define MMC_CLK_SAMPLE_POINIT_MODE_2 2U #define MMC_CLK_SAMPLE_POINIT_MODE_2_HS400 64U #define MMC_CLK_SAMPLE_POINIT_MODE_3 64U #define MMC_CLK_SAMPLE_POINIT_MODE_4 64U #define TM1_OUT_PH90 (0) #define TM1_OUT_PH180 (1) #define TM1_IN_PH90 (0) #define TM1_IN_PH180 (1) #define TM1_IN_PH270 (2) #define TM3_OUT_PH90 (0) #define TM3_OUT_PH180 (1) #define TM4_OUT_PH90 (0) #define TM4_OUT_PH180 (1) /* error number defination */ #define ERR_NO_BEST_DLY (2) /* for smhc v4.1x*/ struct sunxi_mmc_timing_mode1 { u32 cur_spd_md; u32 cur_freq; u8 odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u32 sample_point_cnt; u8 cur_odly; u8 cur_sdly; }; /* for smhc v4.1x*/ struct sunxi_mmc_timing_mode3 { u32 cur_spd_md; u32 cur_freq; u8 odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u32 sample_point_cnt; u32 sdly_unit_ps; u8 dly_calibrate_done; u8 cur_odly; u8 cur_sdly; }; /* for smhc v4.5x*/ struct sunxi_mmc_timing_mode4 { u32 cur_spd_md; u32 cur_freq; u8 odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 dsdly[MAX_CLK_FREQ_NUM]; u8 def_odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_dsdly[MAX_CLK_FREQ_NUM]; u32 sample_point_cnt; u32 sdly_unit_ps; u32 dsdly_unit_ps; u8 dly_calibrate_done; u8 cur_odly; u8 cur_sdly; u8 cur_dsdly; }; /* for smhc v5.1x*/ struct sunxi_mmc_timing_mode2 { u32 cur_spd_md; u32 cur_freq; u8 odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 dsdly[MAX_CLK_FREQ_NUM]; u8 def_odly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_sdly[MAX_SPD_MD_NUM*MAX_CLK_FREQ_NUM]; u8 def_dsdly[MAX_CLK_FREQ_NUM]; u32 sample_point_cnt; //u32 sdly_unit_ps; u32 sample_point_cnt_hs400; u32 dsdly_unit_ps; u8 dly_calibrate_done; u8 cur_odly; u8 cur_sdly; u8 cur_dsdly; }; struct sunxi_mmc_host { u32 mmc_no; u32 hclkbase; u32 hclkrst; u32 mclkbase; u32 database; u32 fatal_err; u32 clock; /* @clock, bankup current clock at host, is updated when configure clock over */ u32 mod_clk; void *reg;//struct sunxi_mmc *reg; void *reg_bak;//struct sunxi_mmc *reg_bak; void *pdes;//struct sunxi_mmc_des* pdes; /*sample delay and output deley setting*/ u32 timing_mode; struct sunxi_mmc_timing_mode1 tm1; struct sunxi_mmc_timing_mode2 tm2; struct sunxi_mmc_timing_mode3 tm3; struct sunxi_mmc_timing_mode4 tm4; /* @retry_cnt used to count the retry times at a spcific speed mode and frequency during initial process or tuning process. it is always equal or less than the number of sample point. */ u32 retry_cnt; struct mmc *mmc; struct mmc_config cfg; /*sample delay and output deley setting*/ u32 raw_int_bak; u32 acmd_err_bak; u32 sample_mode; }; //#define TUNING_LEN (1)//The address which store the tuninng pattern //#define TUNING_ADD (38192-TUNING_LEN)//The address which store the tuninng pattern #define TUNING_LEN (60)//The length of the tuninng pattern #define TUNING_ADD (24576-4-TUNING_LEN)//The address which store the tuninng pattern #define REPEAT_TIMES (30) #define SAMPLE_MODE (2) //secure storage relate #define MAX_SECURE_STORAGE_MAX_ITEM 32 #define SDMMC_SECURE_STORAGE_START_ADD (6*1024*1024/512)//6M #define SDMMC_ITEM_SIZE (4*1024/512)//4K /* IDMA status bit field */ #define SDXC_IDMACTransmitInt BIT(0) #define SDXC_IDMACReceiveInt BIT(1) #define SDXC_IDMACFatalBusErr BIT(2) #define SDXC_IDMACDesInvalid BIT(4) #define SDXC_IDMACCardErrSum BIT(5) #define SDXC_IDMACNormalIntSum BIT(8) #define SDXC_IDMACAbnormalIntSum BIT(9) #define SDXC_IDMACHostAbtInTx BIT(10) #define SDXC_IDMACHostAbtInRx BIT(10) #define SDXC_IDMACIdle (0U << 13) #define SDXC_IDMACSuspend (1U << 13) #define SDXC_IDMACDESCRd (2U << 13) #define SDXC_IDMACDESCCheck (3U << 13) #define SDXC_IDMACRdReqWait (4U << 13) #define SDXC_IDMACWrReqWait (5U << 13) #define SDXC_IDMACRd (6U << 13) #define SDXC_IDMACWr (7U << 13) #define SDXC_IDMACDESCClose (8U << 13) /* delay control */ #define SDXC_StartCal (1<<15) #define SDXC_CalDone (1<<14) #define SDXC_CalDly (0x3F<<8) #define SDXC_EnableDly (1<<7) #define SDXC_CfgDly (0x3F<<0) extern void dumphex32(char* name, char* base, int len); int mmc_clk_io_onoff(int sdc_no, int onoff, int reset_clk); //#define SUPPORT_SUNXI_MMC_FFU #endif /* SUNXI_MMC_H */
33938140ded17ba2ba78d33247a8f68d4b064ea3
e910318d01528d82040507a49eeeb8dade45b31f
/ports/samd/main.c
038373ceb403b4d88382996202b9a969845f6a2f
[ "MIT" ]
permissive
pfalcon/pycopy
e844480a5e5cd463530328889daed2ba87552b8a
3ac90ae9c3c6bbebfba9cada2d37025e35c62796
refs/heads/pfalcon
2023-08-30T09:39:52.290147
2022-09-08T16:42:38
2022-09-08T16:42:38
15,507,576
753
71
MIT
2021-05-08T04:59:21
2013-12-29T11:38:47
C
UTF-8
C
false
false
3,009
c
main.c
/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2019 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "py/compile.h" #include "py/runtime.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/stackctrl.h" #include "lib/utils/gchelper.h" #include "lib/utils/pyexec.h" extern uint8_t _sstack, _estack, _sheap, _eheap; void samd_main(void) { mp_stack_set_top(&_estack); mp_stack_set_limit(&_estack - &_sstack - 1024); for (;;) { gc_init(&_sheap, &_eheap); mp_init(); mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_path), 0); mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), 0); for (;;) { if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { if (pyexec_raw_repl() != 0) { break; } } else { if (pyexec_friendly_repl() != 0) { break; } } } mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n"); gc_sweep_all(); mp_deinit(); } } void gc_collect(void) { gc_collect_start(); gc_helper_collect_regs_and_stack(); gc_collect_end(); } mp_lexer_t *mp_lexer_new_from_file(const char *filename) { mp_raise_OSError(MP_ENOENT); } mp_import_stat_t mp_import_stat(const char *path) { return MP_IMPORT_STAT_NO_EXIST; } mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); void nlr_jump_fail(void *val) { for (;;) { } } #ifndef NDEBUG void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) { mp_printf(MP_PYTHON_PRINTER, "Assertion '%s' failed, at file %s:%d\n", expr, file, line); for (;;) { } } #endif
7f119880f698611baf51a9c2dae129db7a6e62fc
c1096f2729fcc2e76dfcc9d4d277cebb669ef50f
/api/i2c.h
3957257bd440775f9520164e16d31349d2d2d42c
[]
no_license
mikeakohn/java_grinder
8d67f183aebfc412bff8537b23ff8be99f86dea6
273d6e97f46d3fa442b33ae19a2b2cde16dc5c4b
refs/heads/master
2023-08-15T13:17:50.551116
2023-06-20T21:44:37
2023-06-20T21:44:37
15,153,331
481
41
null
2020-01-28T02:30:24
2013-12-13T02:48:12
C++
UTF-8
C
false
false
643
h
i2c.h
/** * Java Grinder * Author: Michael Kohn * Email: mike@mikekohn.net * Web: http://www.mikekohn.net/ * License: GPLv3 * * Copyright 2014-2021 by Michael Kohn * */ #ifndef JAVA_GRINDER_API_I2C_H #define JAVA_GRINDER_API_I2C_H #include "common/JavaClass.h" #include "generator/Generator.h" int i2c( JavaClass *java_class, Generator *generator, const char *method_name); int i2c( JavaClass *java_class, Generator *generator, const char *method_name, int const_val); #if 0 int i2c( JavaClass *java_class, Generator *generator, const char *method_name, int const_val1, int const_val2); #endif #endif
c43badecfd789e15def9b407e1a9eee448cc2a2c
d975a74c5efe4d9790566818c3ca43a70c6ce817
/clang_delta/tests/union-to-struct/union3.c
f66f601d7eaf1bcf977bb8851d42c497cd61a7d9
[ "NCSA", "LicenseRef-scancode-unknown-license-reference" ]
permissive
marxin/cvise
cd24ce051a90b709b5a8e919ff8db2805734981d
594573e041cc2e906c1a81a4aca81ede93efee4a
refs/heads/master
2023-08-31T13:24:35.500801
2023-08-20T13:16:15
2023-08-20T13:16:15
256,755,439
164
17
NOASSERTION
2023-09-14T14:41:58
2020-04-18T13:04:05
C++
UTF-8
C
false
false
27
c
union3.c
void f() { union {} l; }
2a8f58b0c942d2cc1c1ace251a774ff349a7ea70
aa793c2b787ff591f69147e2cc5e23d6c7b4d77e
/src/tinf/adler32.c
5b3c54f53034c87478fd3abd1c92776a52b8be8f
[ "MIT", "BSD-3-Clause", "OFL-1.1", "GPL-2.0-only", "CC0-1.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
AsahiLinux/m1n1
8280a8342c407936beabda0f08a700759a636b05
6d0979e71e83f47c5da5fdb8c5e21eb1268d54e8
refs/heads/main
2023-08-22T20:52:30.090704
2023-08-21T14:16:08
2023-08-21T14:16:08
329,707,886
2,966
200
MIT
2023-09-07T10:19:39
2021-01-14T18:59:03
Python
UTF-8
C
false
false
2,087
c
adler32.c
/* * Adler-32 checksum * * Copyright (c) 2003-2019 Joergen Ibsen * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must * not claim that you wrote the original software. If you use this * software in a product, an acknowledgment in the product * documentation would be appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must * not be misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. */ /* * Adler-32 algorithm taken from the zlib source, which is * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler */ #include "tinf.h" #define A32_BASE 65521 #define A32_NMAX 5552 unsigned int tinf_adler32(const void *data, unsigned int length) { const unsigned char *buf = (const unsigned char *) data; unsigned int s1 = 1; unsigned int s2 = 0; while (length > 0) { int k = length < A32_NMAX ? length : A32_NMAX; int i; for (i = k / 16; i; --i, buf += 16) { s1 += buf[0]; s2 += s1; s1 += buf[1]; s2 += s1; s1 += buf[2]; s2 += s1; s1 += buf[3]; s2 += s1; s1 += buf[4]; s2 += s1; s1 += buf[5]; s2 += s1; s1 += buf[6]; s2 += s1; s1 += buf[7]; s2 += s1; s1 += buf[8]; s2 += s1; s1 += buf[9]; s2 += s1; s1 += buf[10]; s2 += s1; s1 += buf[11]; s2 += s1; s1 += buf[12]; s2 += s1; s1 += buf[13]; s2 += s1; s1 += buf[14]; s2 += s1; s1 += buf[15]; s2 += s1; } for (i = k % 16; i; --i) { s1 += *buf++; s2 += s1; } s1 %= A32_BASE; s2 %= A32_BASE; length -= k; } return (s2 << 16) | s1; }
c199cc59b051a60fb93eeee4c8aa973c61cd387c
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/input/touchscreen/auo-pixcir-ts.c
d3f9f6b0f9b797fef0579ae188efd281db84ee9e
[ "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
17,589
c
auo-pixcir-ts.c
/* * Driver for AUO in-cell touchscreens * * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de> * * loosely based on auo_touch.c from Dell Streak vendor-kernel * * Copyright (c) 2008 QUALCOMM Incorporated. * Copyright (c) 2008 QUALCOMM USA, INC. * * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/interrupt.h> #include <linux/slab.h> #include <linux/input.h> #include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/mutex.h> #include <linux/delay.h> #include <linux/gpio.h> #include <linux/input/auo-pixcir-ts.h> #include <linux/of.h> #include <linux/of_gpio.h> /* * Coordinate calculation: * X1 = X1_LSB + X1_MSB*256 * Y1 = Y1_LSB + Y1_MSB*256 * X2 = X2_LSB + X2_MSB*256 * Y2 = Y2_LSB + Y2_MSB*256 */ #define AUO_PIXCIR_REG_X1_LSB 0x00 #define AUO_PIXCIR_REG_X1_MSB 0x01 #define AUO_PIXCIR_REG_Y1_LSB 0x02 #define AUO_PIXCIR_REG_Y1_MSB 0x03 #define AUO_PIXCIR_REG_X2_LSB 0x04 #define AUO_PIXCIR_REG_X2_MSB 0x05 #define AUO_PIXCIR_REG_Y2_LSB 0x06 #define AUO_PIXCIR_REG_Y2_MSB 0x07 #define AUO_PIXCIR_REG_STRENGTH 0x0d #define AUO_PIXCIR_REG_STRENGTH_X1_LSB 0x0e #define AUO_PIXCIR_REG_STRENGTH_X1_MSB 0x0f #define AUO_PIXCIR_REG_RAW_DATA_X 0x2b #define AUO_PIXCIR_REG_RAW_DATA_Y 0x4f #define AUO_PIXCIR_REG_X_SENSITIVITY 0x6f #define AUO_PIXCIR_REG_Y_SENSITIVITY 0x70 #define AUO_PIXCIR_REG_INT_SETTING 0x71 #define AUO_PIXCIR_REG_INT_WIDTH 0x72 #define AUO_PIXCIR_REG_POWER_MODE 0x73 #define AUO_PIXCIR_REG_VERSION 0x77 #define AUO_PIXCIR_REG_CALIBRATE 0x78 #define AUO_PIXCIR_REG_TOUCHAREA_X1 0x1e #define AUO_PIXCIR_REG_TOUCHAREA_Y1 0x1f #define AUO_PIXCIR_REG_TOUCHAREA_X2 0x20 #define AUO_PIXCIR_REG_TOUCHAREA_Y2 0x21 #define AUO_PIXCIR_REG_EEPROM_CALIB_X 0x42 #define AUO_PIXCIR_REG_EEPROM_CALIB_Y 0xad #define AUO_PIXCIR_INT_TPNUM_MASK 0xe0 #define AUO_PIXCIR_INT_TPNUM_SHIFT 5 #define AUO_PIXCIR_INT_RELEASE (1 << 4) #define AUO_PIXCIR_INT_ENABLE (1 << 3) #define AUO_PIXCIR_INT_POL_HIGH (1 << 2) #define AUO_PIXCIR_INT_MODE_MASK 0x03 /* * Power modes: * active: scan speed 60Hz * sleep: scan speed 10Hz can be auto-activated, wakeup on 1st touch * deep sleep: scan speed 1Hz can only be entered or left manually. */ #define AUO_PIXCIR_POWER_ACTIVE 0x00 #define AUO_PIXCIR_POWER_SLEEP 0x01 #define AUO_PIXCIR_POWER_DEEP_SLEEP 0x02 #define AUO_PIXCIR_POWER_MASK 0x03 #define AUO_PIXCIR_POWER_ALLOW_SLEEP (1 << 2) #define AUO_PIXCIR_POWER_IDLE_TIME(ms) ((ms & 0xf) << 4) #define AUO_PIXCIR_CALIBRATE 0x03 #define AUO_PIXCIR_EEPROM_CALIB_X_LEN 62 #define AUO_PIXCIR_EEPROM_CALIB_Y_LEN 36 #define AUO_PIXCIR_RAW_DATA_X_LEN 18 #define AUO_PIXCIR_RAW_DATA_Y_LEN 11 #define AUO_PIXCIR_STRENGTH_ENABLE (1 << 0) /* Touchscreen absolute values */ #define AUO_PIXCIR_REPORT_POINTS 2 #define AUO_PIXCIR_MAX_AREA 0xff #define AUO_PIXCIR_PENUP_TIMEOUT_MS 10 struct auo_pixcir_ts { struct i2c_client *client; struct input_dev *input; const struct auo_pixcir_ts_platdata *pdata; char phys[32]; /* special handling for touch_indicate interupt mode */ bool touch_ind_mode; wait_queue_head_t wait; bool stopped; }; struct auo_point_t { int coord_x; int coord_y; int area_major; int area_minor; int orientation; }; static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, struct auo_point_t *point) { struct i2c_client *client = ts->client; const struct auo_pixcir_ts_platdata *pdata = ts->pdata; uint8_t raw_coord[8]; uint8_t raw_area[4]; int i, ret; /* touch coordinates */ ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_X1_LSB, 8, raw_coord); if (ret < 0) { dev_err(&client->dev, "failed to read coordinate, %d\n", ret); return ret; } /* touch area */ ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_TOUCHAREA_X1, 4, raw_area); if (ret < 0) { dev_err(&client->dev, "could not read touch area, %d\n", ret); return ret; } for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) { point[i].coord_x = raw_coord[4 * i + 1] << 8 | raw_coord[4 * i]; point[i].coord_y = raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2]; if (point[i].coord_x > pdata->x_max || point[i].coord_y > pdata->y_max) { dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", point[i].coord_x, point[i].coord_y); point[i].coord_x = point[i].coord_y = 0; } /* determine touch major, minor and orientation */ point[i].area_major = max(raw_area[2 * i], raw_area[2 * i + 1]); point[i].area_minor = min(raw_area[2 * i], raw_area[2 * i + 1]); point[i].orientation = raw_area[2 * i] > raw_area[2 * i + 1]; } return 0; } static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) { struct auo_pixcir_ts *ts = dev_id; const struct auo_pixcir_ts_platdata *pdata = ts->pdata; struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; int i; int ret; int fingers = 0; int abs = -1; while (!ts->stopped) { /* check for up event in touch touch_ind_mode */ if (ts->touch_ind_mode) { if (gpio_get_value(pdata->gpio_int) == 0) { input_mt_sync(ts->input); input_report_key(ts->input, BTN_TOUCH, 0); input_sync(ts->input); break; } } ret = auo_pixcir_collect_data(ts, point); if (ret < 0) { /* we want to loop only in touch_ind_mode */ if (!ts->touch_ind_mode) break; wait_event_timeout(ts->wait, ts->stopped, msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS)); continue; } for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) { if (point[i].coord_x > 0 || point[i].coord_y > 0) { input_report_abs(ts->input, ABS_MT_POSITION_X, point[i].coord_x); input_report_abs(ts->input, ABS_MT_POSITION_Y, point[i].coord_y); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, point[i].area_major); input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, point[i].area_minor); input_report_abs(ts->input, ABS_MT_ORIENTATION, point[i].orientation); input_mt_sync(ts->input); /* use first finger as source for singletouch */ if (fingers == 0) abs = i; /* number of touch points could also be queried * via i2c but would require an additional call */ fingers++; } } input_report_key(ts->input, BTN_TOUCH, fingers > 0); if (abs > -1) { input_report_abs(ts->input, ABS_X, point[abs].coord_x); input_report_abs(ts->input, ABS_Y, point[abs].coord_y); } input_sync(ts->input); /* we want to loop only in touch_ind_mode */ if (!ts->touch_ind_mode) break; wait_event_timeout(ts->wait, ts->stopped, msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS)); } return IRQ_HANDLED; } /* * Set the power mode of the device. * Valid modes are * - AUO_PIXCIR_POWER_ACTIVE * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch * - AUO_PIXCIR_POWER_DEEP_SLEEP */ static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode) { struct i2c_client *client = ts->client; int ret; ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_POWER_MODE); if (ret < 0) { dev_err(&client->dev, "unable to read reg %Xh, %d\n", AUO_PIXCIR_REG_POWER_MODE, ret); return ret; } ret &= ~AUO_PIXCIR_POWER_MASK; ret |= mode; ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_POWER_MODE, ret); if (ret) { dev_err(&client->dev, "unable to write reg %Xh, %d\n", AUO_PIXCIR_REG_POWER_MODE, ret); return ret; } return 0; } static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, int int_setting) { struct i2c_client *client = ts->client; const struct auo_pixcir_ts_platdata *pdata = ts->pdata; int ret; ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); if (ret < 0) { dev_err(&client->dev, "unable to read reg %Xh, %d\n", AUO_PIXCIR_REG_INT_SETTING, ret); return ret; } ret &= ~AUO_PIXCIR_INT_MODE_MASK; ret |= int_setting; ret |= AUO_PIXCIR_INT_POL_HIGH; /* always use high for interrupts */ ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING, ret); if (ret < 0) { dev_err(&client->dev, "unable to write reg %Xh, %d\n", AUO_PIXCIR_REG_INT_SETTING, ret); return ret; } ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND; return 0; } /* control the generation of interrupts on the device side */ static int auo_pixcir_int_toggle(struct auo_pixcir_ts *ts, bool enable) { struct i2c_client *client = ts->client; int ret; ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); if (ret < 0) { dev_err(&client->dev, "unable to read reg %Xh, %d\n", AUO_PIXCIR_REG_INT_SETTING, ret); return ret; } if (enable) ret |= AUO_PIXCIR_INT_ENABLE; else ret &= ~AUO_PIXCIR_INT_ENABLE; ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING, ret); if (ret < 0) { dev_err(&client->dev, "unable to write reg %Xh, %d\n", AUO_PIXCIR_REG_INT_SETTING, ret); return ret; } return 0; } static int auo_pixcir_start(struct auo_pixcir_ts *ts) { struct i2c_client *client = ts->client; int ret; ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_ACTIVE); if (ret < 0) { dev_err(&client->dev, "could not set power mode, %d\n", ret); return ret; } ts->stopped = false; mb(); enable_irq(client->irq); ret = auo_pixcir_int_toggle(ts, 1); if (ret < 0) { dev_err(&client->dev, "could not enable interrupt, %d\n", ret); disable_irq(client->irq); return ret; } return 0; } static int auo_pixcir_stop(struct auo_pixcir_ts *ts) { struct i2c_client *client = ts->client; int ret; ret = auo_pixcir_int_toggle(ts, 0); if (ret < 0) { dev_err(&client->dev, "could not disable interrupt, %d\n", ret); return ret; } /* disable receiving of interrupts */ disable_irq(client->irq); ts->stopped = true; mb(); wake_up(&ts->wait); return auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_DEEP_SLEEP); } static int auo_pixcir_input_open(struct input_dev *dev) { struct auo_pixcir_ts *ts = input_get_drvdata(dev); int ret; ret = auo_pixcir_start(ts); if (ret) return ret; return 0; } static void auo_pixcir_input_close(struct input_dev *dev) { struct auo_pixcir_ts *ts = input_get_drvdata(dev); auo_pixcir_stop(ts); return; } #ifdef CONFIG_PM_SLEEP static int auo_pixcir_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct auo_pixcir_ts *ts = i2c_get_clientdata(client); struct input_dev *input = ts->input; int ret = 0; mutex_lock(&input->mutex); /* when configured as wakeup source, device should always wake system * therefore start device if necessary */ if (device_may_wakeup(&client->dev)) { /* need to start device if not open, to be wakeup source */ if (!input->users) { ret = auo_pixcir_start(ts); if (ret) goto unlock; } enable_irq_wake(client->irq); ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP); } else if (input->users) { ret = auo_pixcir_stop(ts); } unlock: mutex_unlock(&input->mutex); return ret; } static int auo_pixcir_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct auo_pixcir_ts *ts = i2c_get_clientdata(client); struct input_dev *input = ts->input; int ret = 0; mutex_lock(&input->mutex); if (device_may_wakeup(&client->dev)) { disable_irq_wake(client->irq); /* need to stop device if it was not open on suspend */ if (!input->users) { ret = auo_pixcir_stop(ts); if (ret) goto unlock; } /* device wakes automatically from SLEEP */ } else if (input->users) { ret = auo_pixcir_start(ts); } unlock: mutex_unlock(&input->mutex); return ret; } #endif static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, auo_pixcir_suspend, auo_pixcir_resume); #ifdef CONFIG_OF static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) { struct auo_pixcir_ts_platdata *pdata; struct device_node *np = dev->of_node; if (!np) return ERR_PTR(-ENOENT); pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { dev_err(dev, "failed to allocate platform data\n"); return ERR_PTR(-ENOMEM); } pdata->gpio_int = of_get_gpio(np, 0); if (!gpio_is_valid(pdata->gpio_int)) { dev_err(dev, "failed to get interrupt gpio\n"); return ERR_PTR(-EINVAL); } pdata->gpio_rst = of_get_gpio(np, 1); if (!gpio_is_valid(pdata->gpio_rst)) { dev_err(dev, "failed to get reset gpio\n"); return ERR_PTR(-EINVAL); } if (of_property_read_u32(np, "x-size", &pdata->x_max)) { dev_err(dev, "failed to get x-size property\n"); return ERR_PTR(-EINVAL); } if (of_property_read_u32(np, "y-size", &pdata->y_max)) { dev_err(dev, "failed to get y-size property\n"); return ERR_PTR(-EINVAL); } /* default to asserting the interrupt when the screen is touched */ pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND; return pdata; } #else static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) { return ERR_PTR(-EINVAL); } #endif static void auo_pixcir_reset(void *data) { struct auo_pixcir_ts *ts = data; gpio_set_value(ts->pdata->gpio_rst, 0); } static int auo_pixcir_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct auo_pixcir_ts_platdata *pdata; struct auo_pixcir_ts *ts; struct input_dev *input_dev; int version; int error; pdata = dev_get_platdata(&client->dev); if (!pdata) { pdata = auo_pixcir_parse_dt(&client->dev); if (IS_ERR(pdata)) return PTR_ERR(pdata); } ts = devm_kzalloc(&client->dev, sizeof(struct auo_pixcir_ts), GFP_KERNEL); if (!ts) return -ENOMEM; input_dev = devm_input_allocate_device(&client->dev); if (!input_dev) { dev_err(&client->dev, "could not allocate input device\n"); return -ENOMEM; } ts->pdata = pdata; ts->client = client; ts->input = input_dev; ts->touch_ind_mode = 0; ts->stopped = true; init_waitqueue_head(&ts->wait); snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&client->dev)); input_dev->name = "AUO-Pixcir touchscreen"; input_dev->phys = ts->phys; input_dev->id.bustype = BUS_I2C; input_dev->open = auo_pixcir_input_open; input_dev->close = auo_pixcir_input_close; __set_bit(EV_ABS, input_dev->evbit); __set_bit(EV_KEY, input_dev->evbit); __set_bit(BTN_TOUCH, input_dev->keybit); /* For single touch */ input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0); input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0); /* For multi touch */ input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0); input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, AUO_PIXCIR_MAX_AREA, 0, 0); input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, AUO_PIXCIR_MAX_AREA, 0, 0); input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); input_set_drvdata(ts->input, ts); error = devm_gpio_request_one(&client->dev, pdata->gpio_int, GPIOF_DIR_IN, "auo_pixcir_ts_int"); if (error) { dev_err(&client->dev, "request of gpio %d failed, %d\n", pdata->gpio_int, error); return error; } error = devm_gpio_request_one(&client->dev, pdata->gpio_rst, GPIOF_DIR_OUT | GPIOF_INIT_HIGH, "auo_pixcir_ts_rst"); if (error) { dev_err(&client->dev, "request of gpio %d failed, %d\n", pdata->gpio_rst, error); return error; } error = devm_add_action(&client->dev, auo_pixcir_reset, ts); if (error) { auo_pixcir_reset(ts); dev_err(&client->dev, "failed to register reset action, %d\n", error); return error; } msleep(200); version = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION); if (version < 0) { error = version; return error; } dev_info(&client->dev, "firmware version 0x%X\n", version); error = auo_pixcir_int_config(ts, pdata->int_setting); if (error) return error; error = devm_request_threaded_irq(&client->dev, client->irq, NULL, auo_pixcir_interrupt, IRQF_TRIGGER_RISING | IRQF_ONESHOT, input_dev->name, ts); if (error) { dev_err(&client->dev, "irq %d requested failed, %d\n", client->irq, error); return error; } /* stop device and put it into deep sleep until it is opened */ error = auo_pixcir_stop(ts); if (error) return error; error = input_register_device(input_dev); if (error) { dev_err(&client->dev, "could not register input device, %d\n", error); return error; } i2c_set_clientdata(client, ts); return 0; } static const struct i2c_device_id auo_pixcir_idtable[] = { { "auo_pixcir_ts", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); #ifdef CONFIG_OF static struct of_device_id auo_pixcir_ts_dt_idtable[] = { { .compatible = "auo,auo_pixcir_ts" }, {}, }; MODULE_DEVICE_TABLE(of, auo_pixcir_ts_dt_idtable); #endif static struct i2c_driver auo_pixcir_driver = { .driver = { .owner = THIS_MODULE, .name = "auo_pixcir_ts", .pm = &auo_pixcir_pm_ops, .of_match_table = of_match_ptr(auo_pixcir_ts_dt_idtable), }, .probe = auo_pixcir_probe, .id_table = auo_pixcir_idtable, }; module_i2c_driver(auo_pixcir_driver); MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
8378aca87aa8c4eb3f4332802c91716d1960714c
39b8d37edbc228c0ee43644f620fd5f7ce448ff8
/src/sclite/sctk.h
21bfffa42db37c40bd3c2c54ef745c5f6b3e66e3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain", "NIST-Software" ]
permissive
usnistgov/SCTK
e29feea7744e7a2a8204f5e90d0a6fd81e6ed690
f48376a203ab17f0d479995d87275db6772dcb4a
refs/heads/master
2023-01-31T15:08:23.855355
2022-09-08T11:53:45
2022-09-08T11:53:45
57,993,905
170
52
NOASSERTION
2023-01-27T22:28:02
2016-05-03T19:00:47
C
UTF-8
C
false
false
10,221
h
sctk.h
/* main include file for the Scoring ToolKit (SCTK) */ /* Created: Jul, 28, 1997 */ #define TK_VERSION "1.3" #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <sys/stat.h> #include <sys/time.h> #include <time.h> #ifdef __cplusplus extern "C" { #endif #include "text.h" #include "booldef.h" #include "wtokstr1.h" #include "path.h" #include "proto.h" #include "order.h" #include "stm.h" #include "pad.h" #include "sgml.h" #include "alex.h" #include "netstr1.h" #include "llist.h" #define db_enter_msg(_s,_db) {if (_db < db_level) printf("DB: Entering %s\n",_s);} #define db_leave_msg(_s,_db) {if (_db < db_level) printf("DB: Leaving %s\n",_s);} #define strdup_safe(_s,_p) (char *)TEXT_strdup((TEXT *)_s) #define malloc_safe(_s,_p) malloc(_s) #define streq(cs,ct) (strcmp(cs,ct) == 0) #ifdef __STDC__ /* rsprinaztf.c */ char *rsprintf PROTO((char *format , ...)); #else /* rsprintf.c */ char *rsprintf PROTO((va_alist)); #endif #define F_ROUND(_n,_p) (((float)((int)((_n) * pow(10.0,(float)(_p)) + ((_n>0.0)?0.5:-0.5)))) / pow(10.0,(float)(_p))) #define F_CEIL(_n,_p) ( ((double)ceil((double)((_n) * pow(10.0,(double)(_p))))) / pow(10.0,(double)(_p))) #define pct(num,dem) (((dem)==0) ? 0 : (double)(num)/(double)(dem) * 100.0) #define form_feed(_f) fprintf(_f," "); #define TRUE 1 #define FALSE 0 /* bit field accessors, and query macros */ #define BF_isSET(_v,_f) (((_v) & (_f)) > 0) #define BF_notSET(_v,_f) (((_v) & (_f)) == 0) #define BF_SET(_v,_f) _v |= (_f) #define BF_FLIP(_v,_f) _v ^= (_f) #define BF_UNSET(_v,_f) _v &= ~(_f) #ifndef MAX #define MAX(_a,_b) (((_a) > (_b)) ? (_a) : (_b)) #endif #ifndef MIN #define MIN(_a,_b) (((_a) < (_b)) ? (_a) : (_b)) #endif #define MAX3(_a,_b,_c) (MAX(_a,(MAX(_b,_c)))) #ifndef M_LOG2E #define M_LOG2E 1.4426950408889634074 #endif /* using slope to linearly interprelate Based on: M = (y2 - y1) / (x2 - y2) (y2 - y1) / (x2 - y2) = (y2 - QY) / (x2 - PX) (x2 - PX) * (y2 - y1) / (x2 - y2) = (y2 - QY) y2 - ((x2 - PX) * (y2 - y1) / (x2 - x2)) = QY */ #define interpelate_y_from_x(_x1, _y1, _x2, _y2, _kn_X) \ (_y2 - ((_x2 - _kn_X) * (_y2 - _y1) / (_x2 - _x1))) #define SCREEN_WIDTH 80 #define FULL_SCREEN 132 #define INF_ASCII_TOO 1 #define CALI_ON 1 #define CALI_NOASCII 2 #define CALI_DELHYPHEN 4 #include "word.h" #include "cores.h" #include "memory.h" #include "rpg.h" typedef struct grp_score{ char *name; int corr; /* num correct words in sent */ int ins; /* num inserted words in sent */ int del; /* num deleted words in sent */ int sub; /* num substituted words in sent */ int merges; /* num of merges */ int splits; /* num of splits */ double weight_ref; /* weighted sum of reference words in sent */ double weight_corr; /* weighted sum of correct words in sent */ double weight_ins; /* weighted sum of inserted words in sent */ double weight_del; /* weighted sum of deleted words in sent */ double weight_sub; /* weighted sum of substituted words in sent */ double weight_merges; /* weighted sum of of merges */ double weight_splits; /* weighted sum of of splits */ int nsent; /* number of sentences, utts, ... */ int serr; /* number of sents with an error */ int max_path; /* Size of PATH array */ int num_path; /* number of PATH's in PATH array */ PATH **path; /* array of PATH pointers */ } GRP; typedef struct pathlabel_item_struct{ char *id; /* the label's id code */ char *title; /* Column heading title for the lable */ char *desc; /* Descriptive text for the label */ } PATHLABEL_ITEM; typedef struct category_item_struct{ char *id; /* the category's id code */ char *title; /* Column heading title for the category */ char *desc; /* Descriptive text for the catagory */ } CATEGORY_ITEM; typedef struct arbitrary_subset_label_struct{ int max_plab; /* max PATHLABEL_ITEMS in 'plab' array */ int num_plab; /* current number of items in 'plab' array */ PATHLABEL_ITEM *plab; /* list of path labels */ int max_cat; /* max CATEGORY_ITEMS in 'cat' array */ int num_cat; /* current number of items in 'cat' array */ CATEGORY_ITEM *cat; /* list of categories */ } ARB_SSET; typedef struct set_score{ char *title; /* the title to call the system in reports */ char *ref_fname; /* filename of the reference file */ char *hyp_fname; /* filename of the hypothesis file */ char *creation_date; /* creation date */ int frag_corr; /* if the comline fragment correct flag */ int opt_del; /* if the comline opt_del flag set */ int weight_ali; /* if the comline word weight alignment set */ char *weight_file; /* if the comline word weight alignment set, wwl filename */ int max_grp; /* maximum number of path groups (speakers) */ int num_grp; /* current number of path groups */ GRP *grp; /* a list of path groups */ ARB_SSET aset; /* struct of arbitrary labelling */ } SCORES; #if __STDC__ FILE * readpipe (char *progname, ...); #else FILE * readpipe (); #endif #include "corresp.h" #include "wwscr_f.h" SCORES *SCORES_init(char *name, int ngrp); void SCORES_free(SCORES *scor); int SCORES_get_grp(SCORES *sc, char *grpname); int find_PATHLABEL_id(SCORES *sc, char *id); int parse_input_comment_line(SCORES *sc, TEXT *buf); void load_comment_labels_from_file(SCORES *scor, char *labfile); void add_PATH_score(SCORES *sc, PATH *path, int grp, int keep_path); void dump_SCORES(SCORES *sc, FILE *fp); void dump_SCORES_alignments(SCORES *sc, FILE *fp, int lw, int full); void dump_SCORES_sgml(SCORES *sc, FILE *fp, TEXT *token_separator, TEXT *token_attribute_separator); int load_SCORES_sgml(FILE *fp, SCORES **scor, int *nscor, int maxscor); void print_system_summary(SCORES *sc, char *sys_root_name, int do_sm, int do_raw, int do_weighted, int feedback); void print_N_system_summary(SCORES *sc[], int nsc, char *out_root_name, char *test_name, int do_raw, int feedback); void print_N_system_executive_summary(SCORES *sc[], int nsc, char *out_root_name, char *test_name, int do_raw, int feedback); void print_SCORES_compare_matrix(SCORES *scor[], int nscor, int **winner, char *tname, char *matrix_name); void print_lur(SCORES *sc, char *sys_root_name, int feedback); void print_N_lur(SCORES *scor[], int nscor, char *outname, char *test_name, int feedback); void compute_SCORE_nce(SCORES *sc, double *nce_system, double *nce_a); void print_N_SCORE(SCORES *scor[], int nscor, char *outname, int max, int feedback, int score_diff); enum id_types {WSJ,RM,ATIS,SWB,SPUID,SP}; SCORES *align_trans_mode_dp(char *ref_file, char *hyp_file, char *title, int keep_path, int case_sense, int feedback, int char_align, enum id_types idt, int infer_word_seg, char *lexicon, int frag_correct, int opt_del, int inf_no_ascii, WWL *wwl, char *lm_file); SCORES *align_ctm_to_stm_dp(char *ref_file, char *hyp_file, char *set_title, int keep_path, int case_sense, int feedback, int char_align, enum id_types idt, int infer_word_seg, char *lexicon, int frag_correct, int opt_del, int inf_no_ascii, int reduce_ref, int reduce_hyp, int left_to_right, WWL *wwl, char *lm_file); SCORES *align_trans_mode_diff(char *ref_file, char *hyp_file, char *title, int keep_path, int case_sense, int feedback, enum id_types idt); SCORES *align_ctm_to_stm_diff(char *ref_file, char *hyp_file, char *set_title, int keep_path, int case_sense, int feedback, enum id_types idt); SCORES *align_text_to_stm(char *ref_file, char *hyp_file, char *set_title, int keep_path, int case_sense, int feedback, enum id_types idt); void expand_words_to_chars(ARC *arc, void *ptr); void decode_opt_del(ARC *arc, void *ptr); void decode_fragment(ARC *arc, void *ptr); PATH *network_dp_align_texts(TEXT *ref, NETWORK *rnet, TEXT *hyp, NETWORK *hnet, int char_align, int case_sense, char *id, int fcorr, int opt_del, int time_align, WWL *wwl, char *lm_file); PATH *infer_word_seg_algo1(TEXT *ref, TEXT *hyp, NETWORK *hnet, int case_sense,char *id, char *lex_fname, int fcorr, int opt_del, int no_ascii); PATH *infer_word_seg_algo2(TEXT *ref, TEXT *hyp, NETWORK *hnet, int case_sense,char *id, char *lex_fname, int fcorr, int opt_del, int flags); SCORES *align_ctm_to_ctm(char *hyp_file, char *ref_file, char *set_title, int feedback, int frag_corr, int opt_del, int case_sense, int time_align, int left_to_right, WWL *wwl, char *lm_file); double overlap(double s1_t1, double s1_t2, double s2_t1, double s2_t2); int score_dtl_sent(SCORES *scor, char *sys_root_name, int feedback); int score_dtl_spkr(SCORES *scor, char *sys_root_name, int feedback); int score_dtl_overall(SCORES *scor, char *sys_root_name, int feedback); char *get_date(void); int hyp_confidences_available(SCORES *scor); int make_SCORES_DET_curve(SCORES *scor[], int nscor, char *outroot, int feedback, char *test_name); int make_binned_confidence(SCORES *scor, char *outroot, int feedback); int make_scaled_binned_confidence(SCORES *scor, char *outroot, int bins, int feedback); int make_confidence_histogram(SCORES *scor, char *outroot, int feedback); /* debug levels */ /* level 1: print function entrances */ /* level 2: print function arguments */ /* level 5: intermediate status */ extern int db; #define LINE_LENGTH 500 #define INF_SEG_ALGO1 1 #define INF_SEG_ALGO2 2 #include "rank.h" #include "statdist.h" #define scfp stderr #ifdef MAIN int db=0, db_level; char *pdb=""; #else extern int db, db_level; extern char *pdb; #endif #ifdef DIFF_EXE #define DIFF_ENABLED 1 #define DIFF_PROGRAM DIFF_EXE #else #define DIFF_ENABLED 0 #define DIFF_PROGRAM "" #endif #ifdef WITH_SLM #include "slm_v2/include/SLM2.h" #endif #include "slm_intf.h" #ifdef __cplusplus } #endif
2edd967e2fedc8eec83f4cdda3da4390b3dfd389
c7707fdbf2a0047d0e913083a79e9ae189a57ce0
/sample/bitmap/cube 3D/src/meshs.c
7f1f32571f2c2da9e40d81d27d9fa703be8ce0a6
[ "MIT", "GPL-3.0-only", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later", "GCC-exception-3.1" ]
permissive
Stephane-D/SGDK
845255abad028880a3a6b8d760e4afc5f70eec55
d84d45664f5de8a582787beebe9bc420215df84b
refs/heads/master
2023-08-25T15:18:54.543956
2023-07-31T14:47:35
2023-07-31T14:47:35
32,350,744
1,577
248
MIT
2023-08-28T11:52:47
2015-03-16T20:22:13
C
UTF-8
C
false
false
1,017
c
meshs.c
#include "genesis.h" // CUBE // // 6----7 // /| /| // 2-+--4 | // | | | | // | 3--+-5 // |/ |/ // 0----1 const Vect3D_f16 cube_coord[8] = { {FIX16(-5), FIX16(-5), FIX16(-5)}, {FIX16(5), FIX16(-5), FIX16(-5)}, {FIX16(-5), FIX16(5), FIX16(-5)}, {FIX16(-5), FIX16(-5), FIX16(5)}, {FIX16(5), FIX16(5), FIX16(-5)}, {FIX16(5), FIX16(-5), FIX16(5)}, {FIX16(-5), FIX16(5), FIX16(5)}, {FIX16(5), FIX16(5), FIX16(5)} }; const u16 cube_poly_ind[6 * 4] = { 6, 3, 5, 7, 0, 2, 4, 1, 2, 6, 7, 4, 3, 0, 1, 5, 1, 4, 7, 5, 3, 6, 2, 0 }; const u16 cube_line_ind[12 * 2] = { 0, 1, 1, 4, 4, 2, 2, 0, 3, 5, 5, 7, 7, 6, 6, 3, 0, 3, 1, 5, 4, 7, 2, 6 }; const Vect3D_f16 cube_face_norm[6] = { {FIX16(0), FIX16(0), FIX16(1)}, {FIX16(0), FIX16(0), FIX16(-1)}, {FIX16(0), FIX16(1), FIX16(0)}, {FIX16(0), FIX16(-1), FIX16(0)}, {FIX16(1), FIX16(0), FIX16(0)}, {FIX16(-1), FIX16(0), FIX16(0)} };
b575cef50f59930281d3fd4f22971d2ade5ba4a5
9ceacf33fd96913cac7ef15492c126d96cae6911
/lib/libcrypto/evp/e_camellia.c
cec7649e3f3aae0327416d4f3f27021f20872346
[]
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
20,334
c
e_camellia.c
/* $OpenBSD: e_camellia.c,v 1.18 2023/07/07 19:37:53 beck Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. 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. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 OpenSSL PROJECT OR * ITS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include <string.h> #include <openssl/opensslconf.h> #ifndef OPENSSL_NO_CAMELLIA #include <openssl/evp.h> #include <openssl/err.h> #include <openssl/camellia.h> #include "evp_local.h" /* Camellia subkey Structure */ typedef struct { CAMELLIA_KEY ks; } EVP_CAMELLIA_KEY; /* Attribute operation for Camellia */ #define data(ctx) ((EVP_CAMELLIA_KEY *)(ctx)->cipher_data) static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { int ret; ret = Camellia_set_key(key, ctx->key_len * 8, ctx->cipher_data); if (ret < 0) { EVPerror(EVP_R_CAMELLIA_KEY_SETUP_FAILED); return 0; } return 1; } static int camellia_128_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { Camellia_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) Camellia_cbc_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); return 1; } static int camellia_128_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb128_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static int camellia_128_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t i, bl; bl = ctx->cipher->block_size; if (inl < bl) return 1; inl -= bl; for (i = 0; i <= inl; i += bl) Camellia_ecb_encrypt(in + i, out + i, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->encrypt); return 1; } static int camellia_128_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { Camellia_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) Camellia_ofb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); return 1; } static const EVP_CIPHER camellia_128_cbc = { .nid = NID_camellia_128_cbc, .block_size = 16, .key_len = 16, .iv_len = 16, .flags = 0 | EVP_CIPH_CBC_MODE, .init = camellia_init_key, .do_cipher = camellia_128_cbc_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_128_cbc(void) { return &camellia_128_cbc; } static const EVP_CIPHER camellia_128_cfb128 = { .nid = NID_camellia_128_cfb128, .block_size = 1, .key_len = 16, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_128_cfb128_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_128_cfb128(void) { return &camellia_128_cfb128; } static const EVP_CIPHER camellia_128_ofb = { .nid = NID_camellia_128_ofb128, .block_size = 1, .key_len = 16, .iv_len = 16, .flags = 0 | EVP_CIPH_OFB_MODE, .init = camellia_init_key, .do_cipher = camellia_128_ofb_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_128_ofb(void) { return &camellia_128_ofb; } static const EVP_CIPHER camellia_128_ecb = { .nid = NID_camellia_128_ecb, .block_size = 16, .key_len = 16, .iv_len = 0, .flags = 0 | EVP_CIPH_ECB_MODE, .init = camellia_init_key, .do_cipher = camellia_128_ecb_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_128_ecb(void) { return &camellia_128_ecb; } static int camellia_192_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { Camellia_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) Camellia_cbc_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); return 1; } static int camellia_192_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb128_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static int camellia_192_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t i, bl; bl = ctx->cipher->block_size; if (inl < bl) return 1; inl -= bl; for (i = 0; i <= inl; i += bl) Camellia_ecb_encrypt(in + i, out + i, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->encrypt); return 1; } static int camellia_192_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { Camellia_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) Camellia_ofb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); return 1; } static const EVP_CIPHER camellia_192_cbc = { .nid = NID_camellia_192_cbc, .block_size = 16, .key_len = 24, .iv_len = 16, .flags = 0 | EVP_CIPH_CBC_MODE, .init = camellia_init_key, .do_cipher = camellia_192_cbc_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_192_cbc(void) { return &camellia_192_cbc; } static const EVP_CIPHER camellia_192_cfb128 = { .nid = NID_camellia_192_cfb128, .block_size = 1, .key_len = 24, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_192_cfb128_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_192_cfb128(void) { return &camellia_192_cfb128; } static const EVP_CIPHER camellia_192_ofb = { .nid = NID_camellia_192_ofb128, .block_size = 1, .key_len = 24, .iv_len = 16, .flags = 0 | EVP_CIPH_OFB_MODE, .init = camellia_init_key, .do_cipher = camellia_192_ofb_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_192_ofb(void) { return &camellia_192_ofb; } static const EVP_CIPHER camellia_192_ecb = { .nid = NID_camellia_192_ecb, .block_size = 16, .key_len = 24, .iv_len = 0, .flags = 0 | EVP_CIPH_ECB_MODE, .init = camellia_init_key, .do_cipher = camellia_192_ecb_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_192_ecb(void) { return &camellia_192_ecb; } static int camellia_256_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { Camellia_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) Camellia_cbc_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); return 1; } static int camellia_256_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb128_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static int camellia_256_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t i, bl; bl = ctx->cipher->block_size; if (inl < bl) return 1; inl -= bl; for (i = 0; i <= inl; i += bl) Camellia_ecb_encrypt(in + i, out + i, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->encrypt); return 1; } static int camellia_256_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { Camellia_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) Camellia_ofb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); return 1; } static const EVP_CIPHER camellia_256_cbc = { .nid = NID_camellia_256_cbc, .block_size = 16, .key_len = 32, .iv_len = 16, .flags = 0 | EVP_CIPH_CBC_MODE, .init = camellia_init_key, .do_cipher = camellia_256_cbc_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_256_cbc(void) { return &camellia_256_cbc; } static const EVP_CIPHER camellia_256_cfb128 = { .nid = NID_camellia_256_cfb128, .block_size = 1, .key_len = 32, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_256_cfb128_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_256_cfb128(void) { return &camellia_256_cfb128; } static const EVP_CIPHER camellia_256_ofb = { .nid = NID_camellia_256_ofb128, .block_size = 1, .key_len = 32, .iv_len = 16, .flags = 0 | EVP_CIPH_OFB_MODE, .init = camellia_init_key, .do_cipher = camellia_256_ofb_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_256_ofb(void) { return &camellia_256_ofb; } static const EVP_CIPHER camellia_256_ecb = { .nid = NID_camellia_256_ecb, .block_size = 16, .key_len = 32, .iv_len = 0, .flags = 0 | EVP_CIPH_ECB_MODE, .init = camellia_init_key, .do_cipher = camellia_256_ecb_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_256_ecb(void) { return &camellia_256_ecb; } static int camellia_128_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; chunk >>= 3; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? chunk * 8 : chunk), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static const EVP_CIPHER camellia_128_cfb1 = { .nid = NID_camellia_128_cfb1, .block_size = 1, .key_len = 128/8, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_128_cfb1_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_128_cfb1(void) { return &camellia_128_cfb1; } static int camellia_192_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; chunk >>= 3; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? chunk * 8 : chunk), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static const EVP_CIPHER camellia_192_cfb1 = { .nid = NID_camellia_192_cfb1, .block_size = 1, .key_len = 192/8, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_192_cfb1_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_192_cfb1(void) { return &camellia_192_cfb1; } static int camellia_256_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; chunk >>= 3; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? chunk * 8 : chunk), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static const EVP_CIPHER camellia_256_cfb1 = { .nid = NID_camellia_256_cfb1, .block_size = 1, .key_len = 256/8, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_256_cfb1_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_256_cfb1(void) { return &camellia_256_cfb1; } static int camellia_128_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb8_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static const EVP_CIPHER camellia_128_cfb8 = { .nid = NID_camellia_128_cfb8, .block_size = 1, .key_len = 128/8, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_128_cfb8_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_128_cfb8(void) { return &camellia_128_cfb8; } static int camellia_192_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb8_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static const EVP_CIPHER camellia_192_cfb8 = { .nid = NID_camellia_192_cfb8, .block_size = 1, .key_len = 192/8, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_192_cfb8_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_192_cfb8(void) { return &camellia_192_cfb8; } static int camellia_256_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = EVP_MAXCHUNK; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { Camellia_cfb8_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static const EVP_CIPHER camellia_256_cfb8 = { .nid = NID_camellia_256_cfb8, .block_size = 1, .key_len = 256/8, .iv_len = 16, .flags = 0 | EVP_CIPH_CFB_MODE, .init = camellia_init_key, .do_cipher = camellia_256_cfb8_cipher, .cleanup = NULL, .ctx_size = sizeof(EVP_CAMELLIA_KEY), .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, .ctrl = NULL, .app_data = NULL, }; const EVP_CIPHER * EVP_camellia_256_cfb8(void) { return &camellia_256_cfb8; } #endif
44297c935d115332a5b9df861dfda7a70bac81b3
802f0c1dd855693f709da4024b50d6d4938c13ff
/examples/c/engine_model/engine_impl_dae_fun_jac_x_xdot_u_z.h
894d9be047f33e93beeaba87c09af5cdf0c8f47f
[ "BSD-2-Clause" ]
permissive
acados/acados
9cd480da3462725506f06199838e3cdae007d0c8
64166a37859108ab74ce6bf7408501f9bd4a89da
refs/heads/master
2023-08-16T13:03:44.298740
2023-08-15T13:07:48
2023-08-15T13:07:48
55,497,573
558
213
NOASSERTION
2023-09-01T09:01:33
2016-04-05T10:06:48
C
UTF-8
C
false
false
1,094
h
engine_impl_dae_fun_jac_x_xdot_u_z.h
/* This file was automatically generated by CasADi. The CasADi copyright holders make no ownership claim of its contents. */ #ifdef __cplusplus extern "C" { #endif #ifndef casadi_real #define casadi_real double #endif #ifndef casadi_int #define casadi_int int #endif int engine_impl_dae_fun_jac_x_xdot_u_z(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem); void engine_impl_dae_fun_jac_x_xdot_u_z_incref(void); void engine_impl_dae_fun_jac_x_xdot_u_z_decref(void); casadi_int engine_impl_dae_fun_jac_x_xdot_u_z_n_out(void); casadi_int engine_impl_dae_fun_jac_x_xdot_u_z_n_in(void); const char* engine_impl_dae_fun_jac_x_xdot_u_z_name_in(casadi_int i); const char* engine_impl_dae_fun_jac_x_xdot_u_z_name_out(casadi_int i); const casadi_int* engine_impl_dae_fun_jac_x_xdot_u_z_sparsity_in(casadi_int i); const casadi_int* engine_impl_dae_fun_jac_x_xdot_u_z_sparsity_out(casadi_int i); int engine_impl_dae_fun_jac_x_xdot_u_z_work(casadi_int *sz_arg, casadi_int* sz_res, casadi_int *sz_iw, casadi_int *sz_w); #ifdef __cplusplus } /* extern "C" */ #endif
db3548e64bcb6dc05732b6994c8b1e7771dc411e
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/libaom/source/libaom/third_party/SVT-AV1/convolve_avx2.h
923cabee7f8fd534e1368fd4f410f2ac25c13079
[ "BSD-2-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause-Clear" ]
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
136,864
h
convolve_avx2.h
/* * Copyright (c) 2018, Alliance for Open Media. All rights reserved * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #ifndef THIRD_PARTY_SVT_AV1_CONVOLVE_AVX2_H_ #define THIRD_PARTY_SVT_AV1_CONVOLVE_AVX2_H_ #include "EbMemory_AVX2.h" #include "EbMemory_SSE4_1.h" #include "synonyms.h" #include "aom_dsp/aom_filter.h" #include "aom_dsp/x86/convolve_avx2.h" #include "aom_dsp/x86/mem_sse2.h" static INLINE void populate_coeffs_4tap_avx2(const __m128i coeffs_128, __m256i coeffs[2]) { const __m256i coeffs_256 = _mm256_broadcastsi128_si256(coeffs_128); // coeffs 2 3 2 3 2 3 2 3 coeffs[0] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0604u)); // coeffs 4 5 4 5 4 5 4 5 coeffs[1] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0a08u)); } static INLINE void populate_coeffs_6tap_avx2(const __m128i coeffs_128, __m256i coeffs[3]) { const __m256i coeffs_256 = _mm256_broadcastsi128_si256(coeffs_128); // coeffs 1 2 1 2 1 2 1 2 coeffs[0] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0402u)); // coeffs 3 4 3 4 3 4 3 4 coeffs[1] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0806u)); // coeffs 5 6 5 6 5 6 5 6 coeffs[2] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0C0Au)); } static INLINE void populate_coeffs_8tap_avx2(const __m128i coeffs_128, __m256i coeffs[4]) { const __m256i coeffs_256 = _mm256_broadcastsi128_si256(coeffs_128); // coeffs 0 1 0 1 0 1 0 1 coeffs[0] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0200u)); // coeffs 2 3 2 3 2 3 2 3 coeffs[1] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0604u)); // coeffs 4 5 4 5 4 5 4 5 coeffs[2] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0a08u)); // coeffs 6 7 6 7 6 7 6 7 coeffs[3] = _mm256_shuffle_epi8(coeffs_256, _mm256_set1_epi16(0x0e0cu)); } static INLINE void prepare_half_coeffs_2tap_ssse3( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [1] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_cvtsi32_si128(*(const int32_t *)(filter + 3)); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); // coeffs 3 4 3 4 3 4 3 4 *coeffs = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0200u)); } static INLINE void prepare_half_coeffs_4tap_ssse3( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [2] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); // coeffs 2 3 2 3 2 3 2 3 coeffs[0] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0604u)); // coeffs 4 5 4 5 4 5 4 5 coeffs[1] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0a08u)); } static INLINE void prepare_half_coeffs_6tap_ssse3( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [3] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); // coeffs 1 2 1 2 1 2 1 2 coeffs[0] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0402u)); // coeffs 3 4 3 4 3 4 3 4 coeffs[1] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0806u)); // coeffs 5 6 5 6 5 6 5 6 coeffs[2] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0C0Au)); } static INLINE void prepare_half_coeffs_8tap_ssse3( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [4] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); // coeffs 0 1 0 1 0 1 0 1 coeffs[0] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0200u)); // coeffs 2 3 2 3 2 3 2 3 coeffs[1] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0604u)); // coeffs 4 5 4 5 4 5 4 5 coeffs[2] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0a08u)); // coeffs 6 7 6 7 6 7 6 7 coeffs[3] = _mm_shuffle_epi8(coeffs_1, _mm_set1_epi16(0x0e0cu)); } static INLINE void prepare_half_coeffs_2tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [1] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_cvtsi32_si128(loadu_int32(filter + 3)); const __m256i filter_coeffs = _mm256_broadcastsi128_si256(coeffs_8); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m256i coeffs_1 = _mm256_srai_epi16(filter_coeffs, 1); // coeffs 3 4 3 4 3 4 3 4 *coeffs = _mm256_shuffle_epi8(coeffs_1, _mm256_set1_epi16(0x0200u)); } static INLINE void prepare_half_coeffs_4tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [2] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); populate_coeffs_4tap_avx2(coeffs_1, coeffs); } static INLINE void prepare_half_coeffs_6tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [3] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); populate_coeffs_6tap_avx2(coeffs_1, coeffs); } static INLINE void prepare_half_coeffs_8tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [4] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); // right shift all filter co-efficients by 1 to reduce the bits required. // This extra right shift will be taken care of at the end while rounding // the result. // Since all filter co-efficients are even, this change will not affect the // end result assert(_mm_test_all_zeros(_mm_and_si128(coeffs_8, _mm_set1_epi16(1)), _mm_set1_epi16((short)0xffff))); const __m128i coeffs_1 = _mm_srai_epi16(coeffs_8, 1); populate_coeffs_8tap_avx2(coeffs_1, coeffs); } static INLINE void prepare_coeffs_2tap_sse2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [1] */) { const int16_t *filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff = _mm_cvtsi32_si128(*(const int32_t *)(filter + 3)); // coeffs 3 4 3 4 3 4 3 4 coeffs[0] = _mm_shuffle_epi32(coeff, 0x00); } static INLINE void prepare_coeffs_4tap_sse2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [2] */) { const int16_t *filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff = _mm_loadu_si128((__m128i *)filter); // coeffs 2 3 2 3 2 3 2 3 coeffs[0] = _mm_shuffle_epi32(coeff, 0x55); // coeffs 4 5 4 5 4 5 4 5 coeffs[1] = _mm_shuffle_epi32(coeff, 0xaa); } static INLINE void prepare_coeffs_6tap_ssse3( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [3] */) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff = _mm_loadu_si128((__m128i *)filter); // coeffs 1 2 1 2 1 2 1 2 coeffs[0] = _mm_shuffle_epi8(coeff, _mm_set1_epi32(0x05040302u)); // coeffs 3 4 3 4 3 4 3 4 coeffs[1] = _mm_shuffle_epi8(coeff, _mm_set1_epi32(0x09080706u)); // coeffs 5 6 5 6 5 6 5 6 coeffs[2] = _mm_shuffle_epi8(coeff, _mm_set1_epi32(0x0D0C0B0Au)); } static INLINE void prepare_coeffs_8tap_sse2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m128i *const coeffs /* [4] */) { const int16_t *filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff = _mm_loadu_si128((__m128i *)filter); // coeffs 0 1 0 1 0 1 0 1 coeffs[0] = _mm_shuffle_epi32(coeff, 0x00); // coeffs 2 3 2 3 2 3 2 3 coeffs[1] = _mm_shuffle_epi32(coeff, 0x55); // coeffs 4 5 4 5 4 5 4 5 coeffs[2] = _mm_shuffle_epi32(coeff, 0xaa); // coeffs 6 7 6 7 6 7 6 7 coeffs[3] = _mm_shuffle_epi32(coeff, 0xff); } static INLINE void prepare_coeffs_2tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [1] */) { const int16_t *filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff_8 = _mm_cvtsi32_si128(*(const int32_t *)(filter + 3)); const __m256i coeff = _mm256_broadcastsi128_si256(coeff_8); // coeffs 3 4 3 4 3 4 3 4 coeffs[0] = _mm256_shuffle_epi32(coeff, 0x00); } static INLINE void prepare_coeffs_4tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [2] */) { const int16_t *filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff_8 = _mm_loadu_si128((__m128i *)filter); const __m256i coeff = _mm256_broadcastsi128_si256(coeff_8); // coeffs 2 3 2 3 2 3 2 3 coeffs[0] = _mm256_shuffle_epi32(coeff, 0x55); // coeffs 4 5 4 5 4 5 4 5 coeffs[1] = _mm256_shuffle_epi32(coeff, 0xaa); } static INLINE void prepare_coeffs_6tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [3]*/) { const int16_t *const filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeffs_8 = _mm_loadu_si128((__m128i *)filter); const __m256i coeff = _mm256_broadcastsi128_si256(coeffs_8); // coeffs 1 2 1 2 1 2 1 2 coeffs[0] = _mm256_shuffle_epi8(coeff, _mm256_set1_epi32(0x05040302u)); // coeffs 3 4 3 4 3 4 3 4 coeffs[1] = _mm256_shuffle_epi8(coeff, _mm256_set1_epi32(0x09080706u)); // coeffs 5 6 5 6 5 6 5 6 coeffs[2] = _mm256_shuffle_epi8(coeff, _mm256_set1_epi32(0x0D0C0B0Au)); } static INLINE void prepare_coeffs_8tap_avx2( const InterpFilterParams *const filter_params, const int32_t subpel_q4, __m256i *const coeffs /* [4] */) { const int16_t *filter = av1_get_interp_filter_subpel_kernel( filter_params, subpel_q4 & SUBPEL_MASK); const __m128i coeff_8 = _mm_loadu_si128((__m128i *)filter); const __m256i coeff = _mm256_broadcastsi128_si256(coeff_8); // coeffs 0 1 0 1 0 1 0 1 coeffs[0] = _mm256_shuffle_epi32(coeff, 0x00); // coeffs 2 3 2 3 2 3 2 3 coeffs[1] = _mm256_shuffle_epi32(coeff, 0x55); // coeffs 4 5 4 5 4 5 4 5 coeffs[2] = _mm256_shuffle_epi32(coeff, 0xaa); // coeffs 6 7 6 7 6 7 6 7 coeffs[3] = _mm256_shuffle_epi32(coeff, 0xff); } static INLINE void load_16bit_5rows_avx2(const int16_t *const src, const ptrdiff_t stride, __m256i dst[5]) { dst[0] = _mm256_loadu_si256((__m256i *)(src + 0 * stride)); dst[1] = _mm256_loadu_si256((__m256i *)(src + 1 * stride)); dst[2] = _mm256_loadu_si256((__m256i *)(src + 2 * stride)); dst[3] = _mm256_loadu_si256((__m256i *)(src + 3 * stride)); dst[4] = _mm256_loadu_si256((__m256i *)(src + 4 * stride)); } static INLINE void load_16bit_7rows_avx2(const int16_t *const src, const ptrdiff_t stride, __m256i dst[7]) { dst[0] = _mm256_loadu_si256((__m256i *)(src + 0 * stride)); dst[1] = _mm256_loadu_si256((__m256i *)(src + 1 * stride)); dst[2] = _mm256_loadu_si256((__m256i *)(src + 2 * stride)); dst[3] = _mm256_loadu_si256((__m256i *)(src + 3 * stride)); dst[4] = _mm256_loadu_si256((__m256i *)(src + 4 * stride)); dst[5] = _mm256_loadu_si256((__m256i *)(src + 5 * stride)); dst[6] = _mm256_loadu_si256((__m256i *)(src + 6 * stride)); } static AOM_FORCE_INLINE void load_16bit_8rows_avx2(const int16_t *const src, const ptrdiff_t stride, __m256i dst[8]) { dst[0] = _mm256_loadu_si256((__m256i *)(src + 0 * stride)); dst[1] = _mm256_loadu_si256((__m256i *)(src + 1 * stride)); dst[2] = _mm256_loadu_si256((__m256i *)(src + 2 * stride)); dst[3] = _mm256_loadu_si256((__m256i *)(src + 3 * stride)); dst[4] = _mm256_loadu_si256((__m256i *)(src + 4 * stride)); dst[5] = _mm256_loadu_si256((__m256i *)(src + 5 * stride)); dst[6] = _mm256_loadu_si256((__m256i *)(src + 6 * stride)); dst[7] = _mm256_loadu_si256((__m256i *)(src + 7 * stride)); } static AOM_FORCE_INLINE void loadu_unpack_16bit_5rows_avx2( const int16_t *const src, const ptrdiff_t stride, __m256i s_256[5], __m256i ss_256[5], __m256i tt_256[5]) { s_256[0] = _mm256_loadu_si256((__m256i *)(src + 0 * stride)); s_256[1] = _mm256_loadu_si256((__m256i *)(src + 1 * stride)); s_256[2] = _mm256_loadu_si256((__m256i *)(src + 2 * stride)); s_256[3] = _mm256_loadu_si256((__m256i *)(src + 3 * stride)); s_256[4] = _mm256_loadu_si256((__m256i *)(src + 4 * stride)); ss_256[0] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); ss_256[1] = _mm256_unpacklo_epi16(s_256[2], s_256[3]); ss_256[3] = _mm256_unpackhi_epi16(s_256[0], s_256[1]); ss_256[4] = _mm256_unpackhi_epi16(s_256[2], s_256[3]); tt_256[0] = _mm256_unpacklo_epi16(s_256[1], s_256[2]); tt_256[1] = _mm256_unpacklo_epi16(s_256[3], s_256[4]); tt_256[3] = _mm256_unpackhi_epi16(s_256[1], s_256[2]); tt_256[4] = _mm256_unpackhi_epi16(s_256[3], s_256[4]); } static AOM_FORCE_INLINE void loadu_unpack_16bit_3rows_avx2( const int16_t *const src, const ptrdiff_t stride, __m256i s_256[3], __m256i ss_256[3], __m256i tt_256[3]) { s_256[0] = _mm256_loadu_si256((__m256i *)(src + 0 * stride)); s_256[1] = _mm256_loadu_si256((__m256i *)(src + 1 * stride)); s_256[2] = _mm256_loadu_si256((__m256i *)(src + 2 * stride)); ss_256[0] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); ss_256[2] = _mm256_unpackhi_epi16(s_256[0], s_256[1]); tt_256[0] = _mm256_unpacklo_epi16(s_256[1], s_256[2]); tt_256[2] = _mm256_unpackhi_epi16(s_256[1], s_256[2]); } static INLINE void convolve_8tap_unpack_avx2(const __m256i s[6], __m256i ss[7]) { ss[0] = _mm256_unpacklo_epi16(s[0], s[1]); ss[1] = _mm256_unpacklo_epi16(s[2], s[3]); ss[2] = _mm256_unpacklo_epi16(s[4], s[5]); ss[4] = _mm256_unpackhi_epi16(s[0], s[1]); ss[5] = _mm256_unpackhi_epi16(s[2], s[3]); ss[6] = _mm256_unpackhi_epi16(s[4], s[5]); } static INLINE __m128i convolve_2tap_ssse3(const __m128i ss[1], const __m128i coeffs[1]) { return _mm_maddubs_epi16(ss[0], coeffs[0]); } static INLINE __m128i convolve_4tap_ssse3(const __m128i ss[2], const __m128i coeffs[2]) { const __m128i res_23 = _mm_maddubs_epi16(ss[0], coeffs[0]); const __m128i res_45 = _mm_maddubs_epi16(ss[1], coeffs[1]); return _mm_add_epi16(res_23, res_45); } static INLINE __m128i convolve_6tap_ssse3(const __m128i ss[3], const __m128i coeffs[3]) { const __m128i res_12 = _mm_maddubs_epi16(ss[0], coeffs[0]); const __m128i res_34 = _mm_maddubs_epi16(ss[1], coeffs[1]); const __m128i res_56 = _mm_maddubs_epi16(ss[2], coeffs[2]); const __m128i res_1256 = _mm_add_epi16(res_12, res_56); return _mm_add_epi16(res_1256, res_34); } static INLINE __m128i convolve_8tap_ssse3(const __m128i ss[4], const __m128i coeffs[4]) { const __m128i res_01 = _mm_maddubs_epi16(ss[0], coeffs[0]); const __m128i res_23 = _mm_maddubs_epi16(ss[1], coeffs[1]); const __m128i res_45 = _mm_maddubs_epi16(ss[2], coeffs[2]); const __m128i res_67 = _mm_maddubs_epi16(ss[3], coeffs[3]); const __m128i res_0145 = _mm_add_epi16(res_01, res_45); const __m128i res_2367 = _mm_add_epi16(res_23, res_67); return _mm_add_epi16(res_0145, res_2367); } static INLINE __m256i convolve_2tap_avx2(const __m256i ss[1], const __m256i coeffs[1]) { return _mm256_maddubs_epi16(ss[0], coeffs[0]); } static INLINE __m256i convolve_4tap_avx2(const __m256i ss[2], const __m256i coeffs[2]) { const __m256i res_23 = _mm256_maddubs_epi16(ss[0], coeffs[0]); const __m256i res_45 = _mm256_maddubs_epi16(ss[1], coeffs[1]); return _mm256_add_epi16(res_23, res_45); } static INLINE __m256i convolve_6tap_avx2(const __m256i ss[3], const __m256i coeffs[3]) { const __m256i res_01 = _mm256_maddubs_epi16(ss[0], coeffs[0]); const __m256i res_23 = _mm256_maddubs_epi16(ss[1], coeffs[1]); const __m256i res_45 = _mm256_maddubs_epi16(ss[2], coeffs[2]); const __m256i res_0145 = _mm256_add_epi16(res_01, res_45); return _mm256_add_epi16(res_0145, res_23); } static INLINE __m256i convolve_8tap_avx2(const __m256i ss[4], const __m256i coeffs[4]) { const __m256i res_01 = _mm256_maddubs_epi16(ss[0], coeffs[0]); const __m256i res_23 = _mm256_maddubs_epi16(ss[1], coeffs[1]); const __m256i res_45 = _mm256_maddubs_epi16(ss[2], coeffs[2]); const __m256i res_67 = _mm256_maddubs_epi16(ss[3], coeffs[3]); const __m256i res_0145 = _mm256_add_epi16(res_01, res_45); const __m256i res_2367 = _mm256_add_epi16(res_23, res_67); return _mm256_add_epi16(res_0145, res_2367); } static INLINE __m128i convolve16_2tap_sse2(const __m128i ss[1], const __m128i coeffs[1]) { return _mm_madd_epi16(ss[0], coeffs[0]); } static INLINE __m128i convolve16_4tap_sse2(const __m128i ss[2], const __m128i coeffs[2]) { const __m128i res_01 = _mm_madd_epi16(ss[0], coeffs[0]); const __m128i res_23 = _mm_madd_epi16(ss[1], coeffs[1]); return _mm_add_epi32(res_01, res_23); } static INLINE __m128i convolve16_6tap_sse2(const __m128i ss[3], const __m128i coeffs[3]) { const __m128i res_01 = _mm_madd_epi16(ss[0], coeffs[0]); const __m128i res_23 = _mm_madd_epi16(ss[1], coeffs[1]); const __m128i res_45 = _mm_madd_epi16(ss[2], coeffs[2]); const __m128i res_0123 = _mm_add_epi32(res_01, res_23); return _mm_add_epi32(res_0123, res_45); } static INLINE __m128i convolve16_8tap_sse2(const __m128i ss[4], const __m128i coeffs[4]) { const __m128i res_01 = _mm_madd_epi16(ss[0], coeffs[0]); const __m128i res_23 = _mm_madd_epi16(ss[1], coeffs[1]); const __m128i res_45 = _mm_madd_epi16(ss[2], coeffs[2]); const __m128i res_67 = _mm_madd_epi16(ss[3], coeffs[3]); const __m128i res_0123 = _mm_add_epi32(res_01, res_23); const __m128i res_4567 = _mm_add_epi32(res_45, res_67); return _mm_add_epi32(res_0123, res_4567); } static INLINE __m256i convolve16_2tap_avx2(const __m256i ss[1], const __m256i coeffs[1]) { return _mm256_madd_epi16(ss[0], coeffs[0]); } static INLINE __m256i convolve16_4tap_avx2(const __m256i ss[2], const __m256i coeffs[2]) { const __m256i res_1 = _mm256_madd_epi16(ss[0], coeffs[0]); const __m256i res_2 = _mm256_madd_epi16(ss[1], coeffs[1]); return _mm256_add_epi32(res_1, res_2); } static INLINE __m256i convolve16_6tap_avx2(const __m256i ss[3], const __m256i coeffs[3]) { const __m256i res_01 = _mm256_madd_epi16(ss[0], coeffs[0]); const __m256i res_23 = _mm256_madd_epi16(ss[1], coeffs[1]); const __m256i res_45 = _mm256_madd_epi16(ss[2], coeffs[2]); const __m256i res_0123 = _mm256_add_epi32(res_01, res_23); return _mm256_add_epi32(res_0123, res_45); } static INLINE __m256i convolve16_8tap_avx2(const __m256i ss[4], const __m256i coeffs[4]) { const __m256i res_01 = _mm256_madd_epi16(ss[0], coeffs[0]); const __m256i res_23 = _mm256_madd_epi16(ss[1], coeffs[1]); const __m256i res_45 = _mm256_madd_epi16(ss[2], coeffs[2]); const __m256i res_67 = _mm256_madd_epi16(ss[3], coeffs[3]); const __m256i res_0123 = _mm256_add_epi32(res_01, res_23); const __m256i res_4567 = _mm256_add_epi32(res_45, res_67); return _mm256_add_epi32(res_0123, res_4567); } static INLINE __m256i x_convolve_4tap_avx2(const __m256i data, const __m256i coeffs[2], const __m256i filt[2]) { __m256i ss[2]; ss[0] = _mm256_shuffle_epi8(data, filt[0]); ss[1] = _mm256_shuffle_epi8(data, filt[1]); return convolve_4tap_avx2(ss, coeffs); } static INLINE __m256i x_convolve_6tap_avx2(const __m256i data, const __m256i coeffs[3], const __m256i filt[3]) { __m256i ss[3]; ss[0] = _mm256_shuffle_epi8(data, filt[0]); ss[1] = _mm256_shuffle_epi8(data, filt[1]); ss[2] = _mm256_shuffle_epi8(data, filt[2]); return convolve_6tap_avx2(ss, coeffs); } static INLINE __m256i x_convolve_8tap_avx2(const __m256i data, const __m256i coeffs[4], const __m256i filt[4]) { __m256i ss[4]; ss[0] = _mm256_shuffle_epi8(data, filt[0]); ss[1] = _mm256_shuffle_epi8(data, filt[1]); ss[2] = _mm256_shuffle_epi8(data, filt[2]); ss[3] = _mm256_shuffle_epi8(data, filt[3]); return convolve_8tap_avx2(ss, coeffs); } static INLINE __m256i sr_y_round_avx2(const __m256i src) { const __m256i round = _mm256_set1_epi16(32); const __m256i dst = _mm256_add_epi16(src, round); return _mm256_srai_epi16(dst, FILTER_BITS - 1); } static INLINE __m128i xy_x_round_sse2(const __m128i src) { const __m128i round = _mm_set1_epi16(2); const __m128i dst = _mm_add_epi16(src, round); return _mm_srai_epi16(dst, 2); } static INLINE __m256i xy_x_round_avx2(const __m256i src) { const __m256i round = _mm256_set1_epi16(2); const __m256i dst = _mm256_add_epi16(src, round); return _mm256_srai_epi16(dst, 2); } static INLINE void xy_x_round_store_2x2_sse2(const __m128i res, int16_t *const dst) { const __m128i d = xy_x_round_sse2(res); _mm_storel_epi64((__m128i *)dst, d); } static INLINE void xy_x_round_store_4x2_sse2(const __m128i res, int16_t *const dst) { const __m128i d = xy_x_round_sse2(res); _mm_storeu_si128((__m128i *)dst, d); } static INLINE void xy_x_round_store_8x2_sse2(const __m128i res[2], int16_t *const dst) { __m128i r[2]; r[0] = xy_x_round_sse2(res[0]); r[1] = xy_x_round_sse2(res[1]); _mm_storeu_si128((__m128i *)dst, r[0]); _mm_storeu_si128((__m128i *)(dst + 8), r[1]); } static INLINE void xy_x_round_store_8x2_avx2(const __m256i res, int16_t *const dst) { const __m256i d = xy_x_round_avx2(res); _mm256_storeu_si256((__m256i *)dst, d); } static INLINE void xy_x_round_store_32_avx2(const __m256i res[2], int16_t *const dst) { __m256i r[2]; r[0] = xy_x_round_avx2(res[0]); r[1] = xy_x_round_avx2(res[1]); const __m256i d0 = _mm256_inserti128_si256(r[0], _mm256_castsi256_si128(r[1]), 1); const __m256i d1 = _mm256_inserti128_si256(r[1], _mm256_extracti128_si256(r[0], 1), 0); _mm256_storeu_si256((__m256i *)dst, d0); _mm256_storeu_si256((__m256i *)(dst + 16), d1); } static INLINE __m128i xy_y_round_sse2(const __m128i src) { const __m128i round = _mm_set1_epi32(1024); const __m128i dst = _mm_add_epi32(src, round); return _mm_srai_epi32(dst, 11); } static INLINE __m128i xy_y_round_half_pel_sse2(const __m128i src) { const __m128i round = _mm_set1_epi16(16); const __m128i dst = _mm_add_epi16(src, round); return _mm_srai_epi16(dst, 5); } static INLINE __m256i xy_y_round_avx2(const __m256i src) { const __m256i round = _mm256_set1_epi32(1024); const __m256i dst = _mm256_add_epi32(src, round); return _mm256_srai_epi32(dst, 11); } static INLINE __m256i xy_y_round_16_avx2(const __m256i r[2]) { const __m256i r0 = xy_y_round_avx2(r[0]); const __m256i r1 = xy_y_round_avx2(r[1]); return _mm256_packs_epi32(r0, r1); } static INLINE __m256i xy_y_round_half_pel_avx2(const __m256i src) { const __m256i round = _mm256_set1_epi16(16); const __m256i dst = _mm256_add_epi16(src, round); return _mm256_srai_epi16(dst, 5); } static INLINE void pack_store_2x2_sse2(const __m128i res, uint8_t *const dst, const ptrdiff_t stride) { const __m128i d = _mm_packus_epi16(res, res); *(int16_t *)dst = (int16_t)_mm_cvtsi128_si32(d); *(int16_t *)(dst + stride) = (int16_t)_mm_extract_epi16(d, 1); } static INLINE void pack_store_4x2_sse2(const __m128i res, uint8_t *const dst, const ptrdiff_t stride) { const __m128i d = _mm_packus_epi16(res, res); store_u8_4x2_sse2(d, dst, stride); } static INLINE void pack_store_4x2_avx2(const __m256i res, uint8_t *const dst, const ptrdiff_t stride) { const __m256i d = _mm256_packus_epi16(res, res); const __m128i d0 = _mm256_castsi256_si128(d); const __m128i d1 = _mm256_extracti128_si256(d, 1); xx_storel_32(dst, d0); xx_storel_32(dst + stride, d1); } static INLINE void pack_store_8x2_avx2(const __m256i res, uint8_t *const dst, const ptrdiff_t stride) { const __m256i d = _mm256_packus_epi16(res, res); const __m128i d0 = _mm256_castsi256_si128(d); const __m128i d1 = _mm256_extracti128_si256(d, 1); _mm_storel_epi64((__m128i *)dst, d0); _mm_storel_epi64((__m128i *)(dst + stride), d1); } static INLINE void pack_store_16x2_avx2(const __m256i res0, const __m256i res1, uint8_t *const dst, const ptrdiff_t stride) { const __m256i d = _mm256_packus_epi16(res0, res1); storeu_u8_16x2_avx2(d, dst, stride); } static INLINE void xy_y_pack_store_16x2_avx2(const __m256i res0, const __m256i res1, uint8_t *const dst, const ptrdiff_t stride) { const __m256i t = _mm256_packus_epi16(res0, res1); const __m256i d = _mm256_permute4x64_epi64(t, 0xD8); storeu_u8_16x2_avx2(d, dst, stride); } static INLINE void pack_store_32_avx2(const __m256i res0, const __m256i res1, uint8_t *const dst) { const __m256i t = _mm256_packus_epi16(res0, res1); const __m256i d = _mm256_permute4x64_epi64(t, 0xD8); _mm256_storeu_si256((__m256i *)dst, d); } static INLINE void xy_y_round_store_2x2_sse2(const __m128i res, uint8_t *const dst, const ptrdiff_t stride) { const __m128i r = xy_y_round_sse2(res); const __m128i rr = _mm_packs_epi32(r, r); pack_store_2x2_sse2(rr, dst, stride); } static INLINE void xy_y_round_store_4x2_avx2(const __m256i res, uint8_t *const dst, const ptrdiff_t stride) { const __m256i r = xy_y_round_avx2(res); const __m256i rr = _mm256_packs_epi32(r, r); pack_store_4x2_avx2(rr, dst, stride); } static INLINE void xy_y_pack_store_32_avx2(const __m256i res0, const __m256i res1, uint8_t *const dst) { const __m256i d = _mm256_packus_epi16(res0, res1); // d = _mm256_permute4x64_epi64(d, 0xD8); _mm256_storeu_si256((__m256i *)dst, d); } static INLINE void xy_y_round_store_32_avx2(const __m256i r0[2], const __m256i r1[2], uint8_t *const dst) { const __m256i ra = xy_y_round_16_avx2(r0); const __m256i rb = xy_y_round_16_avx2(r1); xy_y_pack_store_32_avx2(ra, rb, dst); } static INLINE void convolve_store_32_avx2(const __m256i res0, const __m256i res1, uint8_t *const dst) { const __m256i d = _mm256_packus_epi16(res0, res1); _mm256_storeu_si256((__m256i *)dst, d); } static INLINE __m128i sr_x_round_sse2(const __m128i src) { const __m128i round = _mm_set1_epi16(34); const __m128i dst = _mm_add_epi16(src, round); return _mm_srai_epi16(dst, 6); } static INLINE __m256i sr_x_round_avx2(const __m256i src) { const __m256i round = _mm256_set1_epi16(34); const __m256i dst = _mm256_add_epi16(src, round); return _mm256_srai_epi16(dst, 6); } static INLINE __m128i sr_y_round_sse2(const __m128i src) { const __m128i round = _mm_set1_epi16(32); const __m128i dst = _mm_add_epi16(src, round); return _mm_srai_epi16(dst, FILTER_BITS - 1); } static INLINE void sr_x_round_store_8x2_avx2(const __m256i res, uint8_t *const dst, const ptrdiff_t dst_stride) { const __m256i r = sr_x_round_avx2(res); pack_store_8x2_avx2(r, dst, dst_stride); } static INLINE void sr_x_round_store_16x2_avx2(const __m256i res[2], uint8_t *const dst, const ptrdiff_t dst_stride) { __m256i r[2]; r[0] = sr_x_round_avx2(res[0]); r[1] = sr_x_round_avx2(res[1]); pack_store_16x2_avx2(r[0], r[1], dst, dst_stride); } static INLINE void sr_x_round_store_32_avx2(const __m256i res[2], uint8_t *const dst) { __m256i r[2]; r[0] = sr_x_round_avx2(res[0]); r[1] = sr_x_round_avx2(res[1]); convolve_store_32_avx2(r[0], r[1], dst); } static INLINE void sr_y_round_store_8x2_avx2(const __m256i res, uint8_t *const dst, const ptrdiff_t dst_stride) { const __m256i r = sr_y_round_avx2(res); pack_store_8x2_avx2(r, dst, dst_stride); } static INLINE void sr_y_round_store_16x2_avx2(const __m256i res[2], uint8_t *const dst, const ptrdiff_t dst_stride) { __m256i r[2]; r[0] = sr_y_round_avx2(res[0]); r[1] = sr_y_round_avx2(res[1]); pack_store_16x2_avx2(r[0], r[1], dst, dst_stride); } static INLINE void sr_y_2tap_32_avg_avx2(const uint8_t *const src, const __m256i s0, __m256i *const s1, uint8_t *const dst) { *s1 = _mm256_loadu_si256((__m256i *)src); const __m256i d = _mm256_avg_epu8(s0, *s1); _mm256_storeu_si256((__m256i *)dst, d); } static INLINE void sr_x_2tap_32_avg_avx2(const uint8_t *const src, uint8_t *const dst) { const __m256i s0 = _mm256_loadu_si256((__m256i *)src); const __m256i s1 = _mm256_loadu_si256((__m256i *)(src + 1)); const __m256i d = _mm256_avg_epu8(s0, s1); _mm256_storeu_si256((__m256i *)dst, d); } static INLINE __m128i x_convolve_2tap_2x2_sse4_1(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[1]) { const __m128i sfl = _mm_setr_epi8(0, 1, 1, 2, 4, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i s_128 = load_u8_4x2_sse4_1(src, stride); const __m128i ss = _mm_shuffle_epi8(s_128, sfl); return convolve_2tap_ssse3(&ss, coeffs); } static INLINE __m128i x_convolve_2tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[1]) { const __m128i sfl = _mm_setr_epi8(0, 1, 1, 2, 2, 3, 3, 4, 8, 9, 9, 10, 10, 11, 11, 12); const __m128i s_128 = load_u8_8x2_sse2(src, stride); const __m128i ss = _mm_shuffle_epi8(s_128, sfl); return convolve_2tap_ssse3(&ss, coeffs); } static INLINE void x_convolve_2tap_8x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[1], __m128i r[2]) { __m128i ss[2]; const __m128i s00 = _mm_loadu_si128((__m128i *)src); const __m128i s10 = _mm_loadu_si128((__m128i *)(src + stride)); const __m128i s01 = _mm_srli_si128(s00, 1); const __m128i s11 = _mm_srli_si128(s10, 1); ss[0] = _mm_unpacklo_epi8(s00, s01); ss[1] = _mm_unpacklo_epi8(s10, s11); r[0] = convolve_2tap_ssse3(&ss[0], coeffs); r[1] = convolve_2tap_ssse3(&ss[1], coeffs); } static INLINE __m256i x_convolve_2tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[1]) { __m128i s_128[2][2]; __m256i s_256[2]; s_128[0][0] = _mm_loadu_si128((__m128i *)src); s_128[1][0] = _mm_loadu_si128((__m128i *)(src + stride)); s_128[0][1] = _mm_srli_si128(s_128[0][0], 1); s_128[1][1] = _mm_srli_si128(s_128[1][0], 1); s_256[0] = _mm256_setr_m128i(s_128[0][0], s_128[1][0]); s_256[1] = _mm256_setr_m128i(s_128[0][1], s_128[1][1]); const __m256i ss = _mm256_unpacklo_epi8(s_256[0], s_256[1]); return convolve_2tap_avx2(&ss, coeffs); } static INLINE void x_convolve_2tap_16x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[1], __m256i r[2]) { const __m256i s0_256 = loadu_8bit_16x2_avx2(src, stride); const __m256i s1_256 = loadu_8bit_16x2_avx2(src + 1, stride); const __m256i s0 = _mm256_unpacklo_epi8(s0_256, s1_256); const __m256i s1 = _mm256_unpackhi_epi8(s0_256, s1_256); r[0] = convolve_2tap_avx2(&s0, coeffs); r[1] = convolve_2tap_avx2(&s1, coeffs); } static INLINE void x_convolve_2tap_32_avx2(const uint8_t *const src, const __m256i coeffs[1], __m256i r[2]) { const __m256i s0 = _mm256_loadu_si256((__m256i *)src); const __m256i s1 = _mm256_loadu_si256((__m256i *)(src + 1)); const __m256i ss0 = _mm256_unpacklo_epi8(s0, s1); const __m256i ss1 = _mm256_unpackhi_epi8(s0, s1); r[0] = convolve_2tap_avx2(&ss0, coeffs); r[1] = convolve_2tap_avx2(&ss1, coeffs); } static INLINE __m128i x_convolve_4tap_2x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[2]) { const __m128i sfl0 = _mm_setr_epi8(0, 1, 1, 2, 8, 9, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i sfl1 = _mm_setr_epi8(2, 3, 3, 4, 10, 11, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i s = load_u8_8x2_sse2(src, stride); __m128i ss[2]; ss[0] = _mm_shuffle_epi8(s, sfl0); ss[1] = _mm_shuffle_epi8(s, sfl1); return convolve_4tap_ssse3(ss, coeffs); } static INLINE __m128i x_convolve_4tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[2]) { const __m128i s = load_u8_8x2_sse2(src, stride); const __m128i sfl0 = _mm_setr_epi8(0, 1, 1, 2, 2, 3, 3, 4, 8, 9, 9, 10, 10, 11, 11, 12); const __m128i sfl1 = _mm_setr_epi8(2, 3, 3, 4, 4, 5, 5, 6, 10, 11, 11, 12, 12, 13, 13, 14); __m128i ss[2]; ss[0] = _mm_shuffle_epi8(s, sfl0); ss[1] = _mm_shuffle_epi8(s, sfl1); return convolve_4tap_ssse3(ss, coeffs); } static INLINE __m256i x_convolve_4tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[2], const __m256i filt[2]) { const __m256i s_256 = loadu_8bit_16x2_avx2(src, stride); return x_convolve_4tap_avx2(s_256, coeffs, filt); } static INLINE void x_convolve_4tap_16x2_avx2(const uint8_t *const src, const int32_t src_stride, const __m256i coeffs[2], const __m256i filt[2], __m256i r[2]) { r[0] = x_convolve_4tap_8x2_avx2(src + 0, src_stride, coeffs, filt); r[1] = x_convolve_4tap_8x2_avx2(src + 8, src_stride, coeffs, filt); } static INLINE void x_convolve_4tap_32_avx2(const uint8_t *const src, const __m256i coeffs[2], const __m256i filt[2], __m256i r[2]) { const __m256i s0_256 = _mm256_loadu_si256((__m256i *)src); const __m256i s1_256 = _mm256_loadu_si256((__m256i *)(src + 8)); r[0] = x_convolve_4tap_avx2(s0_256, coeffs, filt); r[1] = x_convolve_4tap_avx2(s1_256, coeffs, filt); } static INLINE __m128i x_convolve_6tap_2x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[3]) { const __m128i sfl0 = _mm_setr_epi8(0, 1, 1, 2, 8, 9, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i sfl1 = _mm_setr_epi8(2, 3, 3, 4, 10, 11, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i sfl2 = _mm_setr_epi8(4, 5, 5, 6, 12, 13, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i s = load_u8_8x2_sse2(src, stride); __m128i ss[3]; ss[0] = _mm_shuffle_epi8(s, sfl0); ss[1] = _mm_shuffle_epi8(s, sfl1); ss[2] = _mm_shuffle_epi8(s, sfl2); return convolve_6tap_ssse3(ss, coeffs); } static INLINE __m128i x_convolve_6tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[3]) { const __m128i s = load_u8_8x2_sse2(src, stride); const __m128i sfl0 = _mm_setr_epi8(0, 1, 1, 2, 8, 9, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i sfl1 = _mm_setr_epi8(2, 3, 3, 4, 10, 11, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0); const __m128i sfl2 = _mm_setr_epi8(4, 5, 5, 6, 12, 13, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0); __m128i ss[3]; ss[0] = _mm_shuffle_epi8(s, sfl0); ss[1] = _mm_shuffle_epi8(s, sfl1); ss[2] = _mm_shuffle_epi8(s, sfl2); return convolve_6tap_ssse3(ss, coeffs); } static INLINE __m256i x_convolve_6tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[3], const __m256i filt[3]) { const __m256i s_256 = loadu_8bit_16x2_avx2(src, stride); return x_convolve_6tap_avx2(s_256, coeffs, filt); } static INLINE void x_convolve_6tap_16x2_avx2(const uint8_t *const src, const int32_t src_stride, const __m256i coeffs[3], const __m256i filt[3], __m256i r[2]) { r[0] = x_convolve_6tap_8x2_avx2(src + 0, src_stride, coeffs, filt); r[1] = x_convolve_6tap_8x2_avx2(src + 8, src_stride, coeffs, filt); } static INLINE void x_convolve_6tap_32_avx2(const uint8_t *const src, const __m256i coeffs[3], const __m256i filt[3], __m256i r[2]) { const __m256i s0_256 = _mm256_loadu_si256((__m256i *)src); const __m256i s1_256 = _mm256_loadu_si256((__m256i *)(src + 8)); r[0] = x_convolve_6tap_avx2(s0_256, coeffs, filt); r[1] = x_convolve_6tap_avx2(s1_256, coeffs, filt); } static INLINE __m256i x_convolve_8tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[4], const __m256i filt[4]) { const __m256i s_256 = loadu_8bit_16x2_avx2(src, stride); return x_convolve_8tap_avx2(s_256, coeffs, filt); } static AOM_FORCE_INLINE void x_convolve_8tap_16x2_avx2(const uint8_t *const src, const int32_t src_stride, const __m256i coeffs[4], const __m256i filt[4], __m256i r[2]) { r[0] = x_convolve_8tap_8x2_avx2(src + 0, src_stride, coeffs, filt); r[1] = x_convolve_8tap_8x2_avx2(src + 8, src_stride, coeffs, filt); } static AOM_FORCE_INLINE void x_convolve_8tap_32_avx2(const uint8_t *const src, const __m256i coeffs[4], const __m256i filt[4], __m256i r[2]) { const __m256i s0_256 = _mm256_loadu_si256((__m256i *)src); const __m256i s1_256 = _mm256_loadu_si256((__m256i *)(src + 8)); r[0] = x_convolve_8tap_avx2(s0_256, coeffs, filt); r[1] = x_convolve_8tap_avx2(s1_256, coeffs, filt); } static INLINE __m128i y_convolve_2tap_2x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[1], __m128i s_16[2]) { __m128i s_128[2]; s_16[1] = _mm_cvtsi32_si128(*(int16_t *)(src + stride)); s_128[0] = _mm_unpacklo_epi16(s_16[0], s_16[1]); s_16[0] = _mm_cvtsi32_si128(*(int16_t *)(src + 2 * stride)); s_128[1] = _mm_unpacklo_epi16(s_16[1], s_16[0]); const __m128i ss = _mm_unpacklo_epi8(s_128[0], s_128[1]); return convolve_2tap_ssse3(&ss, coeffs); } static INLINE __m128i y_convolve_2tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[1], __m128i s_32[2]) { __m128i s_128[2]; s_32[1] = _mm_cvtsi32_si128(*(int32_t *)(src + stride)); s_128[0] = _mm_unpacklo_epi32(s_32[0], s_32[1]); s_32[0] = _mm_cvtsi32_si128(*(int32_t *)(src + 2 * stride)); s_128[1] = _mm_unpacklo_epi32(s_32[1], s_32[0]); const __m128i ss = _mm_unpacklo_epi8(s_128[0], s_128[1]); return convolve_2tap_ssse3(&ss, coeffs); } static INLINE __m256i y_convolve_2tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[1], __m128i s_64[2]) { __m256i s_256[2]; s_64[1] = _mm_loadl_epi64((__m128i *)(src + stride)); s_256[0] = _mm256_setr_m128i(s_64[0], s_64[1]); s_64[0] = _mm_loadl_epi64((__m128i *)(src + 2 * stride)); s_256[1] = _mm256_setr_m128i(s_64[1], s_64[0]); const __m256i ss = _mm256_unpacklo_epi8(s_256[0], s_256[1]); return convolve_2tap_avx2(&ss, coeffs); } static INLINE void y_convolve_2tap_16x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[1], __m128i s_128[2], __m256i r[2]) { __m256i s_256[2]; s_128[1] = _mm_loadu_si128((__m128i *)(src + stride)); s_256[0] = _mm256_setr_m128i(s_128[0], s_128[1]); s_128[0] = _mm_loadu_si128((__m128i *)(src + 2 * stride)); s_256[1] = _mm256_setr_m128i(s_128[1], s_128[0]); const __m256i ss0 = _mm256_unpacklo_epi8(s_256[0], s_256[1]); const __m256i ss1 = _mm256_unpackhi_epi8(s_256[0], s_256[1]); r[0] = convolve_2tap_avx2(&ss0, coeffs); r[1] = convolve_2tap_avx2(&ss1, coeffs); } static INLINE void y_convolve_2tap_32_avx2(const uint8_t *const src, const __m256i coeffs[1], const __m256i s0, __m256i *const s1, __m256i r[2]) { *s1 = _mm256_loadu_si256((__m256i *)src); const __m256i ss0 = _mm256_unpacklo_epi8(s0, *s1); const __m256i ss1 = _mm256_unpackhi_epi8(s0, *s1); r[0] = convolve_2tap_avx2(&ss0, coeffs); r[1] = convolve_2tap_avx2(&ss1, coeffs); } static INLINE __m128i y_convolve_4tap_2x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[2], __m128i s_16[4], __m128i ss_128[2]) { s_16[3] = _mm_cvtsi32_si128(loadu_int16(src + stride)); const __m128i src23 = _mm_unpacklo_epi16(s_16[2], s_16[3]); s_16[2] = _mm_cvtsi32_si128(loadu_int16(src + 2 * stride)); const __m128i src34 = _mm_unpacklo_epi16(s_16[3], s_16[2]); ss_128[1] = _mm_unpacklo_epi8(src23, src34); return convolve_4tap_ssse3(ss_128, coeffs); } static INLINE __m128i y_convolve_4tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[2], __m128i s_32[4], __m128i ss_128[2]) { s_32[3] = _mm_cvtsi32_si128(loadu_int32(src + stride)); const __m128i src23 = _mm_unpacklo_epi32(s_32[2], s_32[3]); s_32[2] = _mm_cvtsi32_si128(loadu_int32(src + 2 * stride)); const __m128i src34 = _mm_unpacklo_epi32(s_32[3], s_32[2]); ss_128[1] = _mm_unpacklo_epi8(src23, src34); return convolve_4tap_ssse3(ss_128, coeffs); } static INLINE __m256i y_convolve_4tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[2], __m128i s_64[4], __m256i ss_256[2]) { s_64[3] = _mm_loadl_epi64((__m128i *)(src + stride)); const __m256i src23 = _mm256_setr_m128i(s_64[2], s_64[3]); s_64[2] = _mm_loadl_epi64((__m128i *)(src + 2 * stride)); const __m256i src34 = _mm256_setr_m128i(s_64[3], s_64[2]); ss_256[1] = _mm256_unpacklo_epi8(src23, src34); return convolve_4tap_avx2(ss_256, coeffs); } static INLINE void y_convolve_4tap_16x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[2], __m128i s_128[4], __m256i ss_256[4], __m256i r[2]) { s_128[3] = _mm_loadu_si128((__m128i *)(src + stride)); const __m256i src23 = _mm256_setr_m128i(s_128[2], s_128[3]); s_128[2] = _mm_loadu_si128((__m128i *)(src + 2 * stride)); const __m256i src34 = _mm256_setr_m128i(s_128[3], s_128[2]); ss_256[1] = _mm256_unpacklo_epi8(src23, src34); ss_256[3] = _mm256_unpackhi_epi8(src23, src34); r[0] = convolve_4tap_avx2(ss_256, coeffs); r[1] = convolve_4tap_avx2(ss_256 + 2, coeffs); } static INLINE __m128i y_convolve_6tap_2x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[3], __m128i s_16[6], __m128i ss_128[3]) { s_16[5] = _mm_cvtsi32_si128(loadu_int16(src + 3 * stride)); const __m128i src45 = _mm_unpacklo_epi16(s_16[4], s_16[5]); s_16[4] = _mm_cvtsi32_si128(loadu_int16(src + 4 * stride)); const __m128i src56 = _mm_unpacklo_epi16(s_16[5], s_16[4]); ss_128[2] = _mm_unpacklo_epi8(src45, src56); return convolve_6tap_ssse3(ss_128, coeffs); } static INLINE void y_convolve_4tap_32x2_avx2( const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[2], __m256i s_256[4], __m256i ss_256[4], __m256i tt_256[4], __m256i r[4]) { s_256[3] = _mm256_loadu_si256((__m256i *)(src + 1 * stride)); ss_256[1] = _mm256_unpacklo_epi8(s_256[2], s_256[3]); ss_256[3] = _mm256_unpackhi_epi8(s_256[2], s_256[3]); s_256[2] = _mm256_loadu_si256((__m256i *)(src + 2 * stride)); tt_256[1] = _mm256_unpacklo_epi8(s_256[3], s_256[2]); tt_256[3] = _mm256_unpackhi_epi8(s_256[3], s_256[2]); r[0] = convolve_4tap_avx2(ss_256 + 0, coeffs); r[1] = convolve_4tap_avx2(ss_256 + 2, coeffs); r[2] = convolve_4tap_avx2(tt_256 + 0, coeffs); r[3] = convolve_4tap_avx2(tt_256 + 2, coeffs); } static INLINE __m128i y_convolve_6tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[3], __m128i s_32[6], __m128i ss_128[3]) { s_32[5] = _mm_cvtsi32_si128(loadu_int32(src + 3 * stride)); const __m128i src45 = _mm_unpacklo_epi32(s_32[4], s_32[5]); s_32[4] = _mm_cvtsi32_si128(loadu_int32(src + 4 * stride)); const __m128i src56 = _mm_unpacklo_epi32(s_32[5], s_32[4]); ss_128[2] = _mm_unpacklo_epi8(src45, src56); return convolve_6tap_ssse3(ss_128, coeffs); } static INLINE __m256i y_convolve_6tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[3], __m128i s_64[6], __m256i ss_256[3]) { s_64[5] = _mm_loadl_epi64((__m128i *)(src + 3 * stride)); const __m256i src45 = _mm256_setr_m128i(s_64[4], s_64[5]); s_64[4] = _mm_loadl_epi64((__m128i *)(src + 4 * stride)); const __m256i src56 = _mm256_setr_m128i(s_64[5], s_64[4]); ss_256[2] = _mm256_unpacklo_epi8(src45, src56); return convolve_6tap_avx2(ss_256, coeffs); } static INLINE void y_convolve_6tap_16x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[3], __m128i s_128[6], __m256i ss_256[6], __m256i r[2]) { s_128[5] = _mm_loadu_si128((__m128i *)(src + 3 * stride)); const __m256i src45 = _mm256_setr_m128i(s_128[4], s_128[5]); s_128[4] = _mm_loadu_si128((__m128i *)(src + 4 * stride)); const __m256i src56 = _mm256_setr_m128i(s_128[5], s_128[4]); ss_256[2] = _mm256_unpacklo_epi8(src45, src56); ss_256[5] = _mm256_unpackhi_epi8(src45, src56); r[0] = convolve_6tap_avx2(ss_256, coeffs); r[1] = convolve_6tap_avx2(ss_256 + 3, coeffs); } static INLINE void y_convolve_6tap_32x2_avx2( const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[3], __m256i s_256[6], __m256i ss_256[6], __m256i tt_256[6], __m256i r[4]) { s_256[5] = _mm256_loadu_si256((__m256i *)(src + 3 * stride)); ss_256[2] = _mm256_unpacklo_epi8(s_256[4], s_256[5]); ss_256[5] = _mm256_unpackhi_epi8(s_256[4], s_256[5]); s_256[4] = _mm256_loadu_si256((__m256i *)(src + 4 * stride)); tt_256[2] = _mm256_unpacklo_epi8(s_256[5], s_256[4]); tt_256[5] = _mm256_unpackhi_epi8(s_256[5], s_256[4]); r[0] = convolve_6tap_avx2(ss_256 + 0, coeffs); r[1] = convolve_6tap_avx2(ss_256 + 3, coeffs); r[2] = convolve_6tap_avx2(tt_256 + 0, coeffs); r[3] = convolve_6tap_avx2(tt_256 + 3, coeffs); } static INLINE __m128i y_convolve_8tap_2x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[4], __m128i s_16[8], __m128i ss_128[4]) { s_16[7] = _mm_cvtsi32_si128(loadu_int16(src + 7 * stride)); const __m128i src67 = _mm_unpacklo_epi16(s_16[6], s_16[7]); s_16[6] = _mm_cvtsi32_si128(loadu_int16(src + 8 * stride)); const __m128i src78 = _mm_unpacklo_epi16(s_16[7], s_16[6]); ss_128[3] = _mm_unpacklo_epi8(src67, src78); return convolve_8tap_ssse3(ss_128, coeffs); } static INLINE __m128i y_convolve_8tap_4x2_ssse3(const uint8_t *const src, const ptrdiff_t stride, const __m128i coeffs[4], __m128i s_32[8], __m128i ss_128[4]) { s_32[7] = _mm_cvtsi32_si128(loadu_int32(src + 7 * stride)); const __m128i src67 = _mm_unpacklo_epi32(s_32[6], s_32[7]); s_32[6] = _mm_cvtsi32_si128(loadu_int32(src + 8 * stride)); const __m128i src78 = _mm_unpacklo_epi32(s_32[7], s_32[6]); ss_128[3] = _mm_unpacklo_epi8(src67, src78); return convolve_8tap_ssse3(ss_128, coeffs); } static INLINE __m256i y_convolve_8tap_8x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[4], __m128i s_64[8], __m256i ss_256[4]) { s_64[7] = _mm_loadl_epi64((__m128i *)(src + 7 * stride)); const __m256i src67 = _mm256_setr_m128i(s_64[6], s_64[7]); s_64[6] = _mm_loadl_epi64((__m128i *)(src + 8 * stride)); const __m256i src78 = _mm256_setr_m128i(s_64[7], s_64[6]); ss_256[3] = _mm256_unpacklo_epi8(src67, src78); return convolve_8tap_avx2(ss_256, coeffs); } static INLINE void y_convolve_8tap_16x2_avx2(const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[4], __m128i s_128[8], __m256i ss_256[8], __m256i r[2]) { s_128[7] = _mm_loadu_si128((__m128i *)(src + 7 * stride)); const __m256i src67 = _mm256_setr_m128i(s_128[6], s_128[7]); s_128[6] = _mm_loadu_si128((__m128i *)(src + 8 * stride)); const __m256i src78 = _mm256_setr_m128i(s_128[7], s_128[6]); ss_256[3] = _mm256_unpacklo_epi8(src67, src78); ss_256[7] = _mm256_unpackhi_epi8(src67, src78); r[0] = convolve_8tap_avx2(ss_256, coeffs); r[1] = convolve_8tap_avx2(ss_256 + 4, coeffs); } static INLINE void y_convolve_8tap_32x2_avx2( const uint8_t *const src, const ptrdiff_t stride, const __m256i coeffs[4], __m256i s_256[8], __m256i ss_256[8], __m256i tt_256[8], __m256i r[4]) { s_256[7] = _mm256_loadu_si256((__m256i *)(src + 7 * stride)); ss_256[3] = _mm256_unpacklo_epi8(s_256[6], s_256[7]); ss_256[7] = _mm256_unpackhi_epi8(s_256[6], s_256[7]); s_256[6] = _mm256_loadu_si256((__m256i *)(src + 8 * stride)); tt_256[3] = _mm256_unpacklo_epi8(s_256[7], s_256[6]); tt_256[7] = _mm256_unpackhi_epi8(s_256[7], s_256[6]); r[0] = convolve_8tap_avx2(ss_256 + 0, coeffs); r[1] = convolve_8tap_avx2(ss_256 + 4, coeffs); r[2] = convolve_8tap_avx2(tt_256 + 0, coeffs); r[3] = convolve_8tap_avx2(tt_256 + 4, coeffs); } static INLINE void xy_x_convolve_2tap_32_avx2(const uint8_t *const src, const __m256i coeffs[1], __m256i r[2]) { const __m256i s0 = _mm256_loadu_si256((__m256i *)src); const __m256i s1 = _mm256_loadu_si256((__m256i *)(src + 1)); const __m256i ss0 = _mm256_unpacklo_epi8(s0, s1); const __m256i ss1 = _mm256_unpackhi_epi8(s0, s1); r[0] = convolve_2tap_avx2(&ss0, coeffs); r[1] = convolve_2tap_avx2(&ss1, coeffs); } static INLINE void xy_x_2tap_32_avx2(const uint8_t *const src, const __m256i coeffs[1], int16_t *const dst) { __m256i r[2]; xy_x_convolve_2tap_32_avx2(src, coeffs, r); const __m256i d0 = xy_x_round_avx2(r[0]); const __m256i d1 = xy_x_round_avx2(r[1]); _mm256_storeu_si256((__m256i *)dst, d0); _mm256_storeu_si256((__m256i *)(dst + 16), d1); } static INLINE void xy_x_4tap_32_avx2(const uint8_t *const src, const __m256i coeffs[2], const __m256i filt[2], int16_t *const dst) { __m256i r[2]; x_convolve_4tap_32_avx2(src, coeffs, filt, r); const __m256i d0 = xy_x_round_avx2(r[0]); const __m256i d1 = xy_x_round_avx2(r[1]); _mm256_storeu_si256((__m256i *)dst, d0); _mm256_storeu_si256((__m256i *)(dst + 16), d1); } static INLINE void xy_x_6tap_32_avx2(const uint8_t *const src, const __m256i coeffs[3], const __m256i filt[3], int16_t *const dst) { __m256i r[2]; x_convolve_6tap_32_avx2(src, coeffs, filt, r); const __m256i d0 = xy_x_round_avx2(r[0]); const __m256i d1 = xy_x_round_avx2(r[1]); _mm256_storeu_si256((__m256i *)dst, d0); _mm256_storeu_si256((__m256i *)(dst + 16), d1); } static INLINE void xy_x_8tap_32_avx2(const uint8_t *const src, const __m256i coeffs[4], const __m256i filt[4], int16_t *const dst) { __m256i r[2]; x_convolve_8tap_32_avx2(src, coeffs, filt, r); const __m256i d0 = xy_x_round_avx2(r[0]); const __m256i d1 = xy_x_round_avx2(r[1]); _mm256_storeu_si256((__m256i *)dst, d0); _mm256_storeu_si256((__m256i *)(dst + 16), d1); } static INLINE __m128i xy_y_convolve_2tap_2x2_sse2(const int16_t *const src, __m128i s_32[2], const __m128i coeffs[1]) { __m128i s_128[2]; s_32[1] = _mm_cvtsi32_si128(loadu_int32(src + 2)); s_128[0] = _mm_unpacklo_epi32(s_32[0], s_32[1]); s_32[0] = _mm_cvtsi32_si128(loadu_int32(src + 2 * 2)); s_128[1] = _mm_unpacklo_epi32(s_32[1], s_32[0]); const __m128i ss = _mm_unpacklo_epi16(s_128[0], s_128[1]); return convolve16_2tap_sse2(&ss, coeffs); } static INLINE __m128i xy_y_convolve_2tap_2x2_half_pel_sse2( const int16_t *const src, __m128i s_32[2]) { __m128i s_128[2]; s_32[1] = _mm_cvtsi32_si128(loadu_int32(src + 2)); s_128[0] = _mm_unpacklo_epi32(s_32[0], s_32[1]); s_32[0] = _mm_cvtsi32_si128(loadu_int32(src + 2 * 2)); s_128[1] = _mm_unpacklo_epi32(s_32[1], s_32[0]); return _mm_add_epi16(s_128[0], s_128[1]); } static INLINE void xy_y_convolve_2tap_4x2_sse2(const int16_t *const src, __m128i s_64[2], const __m128i coeffs[1], __m128i r[2]) { __m128i s_128[2]; s_64[1] = _mm_loadl_epi64((__m128i *)(src + 4)); s_128[0] = _mm_unpacklo_epi64(s_64[0], s_64[1]); s_64[0] = _mm_loadl_epi64((__m128i *)(src + 2 * 4)); s_128[1] = _mm_unpacklo_epi64(s_64[1], s_64[0]); const __m128i ss0 = _mm_unpacklo_epi16(s_128[0], s_128[1]); const __m128i ss1 = _mm_unpackhi_epi16(s_128[0], s_128[1]); r[0] = convolve16_2tap_sse2(&ss0, coeffs); r[1] = convolve16_2tap_sse2(&ss1, coeffs); } static INLINE __m128i xy_y_convolve_2tap_4x2_half_pel_sse2( const int16_t *const src, __m128i s_64[2]) { __m128i s_128[2]; s_64[1] = _mm_loadl_epi64((__m128i *)(src + 4)); s_128[0] = _mm_unpacklo_epi64(s_64[0], s_64[1]); s_64[0] = _mm_loadl_epi64((__m128i *)(src + 2 * 4)); s_128[1] = _mm_unpacklo_epi64(s_64[1], s_64[0]); return _mm_add_epi16(s_128[0], s_128[1]); } static INLINE void xy_y_convolve_2tap_16_avx2(const __m256i s0, const __m256i s1, const __m256i coeffs[1], __m256i r[2]) { const __m256i ss0 = _mm256_unpacklo_epi16(s0, s1); const __m256i ss1 = _mm256_unpackhi_epi16(s0, s1); r[0] = convolve16_2tap_avx2(&ss0, coeffs); r[1] = convolve16_2tap_avx2(&ss1, coeffs); } static INLINE void xy_y_convolve_2tap_8x2_avx2(const int16_t *const src, __m128i s_128[2], const __m256i coeffs[1], __m256i r[2]) { __m256i s_256[2]; s_128[1] = _mm_loadu_si128((__m128i *)(src + 8)); s_256[0] = _mm256_setr_m128i(s_128[0], s_128[1]); s_128[0] = _mm_loadu_si128((__m128i *)(src + 2 * 8)); s_256[1] = _mm256_setr_m128i(s_128[1], s_128[0]); xy_y_convolve_2tap_16_avx2(s_256[0], s_256[1], coeffs, r); } static INLINE __m256i xy_y_convolve_2tap_8x2_half_pel_avx2( const int16_t *const src, __m128i s_128[2]) { __m256i s_256[2]; s_128[1] = _mm_loadu_si128((__m128i *)(src + 8)); s_256[0] = _mm256_setr_m128i(s_128[0], s_128[1]); s_128[0] = _mm_loadu_si128((__m128i *)(src + 2 * 8)); s_256[1] = _mm256_setr_m128i(s_128[1], s_128[0]); return _mm256_add_epi16(s_256[0], s_256[1]); } static INLINE void xy_y_convolve_2tap_16x2_half_pel_avx2( const int16_t *const src, __m256i s_256[2], __m256i r[2]) { s_256[1] = _mm256_loadu_si256((__m256i *)(src + 16)); r[0] = _mm256_add_epi16(s_256[0], s_256[1]); s_256[0] = _mm256_loadu_si256((__m256i *)(src + 2 * 16)); r[1] = _mm256_add_epi16(s_256[1], s_256[0]); } static INLINE void xy_y_store_16x2_avx2(const __m256i r[2], uint8_t *const dst, const ptrdiff_t stride) { const __m256i t = _mm256_packus_epi16(r[0], r[1]); const __m256i d = _mm256_permute4x64_epi64(t, 0xD8); storeu_u8_16x2_avx2(d, dst, stride); } static INLINE void xy_y_convolve_2tap_16x2_avx2(const int16_t *const src, __m256i s[2], const __m256i coeffs[1], __m256i r[4]) { s[1] = _mm256_loadu_si256((__m256i *)(src + 16)); xy_y_convolve_2tap_16_avx2(s[0], s[1], coeffs, r + 0); s[0] = _mm256_loadu_si256((__m256i *)(src + 2 * 16)); xy_y_convolve_2tap_16_avx2(s[1], s[0], coeffs, r + 2); } static INLINE void xy_y_convolve_2tap_32_avx2(const int16_t *const src, const __m256i s0[2], __m256i s1[2], const __m256i coeffs[1], __m256i r[4]) { s1[0] = _mm256_loadu_si256((__m256i *)src); s1[1] = _mm256_loadu_si256((__m256i *)(src + 16)); xy_y_convolve_2tap_16_avx2(s0[0], s1[0], coeffs, r + 0); xy_y_convolve_2tap_16_avx2(s0[1], s1[1], coeffs, r + 2); } static INLINE void xy_y_convolve_2tap_32_all_avx2(const int16_t *const src, const __m256i s0[2], __m256i s1[2], const __m256i coeffs[1], uint8_t *const dst) { __m256i r[4]; xy_y_convolve_2tap_32_avx2(src, s0, s1, coeffs, r); xy_y_round_store_32_avx2(r + 0, r + 2, dst); } static INLINE void xy_y_convolve_2tap_half_pel_32_avx2(const int16_t *const src, const __m256i s0[2], __m256i s1[2], __m256i r[2]) { s1[0] = _mm256_loadu_si256((__m256i *)src); s1[1] = _mm256_loadu_si256((__m256i *)(src + 16)); r[0] = _mm256_add_epi16(s0[0], s1[0]); r[1] = _mm256_add_epi16(s0[1], s1[1]); } static INLINE void xy_y_convolve_2tap_half_pel_32_all_avx2( const int16_t *const src, const __m256i s0[2], __m256i s1[2], uint8_t *const dst) { __m256i r[2]; xy_y_convolve_2tap_half_pel_32_avx2(src, s0, s1, r); r[0] = xy_y_round_half_pel_avx2(r[0]); r[1] = xy_y_round_half_pel_avx2(r[1]); xy_y_pack_store_32_avx2(r[0], r[1], dst); } static INLINE __m128i xy_y_convolve_4tap_2x2_sse2(const int16_t *const src, __m128i s_32[4], __m128i ss_128[2], const __m128i coeffs[2]) { s_32[3] = _mm_cvtsi32_si128(*(int32_t *)(src + 3 * 2)); const __m128i src23 = _mm_unpacklo_epi32(s_32[2], s_32[3]); s_32[2] = _mm_cvtsi32_si128(*(int32_t *)(src + 4 * 2)); const __m128i src34 = _mm_unpacklo_epi32(s_32[3], s_32[2]); ss_128[1] = _mm_unpacklo_epi16(src23, src34); const __m128i r = convolve16_4tap_sse2(ss_128, coeffs); ss_128[0] = ss_128[1]; return r; } static INLINE __m256i xy_y_convolve_4tap_4x2_avx2(const int16_t *const src, __m128i s_64[4], __m256i ss_256[2], const __m256i coeffs[2]) { __m256i s_256[2]; s_64[3] = _mm_loadl_epi64((__m128i *)(src + 3 * 4)); s_256[0] = _mm256_setr_m128i(s_64[2], s_64[3]); s_64[2] = _mm_loadl_epi64((__m128i *)(src + 4 * 4)); s_256[1] = _mm256_setr_m128i(s_64[3], s_64[2]); ss_256[1] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); const __m256i r = convolve16_4tap_avx2(ss_256, coeffs); ss_256[0] = ss_256[1]; return r; } static INLINE void xy_y_convolve_4tap_16_avx2(const __m256i *const ss, const __m256i coeffs[2], __m256i r[2]) { r[0] = convolve16_4tap_avx2(ss, coeffs); r[1] = convolve16_4tap_avx2(ss + 2, coeffs); } static INLINE void xy_y_convolve_4tap_8x2_avx2(const int16_t *const src, __m256i ss_256[4], const __m256i coeffs[2], __m256i r[2]) { __m256i s_256[2]; s_256[0] = _mm256_loadu_si256((__m256i *)(src + 2 * 8)); s_256[1] = _mm256_loadu_si256((__m256i *)(src + 3 * 8)); ss_256[1] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); ss_256[3] = _mm256_unpackhi_epi16(s_256[0], s_256[1]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r); ss_256[0] = ss_256[1]; ss_256[2] = ss_256[3]; } static INLINE void xy_y_convolve_4tap_8x2_half_pel_avx2( const int16_t *const src, const __m256i coeffs[1], __m256i s_256[4], __m256i r[2]) { __m256i a_256[2]; s_256[2] = _mm256_loadu_si256((__m256i *)(src + 2 * 8)); s_256[3] = _mm256_loadu_si256((__m256i *)(src + 3 * 8)); a_256[0] = _mm256_add_epi16(s_256[0], s_256[3]); a_256[1] = _mm256_add_epi16(s_256[1], s_256[2]); xy_y_convolve_2tap_16_avx2(a_256[0], a_256[1], coeffs, r); s_256[0] = s_256[2]; s_256[1] = s_256[3]; } static INLINE void xy_y_convolve_4tap_16x2_avx2( const int16_t *const src, __m256i s_256[4], __m256i ss_256[4], __m256i tt_256[4], const __m256i coeffs[2], __m256i r[4]) { s_256[3] = _mm256_loadu_si256((__m256i *)(src + 3 * 16)); ss_256[1] = _mm256_unpacklo_epi16(s_256[2], s_256[3]); ss_256[3] = _mm256_unpackhi_epi16(s_256[2], s_256[3]); s_256[2] = _mm256_loadu_si256((__m256i *)(src + 4 * 16)); tt_256[1] = _mm256_unpacklo_epi16(s_256[3], s_256[2]); tt_256[3] = _mm256_unpackhi_epi16(s_256[3], s_256[2]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r + 0); xy_y_convolve_4tap_16_avx2(tt_256, coeffs, r + 2); ss_256[0] = ss_256[1]; ss_256[2] = ss_256[3]; tt_256[0] = tt_256[1]; tt_256[2] = tt_256[3]; } static INLINE void xy_y_convolve_4tap_32x2_avx2( const int16_t *const src, const ptrdiff_t stride, __m256i s_256[4], __m256i ss_256[4], __m256i tt_256[4], const __m256i coeffs[2], __m256i r[4]) { s_256[3] = _mm256_loadu_si256((__m256i *)(src + 3 * stride)); ss_256[1] = _mm256_unpacklo_epi16(s_256[2], s_256[3]); ss_256[3] = _mm256_unpackhi_epi16(s_256[2], s_256[3]); s_256[2] = _mm256_loadu_si256((__m256i *)(src + 4 * stride)); tt_256[1] = _mm256_unpacklo_epi16(s_256[3], s_256[2]); tt_256[3] = _mm256_unpackhi_epi16(s_256[3], s_256[2]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r + 0); xy_y_convolve_4tap_16_avx2(tt_256, coeffs, r + 2); ss_256[0] = ss_256[1]; ss_256[2] = ss_256[3]; tt_256[0] = tt_256[1]; tt_256[2] = tt_256[3]; } static INLINE void xy_y_convolve_4tap_16x2_half_pelavx2( const int16_t *const src, __m256i s_256[5], const __m256i coeffs[1], __m256i r[4]) { __m256i a_256[2]; s_256[3] = _mm256_loadu_si256((__m256i *)(src + 3 * 16)); s_256[4] = _mm256_loadu_si256((__m256i *)(src + 4 * 16)); a_256[0] = _mm256_add_epi16(s_256[0], s_256[3]); a_256[1] = _mm256_add_epi16(s_256[1], s_256[2]); xy_y_convolve_2tap_16_avx2(a_256[0], a_256[1], coeffs, r + 0); a_256[0] = _mm256_add_epi16(s_256[1], s_256[4]); a_256[1] = _mm256_add_epi16(s_256[2], s_256[3]); xy_y_convolve_2tap_16_avx2(a_256[0], a_256[1], coeffs, r + 2); s_256[0] = s_256[2]; s_256[1] = s_256[3]; s_256[2] = s_256[4]; } static INLINE __m128i xy_y_convolve_6tap_2x2_sse2(const int16_t *const src, __m128i s_32[6], __m128i ss_128[3], const __m128i coeffs[3]) { s_32[5] = _mm_cvtsi32_si128(*(int32_t *)(src + 5 * 2)); const __m128i src45 = _mm_unpacklo_epi32(s_32[4], s_32[5]); s_32[4] = _mm_cvtsi32_si128(*(int32_t *)(src + 6 * 2)); const __m128i src56 = _mm_unpacklo_epi32(s_32[5], s_32[4]); ss_128[2] = _mm_unpacklo_epi16(src45, src56); const __m128i r = convolve16_6tap_sse2(ss_128, coeffs); ss_128[0] = ss_128[1]; ss_128[1] = ss_128[2]; return r; } static INLINE __m256i xy_y_convolve_6tap_4x2_avx2(const int16_t *const src, __m128i s_64[6], __m256i ss_256[3], const __m256i coeffs[3]) { __m256i s_256[2]; s_64[5] = _mm_loadl_epi64((__m128i *)(src + 5 * 4)); s_256[0] = _mm256_setr_m128i(s_64[4], s_64[5]); s_64[4] = _mm_loadl_epi64((__m128i *)(src + 6 * 4)); s_256[1] = _mm256_setr_m128i(s_64[5], s_64[4]); ss_256[2] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); const __m256i r = convolve16_6tap_avx2(ss_256, coeffs); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; return r; } static INLINE void xy_y_convolve_6tap_16_avx2(const __m256i ss[6], const __m256i coeffs[3], __m256i r[2]) { r[0] = convolve16_6tap_avx2(ss, coeffs); r[1] = convolve16_6tap_avx2(ss + 3, coeffs); } static INLINE void xy_y_convolve_6tap_8x2_avx2(const int16_t *const src, __m256i ss_256[6], const __m256i coeffs[3], __m256i r[2]) { __m256i s_256[2]; s_256[0] = _mm256_loadu_si256((__m256i *)(src + 4 * 8)); s_256[1] = _mm256_loadu_si256((__m256i *)(src + 5 * 8)); ss_256[2] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); ss_256[5] = _mm256_unpackhi_epi16(s_256[0], s_256[1]); xy_y_convolve_6tap_16_avx2(ss_256, coeffs, r); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[3] = ss_256[4]; ss_256[4] = ss_256[5]; } static INLINE void xy_y_convolve_6tap_8x2_half_pel_avx2( const int16_t *const src, const __m256i coeffs[2], __m256i s_256[6], __m256i r[2]) { __m256i a_256[2], ss_256[4]; s_256[4] = _mm256_loadu_si256((__m256i *)(src + 4 * 8)); s_256[5] = _mm256_loadu_si256((__m256i *)(src + 5 * 8)); a_256[0] = _mm256_add_epi16(s_256[0], s_256[5]); a_256[1] = _mm256_add_epi16(s_256[1], s_256[4]); ss_256[0] = _mm256_unpacklo_epi16(a_256[0], a_256[1]); ss_256[1] = _mm256_unpacklo_epi16(s_256[2], s_256[3]); ss_256[2] = _mm256_unpackhi_epi16(a_256[0], a_256[1]); ss_256[3] = _mm256_unpackhi_epi16(s_256[2], s_256[3]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r); s_256[0] = s_256[2]; s_256[1] = s_256[3]; s_256[2] = s_256[4]; s_256[3] = s_256[5]; } static INLINE void xy_y_convolve_6tap_16x2_avx2( const int16_t *const src, const ptrdiff_t stride, __m256i s_256[6], __m256i ss_256[6], __m256i tt_256[6], const __m256i coeffs[3], __m256i r[4]) { s_256[5] = _mm256_loadu_si256((__m256i *)(src + 5 * stride)); ss_256[2] = _mm256_unpacklo_epi16(s_256[4], s_256[5]); ss_256[5] = _mm256_unpackhi_epi16(s_256[4], s_256[5]); s_256[4] = _mm256_loadu_si256((__m256i *)(src + 6 * stride)); tt_256[2] = _mm256_unpacklo_epi16(s_256[5], s_256[4]); tt_256[5] = _mm256_unpackhi_epi16(s_256[5], s_256[4]); xy_y_convolve_6tap_16_avx2(ss_256, coeffs, r + 0); xy_y_convolve_6tap_16_avx2(tt_256, coeffs, r + 2); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[3] = ss_256[4]; ss_256[4] = ss_256[5]; tt_256[0] = tt_256[1]; tt_256[1] = tt_256[2]; tt_256[3] = tt_256[4]; tt_256[4] = tt_256[5]; } static INLINE void xy_y_convolve_6tap_16x2_half_pel_avx2( const int16_t *const src, const ptrdiff_t stride, __m256i s_256[6], __m256i ss_256[4], const __m256i coeffs[2], __m256i r[4]) { __m256i a_256[2]; s_256[5] = _mm256_loadu_si256((__m256i *)(src + 5 * stride)); a_256[0] = _mm256_add_epi16(s_256[0], s_256[5]); a_256[1] = _mm256_add_epi16(s_256[1], s_256[4]); ss_256[0] = _mm256_unpacklo_epi16(a_256[0], a_256[1]); ss_256[1] = _mm256_unpacklo_epi16(s_256[2], s_256[3]); ss_256[2] = _mm256_unpackhi_epi16(a_256[0], a_256[1]); ss_256[3] = _mm256_unpackhi_epi16(s_256[2], s_256[3]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r + 0); a_256[1] = _mm256_add_epi16(s_256[2], s_256[5]); s_256[0] = s_256[2]; s_256[2] = s_256[4]; s_256[4] = _mm256_loadu_si256((__m256i *)(src + 6 * stride)); a_256[0] = _mm256_add_epi16(s_256[1], s_256[4]); s_256[1] = s_256[3]; s_256[3] = s_256[5]; ss_256[0] = _mm256_unpacklo_epi16(a_256[0], a_256[1]); ss_256[1] = _mm256_unpacklo_epi16(s_256[1], s_256[2]); ss_256[2] = _mm256_unpackhi_epi16(a_256[0], a_256[1]); ss_256[3] = _mm256_unpackhi_epi16(s_256[1], s_256[2]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r + 2); } static INLINE __m128i xy_y_convolve_8tap_2x2_sse2(const int16_t *const src, __m128i s_32[8], __m128i ss_128[4], const __m128i coeffs[4]) { s_32[7] = _mm_cvtsi32_si128(*(int32_t *)(src + 7 * 2)); const __m128i src67 = _mm_unpacklo_epi32(s_32[6], s_32[7]); s_32[6] = _mm_cvtsi32_si128(*(int32_t *)(src + 8 * 2)); const __m128i src78 = _mm_unpacklo_epi32(s_32[7], s_32[6]); ss_128[3] = _mm_unpacklo_epi16(src67, src78); const __m128i r = convolve16_8tap_sse2(ss_128, coeffs); ss_128[0] = ss_128[1]; ss_128[1] = ss_128[2]; ss_128[2] = ss_128[3]; return r; } static INLINE __m256i xy_y_convolve_8tap_4x2_avx2(const int16_t *const src, __m128i s_64[8], __m256i ss_256[4], const __m256i coeffs[4]) { __m256i s_256[2]; s_64[7] = _mm_loadl_epi64((__m128i *)(src + 7 * 4)); s_256[0] = _mm256_setr_m128i(s_64[6], s_64[7]); s_64[6] = _mm_loadl_epi64((__m128i *)(src + 8 * 4)); s_256[1] = _mm256_setr_m128i(s_64[7], s_64[6]); ss_256[3] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); const __m256i r = convolve16_8tap_avx2(ss_256, coeffs); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[2] = ss_256[3]; return r; } static INLINE void xy_y_convolve_8tap_16_avx2(const __m256i *const ss, const __m256i coeffs[4], __m256i r[2]) { r[0] = convolve16_8tap_avx2(ss, coeffs); r[1] = convolve16_8tap_avx2(ss + 4, coeffs); } static INLINE void xy_y_convolve_8tap_8x2_avx2(const int16_t *const src, __m256i ss_256[8], const __m256i coeffs[4], __m256i r[2]) { __m256i s_256[2]; s_256[0] = _mm256_loadu_si256((__m256i *)(src + 6 * 8)); s_256[1] = _mm256_loadu_si256((__m256i *)(src + 7 * 8)); ss_256[3] = _mm256_unpacklo_epi16(s_256[0], s_256[1]); ss_256[7] = _mm256_unpackhi_epi16(s_256[0], s_256[1]); xy_y_convolve_8tap_16_avx2(ss_256, coeffs, r); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[2] = ss_256[3]; ss_256[4] = ss_256[5]; ss_256[5] = ss_256[6]; ss_256[6] = ss_256[7]; } static INLINE void xy_y_convolve_8tap_8x2_half_pel_avx2( const int16_t *const src, const __m256i coeffs[2], __m256i s_256[8], __m256i r[2]) { __m256i a_256[4], ss_256[4]; s_256[6] = _mm256_loadu_si256((__m256i *)(src + 6 * 8)); s_256[7] = _mm256_loadu_si256((__m256i *)(src + 7 * 8)); a_256[0] = _mm256_add_epi16(s_256[0], s_256[7]); a_256[1] = _mm256_add_epi16(s_256[1], s_256[6]); a_256[2] = _mm256_add_epi16(s_256[2], s_256[5]); a_256[3] = _mm256_add_epi16(s_256[3], s_256[4]); ss_256[0] = _mm256_unpacklo_epi16(a_256[0], a_256[1]); ss_256[1] = _mm256_unpacklo_epi16(a_256[2], a_256[3]); ss_256[2] = _mm256_unpackhi_epi16(a_256[0], a_256[1]); ss_256[3] = _mm256_unpackhi_epi16(a_256[2], a_256[3]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r); s_256[0] = s_256[2]; s_256[1] = s_256[3]; s_256[2] = s_256[4]; s_256[3] = s_256[5]; s_256[4] = s_256[6]; s_256[5] = s_256[7]; } static AOM_FORCE_INLINE void xy_y_convolve_8tap_16x2_avx2( const int16_t *const src, const ptrdiff_t stride, const __m256i coeffs[4], __m256i s_256[8], __m256i ss_256[8], __m256i tt_256[8], __m256i r[4]) { s_256[7] = _mm256_loadu_si256((__m256i *)(src + 7 * stride)); ss_256[3] = _mm256_unpacklo_epi16(s_256[6], s_256[7]); ss_256[7] = _mm256_unpackhi_epi16(s_256[6], s_256[7]); s_256[6] = _mm256_loadu_si256((__m256i *)(src + 8 * stride)); tt_256[3] = _mm256_unpacklo_epi16(s_256[7], s_256[6]); tt_256[7] = _mm256_unpackhi_epi16(s_256[7], s_256[6]); xy_y_convolve_8tap_16_avx2(ss_256, coeffs, r + 0); xy_y_convolve_8tap_16_avx2(tt_256, coeffs, r + 2); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[2] = ss_256[3]; ss_256[4] = ss_256[5]; ss_256[5] = ss_256[6]; ss_256[6] = ss_256[7]; tt_256[0] = tt_256[1]; tt_256[1] = tt_256[2]; tt_256[2] = tt_256[3]; tt_256[4] = tt_256[5]; tt_256[5] = tt_256[6]; tt_256[6] = tt_256[7]; } static INLINE void xy_y_convolve_8tap_16x2_half_pel_avx2( const int16_t *const src, const ptrdiff_t stride, const __m256i coeffs[4], __m256i s_256[8], __m256i r[4]) { __m256i a_256[4], ss_256[4]; s_256[7] = _mm256_loadu_si256((__m256i *)(src + 7 * stride)); a_256[0] = _mm256_add_epi16(s_256[0], s_256[7]); a_256[1] = _mm256_add_epi16(s_256[1], s_256[6]); a_256[2] = _mm256_add_epi16(s_256[2], s_256[5]); a_256[3] = _mm256_add_epi16(s_256[3], s_256[4]); ss_256[0] = _mm256_unpacklo_epi16(a_256[0], a_256[1]); ss_256[1] = _mm256_unpacklo_epi16(a_256[2], a_256[3]); ss_256[2] = _mm256_unpackhi_epi16(a_256[0], a_256[1]); ss_256[3] = _mm256_unpackhi_epi16(a_256[2], a_256[3]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r + 0); a_256[1] = _mm256_add_epi16(s_256[2], s_256[7]); a_256[2] = _mm256_add_epi16(s_256[3], s_256[6]); a_256[3] = _mm256_add_epi16(s_256[4], s_256[5]); s_256[0] = s_256[2]; s_256[2] = s_256[4]; s_256[4] = s_256[6]; s_256[6] = _mm256_loadu_si256((__m256i *)(src + 8 * stride)); a_256[0] = _mm256_add_epi16(s_256[1], s_256[6]); s_256[1] = s_256[3]; s_256[3] = s_256[5]; s_256[5] = s_256[7]; ss_256[0] = _mm256_unpacklo_epi16(a_256[0], a_256[1]); ss_256[1] = _mm256_unpacklo_epi16(a_256[2], a_256[3]); ss_256[2] = _mm256_unpackhi_epi16(a_256[0], a_256[1]); ss_256[3] = _mm256_unpackhi_epi16(a_256[2], a_256[3]); xy_y_convolve_4tap_16_avx2(ss_256, coeffs, r + 2); } static INLINE void xy_y_round_store_8x2_avx2(const __m256i res[2], uint8_t *const dst, const ptrdiff_t stride) { const __m256i r = xy_y_round_16_avx2(res); pack_store_8x2_avx2(r, dst, stride); } static INLINE void xy_y_round_store_16x2_avx2(const __m256i res[4], uint8_t *const dst, const ptrdiff_t stride) { const __m256i r0 = xy_y_round_16_avx2(res + 0); const __m256i r1 = xy_y_round_16_avx2(res + 2); xy_y_pack_store_16x2_avx2(r0, r1, dst, stride); } static INLINE void sr_y_round_store_32_avx2(const __m256i res[2], uint8_t *const dst) { __m256i r[2]; r[0] = sr_y_round_avx2(res[0]); r[1] = sr_y_round_avx2(res[1]); convolve_store_32_avx2(r[0], r[1], dst); } static INLINE void sr_y_round_store_32x2_avx2(const __m256i res[4], uint8_t *const dst, const int32_t dst_stride) { sr_y_round_store_32_avx2(res, dst); sr_y_round_store_32_avx2(res + 2, dst + dst_stride); } static INLINE void sr_y_2tap_32_avx2(const uint8_t *const src, const __m256i coeffs[1], const __m256i s0, __m256i *const s1, uint8_t *const dst) { __m256i r[2]; y_convolve_2tap_32_avx2(src, coeffs, s0, s1, r); sr_y_round_store_32_avx2(r, dst); } static AOM_FORCE_INLINE void av1_convolve_y_sr_specialized_avx2( const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t w, int32_t h, const InterpFilterParams *filter_params_y, const int32_t subpel_y_q4) { int32_t x, y; __m128i coeffs_128[4]; __m256i coeffs_256[4]; int vert_tap = get_filter_tap(filter_params_y, subpel_y_q4); if (vert_tap == 2) { // vert_filt as 2 tap const uint8_t *src_ptr = src; y = h; if (subpel_y_q4 != 8) { if (w <= 8) { prepare_half_coeffs_2tap_ssse3(filter_params_y, subpel_y_q4, coeffs_128); if (w == 2) { __m128i s_16[2]; s_16[0] = _mm_cvtsi32_si128(*(int16_t *)src_ptr); do { const __m128i res = y_convolve_2tap_2x2_ssse3(src_ptr, src_stride, coeffs_128, s_16); const __m128i r = sr_y_round_sse2(res); pack_store_2x2_sse2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 4) { __m128i s_32[2]; s_32[0] = _mm_cvtsi32_si128(*(int32_t *)src_ptr); do { const __m128i res = y_convolve_2tap_4x2_ssse3(src_ptr, src_stride, coeffs_128, s_32); const __m128i r = sr_y_round_sse2(res); pack_store_4x2_sse2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m128i s_64[2], s_128[2]; assert(w == 8); s_64[0] = _mm_loadl_epi64((__m128i *)src_ptr); do { // Note: Faster than binding to AVX2 registers. s_64[1] = _mm_loadl_epi64((__m128i *)(src_ptr + src_stride)); s_128[0] = _mm_unpacklo_epi64(s_64[0], s_64[1]); s_64[0] = _mm_loadl_epi64((__m128i *)(src_ptr + 2 * src_stride)); s_128[1] = _mm_unpacklo_epi64(s_64[1], s_64[0]); const __m128i ss0 = _mm_unpacklo_epi8(s_128[0], s_128[1]); const __m128i ss1 = _mm_unpackhi_epi8(s_128[0], s_128[1]); const __m128i res0 = convolve_2tap_ssse3(&ss0, coeffs_128); const __m128i res1 = convolve_2tap_ssse3(&ss1, coeffs_128); const __m128i r0 = sr_y_round_sse2(res0); const __m128i r1 = sr_y_round_sse2(res1); const __m128i d = _mm_packus_epi16(r0, r1); _mm_storel_epi64((__m128i *)dst, d); _mm_storeh_epi64((__m128i *)(dst + dst_stride), d); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } } else { prepare_half_coeffs_2tap_avx2(filter_params_y, subpel_y_q4, coeffs_256); if (w == 16) { __m128i s_128[2]; s_128[0] = _mm_loadu_si128((__m128i *)src_ptr); do { __m256i r[2]; y_convolve_2tap_16x2_avx2(src_ptr, src_stride, coeffs_256, s_128, r); sr_y_round_store_16x2_avx2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { __m256i s_256[2]; s_256[0] = _mm256_loadu_si256((__m256i *)src_ptr); do { sr_y_2tap_32_avx2(src_ptr + src_stride, coeffs_256, s_256[0], &s_256[1], dst); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride, coeffs_256, s_256[1], &s_256[0], dst + dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 64) { __m256i s_256[2][2]; s_256[0][0] = _mm256_loadu_si256((__m256i *)(src_ptr + 0 * 32)); s_256[0][1] = _mm256_loadu_si256((__m256i *)(src_ptr + 1 * 32)); do { sr_y_2tap_32_avx2(src_ptr + src_stride, coeffs_256, s_256[0][0], &s_256[1][0], dst); sr_y_2tap_32_avx2(src_ptr + src_stride + 32, coeffs_256, s_256[0][1], &s_256[1][1], dst + 32); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride, coeffs_256, s_256[1][0], &s_256[0][0], dst + dst_stride); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride + 32, coeffs_256, s_256[1][1], &s_256[0][1], dst + dst_stride + 32); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m256i s_256[2][4]; assert(w == 128); s_256[0][0] = _mm256_loadu_si256((__m256i *)(src_ptr + 0 * 32)); s_256[0][1] = _mm256_loadu_si256((__m256i *)(src_ptr + 1 * 32)); s_256[0][2] = _mm256_loadu_si256((__m256i *)(src_ptr + 2 * 32)); s_256[0][3] = _mm256_loadu_si256((__m256i *)(src_ptr + 3 * 32)); do { sr_y_2tap_32_avx2(src_ptr + src_stride, coeffs_256, s_256[0][0], &s_256[1][0], dst); sr_y_2tap_32_avx2(src_ptr + src_stride + 1 * 32, coeffs_256, s_256[0][1], &s_256[1][1], dst + 1 * 32); sr_y_2tap_32_avx2(src_ptr + src_stride + 2 * 32, coeffs_256, s_256[0][2], &s_256[1][2], dst + 2 * 32); sr_y_2tap_32_avx2(src_ptr + src_stride + 3 * 32, coeffs_256, s_256[0][3], &s_256[1][3], dst + 3 * 32); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride, coeffs_256, s_256[1][0], &s_256[0][0], dst + dst_stride); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride + 1 * 32, coeffs_256, s_256[1][1], &s_256[0][1], dst + dst_stride + 1 * 32); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride + 2 * 32, coeffs_256, s_256[1][2], &s_256[0][2], dst + dst_stride + 2 * 32); sr_y_2tap_32_avx2(src_ptr + 2 * src_stride + 3 * 32, coeffs_256, s_256[1][3], &s_256[0][3], dst + dst_stride + 3 * 32); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } } } else { // average to get half pel if (w <= 8) { if (w == 2) { __m128i s_16[2]; s_16[0] = _mm_cvtsi32_si128(*(int16_t *)src_ptr); do { s_16[1] = _mm_cvtsi32_si128(*(int16_t *)(src_ptr + src_stride)); const __m128i d0 = _mm_avg_epu8(s_16[0], s_16[1]); *(int16_t *)dst = (int16_t)_mm_cvtsi128_si32(d0); s_16[0] = _mm_cvtsi32_si128(*(int16_t *)(src_ptr + 2 * src_stride)); const __m128i d1 = _mm_avg_epu8(s_16[1], s_16[0]); *(int16_t *)(dst + dst_stride) = (int16_t)_mm_cvtsi128_si32(d1); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 4) { __m128i s_32[2]; s_32[0] = _mm_cvtsi32_si128(*(int32_t *)src_ptr); do { s_32[1] = _mm_cvtsi32_si128(*(int32_t *)(src_ptr + src_stride)); const __m128i d0 = _mm_avg_epu8(s_32[0], s_32[1]); xx_storel_32(dst, d0); s_32[0] = _mm_cvtsi32_si128(*(int32_t *)(src_ptr + 2 * src_stride)); const __m128i d1 = _mm_avg_epu8(s_32[1], s_32[0]); xx_storel_32(dst + dst_stride, d1); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m128i s_64[2]; assert(w == 8); s_64[0] = _mm_loadl_epi64((__m128i *)src_ptr); do { // Note: Faster than binding to AVX2 registers. s_64[1] = _mm_loadl_epi64((__m128i *)(src_ptr + src_stride)); const __m128i d0 = _mm_avg_epu8(s_64[0], s_64[1]); _mm_storel_epi64((__m128i *)dst, d0); s_64[0] = _mm_loadl_epi64((__m128i *)(src_ptr + 2 * src_stride)); const __m128i d1 = _mm_avg_epu8(s_64[1], s_64[0]); _mm_storel_epi64((__m128i *)(dst + dst_stride), d1); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } } else if (w == 16) { __m128i s_128[2]; s_128[0] = _mm_loadu_si128((__m128i *)src_ptr); do { s_128[1] = _mm_loadu_si128((__m128i *)(src_ptr + src_stride)); const __m128i d0 = _mm_avg_epu8(s_128[0], s_128[1]); _mm_storeu_si128((__m128i *)dst, d0); s_128[0] = _mm_loadu_si128((__m128i *)(src_ptr + 2 * src_stride)); const __m128i d1 = _mm_avg_epu8(s_128[1], s_128[0]); _mm_storeu_si128((__m128i *)(dst + dst_stride), d1); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { __m256i s_256[2]; s_256[0] = _mm256_loadu_si256((__m256i *)src_ptr); do { sr_y_2tap_32_avg_avx2(src_ptr + src_stride, s_256[0], &s_256[1], dst); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride, s_256[1], &s_256[0], dst + dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 64) { __m256i s_256[2][2]; s_256[0][0] = _mm256_loadu_si256((__m256i *)(src_ptr + 0 * 32)); s_256[0][1] = _mm256_loadu_si256((__m256i *)(src_ptr + 1 * 32)); do { sr_y_2tap_32_avg_avx2(src_ptr + src_stride, s_256[0][0], &s_256[1][0], dst); sr_y_2tap_32_avg_avx2(src_ptr + src_stride + 32, s_256[0][1], &s_256[1][1], dst + 32); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride, s_256[1][0], &s_256[0][0], dst + dst_stride); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride + 32, s_256[1][1], &s_256[0][1], dst + dst_stride + 32); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m256i s_256[2][4]; assert(w == 128); s_256[0][0] = _mm256_loadu_si256((__m256i *)(src_ptr + 0 * 32)); s_256[0][1] = _mm256_loadu_si256((__m256i *)(src_ptr + 1 * 32)); s_256[0][2] = _mm256_loadu_si256((__m256i *)(src_ptr + 2 * 32)); s_256[0][3] = _mm256_loadu_si256((__m256i *)(src_ptr + 3 * 32)); do { sr_y_2tap_32_avg_avx2(src_ptr + src_stride, s_256[0][0], &s_256[1][0], dst); sr_y_2tap_32_avg_avx2(src_ptr + src_stride + 1 * 32, s_256[0][1], &s_256[1][1], dst + 1 * 32); sr_y_2tap_32_avg_avx2(src_ptr + src_stride + 2 * 32, s_256[0][2], &s_256[1][2], dst + 2 * 32); sr_y_2tap_32_avg_avx2(src_ptr + src_stride + 3 * 32, s_256[0][3], &s_256[1][3], dst + 3 * 32); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride, s_256[1][0], &s_256[0][0], dst + dst_stride); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride + 1 * 32, s_256[1][1], &s_256[0][1], dst + dst_stride + 1 * 32); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride + 2 * 32, s_256[1][2], &s_256[0][2], dst + dst_stride + 2 * 32); sr_y_2tap_32_avg_avx2(src_ptr + 2 * src_stride + 3 * 32, s_256[1][3], &s_256[0][3], dst + dst_stride + 3 * 32); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } } } else if (vert_tap == 4) { // vert_filt as 4 tap const uint8_t *src_ptr = src - src_stride; y = h; if (w <= 4) { prepare_half_coeffs_4tap_ssse3(filter_params_y, subpel_y_q4, coeffs_128); if (w == 2) { __m128i s_16[4], ss_128[2]; s_16[0] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 0 * src_stride)); s_16[1] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 1 * src_stride)); s_16[2] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 2 * src_stride)); const __m128i src01 = _mm_unpacklo_epi16(s_16[0], s_16[1]); const __m128i src12 = _mm_unpacklo_epi16(s_16[1], s_16[2]); ss_128[0] = _mm_unpacklo_epi8(src01, src12); do { src_ptr += 2 * src_stride; const __m128i res = y_convolve_4tap_2x2_ssse3( src_ptr, src_stride, coeffs_128, s_16, ss_128); const __m128i r = sr_y_round_sse2(res); pack_store_2x2_sse2(r, dst, dst_stride); ss_128[0] = ss_128[1]; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m128i s_32[4], ss_128[2]; assert(w == 4); s_32[0] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 0 * src_stride)); s_32[1] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 1 * src_stride)); s_32[2] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 2 * src_stride)); const __m128i src01 = _mm_unpacklo_epi32(s_32[0], s_32[1]); const __m128i src12 = _mm_unpacklo_epi32(s_32[1], s_32[2]); ss_128[0] = _mm_unpacklo_epi8(src01, src12); do { src_ptr += 2 * src_stride; const __m128i res = y_convolve_4tap_4x2_ssse3( src_ptr, src_stride, coeffs_128, s_32, ss_128); const __m128i r = sr_y_round_sse2(res); pack_store_4x2_sse2(r, dst, dst_stride); ss_128[0] = ss_128[1]; dst += 2 * dst_stride; y -= 2; } while (y); } } else { prepare_half_coeffs_4tap_avx2(filter_params_y, subpel_y_q4, coeffs_256); if (w == 8) { __m128i s_64[4]; __m256i ss_256[2]; s_64[0] = _mm_loadl_epi64((__m128i *)(src_ptr + 0 * src_stride)); s_64[1] = _mm_loadl_epi64((__m128i *)(src_ptr + 1 * src_stride)); s_64[2] = _mm_loadl_epi64((__m128i *)(src_ptr + 2 * src_stride)); // Load lines a and b. Line a to lower 128, line b to upper 128 const __m256i src01 = _mm256_setr_m128i(s_64[0], s_64[1]); const __m256i src12 = _mm256_setr_m128i(s_64[1], s_64[2]); ss_256[0] = _mm256_unpacklo_epi8(src01, src12); do { src_ptr += 2 * src_stride; const __m256i res = y_convolve_4tap_8x2_avx2( src_ptr, src_stride, coeffs_256, s_64, ss_256); sr_y_round_store_8x2_avx2(res, dst, dst_stride); ss_256[0] = ss_256[1]; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 16) { __m128i s_128[4]; __m256i ss_256[4], r[2]; s_128[0] = _mm_loadu_si128((__m128i *)(src_ptr + 0 * src_stride)); s_128[1] = _mm_loadu_si128((__m128i *)(src_ptr + 1 * src_stride)); s_128[2] = _mm_loadu_si128((__m128i *)(src_ptr + 2 * src_stride)); // Load lines a and b. Line a to lower 128, line b to upper 128 const __m256i src01 = _mm256_setr_m128i(s_128[0], s_128[1]); const __m256i src12 = _mm256_setr_m128i(s_128[1], s_128[2]); ss_256[0] = _mm256_unpacklo_epi8(src01, src12); ss_256[2] = _mm256_unpackhi_epi8(src01, src12); do { src_ptr += 2 * src_stride; y_convolve_4tap_16x2_avx2(src_ptr, src_stride, coeffs_256, s_128, ss_256, r); sr_y_round_store_16x2_avx2(r, dst, dst_stride); ss_256[0] = ss_256[1]; ss_256[2] = ss_256[3]; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { // AV1 standard won't have 32x4 case. // This only favors some optimization feature which // subsamples 32x8 to 32x4 and triggers 4-tap filter. __m256i s_256[4], ss_256[4], tt_256[4], r[4]; s_256[0] = _mm256_loadu_si256((__m256i *)(src_ptr + 0 * src_stride)); s_256[1] = _mm256_loadu_si256((__m256i *)(src_ptr + 1 * src_stride)); s_256[2] = _mm256_loadu_si256((__m256i *)(src_ptr + 2 * src_stride)); ss_256[0] = _mm256_unpacklo_epi8(s_256[0], s_256[1]); ss_256[2] = _mm256_unpackhi_epi8(s_256[0], s_256[1]); tt_256[0] = _mm256_unpacklo_epi8(s_256[1], s_256[2]); tt_256[2] = _mm256_unpackhi_epi8(s_256[1], s_256[2]); do { src_ptr += 2 * src_stride; y_convolve_4tap_32x2_avx2(src_ptr, src_stride, coeffs_256, s_256, ss_256, tt_256, r); sr_y_round_store_32x2_avx2(r, dst, dst_stride); ss_256[0] = ss_256[1]; ss_256[2] = ss_256[3]; tt_256[0] = tt_256[1]; tt_256[2] = tt_256[3]; dst += 2 * dst_stride; y -= 2; } while (y); } else { assert(!(w % 32)); __m256i s_256[4], ss_256[4], tt_256[4], r[4]; x = 0; do { const uint8_t *s = src_ptr + x; uint8_t *d = dst + x; s_256[0] = _mm256_loadu_si256((__m256i *)(s + 0 * src_stride)); s_256[1] = _mm256_loadu_si256((__m256i *)(s + 1 * src_stride)); s_256[2] = _mm256_loadu_si256((__m256i *)(s + 2 * src_stride)); ss_256[0] = _mm256_unpacklo_epi8(s_256[0], s_256[1]); ss_256[2] = _mm256_unpackhi_epi8(s_256[0], s_256[1]); tt_256[0] = _mm256_unpacklo_epi8(s_256[1], s_256[2]); tt_256[2] = _mm256_unpackhi_epi8(s_256[1], s_256[2]); y = h; do { s += 2 * src_stride; y_convolve_4tap_32x2_avx2(s, src_stride, coeffs_256, s_256, ss_256, tt_256, r); sr_y_round_store_32x2_avx2(r, d, dst_stride); ss_256[0] = ss_256[1]; ss_256[2] = ss_256[3]; tt_256[0] = tt_256[1]; tt_256[2] = tt_256[3]; d += 2 * dst_stride; y -= 2; } while (y); x += 32; } while (x < w); } } } else if (vert_tap == 6) { // vert_filt as 6 tap const uint8_t *src_ptr = src - 2 * src_stride; if (w <= 4) { prepare_half_coeffs_6tap_ssse3(filter_params_y, subpel_y_q4, coeffs_128); y = h; if (w == 2) { __m128i s_16[6], ss_128[3]; s_16[0] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 0 * src_stride)); s_16[1] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 1 * src_stride)); s_16[2] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 2 * src_stride)); s_16[3] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 3 * src_stride)); s_16[4] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 4 * src_stride)); const __m128i src01 = _mm_unpacklo_epi16(s_16[0], s_16[1]); const __m128i src12 = _mm_unpacklo_epi16(s_16[1], s_16[2]); const __m128i src23 = _mm_unpacklo_epi16(s_16[2], s_16[3]); const __m128i src34 = _mm_unpacklo_epi16(s_16[3], s_16[4]); ss_128[0] = _mm_unpacklo_epi8(src01, src12); ss_128[1] = _mm_unpacklo_epi8(src23, src34); do { src_ptr += 2 * src_stride; const __m128i res = y_convolve_6tap_2x2_ssse3( src_ptr, src_stride, coeffs_128, s_16, ss_128); const __m128i r = sr_y_round_sse2(res); pack_store_2x2_sse2(r, dst, dst_stride); ss_128[0] = ss_128[1]; ss_128[1] = ss_128[2]; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m128i s_32[6], ss_128[3]; assert(w == 4); s_32[0] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 0 * src_stride)); s_32[1] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 1 * src_stride)); s_32[2] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 2 * src_stride)); s_32[3] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 3 * src_stride)); s_32[4] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 4 * src_stride)); const __m128i src01 = _mm_unpacklo_epi32(s_32[0], s_32[1]); const __m128i src12 = _mm_unpacklo_epi32(s_32[1], s_32[2]); const __m128i src23 = _mm_unpacklo_epi32(s_32[2], s_32[3]); const __m128i src34 = _mm_unpacklo_epi32(s_32[3], s_32[4]); ss_128[0] = _mm_unpacklo_epi8(src01, src12); ss_128[1] = _mm_unpacklo_epi8(src23, src34); do { src_ptr += 2 * src_stride; const __m128i res = y_convolve_6tap_4x2_ssse3( src_ptr, src_stride, coeffs_128, s_32, ss_128); const __m128i r = sr_y_round_sse2(res); pack_store_4x2_sse2(r, dst, dst_stride); ss_128[0] = ss_128[1]; ss_128[1] = ss_128[2]; dst += 2 * dst_stride; y -= 2; } while (y); } } else { prepare_half_coeffs_6tap_avx2(filter_params_y, subpel_y_q4, coeffs_256); if (w == 8) { __m128i s_64[6]; __m256i ss_256[3]; s_64[0] = _mm_loadl_epi64((__m128i *)(src_ptr + 0 * src_stride)); s_64[1] = _mm_loadl_epi64((__m128i *)(src_ptr + 1 * src_stride)); s_64[2] = _mm_loadl_epi64((__m128i *)(src_ptr + 2 * src_stride)); s_64[3] = _mm_loadl_epi64((__m128i *)(src_ptr + 3 * src_stride)); s_64[4] = _mm_loadl_epi64((__m128i *)(src_ptr + 4 * src_stride)); // Load lines a and b. Line a to lower 128, line b to upper 128 const __m256i src01 = _mm256_setr_m128i(s_64[0], s_64[1]); const __m256i src12 = _mm256_setr_m128i(s_64[1], s_64[2]); const __m256i src23 = _mm256_setr_m128i(s_64[2], s_64[3]); const __m256i src34 = _mm256_setr_m128i(s_64[3], s_64[4]); ss_256[0] = _mm256_unpacklo_epi8(src01, src12); ss_256[1] = _mm256_unpacklo_epi8(src23, src34); y = h; do { src_ptr += 2 * src_stride; const __m256i res = y_convolve_6tap_8x2_avx2( src_ptr, src_stride, coeffs_256, s_64, ss_256); sr_y_round_store_8x2_avx2(res, dst, dst_stride); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 16) { __m128i s_128[6]; __m256i ss_256[6], r[2]; s_128[0] = _mm_loadu_si128((__m128i *)(src_ptr + 0 * src_stride)); s_128[1] = _mm_loadu_si128((__m128i *)(src_ptr + 1 * src_stride)); s_128[2] = _mm_loadu_si128((__m128i *)(src_ptr + 2 * src_stride)); s_128[3] = _mm_loadu_si128((__m128i *)(src_ptr + 3 * src_stride)); s_128[4] = _mm_loadu_si128((__m128i *)(src_ptr + 4 * src_stride)); // Load lines a and b. Line a to lower 128, line b to upper 128 const __m256i src01 = _mm256_setr_m128i(s_128[0], s_128[1]); const __m256i src12 = _mm256_setr_m128i(s_128[1], s_128[2]); const __m256i src23 = _mm256_setr_m128i(s_128[2], s_128[3]); const __m256i src34 = _mm256_setr_m128i(s_128[3], s_128[4]); ss_256[0] = _mm256_unpacklo_epi8(src01, src12); ss_256[1] = _mm256_unpacklo_epi8(src23, src34); ss_256[3] = _mm256_unpackhi_epi8(src01, src12); ss_256[4] = _mm256_unpackhi_epi8(src23, src34); y = h; do { src_ptr += 2 * src_stride; y_convolve_6tap_16x2_avx2(src_ptr, src_stride, coeffs_256, s_128, ss_256, r); sr_y_round_store_16x2_avx2(r, dst, dst_stride); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[3] = ss_256[4]; ss_256[4] = ss_256[5]; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m256i s_256[6], ss_256[6], tt_256[6], r[4]; assert(!(w % 32)); x = 0; do { const uint8_t *s = src_ptr + x; uint8_t *d = dst + x; s_256[0] = _mm256_loadu_si256((__m256i *)(s + 0 * src_stride)); s_256[1] = _mm256_loadu_si256((__m256i *)(s + 1 * src_stride)); s_256[2] = _mm256_loadu_si256((__m256i *)(s + 2 * src_stride)); s_256[3] = _mm256_loadu_si256((__m256i *)(s + 3 * src_stride)); s_256[4] = _mm256_loadu_si256((__m256i *)(s + 4 * src_stride)); ss_256[0] = _mm256_unpacklo_epi8(s_256[0], s_256[1]); ss_256[1] = _mm256_unpacklo_epi8(s_256[2], s_256[3]); ss_256[3] = _mm256_unpackhi_epi8(s_256[0], s_256[1]); ss_256[4] = _mm256_unpackhi_epi8(s_256[2], s_256[3]); tt_256[0] = _mm256_unpacklo_epi8(s_256[1], s_256[2]); tt_256[1] = _mm256_unpacklo_epi8(s_256[3], s_256[4]); tt_256[3] = _mm256_unpackhi_epi8(s_256[1], s_256[2]); tt_256[4] = _mm256_unpackhi_epi8(s_256[3], s_256[4]); y = h; do { s += 2 * src_stride; y_convolve_6tap_32x2_avx2(s, src_stride, coeffs_256, s_256, ss_256, tt_256, r); sr_y_round_store_32x2_avx2(r, d, dst_stride); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[3] = ss_256[4]; ss_256[4] = ss_256[5]; tt_256[0] = tt_256[1]; tt_256[1] = tt_256[2]; tt_256[3] = tt_256[4]; tt_256[4] = tt_256[5]; d += 2 * dst_stride; y -= 2; } while (y); x += 32; } while (x < w); } } } else if (vert_tap == 8) { // vert_filt as 8 tap const uint8_t *src_ptr = src - 3 * src_stride; if (w <= 4) { prepare_half_coeffs_8tap_ssse3(filter_params_y, subpel_y_q4, coeffs_128); y = h; if (w == 2) { __m128i s_16[8], ss_128[4]; s_16[0] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 0 * src_stride)); s_16[1] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 1 * src_stride)); s_16[2] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 2 * src_stride)); s_16[3] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 3 * src_stride)); s_16[4] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 4 * src_stride)); s_16[5] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 5 * src_stride)); s_16[6] = _mm_cvtsi32_si128(loadu_int16(src_ptr + 6 * src_stride)); const __m128i src01 = _mm_unpacklo_epi16(s_16[0], s_16[1]); const __m128i src12 = _mm_unpacklo_epi16(s_16[1], s_16[2]); const __m128i src23 = _mm_unpacklo_epi16(s_16[2], s_16[3]); const __m128i src34 = _mm_unpacklo_epi16(s_16[3], s_16[4]); const __m128i src45 = _mm_unpacklo_epi16(s_16[4], s_16[5]); const __m128i src56 = _mm_unpacklo_epi16(s_16[5], s_16[6]); ss_128[0] = _mm_unpacklo_epi8(src01, src12); ss_128[1] = _mm_unpacklo_epi8(src23, src34); ss_128[2] = _mm_unpacklo_epi8(src45, src56); do { const __m128i res = y_convolve_8tap_2x2_ssse3( src_ptr, src_stride, coeffs_128, s_16, ss_128); const __m128i r = sr_y_round_sse2(res); pack_store_2x2_sse2(r, dst, dst_stride); ss_128[0] = ss_128[1]; ss_128[1] = ss_128[2]; ss_128[2] = ss_128[3]; src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m128i s_32[8], ss_128[4]; assert(w == 4); s_32[0] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 0 * src_stride)); s_32[1] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 1 * src_stride)); s_32[2] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 2 * src_stride)); s_32[3] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 3 * src_stride)); s_32[4] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 4 * src_stride)); s_32[5] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 5 * src_stride)); s_32[6] = _mm_cvtsi32_si128(loadu_int32(src_ptr + 6 * src_stride)); const __m128i src01 = _mm_unpacklo_epi32(s_32[0], s_32[1]); const __m128i src12 = _mm_unpacklo_epi32(s_32[1], s_32[2]); const __m128i src23 = _mm_unpacklo_epi32(s_32[2], s_32[3]); const __m128i src34 = _mm_unpacklo_epi32(s_32[3], s_32[4]); const __m128i src45 = _mm_unpacklo_epi32(s_32[4], s_32[5]); const __m128i src56 = _mm_unpacklo_epi32(s_32[5], s_32[6]); ss_128[0] = _mm_unpacklo_epi8(src01, src12); ss_128[1] = _mm_unpacklo_epi8(src23, src34); ss_128[2] = _mm_unpacklo_epi8(src45, src56); do { const __m128i res = y_convolve_8tap_4x2_ssse3( src_ptr, src_stride, coeffs_128, s_32, ss_128); const __m128i r = sr_y_round_sse2(res); pack_store_4x2_sse2(r, dst, dst_stride); ss_128[0] = ss_128[1]; ss_128[1] = ss_128[2]; ss_128[2] = ss_128[3]; src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } } else { prepare_half_coeffs_8tap_avx2(filter_params_y, subpel_y_q4, coeffs_256); if (w == 8) { __m128i s_64[8]; __m256i ss_256[4]; s_64[0] = _mm_loadl_epi64((__m128i *)(src_ptr + 0 * src_stride)); s_64[1] = _mm_loadl_epi64((__m128i *)(src_ptr + 1 * src_stride)); s_64[2] = _mm_loadl_epi64((__m128i *)(src_ptr + 2 * src_stride)); s_64[3] = _mm_loadl_epi64((__m128i *)(src_ptr + 3 * src_stride)); s_64[4] = _mm_loadl_epi64((__m128i *)(src_ptr + 4 * src_stride)); s_64[5] = _mm_loadl_epi64((__m128i *)(src_ptr + 5 * src_stride)); s_64[6] = _mm_loadl_epi64((__m128i *)(src_ptr + 6 * src_stride)); // Load lines a and b. Line a to lower 128, line b to upper 128 const __m256i src01 = _mm256_setr_m128i(s_64[0], s_64[1]); const __m256i src12 = _mm256_setr_m128i(s_64[1], s_64[2]); const __m256i src23 = _mm256_setr_m128i(s_64[2], s_64[3]); const __m256i src34 = _mm256_setr_m128i(s_64[3], s_64[4]); const __m256i src45 = _mm256_setr_m128i(s_64[4], s_64[5]); const __m256i src56 = _mm256_setr_m128i(s_64[5], s_64[6]); ss_256[0] = _mm256_unpacklo_epi8(src01, src12); ss_256[1] = _mm256_unpacklo_epi8(src23, src34); ss_256[2] = _mm256_unpacklo_epi8(src45, src56); y = h; do { const __m256i res = y_convolve_8tap_8x2_avx2( src_ptr, src_stride, coeffs_256, s_64, ss_256); sr_y_round_store_8x2_avx2(res, dst, dst_stride); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[2] = ss_256[3]; src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 16) { __m128i s_128[8]; __m256i ss_256[8], r[2]; s_128[0] = _mm_loadu_si128((__m128i *)(src_ptr + 0 * src_stride)); s_128[1] = _mm_loadu_si128((__m128i *)(src_ptr + 1 * src_stride)); s_128[2] = _mm_loadu_si128((__m128i *)(src_ptr + 2 * src_stride)); s_128[3] = _mm_loadu_si128((__m128i *)(src_ptr + 3 * src_stride)); s_128[4] = _mm_loadu_si128((__m128i *)(src_ptr + 4 * src_stride)); s_128[5] = _mm_loadu_si128((__m128i *)(src_ptr + 5 * src_stride)); s_128[6] = _mm_loadu_si128((__m128i *)(src_ptr + 6 * src_stride)); // Load lines a and b. Line a to lower 128, line b to upper 128 const __m256i src01 = _mm256_setr_m128i(s_128[0], s_128[1]); const __m256i src12 = _mm256_setr_m128i(s_128[1], s_128[2]); const __m256i src23 = _mm256_setr_m128i(s_128[2], s_128[3]); const __m256i src34 = _mm256_setr_m128i(s_128[3], s_128[4]); const __m256i src45 = _mm256_setr_m128i(s_128[4], s_128[5]); const __m256i src56 = _mm256_setr_m128i(s_128[5], s_128[6]); ss_256[0] = _mm256_unpacklo_epi8(src01, src12); ss_256[1] = _mm256_unpacklo_epi8(src23, src34); ss_256[2] = _mm256_unpacklo_epi8(src45, src56); ss_256[4] = _mm256_unpackhi_epi8(src01, src12); ss_256[5] = _mm256_unpackhi_epi8(src23, src34); ss_256[6] = _mm256_unpackhi_epi8(src45, src56); y = h; do { y_convolve_8tap_16x2_avx2(src_ptr, src_stride, coeffs_256, s_128, ss_256, r); sr_y_round_store_16x2_avx2(r, dst, dst_stride); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[2] = ss_256[3]; ss_256[4] = ss_256[5]; ss_256[5] = ss_256[6]; ss_256[6] = ss_256[7]; src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { __m256i s_256[8], ss_256[8], tt_256[8], r[4]; assert(!(w % 32)); x = 0; do { const uint8_t *s = src_ptr + x; uint8_t *d = dst + x; s_256[0] = _mm256_loadu_si256((__m256i *)(s + 0 * src_stride)); s_256[1] = _mm256_loadu_si256((__m256i *)(s + 1 * src_stride)); s_256[2] = _mm256_loadu_si256((__m256i *)(s + 2 * src_stride)); s_256[3] = _mm256_loadu_si256((__m256i *)(s + 3 * src_stride)); s_256[4] = _mm256_loadu_si256((__m256i *)(s + 4 * src_stride)); s_256[5] = _mm256_loadu_si256((__m256i *)(s + 5 * src_stride)); s_256[6] = _mm256_loadu_si256((__m256i *)(s + 6 * src_stride)); ss_256[0] = _mm256_unpacklo_epi8(s_256[0], s_256[1]); ss_256[1] = _mm256_unpacklo_epi8(s_256[2], s_256[3]); ss_256[2] = _mm256_unpacklo_epi8(s_256[4], s_256[5]); ss_256[4] = _mm256_unpackhi_epi8(s_256[0], s_256[1]); ss_256[5] = _mm256_unpackhi_epi8(s_256[2], s_256[3]); ss_256[6] = _mm256_unpackhi_epi8(s_256[4], s_256[5]); tt_256[0] = _mm256_unpacklo_epi8(s_256[1], s_256[2]); tt_256[1] = _mm256_unpacklo_epi8(s_256[3], s_256[4]); tt_256[2] = _mm256_unpacklo_epi8(s_256[5], s_256[6]); tt_256[4] = _mm256_unpackhi_epi8(s_256[1], s_256[2]); tt_256[5] = _mm256_unpackhi_epi8(s_256[3], s_256[4]); tt_256[6] = _mm256_unpackhi_epi8(s_256[5], s_256[6]); y = h; do { y_convolve_8tap_32x2_avx2(s, src_stride, coeffs_256, s_256, ss_256, tt_256, r); sr_y_round_store_32x2_avx2(r, d, dst_stride); ss_256[0] = ss_256[1]; ss_256[1] = ss_256[2]; ss_256[2] = ss_256[3]; ss_256[4] = ss_256[5]; ss_256[5] = ss_256[6]; ss_256[6] = ss_256[7]; tt_256[0] = tt_256[1]; tt_256[1] = tt_256[2]; tt_256[2] = tt_256[3]; tt_256[4] = tt_256[5]; tt_256[5] = tt_256[6]; tt_256[6] = tt_256[7]; s += 2 * src_stride; d += 2 * dst_stride; y -= 2; } while (y); x += 32; } while (x < w); } } } } static INLINE void sr_x_2tap_32_avx2(const uint8_t *const src, const __m256i coeffs[1], uint8_t *const dst) { __m256i r[2]; x_convolve_2tap_32_avx2(src, coeffs, r); sr_x_round_store_32_avx2(r, dst); } static INLINE void sr_x_6tap_32_avx2(const uint8_t *const src, const __m256i coeffs[3], const __m256i filt[3], uint8_t *const dst) { __m256i r[2]; x_convolve_6tap_32_avx2(src, coeffs, filt, r); sr_x_round_store_32_avx2(r, dst); } static AOM_FORCE_INLINE void sr_x_8tap_32_avx2(const uint8_t *const src, const __m256i coeffs[4], const __m256i filt[4], uint8_t *const dst) { __m256i r[2]; x_convolve_8tap_32_avx2(src, coeffs, filt, r); sr_x_round_store_32_avx2(r, dst); } static AOM_FORCE_INLINE void av1_convolve_x_sr_specialized_avx2( const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t w, int32_t h, const InterpFilterParams *filter_params_x, const int32_t subpel_x_q4, ConvolveParams *conv_params) { int32_t y = h; __m128i coeffs_128[4]; __m256i coeffs_256[4]; assert(conv_params->round_0 == 3); assert((FILTER_BITS - conv_params->round_1) >= 0 || ((conv_params->round_0 + conv_params->round_1) == 2 * FILTER_BITS)); (void)conv_params; const int horz_tap = get_filter_tap(filter_params_x, subpel_x_q4); if (horz_tap == 2) { // horz_filt as 2 tap const uint8_t *src_ptr = src; if (subpel_x_q4 != 8) { if (w <= 8) { prepare_half_coeffs_2tap_ssse3(filter_params_x, subpel_x_q4, coeffs_128); if (w == 2) { do { const __m128i res = x_convolve_2tap_2x2_sse4_1(src_ptr, src_stride, coeffs_128); const __m128i r = sr_x_round_sse2(res); pack_store_2x2_sse2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 4) { do { const __m128i res = x_convolve_2tap_4x2_ssse3(src_ptr, src_stride, coeffs_128); const __m128i r = sr_x_round_sse2(res); pack_store_4x2_sse2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else { assert(w == 8); do { __m128i res[2]; x_convolve_2tap_8x2_ssse3(src_ptr, src_stride, coeffs_128, res); res[0] = sr_x_round_sse2(res[0]); res[1] = sr_x_round_sse2(res[1]); const __m128i d = _mm_packus_epi16(res[0], res[1]); _mm_storel_epi64((__m128i *)dst, d); _mm_storeh_epi64((__m128i *)(dst + dst_stride), d); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } } else { prepare_half_coeffs_2tap_avx2(filter_params_x, subpel_x_q4, coeffs_256); if (w == 16) { do { __m256i r[2]; x_convolve_2tap_16x2_avx2(src_ptr, src_stride, coeffs_256, r); sr_x_round_store_16x2_avx2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { do { sr_x_2tap_32_avx2(src_ptr, coeffs_256, dst); src_ptr += src_stride; dst += dst_stride; } while (--y); } else if (w == 64) { do { sr_x_2tap_32_avx2(src_ptr + 0 * 32, coeffs_256, dst + 0 * 32); sr_x_2tap_32_avx2(src_ptr + 1 * 32, coeffs_256, dst + 1 * 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } else { assert(w == 128); do { sr_x_2tap_32_avx2(src_ptr + 0 * 32, coeffs_256, dst + 0 * 32); sr_x_2tap_32_avx2(src_ptr + 1 * 32, coeffs_256, dst + 1 * 32); sr_x_2tap_32_avx2(src_ptr + 2 * 32, coeffs_256, dst + 2 * 32); sr_x_2tap_32_avx2(src_ptr + 3 * 32, coeffs_256, dst + 3 * 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } } } else { // average to get half pel if (w == 2) { do { __m128i s_128; s_128 = load_u8_4x2_sse4_1(src_ptr, src_stride); const __m128i s1 = _mm_srli_si128(s_128, 1); const __m128i d = _mm_avg_epu8(s_128, s1); *(uint16_t *)dst = (uint16_t)_mm_cvtsi128_si32(d); *(uint16_t *)(dst + dst_stride) = _mm_extract_epi16(d, 2); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 4) { do { __m128i s_128; s_128 = load_u8_8x2_sse2(src_ptr, src_stride); const __m128i s1 = _mm_srli_si128(s_128, 1); const __m128i d = _mm_avg_epu8(s_128, s1); xx_storel_32(dst, d); *(int32_t *)(dst + dst_stride) = _mm_extract_epi32(d, 2); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 8) { do { const __m128i s00 = _mm_loadu_si128((__m128i *)src_ptr); const __m128i s10 = _mm_loadu_si128((__m128i *)(src_ptr + src_stride)); const __m128i s01 = _mm_srli_si128(s00, 1); const __m128i s11 = _mm_srli_si128(s10, 1); const __m128i d0 = _mm_avg_epu8(s00, s01); const __m128i d1 = _mm_avg_epu8(s10, s11); _mm_storel_epi64((__m128i *)dst, d0); _mm_storel_epi64((__m128i *)(dst + dst_stride), d1); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 16) { do { const __m128i s00 = _mm_loadu_si128((__m128i *)src_ptr); const __m128i s01 = _mm_loadu_si128((__m128i *)(src_ptr + 1)); const __m128i s10 = _mm_loadu_si128((__m128i *)(src_ptr + src_stride)); const __m128i s11 = _mm_loadu_si128((__m128i *)(src_ptr + src_stride + 1)); const __m128i d0 = _mm_avg_epu8(s00, s01); const __m128i d1 = _mm_avg_epu8(s10, s11); _mm_storeu_si128((__m128i *)dst, d0); _mm_storeu_si128((__m128i *)(dst + dst_stride), d1); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { do { sr_x_2tap_32_avg_avx2(src_ptr, dst); src_ptr += src_stride; dst += dst_stride; } while (--y); } else if (w == 64) { do { sr_x_2tap_32_avg_avx2(src_ptr + 0 * 32, dst + 0 * 32); sr_x_2tap_32_avg_avx2(src_ptr + 1 * 32, dst + 1 * 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } else { assert(w == 128); do { sr_x_2tap_32_avg_avx2(src_ptr + 0 * 32, dst + 0 * 32); sr_x_2tap_32_avg_avx2(src_ptr + 1 * 32, dst + 1 * 32); sr_x_2tap_32_avg_avx2(src_ptr + 2 * 32, dst + 2 * 32); sr_x_2tap_32_avg_avx2(src_ptr + 3 * 32, dst + 3 * 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } } } else if (horz_tap == 4) { // horz_filt as 4 tap const uint8_t *src_ptr = src - 1; prepare_half_coeffs_4tap_ssse3(filter_params_x, subpel_x_q4, coeffs_128); if (w == 2) { do { const __m128i res = x_convolve_4tap_2x2_ssse3(src_ptr, src_stride, coeffs_128); const __m128i r = sr_x_round_sse2(res); pack_store_2x2_sse2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 4) { do { const __m128i res = x_convolve_4tap_4x2_ssse3(src_ptr, src_stride, coeffs_128); const __m128i r = sr_x_round_sse2(res); pack_store_4x2_sse2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 8) { // TODO(chiyotsai@google.com): Reuse the old SIMD code here. Need to // rewrite this for better performance later. __m256i filt_256[2]; prepare_coeffs_lowbd(filter_params_x, subpel_x_q4, coeffs_256); filt_256[0] = _mm256_loadu_si256((__m256i const *)filt1_global_avx2); filt_256[1] = _mm256_loadu_si256((__m256i const *)filt2_global_avx2); for (int i = 0; i < h; i += 2) { const __m256i data = _mm256_permute2x128_si256( _mm256_castsi128_si256( _mm_loadu_si128((__m128i *)(&src_ptr[i * src_stride]))), _mm256_castsi128_si256(_mm_loadu_si128( (__m128i *)(&src_ptr[i * src_stride + src_stride]))), 0x20); __m256i res_16b = convolve_lowbd_x_4tap(data, coeffs_256 + 1, filt_256); res_16b = sr_x_round_avx2(res_16b); __m256i res_8b = _mm256_packus_epi16(res_16b, res_16b); const __m128i res_0 = _mm256_castsi256_si128(res_8b); const __m128i res_1 = _mm256_extracti128_si256(res_8b, 1); _mm_storel_epi64((__m128i *)&dst[i * dst_stride], res_0); _mm_storel_epi64((__m128i *)&dst[i * dst_stride + dst_stride], res_1); } } else { assert(!(w % 16)); // TODO(chiyotsai@google.com): Reuse the old SIMD code here. Need to // rewrite this for better performance later. __m256i filt_256[2]; prepare_coeffs_lowbd(filter_params_x, subpel_x_q4, coeffs_256); filt_256[0] = _mm256_loadu_si256((__m256i const *)filt1_global_avx2); filt_256[1] = _mm256_loadu_si256((__m256i const *)filt2_global_avx2); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; j += 16) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 14 15 16 17 // 18 19 20 21 22 23 const __m256i data = _mm256_inserti128_si256( _mm256_loadu_si256((__m256i *)&src_ptr[(i * src_stride) + j]), _mm_loadu_si128((__m128i *)&src_ptr[(i * src_stride) + (j + 8)]), 1); __m256i res_16b = convolve_lowbd_x_4tap(data, coeffs_256 + 1, filt_256); res_16b = sr_x_round_avx2(res_16b); /* rounding code */ // 8 bit conversion and saturation to uint8 __m256i res_8b = _mm256_packus_epi16(res_16b, res_16b); // Store values into the destination buffer // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 res_8b = _mm256_permute4x64_epi64(res_8b, 216); __m128i res = _mm256_castsi256_si128(res_8b); _mm_storeu_si128((__m128i *)&dst[i * dst_stride + j], res); } } } } else { __m256i filt_256[4]; filt_256[0] = _mm256_loadu_si256((__m256i const *)filt1_global_avx2); filt_256[1] = _mm256_loadu_si256((__m256i const *)filt2_global_avx2); filt_256[2] = _mm256_loadu_si256((__m256i const *)filt3_global_avx2); if (horz_tap == 6) { // horz_filt as 6 tap const uint8_t *src_ptr = src - 2; prepare_half_coeffs_6tap_avx2(filter_params_x, subpel_x_q4, coeffs_256); if (w == 8) { do { const __m256i res = x_convolve_6tap_8x2_avx2(src_ptr, src_stride, coeffs_256, filt_256); sr_x_round_store_8x2_avx2(res, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 16) { do { __m256i r[2]; x_convolve_6tap_16x2_avx2(src_ptr, src_stride, coeffs_256, filt_256, r); sr_x_round_store_16x2_avx2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { do { sr_x_6tap_32_avx2(src_ptr, coeffs_256, filt_256, dst); src_ptr += src_stride; dst += dst_stride; } while (--y); } else if (w == 64) { do { sr_x_6tap_32_avx2(src_ptr, coeffs_256, filt_256, dst); sr_x_6tap_32_avx2(src_ptr + 32, coeffs_256, filt_256, dst + 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } else { assert(w == 128); do { sr_x_6tap_32_avx2(src_ptr, coeffs_256, filt_256, dst); sr_x_6tap_32_avx2(src_ptr + 1 * 32, coeffs_256, filt_256, dst + 1 * 32); sr_x_6tap_32_avx2(src_ptr + 2 * 32, coeffs_256, filt_256, dst + 2 * 32); sr_x_6tap_32_avx2(src_ptr + 3 * 32, coeffs_256, filt_256, dst + 3 * 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } } else if (horz_tap == 8) { // horz_filt as 8 tap const uint8_t *src_ptr = src - 3; filt_256[3] = _mm256_loadu_si256((__m256i const *)filt4_global_avx2); prepare_half_coeffs_8tap_avx2(filter_params_x, subpel_x_q4, coeffs_256); if (w == 8) { do { const __m256i res = x_convolve_8tap_8x2_avx2(src_ptr, src_stride, coeffs_256, filt_256); sr_x_round_store_8x2_avx2(res, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 16) { do { __m256i r[2]; x_convolve_8tap_16x2_avx2(src_ptr, src_stride, coeffs_256, filt_256, r); sr_x_round_store_16x2_avx2(r, dst, dst_stride); src_ptr += 2 * src_stride; dst += 2 * dst_stride; y -= 2; } while (y); } else if (w == 32) { do { sr_x_8tap_32_avx2(src_ptr, coeffs_256, filt_256, dst); src_ptr += src_stride; dst += dst_stride; } while (--y); } else if (w == 64) { do { sr_x_8tap_32_avx2(src_ptr, coeffs_256, filt_256, dst); sr_x_8tap_32_avx2(src_ptr + 32, coeffs_256, filt_256, dst + 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } else { assert(w == 128); do { sr_x_8tap_32_avx2(src_ptr, coeffs_256, filt_256, dst); sr_x_8tap_32_avx2(src_ptr + 1 * 32, coeffs_256, filt_256, dst + 1 * 32); sr_x_8tap_32_avx2(src_ptr + 2 * 32, coeffs_256, filt_256, dst + 2 * 32); sr_x_8tap_32_avx2(src_ptr + 3 * 32, coeffs_256, filt_256, dst + 3 * 32); src_ptr += src_stride; dst += dst_stride; } while (--y); } } } } #endif // THIRD_PARTY_SVT_AV1_CONVOLVE_AVX2_H_
eb070f18f4e54fdcdeaebf4838025f3087a294f8
b4afb834fc3a3e2c128b1bf825700031e3df519a
/pyroms/external/gridutils/gridnodes.c
4bfa531b86474ced8a8f0350d5b2e7c941c40626
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ESMG/pyroms
e4e5e9d70d66907a992846b06d61db31afcd24f3
5ea501ef904b01036dd2a0909b7bdc61a56e7eff
refs/heads/python3
2023-03-19T11:11:09.143443
2023-03-10T00:22:13
2023-03-10T00:22:13
1,012,779
102
63
NOASSERTION
2023-03-10T00:23:20
2010-10-21T17:22:48
Python
UTF-8
C
false
false
28,975
c
gridnodes.c
/****************************************************************************** * * File: gridnodes.c * * Created 22/01/2002 * * Author: Pavel Sakov * CSIRO Marine Research * * Purpose: Handling of grid node arrays * Revisions: 14 Feb 2007 PS: added gridnodes_readnextpoint() * *****************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <limits.h> #include <math.h> #include <errno.h> #include <assert.h> #include "nan.h" #include "gridnodes.h" #include "gridmap.h" #include "gucommon.h" #include "kdtree.h" #define BUFSIZE 10240 /* Deviation from Orthogonality = 90 - theta * Aspect Ratio = max(dx,dy) / min(dx,dy) */ typedef struct { double mdo; /* maximum deviation from orthogonality */ int imdo; int jmdo; double ado; /* average deviation from orthogonality */ double mar; /* maximum aspect ratio */ double aar; /* average aspect ratio */ } gridstats; struct gridnodes { int nx; int ny; double** gx; double** gy; NODETYPE type; int validated; gridstats* stats; int nextpoint; }; char* nodetype2str[] = { "not specified", "double density", "center", "corner" }; /* Constructor. Reads double density grid nodes into arrays of X and Y * coordinates. * @param fname File name with grid nodes; can be "stdin" * @param type Node type * @return Gridnodes structure */ gridnodes* gridnodes_read(char* fname, NODETYPE type) { gridnodes* gn = malloc(sizeof(gridnodes)); FILE* f = NULL; int count; char buf[BUFSIZE]; double* xx; double* yy; int i, j; if (gu_verbose) fprintf(stderr, "## grid input: reading from \"%s\"\n", fname); if (strcasecmp(fname, "stdin") == 0 || strcmp(fname, "-") == 0) f = stdin; else f = gu_fopen(fname, "r"); gn->type = type; /* * get grid size */ if (fgets(buf, BUFSIZE, f) == NULL) gu_quit("%s: empty file\n", fname); if (sscanf(buf, "## %d x %d", &gn->nx, &gn->ny) != 2) gu_quit("%s: could not read grid size: expected header in \"## %%d x %%d\" format\n", fname); if (gu_verbose) fprintf(stderr, "## %d x %d grid\n", gn->nx, gn->ny); if (gn->nx < 1) gu_quit("gridnodes_read(): nx = %d: invalid grid size\n", gn->nx); if (gn->ny < 1) gu_quit("gridnodes_read(): ny = %d: invalid grid size\n", gn->ny); if ((double) gn->nx * (double) gn->ny > (double) INT_MAX) gu_quit("gridnodes_read(): grid size (%d x %d) is too big\n", gn->nx, gn->ny); if (type == NT_DD) { if (gn->nx % 2 == 0) gu_quit("gridnodes_read(): nx = %d must be odd for double density grid nodes\n", gn->nx); if (gn->ny % 2 == 0) gu_quit("gridnodes_read(): ny = %d must be odd for double density grid nodes\n", gn->ny); } /* * allocate storage */ gn->gx = gu_alloc2d(gn->nx, gn->ny, sizeof(double)); gn->gy = gu_alloc2d(gn->nx, gn->ny, sizeof(double)); /* * read grid nodes */ for (j = 0, xx = gn->gx[0], yy = gn->gy[0], count = 0; j < gn->ny; ++j) { for (i = 0; i < gn->nx; ++i, ++xx, ++yy) { if (fgets(buf, BUFSIZE, f) == NULL) gu_quit("%s: could not read %d-th point (%d x %d points expected)\n", fname, j * gn->nx + i + 1, gn->nx, gn->ny); if (sscanf(buf, "%lf %lf", xx, yy) != 2) { *xx = NaN; *yy = NaN; continue; } if (!isnan(*xx)) count++; } } if (gu_verbose) { fprintf(stderr, "## %d non-empty grid nodes (%.1f%%)\n", count, 100.0 * count / gn->nx / gn->ny); fflush(stderr); } if (f != stdin) fclose(f); gn->validated = 0; gn->stats = NULL; return gn; } /* Constructor. Creates an empty grid. * * @param nx Number of columns * @param nx Number of rows * @param type Node type * @return Gridnodes structure */ gridnodes* gridnodes_create(int nx, int ny, NODETYPE type) { gridnodes* gn = malloc(sizeof(gridnodes)); gn->nx = nx; gn->ny = ny; gn->gx = gu_alloc2d(nx, ny, sizeof(double)); gn->gy = gu_alloc2d(nx, ny, sizeof(double)); gn->type = type; gn->validated = 0; gn->stats = NULL; gn->nextpoint = 0; return gn; } /* Allows to fill the created gridnodes object point by point. * * @param gn Grid nodes * @param x X coordinate * @param y Y coordinate */ void gridnodes_readnextpoint(gridnodes* gn, double x, double y) { int j = gn->nextpoint / gn->nx; int i = gn->nextpoint % gn->nx; gn->gx[j][i] = x; gn->gy[j][i] = y; gn->nextpoint = (gn->nextpoint + 1) % (gn->nx * gn->ny); } /* Destructor. * @param gn Grid nodes */ void gridnodes_destroy(gridnodes* gn) { if (gn->stats != NULL) free(gn->stats); gu_free2d(gn->gx); gu_free2d(gn->gy); free(gn); } /* * A grid generator calculates particular nodes in double density grid just as * a set of points. Therefore, there may be cells with only some of the * bounding double-density nodes valid (not NaNs), and such cells must be * marked as "non-valid". * * Following is a set of rules used for marking the cells in DD grid: * * 1. Gridwise, a cell is defined by its four corner nodes: a cell is valid if * and only if all four corner cells are valid (not NaNs). * 2. A modeller may use the centre node to mark a cell as non-valid within * an application (e.g. to mark it as a land cell or an outside cell). * 3. A modeler may use edge nodes (those in between corner cells) to mark * an edge as non-valid within an application (e.g. to mark it as a * non-penetrable edge). * * The following validation procedures are supposed to exclude non-valid cells * from the grid. * * Note: theoretically, it is possible that one or more of the four edge nodes * or the centre node will come from the grid generator as NaNs, while all * four corner nodes come as valid nodes. For now, to restore these values from * the corner values, use gridnodes_transform() procedure to transform the grid * from NT_COR to NT_DD type (transform to NT_COR first if you start from NT_DD * grid). */ /* Validates double density grid nodes. * @param gn Grid nodes */ static void gridnodes_validate_dd(gridnodes* gn) { int nx = gn->nx; int ny = gn->ny; double** x = gn->gx; double** y = gn->gy; int count; int i, j; /* * corner nodes: * * mark as non-valid if one or more of the other three corner nodes in each * of the four adjacent cells are non-valid; otherwise leave as is */ for (j = 0; j < ny; j += 2) { for (i = 0; i < nx; i += 2) { if (j > 0 && i > 0 && !isnan(x[j - 2][i - 2]) && !isnan(x[j - 2][i]) && !isnan(x[j][i - 2])) continue; if (j + 2 < ny && i > 0 && !isnan(x[j + 2][i - 2]) && !isnan(x[j + 2][i]) && !isnan(x[j][i - 2])) continue; if (j > 0 && i + 2 < nx && !isnan(x[j - 2][i + 2]) && !isnan(x[j - 2][i]) && !isnan(x[j][i + 2])) continue; if (j + 2 < ny && i + 2 < nx && !isnan(x[j + 2][i + 2]) && !isnan(x[j + 2][i]) && !isnan(x[j][i + 2])) continue; x[j][i] = NaN; y[j][i] = NaN; } } /* * centre nodes: * * mark as non-valid if one or more of the four adjacent corner cells is * non-valid; otherwise leave as is * * (note that it is possible for a valid cell to have a non-valid edge * node; this can be a way to mark an impenetrable face) */ for (j = 1; j < ny; j += 2) { for (i = 1; i < nx; i += 2) { if (isnan(x[j][i])) continue; if (isnan(x[j - 1][i - 1]) || isnan(x[j - 1][i + 1]) || isnan(x[j + 1][i - 1]) || isnan(x[j + 1][i + 1])) { x[j][i] = NaN; y[j][i] = NaN; } } } /* * edge nodes: * * mark as non-valid if one or more of the two adjacent corner cells are * non-valid; otherwise leave as is */ for (j = 0; j < ny; j += 2) { for (i = 1; i < nx; i += 2) { if (isnan(x[j][i])) continue; if ((i - 1 >= 0 && isnan(x[j][i - 1])) || (i + 1 < nx && isnan(x[j][i + 1]))) { x[j][i] = NaN; y[j][i] = NaN; } } } for (j = 1; j < ny; j += 2) { for (i = 0; i < nx; i += 2) { if (isnan(x[j][i])) continue; if ((j - 1 >= 0 && isnan(x[j - 1][i])) || (j + 1 < ny && isnan(x[j + 1][i]))) { x[j][i] = NaN; y[j][i] = NaN; } } } /* * count valid cells */ if (gu_verbose) { for (j = 1, count = 0; j < ny; j += 2) for (i = 1; i < nx; i += 2) if (!isnan(x[j][i])) count++; fprintf(stderr, "## %d valid cells (%.1f%%)\n", count, count * 100.0 / (nx / 2) / (ny / 2)); } } /* Validates corner grid nodes. * @param gn Grid nodes */ static void gridnodes_validate_cor(gridnodes* gn) { int nx = gn->nx; int ny = gn->ny; double** x = gn->gx; double** y = gn->gy; int count; int i, j; for (j = 0; j < ny; ++j) { for (i = 0; i < nx; ++i) { if (i > 0 && j > 0 && !isnan(x[j - 1][i - 1]) && !isnan(x[j - 1][i]) && !isnan(x[j][i - 1])) continue; if (i > 0 && j < ny - 1 && !isnan(x[j][i - 1]) && !isnan(x[j + 1][i - 1]) && !isnan(x[j + 1][i])) continue; if (i < nx - 1 && j > 0 && !isnan(x[j - 1][i]) && !isnan(x[j - 1][i + 1]) && !isnan(x[j][i + 1])) continue; if (i < nx - 1 && j < ny - 1 && !isnan(x[j + 1][i]) && !isnan(x[j][i + 1]) && !isnan(x[j + 1][i + 1])) continue; /* * the node does not belong to any valid cell around it */ x[j][i] = NaN; y[j][i] = NaN; } } if (gu_verbose) { ny--; nx--; for (j = 0, count = 0; j < ny; ++j) for (i = 0; i < nx; ++i) if (!isnan(x[j + 1][i + 1]) && !isnan(x[j + 1][i]) && !isnan(x[j][i + 1]) && !isnan(x[j][i])) count++; fprintf(stderr, "## %d valid cells (%.1f%%)\n", count, count * 100.0 / nx / ny); } } /* Validates grid nodes. * Sets all nodes not belonging to any valid cells to NaNs. * @param gn Grid nodes */ void gridnodes_validate(gridnodes* gn) { if (gu_verbose) fprintf(stderr, "## grid validation:\n"); if (gn->type == NT_DD) gridnodes_validate_dd(gn); else if (gn->type == NT_COR) gridnodes_validate_cor(gn); else if (gu_verbose) fprintf(stderr, "## gridnodes_validate(): nothing to do for nodes of \"%s\" type\n", nodetype2str[gn->type]); gn->validated = 1; if (gu_verbose) fflush(stdout); } /* Makes a deep copy of grid nodes. * @param old Source grid nodes * @return Destination grid nodes */ gridnodes* gridnodes_copy(gridnodes* old) { gridnodes* new = malloc(sizeof(gridnodes)); new->nx = old->nx; new->ny = old->ny; new->type = old->type; new->gx = gu_alloc2d(old->nx, old->ny, sizeof(double)); new->gy = gu_alloc2d(old->nx, old->ny, sizeof(double)); memcpy(&new->gx[0][0], &old->gx[0][0], old->nx * old->ny * sizeof(double)); memcpy(&new->gy[0][0], &old->gy[0][0], old->nx * old->ny * sizeof(double)); return new; } /* Makes a deep copy of subgrid nodes with indices [imin:imax][jmin:jmax]. * @param old Source grid nodes * @param imin Minimal i index * @param imax Maximal i index * @param jmin Minimal j index * @param jmax Maximal j index * @return Destination grid nodes */ gridnodes* gridnodes_subgrid(gridnodes* gn, int imin, int imax, int jmin, int jmax) { gridnodes* new = NULL; int i, j, ii, jj; if (imin < 0) imin = 0; if (imax >= gn->nx) imax = gn->nx - 1; if (jmin < 0) jmin = 0; if (jmax >= gn->ny) jmax = gn->ny - 1; if (imin == 0 && imax == gn->nx - 1 && jmin == 0 && jmax == gn->ny - 1) return gridnodes_copy(gn); new = malloc(sizeof(gridnodes)); new->nx = imax - imin + 1; new->ny = jmax - jmin + 1; new->gx = gu_alloc2d(new->nx, new->ny, sizeof(double)); new->gy = gu_alloc2d(new->nx, new->ny, sizeof(double)); for (j = jmin, jj = 0; j <= jmax; ++j, ++jj) { for (i = imin, ii = 0; i <= imax; ++i, ++ii) { new->gx[jj][ii] = gn->gx[j][i]; new->gy[jj][ii] = gn->gy[j][i]; } } return new; } /* Calculates (x,y) coordinates from fractional indices (fi,fj) using mapping * of the cell (i,j). * * The transformation used to compute the coords is a forward * tetragonal bilinear texture mapping. * * @param gn Pointer to the gridnodes structure used for mapping * @param fi I index value * @param fj J index value * @param i I index of the cell to be used for mapping * @param j J index of the cell to be used for mapping * @param x Pointer to returned X coordinate * @param y Pointer to returned Y coordinate * @return non-zero if successful */ static void fij2xy(gridnodes* gn, double fi, double fj, int i, int j, double* x, double* y) { double u, v; double** gx = gn->gx; double** gy = gn->gy; double a, b, c, d, e, f, g, h; u = fi - i; v = fj - j; if (u == 0.0 && v == 0.0) { *x = gx[j][i]; *y = gy[j][i]; } else if (u == 0.0) { *x = gx[j + 1][i] * v + gx[j][i] * (1.0 - v); *y = gy[j + 1][i] * v + gy[j][i] * (1.0 - v); } else if (v == 0.0) { *x = gx[j][i + 1] * u + gx[j][i] * (1.0 - u); *y = gy[j][i + 1] * u + gy[j][i] * (1.0 - u); } else { a = gx[j][i] - gx[j][i + 1] - gx[j + 1][i] + gx[j + 1][i + 1]; b = gx[j][i + 1] - gx[j][i]; c = gx[j + 1][i] - gx[j][i]; d = gx[j][i]; e = gy[j][i] - gy[j][i + 1] - gy[j + 1][i] + gy[j + 1][i + 1]; f = gy[j][i + 1] - gy[j][i]; g = gy[j + 1][i] - gy[j][i]; h = gy[j][i]; *x = a * u * v + b * u + c * v + d; *y = e * u * v + f * u + g * v + h; } } /* Transforms grid nodes of one type into grid nodes of another type. * @param gn Grid nodes * @param type Type of new grid nodes * @return New grid nodes */ gridnodes* gridnodes_transform(gridnodes* gn, NODETYPE type) { gridnodes* gn1 = NULL; int i, j, i1, j1; if (!gn->validated) gridnodes_validate(gn); if (gn->type == type || type == NT_NONE) return gridnodes_copy(gn); gn1 = malloc(sizeof(gridnodes)); gn1->type = type; gn1->stats = NULL; if (gn->type == NT_DD) { if (type == NT_COR) { gn1->nx = gn->nx / 2 + 1; gn1->ny = gn->ny / 2 + 1; gn1->gx = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); gn1->gy = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); for (j = 0, j1 = 0; j < gn->ny; j += 2, ++j1) { for (i = 0, i1 = 0; i < gn->nx; i += 2, ++i1) { gn1->gx[j1][i1] = gn->gx[j][i]; gn1->gy[j1][i1] = gn->gy[j][i]; } } } else if (type == NT_CEN) { gn1->nx = gn->nx / 2; gn1->ny = gn->ny / 2; gn1->gx = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); gn1->gy = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); for (j = 1, j1 = 0; j < gn->ny; j += 2, ++j1) { for (i = 1, i1 = 0; i < gn->nx; i += 2, ++i1) { gn1->gx[j1][i1] = gn->gx[j][i]; gn1->gy[j1][i1] = gn->gy[j][i]; } } } } else if (gn->type == NT_COR) { if (type == NT_CEN) { gridmap* gm = gridmap_build(gn->nx - 1, gn->ny - 1, gn->gx, gn->gy); gn1->nx = gn->nx - 1; gn1->ny = gn->ny - 1; gn1->gx = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); gn1->gy = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); /* * this may take a while */ for (i = 0; i < gn1->nx; ++i) for (j = 0; j < gn1->ny; ++j) gridmap_fij2xy(gm, i + 0.5, j + 0.5, &gn1->gx[j][i], &gn1->gy[j][i]); gridmap_destroy(gm); } else if (type == NT_DD) { gridmap* gm = gridmap_build(gn->nx - 1, gn->ny - 1, gn->gx, gn->gy); gn1->nx = gn->nx * 2 - 1; gn1->ny = gn->ny * 2 - 1; gn1->gx = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); gn1->gy = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); /* * this may take a while */ for (i = 0; i < gn1->nx; ++i) for (j = 0; j < gn1->ny; ++j) gridmap_fij2xy(gm, i / 2.0, j / 2.0, &gn1->gx[j][i], &gn1->gy[j][i]); gridmap_destroy(gm); } } else if (gn->type == NT_CEN) { if (type == NT_COR) { kdtree* kt = kd_create(2); /* 2 dimensions */ gn1->nx = gn->nx + 1; gn1->ny = gn->ny + 1; gn1->gx = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); gn1->gy = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); /* * put positions of the cells formed by cell centers into kd tree */ for (i = 0; i < gn->nx - 1; ++i) { for (j = 0; j < gn->ny - 1; ++j) { if (!isnan(gn->gx[j][i]) && !isnan(gn->gx[j + 1][i]) && !isnan(gn->gx[j][i + 1]) && !isnan(gn->gx[j + 1][i + 1])) { double pos[2]; pos[0] = (double) i + 0.5; pos[1] = (double) j + 0.5; kd_insert(kt, pos, NULL); } } } /* * for each node coordinate find the nearest point in the kd tree; * if it is in a neighbour cell - then extrapolate the cell * position using the mapping of this cell */ for (i = 0; i < gn1->nx; ++i) { for (j = 0; j < gn1->ny; ++j) { double pos[2]; double pos1[2]; kdres* nearest = NULL; pos[0] = (double) i - 0.5; pos[1] = (double) j - 0.5; nearest = kd_nearest(kt, pos); kd_res_item(nearest, pos1); if (hypot(pos1[0] - pos[0], pos1[1] - pos[1]) < 1.5) { fij2xy(gn, pos[0], pos[1], (int) pos1[0], (int) pos1[1], &gn1->gx[j][i], &gn1->gy[j][i]); } else { gn1->gx[j][i] = NaN; gn1->gy[j][i] = NaN; } } } gn->type = NT_COR; gridnodes_validate_cor(gn1); kd_free(kt); } else if (type == NT_DD) { kdtree* kt = kd_create(2); /* 2 dimensions */ gn1->nx = gn->nx * 2 + 1; gn1->ny = gn->ny * 2 + 1; gn1->gx = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); gn1->gy = gu_alloc2d(gn1->nx, gn1->ny, sizeof(double)); /* * put positions of the cells formed by cell centers into kd tree */ for (i = 0; i < gn->nx - 1; ++i) { for (j = 0; j < gn->ny - 1; ++j) { if (!isnan(gn->gx[j][i]) && !isnan(gn->gx[j + 1][i]) && !isnan(gn->gx[j][i + 1]) && !isnan(gn->gx[j + 1][i + 1])) { double pos[2]; pos[0] = (double) i + 0.5; pos[1] = (double) j + 0.5; kd_insert(kt, pos, NULL); } } } /* * for each node coordinate find the nearest point in the kd tree; * if it is in a neighbour cell - then extrapolate the cell * position using the mapping of this cell */ for (i = 0; i < gn1->nx; ++i) { for (j = 0; j < gn1->ny; ++j) { double pos[2]; double pos1[2]; kdres* nearest = NULL; pos[0] = (double) i / 2.0 - 0.5; pos[1] = (double) j / 2.0 - 0.5; nearest = kd_nearest(kt, pos); kd_res_item(nearest, pos1); if (hypot(pos1[0] - pos[0], pos1[1] - pos[1]) < 1.5) { fij2xy(gn, pos[0], pos[1], (int) pos1[0], (int) pos1[1], &gn1->gx[j][i], &gn1->gy[j][i]); } else { gn1->gx[j][i] = NaN; gn1->gy[j][i] = NaN; } } } gn->type = NT_DD; gridnodes_validate_dd(gn1); kd_free(kt); } } gn1->validated = 1; /* an internally generated grid is supposed * to be OK */ return gn1; } void gridnodes_applymask(gridnodes* gn, int** mask) { if (gn->type == NT_DD) { double** x = gn->gx; double** y = gn->gy; int nx = gn->nx; int ny = gn->ny; int i, j, ii, jj; for (j = 1, jj = 0; j < ny; j += 2, ++jj) { for (i = 1, ii = 0; i < nx; i += 2, ++ii) { if (mask[jj][ii] == 0) { x[j][i] = NaN; y[j][i] = NaN; } } } /* * corner nodes: * * mark as non-valid if all four center nodes of the adjacent cells are * non-valid */ for (j = 0; j < ny; j += 2) { for (i = 0; i < nx; i += 2) { if (j > 0 && i > 0 && !isnan(x[j - 1][i - 1])) continue; if (j + 1 < ny && i > 0 && !isnan(x[j + 1][i - 1])) continue; if (j > 0 && i + 1 < nx && !isnan(x[j - 1][i + 1])) continue; if (j + 1 < ny && i + 1 < nx && !isnan(x[j + 1][i + 1])) continue; x[j][i] = NaN; y[j][i] = NaN; } } gridnodes_validate(gn); } else if (gn->type == NT_CEN) { double** x = gn->gx; double** y = gn->gy; int nx = gn->nx; int ny = gn->ny; int i, j; for (j = 0; j < ny; j++) { for (i = 0; i < nx; i++) { if (mask[j][i] == 0) { x[j][i] = NaN; y[j][i] = NaN; } } } } else if (gn->type == NT_COR) gu_quit("gridnodes_applymask(): applying mask to nodes of type \"%s\" is not supported\n", nodetype2str[NT_COR]); else if (gn->type == NT_NONE) gu_quit("gridnodes_applymask(): nodes type not specified\n"); } /* Writes grid nodes into a file. * @param gn Grid nodes * @param fname File name; can be "stdout" * @param ctype Output coordinate type: CT_XY for XY, CT_X for X and CT_Y for Y */ void gridnodes_write(gridnodes* gn, char* fname, COORDTYPE ctype) { FILE* f = NULL; double** x = gn->gx; double** y = gn->gy; int nx = gn->nx; int ny = gn->ny; int count = 0; int i, j; if (gu_verbose) { fprintf(stderr, "## grid output: writing to \"%s\"\n", fname); fprintf(stderr, "## %d x %d grid\n", gn->nx, gn->ny); } if (!strcasecmp(fname, "stdout")) { f = stdout; } else f = gu_fopen(fname, "w"); fprintf(f, "## %d x %d\n", nx, ny); if (ctype == CT_XY) { for (j = 0; j < ny; ++j) { for (i = 0; i < nx; ++i) { if (isnan(x[j][i])) fprintf(f, "NaN NaN\n"); else { fprintf(f, "%.15g %.15g\n", x[j][i], y[j][i]); count++; } } } } else if (ctype == CT_X) { for (j = 0; j < ny; ++j) { for (i = 0; i < nx; ++i) { if (isnan(x[j][i])) fprintf(f, "NaN\n"); else { fprintf(f, "%.15g\n", x[j][i]); count++; } } } } else if (ctype == CT_Y) { for (j = 0; j < ny; ++j) { for (i = 0; i < nx; ++i) { if (isnan(x[j][i])) fprintf(f, "NaN\n"); else { fprintf(f, "%.15g\n", y[j][i]); count++; } } } } if (gu_verbose) fprintf(stderr, "## %d non-empty grid nodes (%.1f%%)\n", count, 100.0 * count / gn->nx / gn->ny); if (f != stdout) fclose(f); else fflush(stdout); } static void gridstats_init(gridstats* gs) { gs->mdo = NaN; gs->imdo = -1; gs->jmdo = -1; gs->ado = NaN; gs->mar = NaN; gs->aar = NaN; } static double dtheta(double x1, double y1, double x2, double y2) { double cos_th = (x1 * x2 + y1 * y2) / hypot(x1, y1) / hypot(x2, y2) / 2.0; double th = acos(cos_th) * 180.0 / M_PI; double dth = fabs(90.0 - th); return dth; } static void gridnodes_calcstats_cor(gridnodes* gn) { int nx = gn->nx - 1; int ny = gn->ny - 1; double** x = gn->gx; double** y = gn->gy; double dor_sum = 0.0; double dor_max = 0.0; double ar_max = 1.0; double ar_sum = 0.0; int ncell = 0; int imdo = -1; int jmdo = -1; int i, j; if (gn->stats == NULL) gn->stats = malloc(sizeof(gridstats)); gridstats_init(gn->stats); for (j = 0; j < ny; ++j) for (i = 0; i < nx; ++i) if (!isnan(x[j + 1][i + 1]) && !isnan(x[j + 1][i]) && !isnan(x[j][i + 1]) && !isnan(x[j][i])) { double dor[4]; double ar; int k; dor[0] = dtheta(x[j][i + 1] - x[j][i], y[j][i + 1] - y[j][i], x[j + 1][i] - x[j][i], y[j + 1][i] - y[j][i]); dor[1] = dtheta(x[j + 1][i + 1] - x[j][i + 1], y[j + 1][i + 1] - y[j][i + 1], x[j][i + 1] - x[j][i], y[j][i + 1] - y[j][i]); dor[2] = dtheta(x[j + 1][i] - x[j + 1][i + 1], y[j + 1][i] - y[j + 1][i + 1], x[j + 1][i + 1] - x[j][i + 1], y[j + 1][i + 1] - y[j][i + 1]); dor[3] = dtheta(x[j + 1][i] - x[j + 1][i + 1], y[j + 1][i] - y[j + 1][i + 1], x[j + 1][i] - x[j][i], y[j + 1][i] - y[j][i]); for (k = 0; k < 4; ++k) { if (dor[k] > dor_max) { dor_max = dor[k]; imdo = i; jmdo = j; } dor_sum += dor[k]; } ar = hypot(x[j][i] + x[j][i + 1] - x[j + 1][i] - x[j + 1][i + 1], y[j][i] + y[j][i + 1] - y[j + 1][i] - y[j + 1][i + 1]) / hypot(x[j][i] + x[j + 1][i] - x[j][i + 1] - x[j + 1][i + 1], y[j][i] + y[j + 1][i] - y[j][i + 1] - y[j + 1][i + 1]); if (ar < 1.0) ar = 1.0 / ar; if (ar > ar_max) ar_max = ar; ar_sum += ar; ncell++; } gn->stats->mdo = dor_max; gn->stats->imdo = imdo; gn->stats->jmdo = jmdo; gn->stats->ado = dor_sum / ncell / 4.0; gn->stats->mar = ar_max; gn->stats->aar = ar_sum / ncell; } void gridnodes_calcstats(gridnodes* gn) { gridnodes* gn1; if (gn->stats == NULL) gn->stats = malloc(sizeof(gridstats)); gridstats_init(gn->stats); if (gn->type == NT_CEN || gn->type == NT_NONE) { if (gu_verbose) fprintf(stderr, "## gridnodes_calcstats(): do not know what to do with nodes of \"%s\" type\n", nodetype2str[gn->type]); return; } if (!gn->validated) gridnodes_validate(gn); gn1 = (gn->type == NT_COR) ? gn : gridnodes_transform(gn, NT_COR); gridnodes_calcstats_cor(gn1); if (gn->type != NT_COR) { memcpy(gn->stats, gn1->stats, sizeof(gridstats)); gridnodes_destroy(gn1); } if (gu_verbose) { fprintf(stderr, "## maximum deviation from orthogonality = %.3f deg, in cell (%d,%d)\n", gn->stats->mdo, gn->stats->imdo, gn->stats->jmdo); fprintf(stderr, "## mean deviation from orthogonality = %.3f deg\n", gn->stats->ado); fprintf(stderr, "## maximum aspect ratio = %.3f\n", gn->stats->mar); fprintf(stderr, "## mean aspect ratio = %.3f\n", gn->stats->aar); } } int gridnodes_getnx(gridnodes* gn) { return gn->nx; } int gridnodes_getny(gridnodes* gn) { return gn->ny; } double** gridnodes_getx(gridnodes* gn) { return gn->gx; } double** gridnodes_gety(gridnodes* gn) { return gn->gy; } int gridnodes_getnce1(gridnodes* gn) { if (gn->type == NT_DD) return (gn->nx - 1) / 2; else if (gn->type == NT_COR) return gn->nx - 1; else if (gn->type == NT_CEN) return gn->nx; else gu_quit("gridnodes_getnce1(): node type not specified\n"); return 0; } int gridnodes_getnce2(gridnodes* gn) { if (gn->type == NT_DD) return (gn->ny - 1) / 2; else if (gn->type == NT_COR) return gn->ny - 1; else if (gn->type == NT_CEN) return gn->ny; else gu_quit("gridnodes_getnce2(): node type not specified\n"); return 0; }
ff1e57ae7bb3c36d164dc12b4e7f98175737dc0d
e683a0b8dbb87c7ceb99e0d06896174a559d2c67
/Tools/swat/curses/cr_put.c
fe8e8f9686fd92b890b5367bc581890b550a94dd
[ "Apache-2.0" ]
permissive
bluewaysw/pcgeos
f093d79567d977d992f47065056d14d5a04b9f14
c6ae4c8e77b54b9ff654c3916f2191f8b1a1b65d
refs/heads/master
2023-08-31T00:17:54.481175
2023-08-29T19:00:49
2023-08-29T19:00:49
157,968,410
603
88
Apache-2.0
2023-09-13T07:44:06
2018-11-17T09:09:55
Assembly
UTF-8
C
false
false
8,511
c
cr_put.c
/* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef lint static char sccsid[] = "@(#)cr_put.c 5.1 (Berkeley) 6/7/85"; #endif not lint # include "curses.ext" # define HARDTABS 8 #if !defined(_MSDOS) extern char *tgoto(); int plodput(); #endif /* * Terminal driving and line formatting routines. * Basic motion optimizations are done here as well * as formatting of lines (printing of control characters, * line numbering and the like). */ /* * Sync the position of the output cursor. * Most work here is rounding for terminal boundaries getting the * column position implied by wraparound or the lack thereof and * rolling up the screen to get destline on the screen. */ static int outcol, outline, destcol, destline; extern WINDOW *_win; mvcur(ly, lx, y, x) int ly, lx, y, x; { #ifdef DEBUG fprintf(outf, "MVCUR: moving cursor from (%d,%d) to (%d,%d)\n", ly, lx, y, x); #endif destcol = x; destline = y; outcol = lx; outline = ly; fgoto(); } fgoto() { reg char *cgp; reg int l, c; if (destcol >= COLS) { destline += destcol / COLS; destcol %= COLS; } if (outcol >= COLS) { l = (outcol + 1) / COLS; outline += l; outcol %= COLS; #if !defined(_MSDOS) /* DOS implementation always wraps */ if (AM == 0) { while (l > 0) { if (_pfast) if (CR) _puts(CR); else _putchar('\r'); if (NL) _puts(NL); else _putchar('\n'); l--; } outcol = 0; } #endif /* _MSDOS */ if (outline > LINES - 1) { destline -= outline - (LINES - 1); outline = LINES - 1; } } if (destline >= LINES) { l = destline; destline = LINES - 1; if (outline < LINES - 1) { c = destcol; if (_pfast == 0 && !CA) destcol = 0; fgoto(); destcol = c; } while (l >= LINES) { /* * The following linefeed (or simulation thereof) * is supposed to scroll up the screen, since we * are on the bottom line. We make the assumption * that linefeed will scroll. If ns is in the * capability list this won't work. We should * probably have an sc capability but sf will * generally take the place if it works. * * Superbee glitch: in the middle of the screen we * have to use esc B (down) because linefeed screws up * in "Efficient Paging" (what a joke) mode (which is * essential in some SB's because CRLF mode puts garbage * in at end of memory), but you must use linefeed to * scroll since down arrow won't go past memory end. * I turned this off after recieving Paul Eggert's * Superbee description which wins better. */ #if !defined(_MSDOS) if (NL /* && !XB */ && _pfast) _puts(NL); else _putchar('\n'); #else DosNewLine(); #endif l--; if (_pfast == 0) outcol = 0; } } if (destline < outline && !(CA || UP)) destline = outline; #if !defined(_MSDOS) if (CA) { cgp = tgoto(CM, destcol, destline); if (plod(strlen(cgp)) > 0) plod(0); else tputs(cgp, 0, _putchar); } else plod(0); #else /* Cursor motion always supported under DOS */ DosGoto(destcol, destline); #endif outline = destline; outcol = destcol; } #if !defined(_MSDOS) /* Should never need this under DOS... */ /* * Move (slowly) to destination. * Hard thing here is using home cursor on really deficient terminals. * Otherwise just use cursor motions, hacking use of tabs and overtabbing * and backspace. */ static int plodcnt, plodflg; plodput(c) { if (plodflg) plodcnt--; else _putchar(c); } plod(cnt) { register int i, j, k; register int soutcol, soutline; plodcnt = plodflg = cnt; soutcol = outcol; soutline = outline; /* * Consider homing and moving down/right from there, vs moving * directly with local motions to the right spot. */ if (HO) { /* * i is the cost to home and tab/space to the right to * get to the proper column. This assumes ND space costs * 1 char. So i+destcol is cost of motion with home. */ if (GT) i = (destcol / HARDTABS) + (destcol % HARDTABS); else i = destcol; /* * j is cost to move locally without homing */ if (destcol >= outcol) { /* if motion is to the right */ j = destcol / HARDTABS - outcol / HARDTABS; if (GT && j) j += destcol % HARDTABS; else j = destcol - outcol; } else /* leftward motion only works if we can backspace. */ if (outcol - destcol <= i && (BS || BC)) i = j = outcol - destcol; /* cheaper to backspace */ else j = i + 1; /* impossibly expensive */ /* k is the absolute value of vertical distance */ k = outline - destline; if (k < 0) k = -k; j += k; /* * Decision. We may not have a choice if no UP. */ if (i + destline < j || (!UP && destline < outline)) { /* * Cheaper to home. Do it now and pretend it's a * regular local motion. */ tputs(HO, 0, plodput); outcol = outline = 0; } else if (LL) { /* * Quickly consider homing down and moving from there. * Assume cost of LL is 2. */ k = (LINES - 1) - destline; if (i + k + 2 < j && (k<=0 || UP)) { tputs(LL, 0, plodput); outcol = 0; outline = LINES - 1; } } } else /* * No home and no up means it's impossible. */ if (!UP && destline < outline) return -1; if (GT) i = destcol % HARDTABS + destcol / HARDTABS; else i = destcol; /* if (BT && outcol > destcol && (j = (((outcol+7) & ~7) - destcol - 1) >> 3)) { j *= (k = strlen(BT)); if ((k += (destcol&7)) > 4) j += 8 - (destcol&7); else j += k; } else */ j = outcol - destcol; /* * If we will later need a \n which will turn into a \r\n by * the system or the terminal, then don't bother to try to \r. */ if ((NONL || !_pfast) && outline < destline) goto dontcr; /* * If the terminal will do a \r\n and there isn't room for it, * then we can't afford a \r. */ if (NC && outline >= destline) goto dontcr; /* * If it will be cheaper, or if we can't back up, then send * a return preliminarily. */ if (j > i + 1 || outcol > destcol && !BS && !BC) { /* * BUG: this doesn't take the (possibly long) length * of CR into account. */ if (CR) tputs(CR, 0, plodput); else plodput('\r'); if (NC) { if (NL) tputs(NL, 0, plodput); else plodput('\n'); outline++; } outcol = 0; } dontcr: while (outline < destline) { outline++; if (NL) tputs(NL, 0, plodput); else plodput('\n'); if (plodcnt < 0) goto out; if (NONL || _pfast == 0) outcol = 0; } if (BT) k = strlen(BT); while (outcol > destcol) { if (plodcnt < 0) goto out; /* if (BT && outcol - destcol > k + 4) { tputs(BT, 0, plodput); outcol--; outcol &= ~7; continue; } */ outcol--; if (BC) tputs(BC, 0, plodput); else plodput('\b'); } while (outline > destline) { outline--; tputs(UP, 0, plodput); if (plodcnt < 0) goto out; } if (GT && destcol - outcol > 1) { for (;;) { i = tabcol(outcol, HARDTABS); if (i > destcol) break; if (TA) tputs(TA, 0, plodput); else plodput('\t'); outcol = i; } if (destcol - outcol > 4 && i < COLS && (BC || BS)) { if (TA) tputs(TA, 0, plodput); else plodput('\t'); outcol = i; while (outcol > destcol) { outcol--; if (BC) tputs(BC, 0, plodput); else plodput('\b'); } } } while (outcol < destcol) { /* * move one char to the right. We don't use ND space * because it's better to just print the char we are * moving over. */ if (_win != NULL) if (plodflg) /* avoid a complex calculation */ plodcnt--; else { i = curscr->_y[outline][outcol]; if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT)) _putchar(i); else goto nondes; } else nondes: if (ND) tputs(ND, 0, plodput); else plodput(' '); outcol++; if (plodcnt < 0) goto out; } out: if (plodflg) { outcol = soutcol; outline = soutline; } return(plodcnt); } /* * Return the column number that results from being in column col and * hitting a tab, where tabs are set every ts columns. Work right for * the case where col > COLS, even if ts does not divide COLS. */ tabcol(col, ts) int col, ts; { int offset, result; if (col >= COLS) { offset = COLS * (col / COLS); col -= offset; } else offset = 0; return col + ts - (col % ts) + offset; } #endif /* !_MSDOS */
a7a5ff358eee3e96db9bff4979bb309fe98035fb
a65e2aac013b48ddfe5d6a7d108c2b84855d1148
/boot/zcbor/include/zcbor_debug.h
5f9b4778ff1ec77713bc4a39360bb382a85a3ce8
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
mcu-tools/mcuboot
25ccdee3b1d319e09c9381cd00bc854efdc0142b
e188dbb0e1c1e2e2cecd627fbf2e13042222b1da
refs/heads/main
2023-08-30T09:17:10.520597
2023-08-29T06:43:16
2023-08-29T14:01:02
76,305,806
623
320
Apache-2.0
2023-09-13T11:46:03
2016-12-12T23:53:39
C
UTF-8
C
false
false
1,515
h
zcbor_debug.h
/* * Copyright (c) 2020 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #ifndef ZCBOR_DEBUG_H__ #define ZCBOR_DEBUG_H__ #include <stdint.h> #include <stdbool.h> #include <stddef.h> #include "zcbor_common.h" #ifdef __cplusplus extern "C" { #endif __attribute__((used)) static void zcbor_print_compare_lines(const uint8_t *str1, const uint8_t *str2, uint32_t size) { for (uint32_t j = 0; j < size; j++) { printk ("%x ", str1[j]); } printk("\r\n"); for (uint32_t j = 0; j < size; j++) { printk ("%x ", str2[j]); } printk("\r\n"); for (uint32_t j = 0; j < size; j++) { printk ("%x ", str1[j] != str2[j]); } printk("\r\n"); printk("\r\n"); } __attribute__((used)) static void zcbor_print_compare_strings(const uint8_t *str1, const uint8_t *str2, uint32_t size) { for (uint32_t i = 0; i <= size / 16; i++) { printk("line %d (char %d)\r\n", i, i*16); zcbor_print_compare_lines(&str1[i*16], &str2[i*16], MIN(16, (size - i*16))); } printk("\r\n"); } __attribute__((used)) static void zcbor_print_compare_strings_diff(const uint8_t *str1, const uint8_t *str2, uint32_t size) { bool printed = false; for (uint32_t i = 0; i <= size / 16; i++) { if (memcmp(&str1[i*16], &str2[i*16], MIN(16, (size - i*16)) != 0)) { printk("line %d (char %d)\r\n", i, i*16); zcbor_print_compare_lines(&str1[i*16], &str2[i*16], MIN(16, (size - i*16))); printed = true; } } if (printed) { printk("\r\n"); } } #ifdef __cplusplus } #endif #endif /* ZCBOR_DEBUG_H__ */