blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
268
content_id
stringlengths
40
40
detected_licenses
listlengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
5
118
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
816 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
2.31k
677M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
151 values
src_encoding
stringclasses
33 values
language
stringclasses
1 value
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
3
10.3M
extension
stringclasses
119 values
content
stringlengths
3
10.3M
authors
listlengths
1
1
author_id
stringlengths
0
228
0bedcd29a446f8aaaef5bc6d3d55c2ca66d100d2
0d1336c731fef5d52c1ca1a3584d3eb9eb4a50ec
/C/URI - 1010 - C - Cálculo Simples.c
25d01084cdb807e407e2d81a35ba715b6f5b5549
[]
no_license
DiegojSts/atividades_algoritmos_uri
ed138b5ee41675fd11ad6e0bbae5d45f50d7df65
7cd840d5e9a6f994b58e8d52ae79036ddb428dc2
refs/heads/master
2023-02-26T19:59:51.637552
2021-02-03T19:30:02
2021-02-03T19:30:02
null
0
0
null
null
null
null
ISO-8859-1
C
false
false
1,052
c
#include <stdio.h> /* Neste problema, deve-se ler o código de uma peça 1, o número de peças 1, o valor unitário de cada peça 1, o código de uma peça 2, o número de peças 2 e o valor unitário de cada peça 2. Após, calcule e mostre o valor a ser pago. Entrada O arquivo de entrada contém duas linhas de dados. Em cada linha haverá 3 valores, respectivamente dois inteiros e um valor com 2 casas decimais. Saída A saída deverá ser uma mensagem conforme o exemplo fornecido abaixo, lembrando de deixar um espaço após os dois pontos e um espaço após o "R$". O valor deverá ser apresentado com 2 casas após o ponto.Faça um programa que leia o nome de um vendedor, o seu salário fixo e o total de vendas efetuadas por ele no mês */ int main() { int cod1, qtd1; int cod2, qtd2; double vl1, vl2, res; scanf("%d %d %lf", &cod1, &qtd1, &vl1); scanf("%d %d %lf", &cod2, &qtd2, &vl2); res = (qtd1 * vl1) + (qtd2 * vl2); printf("VALOR A PAGAR: R$ %.2f\n", res); return 0; }
[ "diegojs03@hotmail.com" ]
diegojs03@hotmail.com
3131d33469d72740aeae3c2296d6758fe4b1102b
699751f70d8320173e811d46df5ee33e93485c66
/0x04-more_functions_nested_loops/9-fizz_buzz.c
cb5d7033d37a3075c291659e8dc87c0d4560daf5
[]
no_license
jenntang1/holbertonschool-low_level_programming
d32296e0c565d54447bf929dd4681af44e6173a8
ec07919d0f384cfac32ca773cf63172296c5d940
refs/heads/master
2020-07-28T04:46:50.733071
2020-04-17T15:22:40
2020-04-17T15:22:40
209,313,514
0
1
null
null
null
null
UTF-8
C
false
false
466
c
#include <stdio.h> /** * main - function to print Fizz-Buzz * * Description: The Fizz-Buzz test * Return: 0 for success. */ int main(void) { int test; for (test = 1; test <= 100; test++) { if (!(test % 15)) { printf("FizzBuzz"); } else if (!(test % 3)) { printf("Fizz"); } else if (!(test % 5)) { printf("Buzz"); } else { printf("%d", test); } if (test != 100) { printf(" "); } } printf("\n"); return (0); }
[ "1039@holbertonschool.com" ]
1039@holbertonschool.com
9b6ecb50f5db82179f459a0ba2be385de0c32599
4fa979e7fe0e4a237b8ba6542d29b9304e8bb08d
/0x09-static_libraries/holberton.h
6c3302b8cc87535f84e26357c69f6e1add930422
[]
no_license
oumaymabg/holbertonschool-low_level_programming
0d6d3e2f73aef4d7e3126d7194a61f4e1f7292bb
b401c437e6319caf30e968bca9d4047835c5522a
refs/heads/master
2023-03-08T22:10:52.478970
2021-02-27T22:22:25
2021-02-27T22:22:25
271,235,619
1
0
null
null
null
null
UTF-8
C
false
false
651
h
int _putchar(char *c); int _islower(int c); int _isalpha(int c); int _abs(int n); int _isupper(int c); int _isdigit(int c); int _strlen(char *s); void _puts(char *s); char *_strcpy(char *dest, char *src); int _atoi(char *s); char *_strcat(char *dest, char *src); char *_strncat(char *dest, char *src, int n); char *_strncpy(char *dest, char *src, int n); int _strcmp(char *s1, char *s2); char *_memset(char *s, char b, unsigned int n); char *_memcpy(char *dest, char *src, unsigned int n); char *_strchr(char *s, char c); unsigned int _strspn(char *s, char *accept); char *_strpbrk(char *s, char *accept); char *_strstr(char *haystack, char *needle);
[ "oumaymabou257@gmail.com" ]
oumaymabou257@gmail.com
d66cebda83c955c0a9b617fd57bc1413e4b3e528
3246ec83bdc97f382c68a0dfe594110b05799080
/crypt.h
5aeab34360ae83ada94a51933bd773f4c88ba5e6
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-info-zip-2009-01", "Info-ZIP", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
zorba-the-geek/zip31d
af8fdc780a8dd218daa3fcc052f9a25c8a2e6539
28f51642df852320a8617f9e70becbdb39c71d8d
refs/heads/master
2020-04-05T01:32:35.702341
2018-11-06T20:01:07
2018-11-06T20:01:07
156,439,998
1
0
null
null
null
null
UTF-8
C
false
false
6,303
h
/* Copyright (c) 1990-2015 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2009-Jan-2 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* crypt.h (full version) by Info-ZIP. The main (Traditional) encryption/decryption source code for Info-Zip software was originally written in Europe. To the best of our knowledge, it can be freely distributed in both source and object forms from any country, including the USA under License Exception TSU of the U.S. Export Administration Regulations (section 740.13(e)) of 6 June 2002. NOTE on copyright history: Some previous versions of this source package (up to version 2.8) were not copyrighted and put in the public domain. If you cannot comply with the Info-Zip LICENSE, you may want to look for one of those public domain versions. */ /* This file is part of the Traditional (ZipCrypto) kit, which includes * this file and crypt.c. Now that Traditional Zip encryption is included * in the base source kits (Zip, UnZip), these files are no longer supplied * seperately and are now considered part of each base source kit. * * See README_CR.txt for more information on the ZCRYPT Traditional * encryption package. The version of ZCRYPT is now fixed at 3.0. This will * change only if the algorithms for Traditional encryption change. Further * changes to crypt.h and crypt.c will be tracked as part of each base source * kit. * * AES_WG encryption uses files in the aes_wg directory in addition to the * basic crypt.c and crypt.h. These files must be added from a separate * Info-ZIP AES WG kit. This implementation of AES encryption is intended to * be compatible with the WinZip AES implementation, and uses AES encryption * code supplied by Brian Gladman. For more information, see the file * aes_wg/README_AES_WG.txt in the Info-ZIP AES WG kit. See INSTALL * for information on how to get that kit. * * Contact us if an encryption-free version of either Zip or UnZip is needed. */ #ifndef __crypt_h /* Don't include more than once. */ # define __crypt_h # ifdef IZ_CRYPT_ANY # undef IZ_CRYPT_ANY # endif # if defined( IZ_CRYPT_AES_WG) || defined( IZ_CRYPT_TRAD) # define IZ_CRYPT_ANY # endif /* defined( IZ_CRYPT_AES_WG) || defined( IZ_CRYPT_TRAD) */ # ifdef IZ_CRYPT_ANY # ifdef IZ_CRYPT_AES_WG # include "aes_wg/fileenc.h" # endif /* def IZ_CRYPT_AES_WG */ /* Set this to 1 for beta, 0 for release. */ #if 0 # define CR_BETA #endif # define CR_MAJORVER 3 # define CR_MINORVER 0 # ifdef CR_BETA # define CR_BETA_VER "l BETA" # define CR_VERSION_DATE "21 Mar 2013" /* Last real code change. */ # else # define CR_BETA_VER "" # define CR_VERSION_DATE "30 Aug 2015" /* Last public release date. */ # define CR_RELEASE # endif # ifndef __G /* UnZip only, for now (DLL stuff). */ # define __G # define __G__ # define __GDEF # define __GPRO void # define __GPRO__ # endif # if defined(MSDOS) || defined(OS2) || defined(WIN32) # ifndef DOS_OS2_W32 # define DOS_OS2_W32 # endif # endif # if defined(DOS_OS2_W32) || defined(__human68k__) # ifndef DOS_H68_OS2_W32 # define DOS_H68_OS2_W32 # endif # endif # if defined(VM_CMS) || defined(MVS) # ifndef CMS_MVS # define CMS_MVS # endif # endif /* To allow combining of Zip and UnZip static libraries in a single binary, * the Zip and UnZip versions of the crypt core functions must have * different names. */ # ifdef ZIP # ifdef REALLY_SHORT_SYMS # define decrypt_byte zdcrby # else # define decrypt_byte zp_decrypt_byte # endif # define update_keys zp_update_keys # define init_keys zp_init_keys # else /* def ZIP */ # ifdef REALLY_SHORT_SYMS # define decrypt_byte dcrbyt # endif # endif /* def ZIP [else] */ # define IZ_PWLEN 256 /* Input buffer size for reading encryption key. */ # ifndef PWLEN /* for compatibility with older zcrypt release. */ # define PWLEN IZ_PWLEN # endif # define RAND_HEAD_LEN 12 /* Length of Trad. encryption random header. */ /* Encrypted data header and password check buffer sizes. * (One buffer accommodates both types.) */ # ifdef IZ_CRYPT_AES_WG /* All data from extra field block. */ # if (MAX_SALT_LENGTH + 2 > RAND_HEAD_LEN) # define ENCR_HEAD_LEN (MAX_SALT_LENGTH + 2) # endif /* Data required for password check. */ # if (PWD_VER_LENGTH > RAND_HEAD_LEN) # define ENCR_PW_CHK_LEN PWD_VER_LENGTH # endif # endif /* def IZ_CRYPT_AES_WG */ # ifndef ENCR_HEAD_LEN # define ENCR_HEAD_LEN RAND_HEAD_LEN # endif # ifndef ENCR_PW_CHK_LEN # define ENCR_PW_CHK_LEN RAND_HEAD_LEN # endif /* The crc_32_tab array must be provided externally for the crypt calculus. */ /* Encode byte c, using temp t. Warning: c must not have side effects. */ # define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c)) /* Decode byte c in place. */ # define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G)) int decrypt_byte OF((__GPRO)); int update_keys OF((__GPRO__ int c)); void init_keys OF((__GPRO__ ZCONST char *passwd)); # ifdef ZIP void crypthead OF((ZCONST char *, ulg)); # ifdef UTIL int zipcloak OF((struct zlist far *, ZCONST char *)); int zipbare OF((struct zlist far *, ZCONST char *)); # else /* def UTIL */ unsigned zfwrite OF((zvoid *, extent, extent)); extern char *key; /* Encryption key */ extern char *passwd; /* Password before keyfile content added */ # endif /* def UTIL [else] */ # endif /* def ZIP */ # if (defined(UNZIP) && !defined(FUNZIP)) int decrypt OF((__GPRO__ ZCONST char *passwrd)); # endif # ifdef FUNZIP extern int encrypted; # ifdef NEXTBYTE # undef NEXTBYTE # endif # define NEXTBYTE \ (encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in)) # endif /* def FUNZIP */ # else /* def IZ_CRYPT_ANY */ /* Dummy version. */ # define zencode # define zdecode # define zfwrite(b,s,c) bfwrite(b,s,c,BFWRITE_DATA) # endif /* def IZ_CRYPT_ANY [else] */ #endif /* ndef __crypt_h */
[ "zorba@localhost" ]
zorba@localhost
7b6c69a6202ce37e0fe6f1789c9e653ac5695724
ff0ed3fa4753f73562a840c99a8b6549eb5a889e
/librss/include/RSS_Html.h
7d79eb5f6418d5409b73f1989279c84416df27a2
[]
no_license
astatine-/TrayRSS
1d7ce2337c4e31b6447b9ed516ca88db575b0e37
dfd810d084b53bc17c78861267f760562b6e14a1
refs/heads/master
2016-09-10T00:41:39.483528
2012-08-28T13:06:22
2012-08-28T13:06:22
null
0
0
null
null
null
null
UTF-8
C
false
false
979
h
#ifndef __RSS_HTML_H__ #define __RSS_HTML_H__ #include "RSS.h" /* ISO 10646 */ /** For stroing info about html named entities such as &amp; , &quote; etc */ typedef struct RSS_Html_entity { RSS_char encoded[9]; /* longest entity len = 8 -> &yacute; */ RSS_char decoded; size_t len; } RSS_Html_entity; #define RSS_HTML_ENTITIES_TABLE_LEN 7 static const RSS_Html_entity entities[RSS_HTML_ENTITIES_TABLE_LEN] = { { RSS_text("&lt;"), RSS_text('<'), 4 }, { RSS_text("&gt;"), RSS_text('>'), 4 }, { RSS_text("&lt;"), RSS_text('<'), 4 }, { RSS_text("&amp;"), RSS_text('&'), 5 }, { RSS_text("&quot;"), RSS_text('"'), 6 }, { RSS_text("&nbsp;"), RSS_text(' '), 6 }, { RSS_text("&apos;"), RSS_text('\''), 6 } }; /** Parses &#1234; */ RSS_char RSS_html_entity_parse_dec(const RSS_char* str, size_t* pos); /** Parses &#x1234; */ RSS_char RSS_html_entity_parse_hex(const RSS_char* str, size_t* pos); /** Html decode */ RSS_char* RSS_html_decode(const RSS_char* str); #endif
[ "arun - at - tanksali - dot - com" ]
arun - at - tanksali - dot - com
4c7149e7fe7413b2b08308349e08b45e1c3ffe2a
41aabf46980c46c2767c41050354d078abbdc5b7
/leap.c
bcfd5ab6c689a0ef3fb4fe9b7e7b8d225cd41b69
[]
no_license
songingyu/1010
5112c129d4de23fc56e59d24a1134123a959bc6b
4c0b2da90119d01d92f7f0f2a6db2b2efd30047e
refs/heads/master
2020-08-09T14:46:03.195581
2019-10-10T06:55:15
2019-10-10T06:55:15
214,109,210
0
0
null
null
null
null
UHC
C
false
false
330
c
#include<stdio.h> int main() { int year; printf("년도입력:"); scanf("%d", &year); if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { printf("%d년은 윤년(leap year) 입니다.\n",year); } else { printf("%d년은 평년(common year)입니다.\n",year); } return 0; }
[ "noreply@github.com" ]
songingyu.noreply@github.com
35cb1163c97eabd367a1aaa6bbc8d8149a22dd89
22b817c31ce2a54cba4f7a8597a6867dd0414f87
/fkn/StdAfx.h
89911afd2d0f96ac5f3e288cc1207a7f456ef6d8
[ "MIT" ]
permissive
philm001/FEMM
904c72e653f89784693bf1b83aefb3b26aed4848
e091281e86ac22ed31a3bfc7d854ff42527ffdc7
refs/heads/master
2020-03-14T23:56:28.511905
2018-05-02T13:41:10
2018-05-02T13:41:10
131,856,027
0
0
null
2018-05-02T13:38:43
2018-05-02T13:38:42
null
UTF-8
C
false
false
575
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #define _CRT_SECURE_NO_WARNINGS #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows 95 Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT int MsgBox(CString s); int MsgBox(PSTR sz,...);
[ "=phillipmobley2@gmail.com" ]
=phillipmobley2@gmail.com
80d8e1d682f6fbfeb76707fbf1d463205426c9a5
f38480d2880b57a0af7113fef89b58c339247caa
/Sources/fnet_stack/fnet.h
246175d18d3dc1b838e110355efe46e4a1174d7d
[]
no_license
SoFiHa/twrk60_fnet_test
4aac2d1867bd3846064b9d86b077f1232b490909
f836675189bf4c1d713f52e573d6d9f633312b98
refs/heads/master
2021-01-20T20:21:49.612846
2016-07-26T07:34:00
2016-07-26T07:34:00
64,200,557
0
0
null
null
null
null
UTF-8
C
false
false
3,105
h
/************************************************************************** * * Copyright 2011-2016 by Andrey Butok. FNET Community. * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, 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. * **********************************************************************/ /*! * * @file fnet.h * * @author Andrey Butok * * @brief Main including header for the FNET project. * ***************************************************************************/ #ifndef _FNET_H_ #define _FNET_H_ #include "fnet_config.h" #include "port/compiler/fnet_comp.h" #include "port/cpu/fnet_cpu.h" #include "stack/fnet_stack.h" #include "services/fnet_services.h" #include "port/os/fnet_os.h" /*! @addtogroup fnet_define * These definitions are used for reference purposes only. * @n */ /*! @{*/ /**************************************************************************/ /*! * @def FNET_DESCRIPTION * @brief Description string of the FNET TCP/IP stack. * @showinitializer ******************************************************************************/ #define FNET_DESCRIPTION "FNET TCP/IP Stack" /**************************************************************************/ /*! * @def FNET_LICENSE * @brief License string of the FNET TCP/IP stack. * @showinitializer ******************************************************************************/ #define FNET_LICENSE "APACHEv2" /**************************************************************************/ /*! * @def FNET_COPYRIGHT * @brief Copyright string of the FNET TCP/IP stack. * @showinitializer ******************************************************************************/ #define FNET_COPYRIGHT "Copyright by FNET Community" /**************************************************************************/ /*! * @def FNET_BUILD_DATE * @brief Build date and time of the project as a string. * @showinitializer ******************************************************************************/ #define FNET_BUILD_DATE __DATE__ " at " __TIME__ /**************************************************************************/ /*! * @def FNET_VERSION * @brief Current version number of the FNET TCP/IP stack. * The resulting value format is xx.xx.xx = major.minor.revision, as a * string. * @showinitializer ******************************************************************************/ #define FNET_VERSION "3.3.0" /*! @} */ #endif /* _FNET_H_ */
[ "s.kolberg@sofiha.de" ]
s.kolberg@sofiha.de
c7405501fff4262a4238e3748833670176a5d299
c02710c388c0142d1a4421ee7359153de639395e
/mcuconf.h
af89f835dbdce191c82e14f33d7d02359041f092
[]
no_license
w4kpm/stm32f429-discovery-chibios-pppos
5dc37bc7bfcbd058bc1b69346d27ca7880a44c6f
5108c46ac2a3027519ace5391e9301e75bb8211a
refs/heads/master
2021-01-13T01:31:11.903770
2015-07-17T00:19:36
2015-07-17T00:19:36
38,087,601
1
1
null
null
null
null
UTF-8
C
false
false
14,424
h
/* ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _MCUCONF_H_ #define _MCUCONF_H_ /* * STM32F4xx drivers configuration. * The following settings override the default settings present in * the various device driver implementation headers. * Note that the settings for each driver only have effect if the whole * driver is enabled in halconf.h. * * IRQ priorities: * 15...0 Lowest...Highest. * * DMA priorities: * 0...3 Lowest...Highest. */ #define STM32F4xx_MCUCONF /* * HAL driver system settings. */ #define STM32_NO_INIT FALSE #define STM32_HSI_ENABLED TRUE #define STM32_LSI_ENABLED TRUE #define STM32_HSE_ENABLED TRUE #define STM32_LSE_ENABLED FALSE #define STM32_CLOCK48_REQUIRED TRUE #define STM32_SW STM32_SW_PLL #define STM32_PLLSRC STM32_PLLSRC_HSE #define STM32_PLLM_VALUE 8 #define STM32_PLLN_VALUE 336 #define STM32_PLLP_VALUE 2 #define STM32_PLLQ_VALUE 7 #define STM32_HPRE STM32_HPRE_DIV1 #define STM32_PPRE1 STM32_PPRE1_DIV4 #define STM32_PPRE2 STM32_PPRE2_DIV2 #define STM32_RTCSEL STM32_RTCSEL_LSI #define STM32_RTCPRE_VALUE 8 #define STM32_MCO1SEL STM32_MCO1SEL_HSI #define STM32_MCO1PRE STM32_MCO1PRE_DIV1 #define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK #define STM32_MCO2PRE STM32_MCO2PRE_DIV5 #define STM32_I2SSRC STM32_I2SSRC_CKIN #define STM32_PLLI2SN_VALUE 192 #define STM32_PLLI2SR_VALUE 5 #define STM32_PVD_ENABLE FALSE #define STM32_PLS STM32_PLS_LEV0 #define STM32_BKPRAM_ENABLE FALSE /* * ADC driver system settings. */ #define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 #define STM32_ADC_USE_ADC1 FALSE #define STM32_ADC_USE_ADC2 FALSE #define STM32_ADC_USE_ADC3 FALSE #define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) #define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) #define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1) #define STM32_ADC_ADC1_DMA_PRIORITY 2 #define STM32_ADC_ADC2_DMA_PRIORITY 2 #define STM32_ADC_ADC3_DMA_PRIORITY 2 #define STM32_ADC_IRQ_PRIORITY 6 #define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6 #define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 6 #define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 6 /* * CAN driver system settings. */ #define STM32_CAN_USE_CAN1 FALSE #define STM32_CAN_USE_CAN2 FALSE #define STM32_CAN_CAN1_IRQ_PRIORITY 11 #define STM32_CAN_CAN2_IRQ_PRIORITY 11 /* * DAC driver system settings. */ #define STM32_DAC_DUAL_MODE FALSE #define STM32_DAC_USE_DAC1_CH1 FALSE #define STM32_DAC_USE_DAC1_CH2 FALSE #define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10 #define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10 #define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2 #define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2 #define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) #define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) /* * EXT driver system settings. */ #define STM32_EXT_EXTI0_IRQ_PRIORITY 6 #define STM32_EXT_EXTI1_IRQ_PRIORITY 6 #define STM32_EXT_EXTI2_IRQ_PRIORITY 6 #define STM32_EXT_EXTI3_IRQ_PRIORITY 6 #define STM32_EXT_EXTI4_IRQ_PRIORITY 6 #define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6 #define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6 #define STM32_EXT_EXTI16_IRQ_PRIORITY 6 #define STM32_EXT_EXTI17_IRQ_PRIORITY 15 #define STM32_EXT_EXTI18_IRQ_PRIORITY 6 #define STM32_EXT_EXTI19_IRQ_PRIORITY 6 #define STM32_EXT_EXTI20_IRQ_PRIORITY 6 #define STM32_EXT_EXTI21_IRQ_PRIORITY 15 #define STM32_EXT_EXTI22_IRQ_PRIORITY 15 /* * GPT driver system settings. */ #define STM32_GPT_USE_TIM1 FALSE #define STM32_GPT_USE_TIM2 FALSE #define STM32_GPT_USE_TIM3 FALSE #define STM32_GPT_USE_TIM4 FALSE #define STM32_GPT_USE_TIM5 FALSE #define STM32_GPT_USE_TIM6 FALSE #define STM32_GPT_USE_TIM7 FALSE #define STM32_GPT_USE_TIM8 FALSE #define STM32_GPT_USE_TIM9 FALSE #define STM32_GPT_USE_TIM11 FALSE #define STM32_GPT_USE_TIM12 FALSE #define STM32_GPT_USE_TIM14 FALSE #define STM32_GPT_TIM1_IRQ_PRIORITY 7 #define STM32_GPT_TIM2_IRQ_PRIORITY 7 #define STM32_GPT_TIM3_IRQ_PRIORITY 7 #define STM32_GPT_TIM4_IRQ_PRIORITY 7 #define STM32_GPT_TIM5_IRQ_PRIORITY 7 #define STM32_GPT_TIM6_IRQ_PRIORITY 7 #define STM32_GPT_TIM7_IRQ_PRIORITY 7 #define STM32_GPT_TIM8_IRQ_PRIORITY 7 #define STM32_GPT_TIM9_IRQ_PRIORITY 7 #define STM32_GPT_TIM11_IRQ_PRIORITY 7 #define STM32_GPT_TIM12_IRQ_PRIORITY 7 #define STM32_GPT_TIM14_IRQ_PRIORITY 7 /* * I2C driver system settings. */ #define STM32_I2C_USE_I2C1 FALSE #define STM32_I2C_USE_I2C2 FALSE #define STM32_I2C_USE_I2C3 FALSE #define STM32_I2C_BUSY_TIMEOUT 50 #define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) #define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) #define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) #define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) #define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) #define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) #define STM32_I2C_I2C1_IRQ_PRIORITY 5 #define STM32_I2C_I2C2_IRQ_PRIORITY 5 #define STM32_I2C_I2C3_IRQ_PRIORITY 5 #define STM32_I2C_I2C1_DMA_PRIORITY 3 #define STM32_I2C_I2C2_DMA_PRIORITY 3 #define STM32_I2C_I2C3_DMA_PRIORITY 3 #define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") /* * ICU driver system settings. */ #define STM32_ICU_USE_TIM1 FALSE #define STM32_ICU_USE_TIM2 FALSE #define STM32_ICU_USE_TIM3 FALSE #define STM32_ICU_USE_TIM4 FALSE #define STM32_ICU_USE_TIM5 FALSE #define STM32_ICU_USE_TIM8 FALSE #define STM32_ICU_USE_TIM9 FALSE #define STM32_ICU_TIM1_IRQ_PRIORITY 7 #define STM32_ICU_TIM2_IRQ_PRIORITY 7 #define STM32_ICU_TIM3_IRQ_PRIORITY 7 #define STM32_ICU_TIM4_IRQ_PRIORITY 7 #define STM32_ICU_TIM5_IRQ_PRIORITY 7 #define STM32_ICU_TIM8_IRQ_PRIORITY 7 #define STM32_ICU_TIM9_IRQ_PRIORITY 7 /* * MAC driver system settings. */ #define STM32_MAC_TRANSMIT_BUFFERS 2 #define STM32_MAC_RECEIVE_BUFFERS 4 #define STM32_MAC_BUFFERS_SIZE 1522 #define STM32_MAC_PHY_TIMEOUT 100 #define STM32_MAC_ETH1_CHANGE_PHY_STATE TRUE #define STM32_MAC_ETH1_IRQ_PRIORITY 13 #define STM32_MAC_IP_CHECKSUM_OFFLOAD 0 /* * PWM driver system settings. */ #define STM32_PWM_USE_ADVANCED FALSE #define STM32_PWM_USE_TIM1 FALSE #define STM32_PWM_USE_TIM2 FALSE #define STM32_PWM_USE_TIM3 FALSE #define STM32_PWM_USE_TIM4 FALSE #define STM32_PWM_USE_TIM5 FALSE #define STM32_PWM_USE_TIM8 FALSE #define STM32_PWM_USE_TIM9 FALSE #define STM32_PWM_TIM1_IRQ_PRIORITY 7 #define STM32_PWM_TIM2_IRQ_PRIORITY 7 #define STM32_PWM_TIM3_IRQ_PRIORITY 7 #define STM32_PWM_TIM4_IRQ_PRIORITY 7 #define STM32_PWM_TIM5_IRQ_PRIORITY 7 #define STM32_PWM_TIM8_IRQ_PRIORITY 7 #define STM32_PWM_TIM9_IRQ_PRIORITY 7 /* * SDC driver system settings. */ #define STM32_SDC_SDIO_DMA_PRIORITY 3 #define STM32_SDC_SDIO_IRQ_PRIORITY 9 #define STM32_SDC_WRITE_TIMEOUT_MS 250 #define STM32_SDC_READ_TIMEOUT_MS 25 #define STM32_SDC_CLOCK_ACTIVATION_DELAY 10 #define STM32_SDC_SDIO_UNALIGNED_SUPPORT TRUE #define STM32_SDC_SDIO_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) /* * SERIAL driver system settings. */ #define STM32_SERIAL_USE_USART1 TRUE #define STM32_SERIAL_USE_USART2 FALSE #define STM32_SERIAL_USE_USART3 FALSE #define STM32_SERIAL_USE_UART4 TRUE #define STM32_SERIAL_USE_UART5 FALSE #define STM32_SERIAL_USE_USART6 FALSE #define STM32_SERIAL_USART1_PRIORITY 12 #define STM32_SERIAL_USART2_PRIORITY 12 #define STM32_SERIAL_USART3_PRIORITY 12 #define STM32_SERIAL_UART4_PRIORITY 12 #define STM32_SERIAL_UART5_PRIORITY 12 #define STM32_SERIAL_USART6_PRIORITY 12 /* * SPI driver system settings. */ #define STM32_SPI_USE_SPI1 FALSE #define STM32_SPI_USE_SPI2 FALSE #define STM32_SPI_USE_SPI3 FALSE #define STM32_SPI_USE_SPI4 FALSE #define STM32_SPI_USE_SPI5 TRUE #define STM32_SPI_USE_SPI6 FALSE #define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) #define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) #define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) #define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) #define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) #define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) #define STM32_SPI_SPI4_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) #define STM32_SPI_SPI4_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1) #define STM32_SPI_SPI5_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) #define STM32_SPI_SPI5_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) #define STM32_SPI_SPI6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 6) #define STM32_SPI_SPI6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) #define STM32_SPI_SPI1_DMA_PRIORITY 1 #define STM32_SPI_SPI2_DMA_PRIORITY 1 #define STM32_SPI_SPI3_DMA_PRIORITY 1 #define STM32_SPI_SPI4_DMA_PRIORITY 1 #define STM32_SPI_SPI5_DMA_PRIORITY 1 #define STM32_SPI_SPI6_DMA_PRIORITY 1 #define STM32_SPI_SPI1_IRQ_PRIORITY 10 #define STM32_SPI_SPI2_IRQ_PRIORITY 10 #define STM32_SPI_SPI3_IRQ_PRIORITY 10 #define STM32_SPI_SPI4_IRQ_PRIORITY 10 #define STM32_SPI_SPI5_IRQ_PRIORITY 10 #define STM32_SPI_SPI6_IRQ_PRIORITY 10 #define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") /* * ST driver system settings. */ #define STM32_ST_IRQ_PRIORITY 8 #define STM32_ST_USE_TIMER 2 /* * UART driver system settings. */ #define STM32_UART_USE_USART1 FALSE #define STM32_UART_USE_USART2 FALSE #define STM32_UART_USE_USART3 FALSE #define STM32_UART_USE_UART4 FALSE #define STM32_UART_USE_UART5 FALSE #define STM32_UART_USE_USART6 FALSE #define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) #define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) #define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) #define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) #define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 1) #define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) #define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) #define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) #define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) #define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) #define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) #define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) #define STM32_UART_USART1_IRQ_PRIORITY 12 #define STM32_UART_USART2_IRQ_PRIORITY 12 #define STM32_UART_USART3_IRQ_PRIORITY 12 #define STM32_UART_UART4_IRQ_PRIORITY 12 #define STM32_UART_UART5_IRQ_PRIORITY 12 #define STM32_UART_USART6_IRQ_PRIORITY 12 #define STM32_UART_USART1_DMA_PRIORITY 0 #define STM32_UART_USART2_DMA_PRIORITY 0 #define STM32_UART_USART3_DMA_PRIORITY 0 #define STM32_UART_UART4_DMA_PRIORITY 0 #define STM32_UART_UART5_DMA_PRIORITY 0 #define STM32_UART_USART6_DMA_PRIORITY 0 #define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") /* * USB driver system settings. */ #define STM32_USB_USE_OTG1 FALSE #define STM32_USB_USE_OTG2 TRUE #define STM32_USB_OTG1_IRQ_PRIORITY 14 #define STM32_USB_OTG2_IRQ_PRIORITY 14 #define STM32_USB_OTG1_RX_FIFO_SIZE 512 #define STM32_USB_OTG2_RX_FIFO_SIZE 1024 #define STM32_USB_OTG_THREAD_PRIO LOWPRIO #define STM32_USB_OTG_THREAD_STACK_SIZE 128 #define STM32_USB_OTGFIFO_FILL_BASEPRI 0 #endif /* _MCUCONF_H_ */
[ "kelly@fammcdonald.net" ]
kelly@fammcdonald.net
f698464e63659abfe0ba14579f2d706f6b711dc3
37c593b4c9b42d38ebfcac8d7160282c43fdb324
/model/Scade/System/TracksideDynamicModel/TestTracks/UtrechtAmsterdam_oETCS/Simulation/TestP057_Internal_Tests_inputs.c
cf822e6a1ff7233454d1ab8242aef2275a930d3e
[]
no_license
stefan-karg/modeling
d4211778a2e7f2d4948ea38442096edb0f317051
c0855d85430e5d8313c04a9b8918cd3d596e48ec
refs/heads/master
2021-01-16T19:56:51.201532
2015-08-26T13:55:57
2015-08-26T13:55:57
26,961,581
0
0
null
null
null
null
UTF-8
C
false
false
583
c
/* $*************** KCG Version 6.1.3 (build i6) **************** ** Command: s2c613 -config C:/GITHUB/modeling/model/Scade/System/TracksideDynamicModel/TestTracks/UtrechtAmsterdam_oETCS/Simulation\kcg_s2c_config.txt ** Generation date: 2015-08-20T16:18:38 *************************************************************$ */ #include "TestP057_Internal_Tests.h" /* $*************** KCG Version 6.1.3 (build i6) **************** ** TestP057_Internal_Tests_inputs.c ** Generation date: 2015-08-20T16:18:38 *************************************************************$ */
[ "j.gaertner@railergy.com" ]
j.gaertner@railergy.com
3dad866f15ee53c10707d0dd148e86fa5d9bf691
59dd61ebf101f8f037018d026231301ead18aa32
/Code/Rockstar Games/File Format/Raw/IMG/CIMGFormat_Version2_Header1.h
dbef2ea840fa369a223ff407e86e8a92dfd35289
[]
no_license
X-Seti/KGM
d4e6900d590bc22c9be90e6a7129699a1119902c
edc034930f1dfbb61027992f9347ef5f0bdb0cb4
refs/heads/master
2020-12-30T19:36:52.838360
2017-07-11T16:45:43
2017-07-11T16:45:43
60,021,522
0
0
null
2016-05-30T15:46:12
2016-05-30T15:46:12
null
UTF-8
C
false
false
266
h
#ifndef CIMGFormat_Version2_Header1_H #define CIMGFormat_Version2_Header1_H #include "Types.h" #include "Namespace.h" #pragma pack(push, 1) struct RG::CIMGFormat_Version2_Header1 { uint8 m_ucMagicNumber[4]; uint32 m_uiEntryCount; }; #pragma pack(pop) #endif
[ "mexuk@hotmail.co.uk" ]
mexuk@hotmail.co.uk
2e7ef46c39adb52c71a7c85c9f7b72076e1a09b5
76f7459a09acb9be2d52407132f5ff8955627da2
/frame/compat/attic/bla_rot.c
5c97d3961166ac336897f4aa485a475359335487
[ "BSD-3-Clause" ]
permissive
flame/blis
448bc0ad139b726188129c5627c304274b41c3c1
6dcf7666eff14348e82fbc2750be4b199321e1b9
refs/heads/master
2023-09-01T14:56:11.920485
2023-08-27T19:18:57
2023-08-27T19:18:57
16,143,904
1,696
361
NOASSERTION
2023-08-27T19:18:58
2014-01-22T15:58:24
C
UTF-8
C
false
false
2,725
c
/* BLIS An object-based framework for developing high-performance BLAS-like libraries. Copyright (C) 2014, The University of Texas at Austin Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name(s) of the copyright holder(s) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "blis.h" // // Define BLAS-to-BLIS interfaces. // #undef GENTFUNCR2 #define GENTFUNCR2( ftype_xy, ftype_r, chxy, chr, blasname, blisname ) \ \ void PASTEF772(chxy,chr,blasname)( \ f77_int* n, \ ftype_xy* x, f77_int* incx, \ ftype_xy* y, f77_int* incy, \ ftype_r* c, \ ftype_r* s \ ) \ { \ dim_t n0; \ ftype_xy* x0; \ ftype_xy* y0; \ inc_t incx0; \ inc_t incy0; \ \ /* Convert/typecast negative values of n to zero. */ \ bli_convert_blas_dim1( *n, n0 ); \ \ /* If the input increments are negative, adjust the pointers so we can use positive increments instead. */ \ bli_convert_blas_incv( n0, x, *incx, x0, incx0 ); \ bli_convert_blas_incv( n0, y, *incy, y0, incy0 ); \ \ bli_check_error_code( BLIS_NOT_YET_IMPLEMENTED ); \ } #ifdef BLIS_ENABLE_BLAS INSERT_GENTFUNCR2_BLAS( rot, ROT_KERNEL ) #endif
[ "field@cs.utexas.edu" ]
field@cs.utexas.edu
11df72708c36188c1c4d7012fb645ac96a58050d
008060072ef30e7ee7920e92e32cce337d85030d
/feeds/ipq807x/qca-ssdk/src/src/ref/ref_vlan.c
4b99f2c4c19824cacd84e6c33a0efbf2dbb5637b
[ "BSD-3-Clause" ]
permissive
Kenneth-Lu/wlan-ap
2859803835876137427da3fc94d828c9f99a7cce
4468e90d2c0edf4d4b68b33e7b22259f8501ba40
refs/heads/plume/dev
2023-07-14T20:23:04.325249
2021-02-26T14:14:27
2021-03-01T15:44:14
357,393,186
1
1
BSD-3-Clause
2021-06-09T04:51:30
2021-04-13T01:54:40
null
UTF-8
C
false
false
15,427
c
/* * Copyright (c) 2012, 2014, 2017, The Linux Foundation. All rights reserved. * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all copies. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "sw.h" #include "ssdk_init.h" #include "fal_init.h" #include "fal_misc.h" #include "fal_mib.h" #include "fal_port_ctrl.h" #include "fal_portvlan.h" #include "fal_fdb.h" #include "fal_stp.h" #include "fal_igmp.h" #include "fal_qos.h" #include "fal_acl.h" #include "hsl.h" #include "hsl_dev.h" #include "ssdk_init.h" #include "ssdk_dts.h" #include "hsl_phy.h" #include <linux/kconfig.h> #include <linux/version.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/phy.h> #include <linux/platform_device.h> #include <linux/types.h> //#include <asm/mach-types.h> #include <generated/autoconf.h> #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)) #include <linux/ar8216_platform.h> #endif #include <linux/delay.h> #include <linux/phy.h> #include <linux/netdevice.h> #include "ssdk_plat.h" #include "ref_vlan.h" #ifdef BOARD_AR71XX #include "ssdk_uci.h" #endif extern ssdk_chip_type SSDK_CURRENT_CHIP_TYPE; #if !defined(IN_VLAN_MINI) sw_error_t qca_lan_wan_cfg_set(a_uint32_t dev_id, qca_lan_wan_cfg_t *lan_wan_cfg) { a_uint32_t i = 0, lan_bmp = 0, wan_bmp = 0; sw_error_t rv = SW_OK; fal_vlan_t vlan_entry; SW_RTN_ON_NULL(lan_wan_cfg); switch (SSDK_CURRENT_CHIP_TYPE) { case CHIP_ISIS: case CHIP_ISISC: case CHIP_DESS: break; default: return SW_NOT_SUPPORTED; } fal_vlan_flush(dev_id); aos_mem_set(&vlan_entry, 0, sizeof(vlan_entry)); if (lan_wan_cfg->lan_only_mode) { #if defined(IN_PORTVLAN) while (i < sizeof(lan_wan_cfg->v_port_info)/sizeof(lan_wan_cfg->v_port_info[0])) { if (lan_wan_cfg->v_port_info[i].valid) { /* use the portbased vlan table for forwarding */ rv = fal_port_1qmode_set(dev_id, lan_wan_cfg->v_port_info[i].port_id, FAL_1Q_DISABLE); SW_RTN_ON_ERROR(rv); rv = fal_port_egvlanmode_set(dev_id, lan_wan_cfg->v_port_info[i].port_id, FAL_EG_UNMODIFIED); SW_RTN_ON_ERROR(rv); rv = fal_port_default_cvid_set(dev_id, lan_wan_cfg->v_port_info[i].port_id, 0); SW_RTN_ON_ERROR(rv); lan_bmp |= (0x1 << lan_wan_cfg->v_port_info[i].port_id); } i++; } /* CPU port 0 configurations */ rv = fal_port_1qmode_set(dev_id, SSDK_PORT_CPU, FAL_1Q_DISABLE); SW_RTN_ON_ERROR(rv); rv = fal_port_egvlanmode_set(dev_id, SSDK_PORT_CPU, FAL_EG_UNMODIFIED); SW_RTN_ON_ERROR(rv); rv = fal_port_default_cvid_set(dev_id, SSDK_PORT_CPU, 0); SW_RTN_ON_ERROR(rv); rv = fal_portvlan_member_update(dev_id, SSDK_PORT_CPU, lan_bmp); SW_RTN_ON_ERROR(rv); #endif } else { while (i < sizeof(lan_wan_cfg->v_port_info)/sizeof(lan_wan_cfg->v_port_info[0])) { if (lan_wan_cfg->v_port_info[i].valid) { rv = fal_vlan_find(dev_id, lan_wan_cfg->v_port_info[i].vid, &vlan_entry); /* create vlan entry if the vlan entry does not exist */ if (rv == SW_NOT_FOUND) { rv = fal_vlan_create(dev_id, lan_wan_cfg->v_port_info[i].vid); SW_RTN_ON_ERROR(rv); #if defined(IN_PORTVLAN) rv = fal_port_1qmode_set(dev_id, SSDK_PORT_CPU, FAL_1Q_SECURE); SW_RTN_ON_ERROR(rv); #endif rv = fal_vlan_member_add(dev_id, lan_wan_cfg->v_port_info[i].vid, SSDK_PORT_CPU, FAL_EG_TAGGED); SW_RTN_ON_ERROR(rv); } rv = fal_vlan_member_add(dev_id, lan_wan_cfg->v_port_info[i].vid, lan_wan_cfg->v_port_info[i].port_id, FAL_EG_UNTAGGED); SW_RTN_ON_ERROR(rv); #if defined(IN_PORTVLAN) rv = fal_port_1qmode_set(dev_id, lan_wan_cfg->v_port_info[i].port_id, FAL_1Q_SECURE); SW_RTN_ON_ERROR(rv); rv = fal_port_default_cvid_set(dev_id, lan_wan_cfg->v_port_info[i].port_id, lan_wan_cfg->v_port_info[i].vid); SW_RTN_ON_ERROR(rv); #endif if (lan_wan_cfg->v_port_info[i].is_wan_port) { wan_bmp |= (0x1 << lan_wan_cfg->v_port_info[i].port_id); } else { lan_bmp |= (0x1 << lan_wan_cfg->v_port_info[i].port_id); } } i++; } } ssdk_lan_bmp_set(dev_id, lan_bmp); ssdk_wan_bmp_set(dev_id, wan_bmp); qca_ssdk_port_bmp_set(dev_id, lan_bmp|wan_bmp); #if defined(DESS) && defined(IN_TRUNK) if(SSDK_CURRENT_CHIP_TYPE == CHIP_DESS) { ssdk_dess_trunk_init(dev_id, wan_bmp); } #endif #if defined(IN_PORTVLAN) ssdk_portvlan_init(dev_id); #endif return rv; } sw_error_t qca_lan_wan_cfg_get(a_uint32_t dev_id, qca_lan_wan_cfg_t *lan_wan_cfg) { sw_error_t rv = SW_OK; fal_vlan_t vlan_entry; fal_pbmp_t member_pmap, lan_bmp, wan_bmp; a_uint32_t port_id, entry_id, vlan_id; SW_RTN_ON_NULL(lan_wan_cfg); switch (SSDK_CURRENT_CHIP_TYPE) { case CHIP_ISIS: case CHIP_ISISC: case CHIP_DESS: break; default: return SW_NOT_SUPPORTED; } lan_bmp = ssdk_lan_bmp_get(dev_id); wan_bmp = ssdk_wan_bmp_get(dev_id); member_pmap = lan_bmp | wan_bmp; vlan_id = FAL_NEXT_ENTRY_FIRST_ID; entry_id = 0; while (1) { aos_mem_set(&vlan_entry, 0, sizeof(vlan_entry)); rv = fal_vlan_next(dev_id, vlan_id, &vlan_entry); if (rv != SW_OK) { break; } /* * the special port id should be existed only in one vlan entry * starting from port 1. */ port_id = 1; while (vlan_entry.mem_ports >> port_id) { if (((vlan_entry.mem_ports >> port_id) & 1) && SW_IS_PBMP_MEMBER(member_pmap, port_id)) { lan_wan_cfg->v_port_info[entry_id].port_id = port_id; lan_wan_cfg->v_port_info[entry_id].vid = vlan_entry.vid; lan_wan_cfg->v_port_info[entry_id].valid = A_TRUE; lan_wan_cfg->v_port_info[entry_id].is_wan_port = SW_IS_PBMP_MEMBER(wan_bmp, port_id) ? A_TRUE : A_FALSE; entry_id++; } port_id++; } vlan_id = vlan_entry.vid; } /* * no vlan entry exists, the portbased vlan used. */ #if defined(IN_PORTVLAN) if (entry_id == 0) { lan_wan_cfg->lan_only_mode = A_TRUE; port_id = 1; while (lan_bmp >> port_id) { if ((lan_bmp >> port_id) & 1) { lan_wan_cfg->v_port_info[entry_id].port_id = port_id; lan_wan_cfg->v_port_info[entry_id].vid = 0; lan_wan_cfg->v_port_info[entry_id].is_wan_port = A_FALSE; member_pmap = 0; #if !defined(IN_PORTVLAN_MINI) fal_portvlan_member_get(dev_id, port_id, &member_pmap); #endif lan_wan_cfg->v_port_info[entry_id].valid = member_pmap ? A_TRUE : A_FALSE; entry_id++; } port_id++; } } #endif return SW_OK; } #endif int qca_ar8327_sw_enable_vlan0(a_uint32_t dev_id, a_bool_t enable, a_uint8_t portmap) { fal_vlan_t entry; fal_acl_rule_t rule; int i = 0; memset(&entry, 0, sizeof(fal_vlan_t)); memset(&rule, 0, sizeof(fal_acl_rule_t)); for (i = 0; i < AR8327_NUM_PORTS; i ++) { fal_port_tls_set(dev_id, i, A_FALSE); fal_port_vlan_propagation_set(dev_id, i, FAL_VLAN_PROPAGATION_REPLACE); } if (enable) { entry.fid = 0; entry.mem_ports = portmap; entry.unmodify_ports = portmap; entry.vid = 0; fal_vlan_entry_append(dev_id, &entry); for (i = 0; i < AR8327_NUM_PORTS; i++) { if (portmap & (0x1 << i)) { fal_port_egvlanmode_set(dev_id, i, FAL_EG_UNTOUCHED); fal_port_tls_set(dev_id, i, A_TRUE); fal_port_vlan_propagation_set(dev_id, i, FAL_VLAN_PROPAGATION_DISABLE); fal_acl_port_udf_profile_set(dev_id, i, FAL_ACL_UDF_TYPE_L2, 12, 4); } } fal_acl_list_creat(dev_id, 0, 0); rule.rule_type = FAL_ACL_RULE_UDF; rule.udf_len = 4; rule.udf_val[0] = 0x81; rule.udf_val[1] = 0; rule.udf_val[2] = 0; rule.udf_val[3] = 0; rule.udf_mask[0] = 0xff; rule.udf_mask[1] = 0xff; rule.udf_mask[2] = 0xf; rule.udf_mask[3] = 0xff; FAL_FIELD_FLG_SET(rule.field_flg, FAL_ACL_FIELD_UDF); FAL_ACTION_FLG_SET(rule.action_flg, FAL_ACL_ACTION_REMARK_LOOKUP_VID); fal_acl_rule_add(dev_id, 0, 0, 1, &rule); for (i = 0; i < AR8327_NUM_PORTS; i ++) { fal_acl_list_unbind(dev_id, 0, 0, 0, i); if (portmap & (0x1 << i)) { fal_acl_list_bind(dev_id, 0, 0, 0, i); } } fal_acl_status_set(dev_id, A_TRUE); } else { fal_acl_rule_delete(dev_id, 0, 0, 1); } return 0; } #if defined(IN_SWCONFIG) int qca_ar8327_sw_set_vlan(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); priv->vlan = !!val->value.i; #ifdef BOARD_AR71XX if(SSDK_CURRENT_CHIP_TYPE == CHIP_SHIVA) { ssdk_uci_sw_set_vlan(attr, val); } #endif return 0; } int qca_ar8327_sw_get_vlan(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); val->value.i = priv->vlan; return 0; } int qca_ar8327_sw_set_vid(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); priv->vlan_id[val->port_vlan] = val->value.i; #ifdef BOARD_AR71XX if(SSDK_CURRENT_CHIP_TYPE == CHIP_SHIVA) { ssdk_uci_sw_set_vid(attr, val); } #endif return 0; } int qca_ar8327_sw_get_vid(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); val->value.i = priv->vlan_id[val->port_vlan]; return 0; } int qca_ar8327_sw_get_pvid(struct switch_dev *dev, int port, int *vlan) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); *vlan = priv->pvid[port]; return 0; } int qca_ar8327_sw_set_pvid(struct switch_dev *dev, int port, int vlan) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); /* make sure no invalid PVIDs get set */ if (vlan >= dev->vlans) return -1; priv->pvid[port] = vlan; #ifdef BOARD_AR71XX if(SSDK_CURRENT_CHIP_TYPE == CHIP_SHIVA) { ssdk_uci_sw_set_pvid(port, vlan); } #endif return 0; } int qca_ar8327_sw_get_ports(struct switch_dev *dev, struct switch_val *val) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); a_uint8_t ports = priv->vlan_table[val->port_vlan]; int i; val->len = 0; for (i = 0; i < dev->ports; i++) { struct switch_port *p; if (!(ports & (1 << i))) continue; p = &val->value.ports[val->len++]; p->id = i; if (priv->vlan_tagged[val->port_vlan] & (1 << i)) p->flags = (1 << SWITCH_PORT_FLAG_TAGGED); else p->flags = 0; /*Handle for VLAN 0*/ if (val->port_vlan == 0) p->flags = (1 << SWITCH_PORT_FLAG_TAGGED); } return 0; } int qca_ar8327_sw_set_ports(struct switch_dev *dev, struct switch_val *val) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); a_uint8_t *vt = &priv->vlan_table[val->port_vlan]; int i; #ifdef BOARD_AR71XX if(SSDK_CURRENT_CHIP_TYPE == CHIP_SHIVA) { ssdk_uci_sw_set_ports(val); } #endif /*Handle for VLAN 0*/ if (val->port_vlan == 0) { priv->vlan_table[0] = 0; for (i = 0; i < val->len; i++) { struct switch_port *p = &val->value.ports[i]; priv->vlan_table[0] |= (1 << p->id); } return 0; } if (priv->vlan_id[val->port_vlan] == 0) priv->vlan_id[val->port_vlan] = val->port_vlan; *vt = 0; for (i = 0; i < val->len; i++) { struct switch_port *p = &val->value.ports[i]; if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) { priv->vlan_tagged[val->port_vlan] |= (1 << p->id); } else { priv->vlan_tagged[val->port_vlan] &= ~(1 << p->id); priv->pvid[p->id] = val->port_vlan; } *vt |= 1 << p->id; } return 0; } int qca_ar8327_sw_hw_apply(struct switch_dev *dev) { struct qca_phy_priv *priv = qca_phy_priv_get(dev); fal_pbmp_t *portmask = NULL; int i, j; if (priv->version == QCA_VER_HPPE) { return 0; } portmask = aos_mem_alloc(sizeof(fal_pbmp_t) * dev->ports); if (portmask == NULL) { SSDK_ERROR("%s: portmask malloc failed. \n", __func__); return -1; } memset(portmask, 0, sizeof(fal_pbmp_t) * dev->ports); mutex_lock(&priv->reg_mutex); if (!priv->init) { /*Handle VLAN 0 entry*/ if (priv->vlan_id[0] == 0 && priv->vlan_table[0] == 0) { qca_ar8327_sw_enable_vlan0(priv->device_id, A_FALSE, 0); } /* calculate the port destination masks and load vlans * into the vlan translation unit */ for (j = 0; j < AR8327_MAX_VLANS; j++) { u8 vp = priv->vlan_table[j]; if (!vp) { fal_vlan_delete(priv->device_id, priv->vlan_id[j]); continue; } fal_vlan_delete(priv->device_id, priv->vlan_id[j]); fal_vlan_create(priv->device_id, priv->vlan_id[j]); for (i = 0; i < dev->ports; i++) { u8 mask = (1 << i); if (vp & mask) { fal_vlan_member_add(priv->device_id, priv->vlan_id[j], i, (mask & priv->vlan_tagged[j])? FAL_EG_TAGGED : FAL_EG_UNTAGGED); portmask[i] |= vp & ~mask; } } if (SSDK_CURRENT_CHIP_TYPE == CHIP_SHIVA) fal_vlan_member_update(priv->device_id,priv->vlan_id[j],vp,0); } /*Hanlde VLAN 0 entry*/ if (priv->vlan_id[0] == 0 && priv->vlan_table[0]) { qca_ar8327_sw_enable_vlan0(priv->device_id,A_TRUE, priv->vlan_table[0]); } } else { /* vlan disabled: port based vlan used */ ssdk_portvlan_init(priv->device_id); } /* update the port destination mask registers and tag settings */ for (i = 0; i < dev->ports; i++) { int pvid; fal_pt_1qmode_t ingressMode; fal_pt_1q_egmode_t egressMode; if (priv->vlan) { pvid = priv->vlan_id[priv->pvid[i]]; ingressMode = FAL_1Q_SECURE; } else { pvid = 0; ingressMode = FAL_1Q_DISABLE; } egressMode = FAL_EG_UNTOUCHED; fal_port_1qmode_set(priv->device_id, i, ingressMode); fal_port_egvlanmode_set(priv->device_id, i, egressMode); fal_port_default_cvid_set(priv->device_id, i, pvid); if (!priv->init && priv->vlan) { fal_portvlan_member_update(priv->device_id, i, portmask[i]); } } aos_mem_free(portmask); portmask = NULL; mutex_unlock(&priv->reg_mutex); return 0; } #endif
[ "john@phrozen.org" ]
john@phrozen.org
47641523da5c5471801de469cdf2b0b1d43f8458
c512a52861f552c1b1935a0ca94cc4fce41ecae9
/SystemCall/syscall.c
dd10880e23253f60e1d4abd3ea7970affb92b463
[]
no_license
KenanRico/crefs
1bb97c5756cd50bbc8b5e213640a9394bfac0dca
e53b204c5c1f8ed59af51d71941a1a70cb6b052e
refs/heads/master
2020-04-14T00:56:16.302566
2019-10-20T14:24:42
2019-10-20T14:24:42
163,546,500
0
0
null
null
null
null
UTF-8
C
false
false
7,624
c
#include <types.h> #include <kern/errno.h> #include <lib.h> #include <machine/pcb.h> #include <machine/spl.h> #include <machine/trapframe.h> #include <kern/callno.h> #include <syscall.h> #include <thread.h> #include "addrspace.h" #include "vfs.h" /* * System call handler. * * A pointer to the trapframe created during exception entry (in * exception.S) is passed in. * * The calling conventions for syscalls are as follows: Like ordinary * function calls, the first 4 32-bit arguments are passed in the 4 * argument registers a0-a3. In addition, the system call number is * passed in the v0 register. * * On successful return, the return value is passed back in the v0 * register, like an ordinary function call, and the a3 register is * also set to 0 to indicate success. * * On an error return, the error code is passed back in the v0 * register, and the a3 register is set to 1 to indicate failure. * (Userlevel code takes care of storing the error code in errno and * returning the value -1 from the actual userlevel syscall function. * See src/lib/libc/syscalls.S and related files.) * * Upon syscall return the program counter stored in the trapframe * must be incremented by one instruction; otherwise the exception * return code will restart the "syscall" instruction and the system * call will repeat forever. * * Since none of the OS/161 system calls have more than 4 arguments, * there should be no need to fetch additional arguments from the * user-level stack. * * Watch out: if you make system calls that have 64-bit quantities as * arguments, they will get passed in pairs of registers, and not * necessarily in the way you expect. We recommend you don't do it. * (In fact, we recommend you don't use 64-bit quantities at all. See * arch/mips/include/types.h.) */ extern struct thread* curthread; void mips_syscall(struct trapframe *tf) { int callno; int32_t retval; int err; assert(curspl == 0); callno = tf->tf_v0; /* * Initialize retval to 0. Many of the system calls don't * really return a value, just 0 for success and -1 on * error. Since retval is the value returned on success, * initialize it to 0 by default; thus it's not necessary to * deal with it except for calls that return other values, * like write. */ retval = 0; switch (callno) { case SYS_reboot: err = sys_reboot(tf->tf_a0); break; case SYS_fork: err = fork(tf, &retval); break; case SYS_getpid: err = 0; retval = curthread->process_id; break; case SYS_waitpid: err = waitpid(tf->tf_a0, tf->tf_a1, tf->tf_a2, &retval); break; case SYS__exit: exit(tf->tf_a0); break; case SYS_read: err = sys_read(tf->tf_a0, (char *) tf->tf_a1, tf->tf_a2, &retval); break; case SYS_write: err = sys_write(tf->tf_a0, (void *) tf->tf_a1, tf->tf_a2, &retval); break; case SYS_execv: err = execv((const char *)tf->tf_a0, (char *const*)tf->tf_a1, &retval); break; /* Add stuff here */ default: kprintf("Unknown syscall %d\n", callno); err = ENOSYS; break; } if (err) { /* * Return the error code. This gets converted at * userlevel to a return value of -1 and the error * code in errno. */ tf->tf_v0 = err; tf->tf_a3 = 1; /* signal an error */ } else { /* Success. */ tf->tf_v0 = retval; tf->tf_a3 = 0; /* signal no error */ } /* * Now, advance the program counter, to avoid restarting * the syscall over and over again. */ tf->tf_epc += 4; /* Make sure the syscall code didn't forget to lower spl */ assert(curspl == 0); } int fork(struct trapframe *tf, int* retval) { int s = splhigh(); struct addrspace *childSpace; struct thread *childthread; struct trapframe *child_tf; int value = as_copy(curthread->t_vmspace, &childSpace); if (value != 0) { splx(s); return value; } if (childSpace == NULL) { splx(s); return -1; } child_tf = kmalloc(sizeof (struct trapframe)); if (child_tf == NULL) { splx(s); return ENOMEM; } memcpy(child_tf, tf, sizeof (struct trapframe)); value = thread_fork(curthread->t_name, (void*) child_tf, (unsigned long) childSpace, md_forkentry, &childthread); if (value != 0) { splx(s); return ENOMEM; } *retval = childthread->process_id; splx(s); return 0; } void md_forkentry(void *tf, unsigned long childSpace) { struct trapframe child_tf = *(struct trapframe*) tf; child_tf.tf_v0 = 0; child_tf.tf_a3 = 0; child_tf.tf_epc += 4; curthread->t_vmspace = (struct addrspace*) childSpace; as_activate(curthread->t_vmspace); mips_usermode(&child_tf); } void exit(int code) { process_exitcode[curthread->process_id] = code; process_exit[curthread->process_id] = 1; if (curthread->process_id >= 10) V(process_sem[curthread->process_id]); thread_exit(); } int waitpid(pid_t pid, int* status, int options, int* retval) { if (process_occupied[pid] == 0 || options != 0) return EINVAL; if (parent_thread[pid] != curthread) return EINVAL; if (status == NULL) return EFAULT; P(process_sem[pid]); *status = process_exitcode[pid]; *retval = pid; process_exit[pid] = 0; process_exitcode[pid] = 0; parent_thread[pid] = NULL; sem_destroy(process_sem[pid]); process_occupied[pid] = 0; return 0; } int sys_read(int fd, char *buf1, size_t buflen, int* retval) { if (buf1 == NULL) { *retval = -1; return EFAULT; } if (fd != 0) { *retval = -1; return EBADF; } if (buflen == 0){ *retval = -1; return EIO; } int counter; for (counter = 0; counter < buflen; counter++) { char* charbuf; *charbuf = (char) getch(); if (charbuf == NULL){ *retval = -1; return EFAULT; } int a = copyout((void*)charbuf, (userptr_t) buf1 + counter, 1); if (a != 0){ *retval = -1; return a; } buf1++; } *retval = buflen; return 0; } int sys_write(int fd, void *buf1, size_t buflen, int* retval) { char *buf; buf = kmalloc(sizeof(char) * (buflen + 1)); if (buf == NULL) { *retval = -1; return ENOMEM; } if (buf1 == NULL) { *retval = -1; return EFAULT; } if (buflen == 0){ *retval = -1; return EIO; } if (fd != 1 && fd != 2) { *retval = -1; return EBADF; } copyin((const_userptr_t)buf1, buf, buflen); buf[buflen] = '\0'; int i; for(i = 0; i < buflen; i++){ putch((int)buf[i]); } *retval = buflen; kfree(buf); return 0; } int execv(const char *program, char *const *args,int *retval){ int spl=splhigh(); if(program==NULL){ return EINVAL; } struct vnode *v; char* path = (char *) kmalloc(128 * sizeof(char)); curthread->t_vmspace=as_create(); if(curthread->t_vmspace){ vfs_close(v); return ENOMEM; } }
[ "kenan.hu@mail.utoronto.ca" ]
kenan.hu@mail.utoronto.ca
fe9e8e6f19e9ed346657d81038066b5a7bb9898d
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/external/bsd/drm2/dist/drm/amd/display/dc/gpio/dcn21/hw_factory_dcn21.h
e19085a2addba44cce07c732db2abede44022561
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
1,464
h
/* $NetBSD: hw_factory_dcn21.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $ */ /* * Copyright 2018 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. * * Authors: AMD * */ #ifndef __DAL_HW_FACTORY_DCN21_H__ #define __DAL_HW_FACTORY_DCN21_H__ /* Initialize HW factory function pointers and pin info */ void dal_hw_factory_dcn21_init(struct hw_factory *factory); #endif /* __DAL_HW_FACTORY_DCN20_H__ */
[ "riastradh@NetBSD.org" ]
riastradh@NetBSD.org
d48157e2a0992de1595aac5218a1713d5bf762fd
9afdd0184d38855bbede2fe396762b9faf264510
/src/itoa.c
f30389550df31482af27a93d34908494c15bbbe5
[ "BSD-3-Clause" ]
permissive
pabigot/embtextf
a45d23a6480401e616b9e5f438d829c897a991d0
a114a91bb4a82001c6b6b3a03facb78b4e980a62
refs/heads/master
2021-01-01T16:25:27.150996
2015-02-09T03:52:26
2015-02-09T03:52:26
8,961,773
3
0
null
null
null
null
UTF-8
C
false
false
128
c
#include <embtextf/xtoa.h> #define INT_T int #define STOA embtextf_itoa #define UTOA embtextf_utoa #include "embtextf/xtoa.inc"
[ "pab@pabigot.com" ]
pab@pabigot.com
6493ae047bf03a9665bce64b2a10116f1f33eff7
83214753e9183327e98af0e6768e9be5385e5282
/kungfu/class/qingcheng/npc/luo.c
7ed83a7108971c0449e6ff6ef69fd81107abb28f
[]
no_license
MudRen/hymud
f5b3bb0e0232f23a48cb5f1db2e34f08be99614e
b9433df6cf48e936b07252b15b60806ff55bb2f3
refs/heads/main
2023-04-04T22:44:23.880558
2021-04-07T15:45:16
2021-04-07T15:45:16
318,484,633
1
5
null
null
null
null
GB18030
C
false
false
1,251
c
// luo.c inherit NPC; //inherit F_SKILL; #include <ansi.h> void create() { set_name("罗人杰", ({ "luo renjie", "luo", "renjie" })); set("gender", "男性"); set("nickname", HIC"青城四秀"NOR); set("age", 25); set("long", "他就是「英雄豪杰,青城四秀」之一,武功也远高同门。\n"); set("combat_exp", 80000); set("shen_type", -1); set_skill("sword", 80); set_skill("dodge", 80); set_skill("parry", 80); set_skill("strike", 80); set_skill("unarmed", 80); set_skill("force", 180); set_skill("pixie-sword", 80); set_skill("songfeng-jian", 80); set_skill("chuanhua", 80); set_skill("wuying-leg", 80); set_skill("cuixin-strike", 80); set_skill("qingming-xuangong", 80); map_skill("force", "qingming-xuangong"); map_skill("unarmed", "wuying-leg"); map_skill("strike", "cuixin-strike"); map_skill("dodge", "chuanhua"); map_skill("parry", "bixie-sword"); map_skill("sword", "songfeng-jian"); prepare_skill("unarmed", "wuying-leg"); prepare_skill("strike", "cuixin-strike"); map_skill("parry", "bixie-sword"); map_skill("sword", "bixie-sword"); create_family("青城派", 6, "弟子"); setup(); carry_object("/clone/weapon/changjian")->wield(); carry_object("/d/wudang/obj/bluecloth")->wear(); }
[ "i@oiuv.cn" ]
i@oiuv.cn
918d0693a28fe0a5bd35da58378a01ea16b3bbae
66862c422fda8b0de8c4a6f9d24eced028805283
/cmake-3.17.5/Tests/Plugin/src/example_mod_1.c
2b740b8db3491b01cd2bdbace8339750a583f633
[ "BSD-3-Clause", "MIT" ]
permissive
zhh2005757/slambook2_in_Docker
57ed4af958b730e6f767cd202717e28144107cdb
f0e71327d196cdad3b3c10d96eacdf95240d528b
refs/heads/main
2023-09-01T03:26:37.542232
2021-10-27T11:45:47
2021-10-27T11:45:47
416,666,234
17
6
MIT
2021-10-13T09:51:00
2021-10-13T09:12:15
null
UTF-8
C
false
false
378
c
#include <example.h> #include <stdio.h> #if defined(_WIN32) # define MODULE_EXPORT __declspec(dllexport) #else # define MODULE_EXPORT #endif #ifdef __WATCOMC__ # define MODULE_CCONV __cdecl #else # define MODULE_CCONV #endif MODULE_EXPORT int MODULE_CCONV example_mod_1_function(int n) { int result = example_exe_function() + n; printf("world\n"); return result; }
[ "594353397@qq.com" ]
594353397@qq.com
015cafb6a6590ae1cfbf6dc2fe9fee34d1a7331e
5a39b25482b93b554a3b2b11b2c71063801c941d
/kernel/graphic/graphic.c
2d1335785f54c1ea922ae578aad542ad86596585
[]
no_license
hanjianqiao/dingus
5588f38c84ab989ef51bc63483438ceb5610df5f
9bd905d38eea2da0f843ec368f1bfd10bd114476
refs/heads/master
2021-01-25T08:49:25.058626
2014-07-09T16:31:25
2014-07-09T16:31:25
21,385,789
1
1
null
null
null
null
UTF-8
C
false
false
1,961
c
#include "../include/kernel.h" void boxfill8(unsigned char *vram, int xsize, unsigned char c, int x0, int y0, int x1, int y1){ int x, y; for (y = y0; y <= y1; y++) { for (x = x0; x <= x1; x++) vram[y * xsize + x] = c; } return; } void putfont8(char *vram, int xsize, int x, int y, char c, char *font) { int i; char *p, d /* data */; for (i = 0; i < 16; i++) { p = vram + (y + i) * xsize + x; d = font[i]; if ((d & 0x80) != 0) { p[0] = c; } if ((d & 0x40) != 0) { p[1] = c; } if ((d & 0x20) != 0) { p[2] = c; } if ((d & 0x10) != 0) { p[3] = c; } if ((d & 0x08) != 0) { p[4] = c; } if ((d & 0x04) != 0) { p[5] = c; } if ((d & 0x02) != 0) { p[6] = c; } if ((d & 0x01) != 0) { p[7] = c; } } return; } void putfonts8_asc(char *vram, int xsize, int x, int y, char c, unsigned char *s) { extern char ascii[4096]; for (; *s != 0x00; s++) { putfont8(vram, xsize, x, y, c, ascii + *s * 16); x += 8; } return; } void putfonts8_asc_count(char *vram, int xsize, int x, int y, char c, unsigned char *s, int len) { extern char ascii[4096]; unsigned int i; for (i = 0; i < len; i++, s++) { putfont8(vram, xsize, x, y, c, ascii + *s * 16); x += 8; } return; } void putHex(char *vram, int xsize, int x, int y, char c, unsigned char *s){ extern char ascii[4096]; if((*s)/16 < 10){ putfont8(vram, xsize, x, y, c, ascii + '0' * 16 + (*s)/16 * 16); }else{ putfont8(vram, xsize, x, y, c, ascii + ('A' - 10) * 16 + (*s)/16 * 16); } x += 8; if((*s)%16 < 10){ putfont8(vram, xsize, x, y, c, ascii + '0' * 16 + (*s)%16 * 16); }else{ putfont8(vram, xsize, x, y, c, ascii + ('A' - 10) * 16 + (*s++)%16 * 16); } } void putHexs(char *vram, int xsize, int x, int y, char c, unsigned char *s, int len){ extern char ascii[4096]; for (; len > 0x00; len--) { putHex(vram, xsize, x, y, c, s++); x += 16; putfont8(vram, xsize, x, y, c, ascii + ' ' * 16); x += 8; if(len % 27 == 0){ y += 24; x = 0; } } }
[ "hanjianqiao@gmail.com" ]
hanjianqiao@gmail.com
2bcec9f1b8b68c298ea333d66bdbd3224e27ec39
cf2359c1f7f340da4f83b2cc60d47e054255276a
/software/freertos-demo/Core/Src/usart.c
28d1f750df21c07641d73852c79c3f619ee534f3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
hbrobotics/hbrc_ros_robot_platform
83612a659d5b17d45ac0ed7d17f779d02285b985
b2abdb21aa0b173200880de2371d9073f42c90dd
refs/heads/master
2021-08-03T00:21:49.504908
2021-07-25T23:18:45
2021-07-25T23:18:45
222,811,388
5
5
null
2021-07-25T23:18:45
2019-11-19T23:43:08
C
UTF-8
C
false
false
3,288
c
/** ****************************************************************************** * @file usart.c * @brief This file provides code for the configuration * of the USART instances. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "usart.h" /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ UART_HandleTypeDef huart3; /* USART3 init function */ void MX_USART3_UART_Init(void) { /* USER CODE BEGIN USART3_Init 0 */ /* USER CODE END USART3_Init 0 */ /* USER CODE BEGIN USART3_Init 1 */ /* USER CODE END USART3_Init 1 */ huart3.Instance = USART3; huart3.Init.BaudRate = 115200; huart3.Init.WordLength = UART_WORDLENGTH_8B; huart3.Init.StopBits = UART_STOPBITS_1; huart3.Init.Parity = UART_PARITY_NONE; huart3.Init.Mode = UART_MODE_TX_RX; huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart3.Init.OverSampling = UART_OVERSAMPLING_16; huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if (HAL_UART_Init(&huart3) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART3_Init 2 */ /* USER CODE END USART3_Init 2 */ } void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(uartHandle->Instance==USART3) { /* USER CODE BEGIN USART3_MspInit 0 */ /* USER CODE END USART3_MspInit 0 */ /* USART3 clock enable */ __HAL_RCC_USART3_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); /**USART3 GPIO Configuration PD8 ------> USART3_TX PD9 ------> USART3_RX */ GPIO_InitStruct.Pin = STL_RX_Pin|STL_TX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF7_USART3; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /* USER CODE BEGIN USART3_MspInit 1 */ /* USER CODE END USART3_MspInit 1 */ } } void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) { if(uartHandle->Instance==USART3) { /* USER CODE BEGIN USART3_MspDeInit 0 */ /* USER CODE END USART3_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART3_CLK_DISABLE(); /**USART3 GPIO Configuration PD8 ------> USART3_TX PD9 ------> USART3_RX */ HAL_GPIO_DeInit(GPIOD, STL_RX_Pin|STL_TX_Pin); /* USER CODE BEGIN USART3_MspDeInit 1 */ /* USER CODE END USART3_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
[ "jnugen@gmail.com" ]
jnugen@gmail.com
ce832fe55a21cdc24b2988b3974b2e6e96a4e77e
0725729da64cd6fa2202b38b642ea3d68a858350
/src/wsnos/platform/WSN-JH02-ZD/driver/spi.h
3e585607ae4dc736d41a2d1fdb1d29d004b4334f
[]
no_license
wjf3310105/can_send_recv
b69d731c5fb102b5ab708475965222b6bdf2cf54
93fd70b5498a9583a81fe2e08c035bd1ee7201f8
refs/heads/master
2021-06-30T07:28:16.219221
2017-09-20T06:32:27
2017-09-20T06:32:27
104,175,227
1
1
null
null
null
null
UTF-8
C
false
false
1,998
h
/** * @brief : this * @file : spi.h * @version : v0.0.1 * @author : gang.cheng * @date : 2017-04-24 * change logs : * Date Version Author Note * 2017-04-24 v0.0.1 gang.cheng first version */ #ifndef __SPI_H__ #define __SPI_H__ #include "common/lib/data_type_def.h" typedef enum { SPI1, SPI2 } spi_enum; typedef struct spi_s { uint8_t Spi; pin_id_t Mosi; pin_id_t Miso; pin_id_t Sclk; pin_id_t Nss; } Spi_t; void spi_com_set(Spi_t *spi, uint8_t com); /*! * \brief Initializes the SPI object and MCU peripheral * * \remark When NSS pin is software controlled set the pin name to NC otherwise * set the pin name to be used. * * \param [IN] spi SPI object * \param [IN] mosi SPI MOSI pin name to be used * \param [IN] miso SPI MISO pin name to be used * \param [IN] sclk SPI SCLK pin name to be used * \param [IN] nss SPI NSS pin name to be used */ void spi_init(Spi_t *spi, pin_name_e mosi, pin_name_e miso, pin_name_e sclk, pin_name_e nss); void spi_disable(Spi_t *spi); void spi_enable(Spi_t *spi); void spi_deinit(Spi_t *spi); /*! * \brief Configures the SPI peripheral * * \remark Slave mode isn't currently handled * * \param [IN] obj SPI object * \param [IN] bits Number of bits to be used. [8 or 16] * \param [IN] cpol Clock polarity * \param [IN] cpha Clock phase * \param [IN] slave When set the peripheral acts in slave mode */ void spi_format(Spi_t *spi, int8_t bits, int8_t cpol, int8_t cpha, int8_t slave); /*! * \brief Sets the SPI speed * * \param [IN] obj SPI object * \param [IN] hz SPI clock frequency in hz */ void spi_frequency( Spi_t *spi, uint32_t hz ); /*! * \brief Sends outData and receives inData * * \param [IN] spi SPI object * \param [IN] outData Byte to be sent * \retval inData Received byte. */ uint16_t spi_inout( Spi_t *spi, uint16_t out_data ); #endif
[ "wangjifang@wsn.cn" ]
wangjifang@wsn.cn
b2a780459176982e2b7f2fb94c72a329e6a99638
7a288556ef88974e6877472740fd76e1014fe5a7
/thirdparty/freertos/demo/oled1_event_groups_xpro_example/samd20_xplained_pro/iar/asf.h
f0ad2bce9c79856f3fab7d73554c62430a964ba0
[]
no_license
Realtime-7/asf
0452a55c62b869da48a771811dc9157d352c6470
2062737bc4a5f1eada3d43b2987c365b8b8c1881
refs/heads/master
2021-01-14T10:26:32.948063
2014-11-25T16:19:51
2014-11-25T16:19:51
null
0
0
null
null
null
null
UTF-8
C
false
false
3,839
h
/** * \file * * \brief Autogenerated API include file for the Atmel Software Framework (ASF) * * Copyright (c) 2012 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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. * * \asf_license_stop * */ #ifndef ASF_H #define ASF_H /* * This file includes all API header files for the selected drivers from ASF. * Note: There might be duplicate includes required by more than one driver. * * The file is automatically generated and will be re-written when * running the ASF driver selector tool. Any changes will be discarded. */ // From module: Common SAM0 compiler driver #include <compiler.h> #include <status_codes.h> // From module: Delay routines #include <delay.h> // From module: FreeRTOS - kernel 8.0.1 #include <FreeRTOS.h> #include <StackMacros.h> #include <croutine.h> #include <event_groups.h> #include <list.h> #include <mpu_wrappers.h> #include <portable.h> #include <projdefs.h> #include <queue.h> #include <semphr.h> #include <task.h> #include <timers.h> // From module: GFX Monochrome - Monochrome Graphic Library #include <gfx_mono.h> // From module: GFX Monochrome - System Font #include <sysfont.h> // From module: Generic board support #include <board.h> // From module: Interrupt management - SAM implementation #include <interrupt.h> // From module: PORT - GPIO Pin Control #include <port.h> // From module: Part identification macros #include <parts.h> // From module: SERCOM Callback API #include <sercom.h> #include <sercom_interrupt.h> // From module: SERCOM SPI - Serial Peripheral Interface (Callback APIs) #include <spi.h> #include <spi_interrupt.h> // From module: SERCOM USART - Serial Communications (Callback APIs) #include <usart.h> #include <usart_interrupt.h> // From module: SSD1306 OLED controller #include <ssd1306.h> // From module: SYSTEM - Clock Management for SAMD20 #include <clock.h> #include <gclk.h> // From module: SYSTEM - Core System Driver #include <system.h> // From module: SYSTEM - I/O Pin Multiplexer #include <pinmux.h> // From module: SYSTEM - Interrupt Driver #include <system_interrupt.h> // From module: User I/O driver for FreeRTOS demo #include <cdc.h> #include <oled1.h> #endif // ASF_H
[ "it.daniher@gmail.com" ]
it.daniher@gmail.com
43192ef09b50a3276278165e5926f0af1653cfe8
c7b869b54873b27de7a6dc7c198f7c8424e4bdce
/Week_01-Projects/mario_harder_pset.c
ce4d72105adee4ad14d332669fb512e8283a4322
[]
no_license
Philbarboza/CS50-s-Course-Projects
a474cb07f31b6beff38c122eb46e665c7ede3e46
bf093d358e8f6a13ba0e1dfb86f60fc6ed020f42
refs/heads/master
2021-03-05T17:58:22.554895
2020-04-23T10:44:13
2020-04-23T10:44:13
246,138,892
0
0
null
null
null
null
UTF-8
C
false
false
1,211
c
#include <cs50.h> #include <stdio.h> // goal: create a pyramid that can have a height between 1 and 8 inclusively and has the following appearance: // # # // ## ## // ### ### // #### #### // ##### ##### // ###### ###### int main(void) { int h; do // prompt user, so that he types in the height and assign answer to variable h { h = get_int("Height: "); } // re-prompt user as long as his or her answer is not between 1 and 8 inclusively while (h < 1 || h > 8); // for loop to get to the next row or line for (int i = 0; i < h; i++) { // creating spaces (previously dots) along a row and this as long as d < (h-i) for (int d = 1; d < (h - i); d++) { printf(" "); } // creating # along a row, as long as x <= i for (int x = 0; x <= i; x++) { printf("#"); } // create middle gap for (int g = 0; g < 1; g++) { printf(" "); } // crate the # for the right part of the pyramid for (int r = 0; r <= i; r++) { printf("#"); } printf("\n"); } }
[ "noreply@github.com" ]
Philbarboza.noreply@github.com
4dc80a82718b713066ced5742f3acbec02fa79ea
a8b22dc41d3d7f93f43bb871e585692f3599a12f
/source/powermon_fileio.c
fa996238eb52400d50e0224390e44d060adaa9ad
[]
no_license
ReggieMoto/PowerMon
7088acc1c0243c066aaaccb88c06b3a5afa1061d
28d0d3f0f43fc4d5c71393e3a268ef85a1e243af
refs/heads/master
2021-07-10T19:00:51.123790
2021-04-03T20:16:32
2021-04-03T20:16:32
99,441,296
0
0
null
2021-04-03T20:16:32
2017-08-05T18:37:02
C
UTF-8
C
false
false
948
c
/* ============================================================== */ /* * powermon_fileio.c * * Copyright (c) 2017 David Hammond * All Rights Reserved. */ /* ============================================================== */ /* * NOTICE: All information contained herein is and remains the * property of David Hammond. The intellectual and technical * concepts contained herein are proprietary to David Hammond * and may be covered by U.S.and Foreign Patents, patents in * process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this * material is strictly forbidden unless prior written permission * is obtained David Hammond. */ /* ============================================================== */ int readLogFile(void) { return (0); } int writeLogFile(void) { return (0); } int readLoginAccounts(void) { return (0); } int writeLoginAccounts(void) { return (0); }
[ "home@davidhammond.net" ]
home@davidhammond.net
731c9eef0d52613f42c8553373bb9a98779a9679
11e97f87deb25babb4a32c80941e7ff4e476c92a
/OPT/TC3AutoDual/T3DualAuto/ADLINK/PCIS-DASK/Samples/9111/SDK9111/Util9111.c
3463626433b773ab8ed7fd5aa5d7a9d99aa76728
[]
no_license
xhyangxianjun/Builder6-program
b9d03d98658db5a5a8cf1586210a373bc391dc48
a12d811d7a5fa3dba6d3e8c05989a41cb89783de
refs/heads/master
2022-04-03T00:25:47.274355
2019-09-19T08:26:56
2019-09-19T08:26:56
null
0
0
null
null
null
null
UTF-8
C
false
false
31,277
c
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include "dask.h" #include "resource.h" #define IDM_EXIT 110 #define IDM_SETUP 101 #define IDC_SCROLL 207 #define IDC_SPIN 301 #define IDC_START 208 #define IDC_STOP 209 #define IDC_PAUSE 210 #define IDC_EDIT 211 #define IDC_GAIN 212 #define IDC_DA 400 #define TIMER1 1 #define NONE 0 int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int); long PASCAL MainWndProc(HWND, UINT, WPARAM, LPARAM); HANDLE hInst; HWND hAddrComboBox; HWND hCardComboBox; HWND hADScroll; HWND hEdit; HWND MainhWnd; I16 card=-1, card_number = 0; I16 input=0, output=0; I16 oldinput=0,analog_input[16],adinput[16],old_adinput1[16],old_adinput2[16]; U8 input_lo=0, input_hi=0; int Card_Type=PCI_9111DG; I16 card_value[2] = {PCI_9111DG, PCI_9111HR}; LPSTR Card_Name[2]={"PCI9111DG", "PCI9111HR"}; LPSTR AD_Range[5]={"+/-10V","+/-5V","+/-2.5V","+/-1.25V","+/-0.625V"}; I16 range_value[5] = {AD_B_10_V, AD_B_5_V, AD_B_2_5_V, AD_B_1_25_V, AD_B_0_625_V}; HBRUSH hLTGreenBrush,hGreenBrush,hBlueBrush,hYellowBrush,hRedBrush,hBlackBrush,hWhiteBrush,hLTRedBrush,hLTBlueBrush; HPEN hRedPen,hYellowPen,hGreenPen,hBluePen,hLTBluePen,hLTRedPen,hLTGreenPen,hWhitePen; I16 sample_rate=10, time_interval, range=AD_B_5_V; POINT input_pos[16]= {{470, 280}, {440, 280}, {410, 280}, {380, 280}, {350, 280}, {320, 280}, { 290, 280}, {260, 280}, {230, 280}, {200, 280}, {170, 280}, {140, 280}, {110, 280}, {80, 280}, { 50, 280}, { 20, 280}, }; POINT output_pos[16] ={ {470, 340}, {440, 340}, {410, 340}, {380, 340}, {350, 340}, {320, 340}, { 290, 340}, {260, 340}, {230, 340}, {200, 340}, {170, 340}, {140, 340}, {110, 340}, {80, 340}, { 50, 340}, { 20, 340}, }; POINT io_pos[16] ={ {395, 40}, {370, 40}, {345, 40}, {320, 40}, {295, 40}, {270, 40}, { 245, 40}, {220, 40}, {195, 40}, {170, 40}, {145, 40}, {120, 40}, {95, 40}, {70, 40}, { 45, 40}, { 20, 40}, }; BOOL bCheck1[8],bCheck2[8],bStart=FALSE,bStop=FALSE,bPause=FALSE; BOOL InitApplication(HANDLE); BOOL InitInstance(HANDLE, int); int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow) HANDLE hInstance, hPrevInstance; LPSTR lpCmdLine; int nCmdShow; { MSG msg; if (!hPrevInstance) if (!InitApplication(hInstance)) return(FALSE); if (!InitInstance(hInstance, nCmdShow)) return(FALSE); while (GetMessage(&msg, NULL, NULL, NULL)) { TranslateMessage(&msg); DispatchMessage(&msg); } return(msg.wParam); } BOOL InitApplication(hInstance) HANDLE hInstance; { WNDCLASS wc; /* Main Window Class */ wc.style = NULL; wc.lpfnWndProc = (WNDPROC)MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, "MyIcon"); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(LTGRAY_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "GenericWClass"; if (!RegisterClass(&wc)) return(FALSE); } BOOL InitInstance(hInstance, nCmdShow) HANDLE hInstance; int nCmdShow; { HWND hWnd; HMENU hSampleMenu; hInst = hInstance; hSampleMenu = LoadMenu(hInstance, "U7120Menu"); hWnd = CreateWindow("GenericWClass", (LPCSTR)"PCI-9111", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 530, 480, NULL, hSampleMenu, hInstance, NULL); MainhWnd=hWnd; if (!hWnd) return(FALSE); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return(TRUE); } BOOL PASCAL setup(HWND hWnd, unsigned message, WPARAM wParam, LPARAM lParam) { int i,k; char n[16]; char s[50]; switch (message) { case WM_INITDIALOG: for (i=0;i<2;i++) { SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_ADDSTRING, NULL, (LONG)Card_Name[i]); } SendMessage(GetDlgItem(hWnd,IDC_COMBO1) , CB_SETCURSEL, 0, 0L); for (i=0;i<16;i++) { wsprintf(n, "%d", i); _strupr(n); SendMessage(GetDlgItem(hWnd,IDC_COMBO2), CB_ADDSTRING, NULL, (LONG)(LPSTR) n); } SendMessage(GetDlgItem(hWnd,IDC_COMBO2) , CB_SETCURSEL, 0, 0L); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_COMBO1: if (HIWORD(wParam) == CBN_CLOSEUP) { i = (int)SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_GETCURSEL, 0, 0L); SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_GETLBTEXT, i, (LPARAM)((LPCSTR)n)); Card_Type = card_value[i]; } return(TRUE); case IDC_COMBO2: if (HIWORD(wParam) == CBN_CLOSEUP) { i = (int)SendMessage(GetDlgItem(hWnd,IDC_COMBO2), CB_GETCURSEL, 0, 0L); SendMessage(GetDlgItem(hWnd,IDC_COMBO2), CB_GETLBTEXT, i, (LPARAM)((LPCSTR)n)); card_number = i; } return(TRUE); case IDOK: if ((card=Register_Card(Card_Type, card_number)) < 0) { wsprintf(s, "Register_Card Error = %d\n", card); MessageBox(hWnd, s, "Error", MB_OK); SendMessage(hWnd, WM_CLOSE, 0, 0L); break; } EndDialog(hWnd, TRUE); InvalidateRect(hWnd, NULL, FALSE); return (TRUE); case IDCANCEL: EndDialog(hWnd, TRUE); return (TRUE); } break; } return (FALSE); } long PASCAL MainWndProc(hWnd, message, wParam, lParam) HWND hWnd; UINT message; WPARAM wParam; LPARAM lParam; { HDC hDC; PAINTSTRUCT ps; int i, k, px, py; char n[15]; double Pi = 3.1415926535; static U16 pos=0; switch(message) { case WM_CREATE: DialogBox(hInst,IDD_DIALOG2, hWnd, setup); if(card<0) { SendMessage(hWnd, WM_CLOSE, 0, 0L); break; } for (i=0;i<8;i++) { bCheck1[i]=FALSE; bCheck2[i]=FALSE; old_adinput1[i]=-1; old_adinput2[i]=-1; } hAddrComboBox = CreateWindow("ComboBox", NULL, CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL, output_pos[4].x+90, io_pos[0].y+70, 85, 120, hWnd, IDC_GAIN, hInst, NULL); for (i=0;i<5;i++) { SendMessage(hAddrComboBox, CB_ADDSTRING, NULL, (LONG)AD_Range[i]); } SendMessage(hAddrComboBox ,CB_SETCURSEL, 1, 0L); hADScroll=CreateWindow("SCROLLBAR", NULL, WS_CHILD | WS_VISIBLE | SBS_HORZ, output_pos[8].x+10, io_pos[15].y+200,190, 18, hWnd, IDC_SCROLL, hInst, NULL); SetScrollRange(hADScroll,SB_CTL,0,4095,TRUE); SetScrollPos(hADScroll,SB_CTL,0,TRUE); CreateWindow("BUTTON","Start" , WS_CHILD | WS_VISIBLE , output_pos[10].x+110, output_pos[10].y+50,50, 30, hWnd, IDC_START, hInst, NULL); CreateWindow("BUTTON","Stop" , WS_CHILD | WS_VISIBLE , output_pos[10].x+170, output_pos[10].y+50,50, 30, hWnd, IDC_STOP, hInst, NULL); CreateWindow("BUTTON","Pause" , WS_CHILD | WS_VISIBLE , output_pos[10].x+230, output_pos[10].y+50,50, 30, hWnd, IDC_PAUSE, hInst, NULL); CreateWindow("BUTTON","0" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT , output_pos[4].x+50, io_pos[0].y-5,25,15, hWnd,IDC_DA, hInst, NULL); CreateWindow("BUTTON","1" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+13,25,15, hWnd,IDC_DA+1, hInst, NULL); CreateWindow("BUTTON","2" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+31,25,15, hWnd,IDC_DA+2, hInst, NULL); CreateWindow("BUTTON","3" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+49,25,15, hWnd,IDC_DA+3, hInst, NULL); CreateWindow("BUTTON","4" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y-5,25,15, hWnd,IDC_DA+4, hInst, NULL); CreateWindow("BUTTON","5" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+13,25,15, hWnd, IDC_DA+5, hInst, NULL); CreateWindow("BUTTON","6" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+31,25,15, hWnd,IDC_DA+6, hInst, NULL); CreateWindow("BUTTON","7" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+49,25,15, hWnd, IDC_DA+7, hInst, NULL); CreateWindow("BUTTON","0" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+97,25,15, hWnd, IDC_DA+8, hInst, NULL); CreateWindow("BUTTON","1" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+115,25,15, hWnd, IDC_DA+9, hInst, NULL); CreateWindow("BUTTON","2" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+133,25,15, hWnd, IDC_DA+10, hInst, NULL); CreateWindow("BUTTON","3" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+50, io_pos[0].y+151,25,15, hWnd, IDC_DA+11, hInst, NULL); CreateWindow("BUTTON","4" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+97,25,15, hWnd, IDC_DA+12, hInst, NULL); CreateWindow("BUTTON","5" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+115,25,15, hWnd, IDC_DA+13, hInst, NULL); CreateWindow("BUTTON","6" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+133,25,15, hWnd, IDC_DA+14, hInst, NULL); CreateWindow("BUTTON","7" , WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | BS_LEFTTEXT, output_pos[4].x+100, io_pos[0].y+151,25,15, hWnd, IDC_DA+15, hInst, NULL); hLTGreenBrush = CreateSolidBrush(RGB(0, 255, 0)); hGreenBrush = CreateSolidBrush(RGB(0, 128, 0)); hBlueBrush = CreateSolidBrush(RGB(0, 0, 255)); hRedBrush = CreateSolidBrush(RGB(255, 0, 0)); hYellowBrush= CreateSolidBrush(RGB(255,255,0)); hBlackBrush= CreateSolidBrush(RGB(0,0,0)); hLTBlueBrush= CreateSolidBrush(RGB(0,255,255)); hLTRedBrush= CreateSolidBrush(RGB(255,128,0)); hWhiteBrush= CreateSolidBrush(RGB(255,255,255)); hRedPen= CreatePen(PS_SOLID,1,RGB(255,0,0)); hYellowPen= CreatePen(PS_SOLID,1,RGB(255,255,0)); hBluePen= CreatePen(PS_SOLID,1,RGB(0,0,255)); hGreenPen= CreatePen(PS_SOLID,1,RGB(0,255,0)); hLTBluePen= CreatePen(PS_SOLID,1,RGB(0,128,255)); hLTRedPen= CreatePen(PS_SOLID,1,RGB(255,128,0)); hLTGreenPen= CreatePen(PS_SOLID,1,RGB(0,128,0)); hWhitePen= CreatePen(PS_SOLID,1,RGB(255,255,255)); break; case WM_PAINT: hDC = BeginPaint(hWnd, &ps); // Digital Input Box SelectObject(hDC, hLTGreenBrush); Rectangle(hDC, input_pos[15].x-10, input_pos[15].y-14, input_pos[0].x+26, input_pos[0].y+40); SetTextColor(hDC,RGB(255,255,255)); SetBkColor(hDC, RGB(0, 0, 255)); TextOut(hDC, input_pos[15].x, input_pos[15].y-18, "Digital Input",13); // Digital Output Box SelectObject(hDC, hGreenBrush); Rectangle(hDC, output_pos[15].x-10, output_pos[15].y-14, output_pos[0].x+26, output_pos[0].y+40); SetTextColor(hDC,RGB(255,0,0)); SetBkColor(hDC, RGB(0, 0, 255)); TextOut(hDC, output_pos[15].x, output_pos[15].y-20, "Digital Output", 14); // Analog Input Box SelectObject(hDC, GetStockObject(GRAY_BRUSH)); Rectangle(hDC, output_pos[15].x-10, io_pos[15].y-24, output_pos[0].x+26, io_pos[0].y+175); SetTextColor(hDC,RGB(255,255,0)); SetBkColor(hDC, RGB(0, 0, 255)); TextOut(hDC, io_pos[15].x, io_pos[15].y-35, "Analog Input(A/D)", 17); SelectObject(hDC, hBlackBrush); Rectangle(hDC, output_pos[15].x+35, io_pos[15].y-2, output_pos[4].x+41, io_pos[0].y+83); Rectangle(hDC, output_pos[15].x+35, io_pos[15].y+87, output_pos[4].x+41, io_pos[0].y+172); // Analog Output Box SelectObject(hDC, GetStockObject(GRAY_BRUSH)); Rectangle(hDC, output_pos[15].x-10, io_pos[15].y+180, output_pos[0].x+26, io_pos[0].y+225); SetTextColor(hDC,RGB(255,255,0)); SetBkColor(hDC, RGB(0, 0, 255)); TextOut(hDC, io_pos[15].x, io_pos[15].y+175, "Analog Output(D/A)", 18); // Channel Label SetTextColor(hDC,RGB(0,0,0)); SetBkColor(hDC, RGB(0, 255, 0)); TextOut(hDC, input_pos[15].x, input_pos[15].y+20, "15 0", 114); SetBkColor(hDC, RGB(0, 128, 0)); TextOut(hDC, output_pos[15].x, output_pos[15].y+20, "15 0", 114); SetBkColor(hDC, RGB(0, 255, 0)); SelectObject(hDC,hYellowBrush ); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y-5,output_pos[4].x+90, io_pos[0].y+10); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+97,output_pos[4].x+90, io_pos[0].y+112); SelectObject(hDC, hGreenBrush); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+13,output_pos[4].x+90, io_pos[0].y+28); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+115,output_pos[4].x+90, io_pos[0].y+130); SelectObject(hDC, hBlueBrush); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+31,output_pos[4].x+90, io_pos[0].y+46); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+133,output_pos[4].x+90, io_pos[0].y+148); SelectObject(hDC, hRedBrush); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+49,output_pos[4].x+90, io_pos[0].y+64); Rectangle(hDC,output_pos[4].x+78, io_pos[0].y+151,output_pos[4].x+90, io_pos[0].y+166); SelectObject(hDC, hLTBlueBrush); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y-5,output_pos[4].x+140, io_pos[0].y+10); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+97,output_pos[4].x+140, io_pos[0].y+112); SelectObject(hDC, hLTRedBrush); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+13,output_pos[4].x+140, io_pos[0].y+28); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+115,output_pos[4].x+140, io_pos[0].y+130); SelectObject(hDC, hLTGreenBrush); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+31,output_pos[4].x+140, io_pos[0].y+46); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+133,output_pos[4].x+140, io_pos[0].y+148); SelectObject(hDC, hWhiteBrush); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+49,output_pos[4].x+140, io_pos[0].y+64); Rectangle(hDC,output_pos[4].x+128, io_pos[0].y+151,output_pos[4].x+140, io_pos[0].y+166); SetBkMode(hDC,TRANSPARENT); TextOut(hDC,output_pos[15].x, output_pos[15].y+56,"Card",4); TextOut(hDC,output_pos[15].x, output_pos[15].y+69,"Type",4); SetBkMode(hDC,TRANSPARENT); TextOut(hDC,output_pos[8].x+20, io_pos[15].y+182,"-10 -6 -2 2 6 10",33); TextOut(hDC,output_pos[4].x+50, io_pos[0].y+67,"Input",5); TextOut(hDC,output_pos[4].x+50, io_pos[0].y+80,"Range",5); TextOut(hDC,input_pos[15].x, io_pos[15].y-19,"Volts",5); switch (range) { case AD_B_10_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"10.0",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+67,"-10.0",5); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"10.0",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+159,"-10.0",5); break; case AD_B_5_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"5.00",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+67,"-5.00",5); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"5.00",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+159,"-5.00",5); break; case AD_B_2_5_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"2.50",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+67,"-2.50",5); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"2.50",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+159,"-2.50",5); break; case AD_B_1_25_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"1.25",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+67,"-1.25",5); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"1.25",4); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+159,"-1.25",5); break; case AD_B_0_625_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"0.625",5); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+67,"-0.625",6); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"0.625",5); TextOut(hDC,input_pos[15].x-8, io_pos[15].y+159,"-0.625",6); break; case AD_U_10_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"10.0",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+67," 0.0",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"10.0",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+159," 0.0",4); break; case AD_U_5_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"5.00",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+67,"0.00",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"5.00",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+159,"0.00",4); break; case AD_U_2_5_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"2.50",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+67,"0.00",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"2.50",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+159,"0.00",4); break; case AD_U_1_25_V: TextOut(hDC,input_pos[15].x-5, io_pos[15].y-5,"1.25",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+67,"0.00",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+87,"1.25",4); TextOut(hDC,input_pos[15].x-5, io_pos[15].y+159,"0.00",4); break; } TextOut(hDC,input_pos[10].x, io_pos[10].y-19,"Signals",7); TextOut(hDC,output_pos[4].x+50, io_pos[0].y-20,"Channel",7); SetBkMode(hDC,OPAQUE); // Detect Channel Input for (i=0; i<16; i++) { if ((input>>i)&0x01) SelectObject(hDC, hRedBrush); else SelectObject(hDC, GetStockObject(WHITE_BRUSH)); Ellipse(hDC, input_pos[i].x, input_pos[i].y, input_pos[i].x+20, input_pos[i].y+20); } // Channel Output for (i=0; i<16; i++) { if ((output>>i)&0x01) SelectObject(hDC, hRedBrush); else SelectObject(hDC, GetStockObject(WHITE_BRUSH)); Ellipse(hDC, output_pos[i].x, output_pos[i].y, output_pos[i].x+20, output_pos[i].y+20); } EndPaint(hWnd, &ps); break; case WM_HSCROLL: switch(LOWORD(wParam)) { case SB_THUMBPOSITION : pos=HIWORD(wParam); break; } SetScrollPos(lParam,SB_CTL,pos,TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_EXIT: SendMessage(hWnd, WM_CLOSE, 0, 0L); break; case IDC_START: time_interval=1000/sample_rate; SetTimer(hWnd, TIMER1, time_interval, NULL); srand((unsigned)time(NULL)); bStop=FALSE; bPause=FALSE; bStart=TRUE; break; case IDC_STOP: KillTimer(hWnd, TIMER1); bStop=TRUE; bPause=FALSE; bStart=FALSE; hDC = GetDC(hWnd); SelectObject(hDC, hBlackBrush); Rectangle(hDC, output_pos[15].x+35, io_pos[15].y-2, output_pos[4].x+41, io_pos[0].y+83); Rectangle(hDC, output_pos[15].x+35, io_pos[15].y+87, output_pos[4].x+41, io_pos[0].y+172); ReleaseDC(hWnd, hDC); break; case IDC_PAUSE: KillTimer(hWnd, TIMER1); bStop=FALSE; bPause=TRUE; bStart=FALSE; break; case IDC_DA: case IDC_DA+1: case IDC_DA+2: case IDC_DA+3: case IDC_DA+4: case IDC_DA+5: case IDC_DA+6: case IDC_DA+7: k=LOWORD(wParam)-IDC_DA; if (bCheck1[k]) { SendMessage(GetDlgItem(hWnd,wParam), BM_SETCHECK, 0, 0); bCheck1[k]=FALSE; } else { SendMessage(GetDlgItem(hWnd,wParam), BM_SETCHECK, 1, 0); bCheck1[k]=TRUE; } break; case IDC_DA+8: case IDC_DA+9: case IDC_DA+10: case IDC_DA+11: case IDC_DA+12: case IDC_DA+13: case IDC_DA+14: case IDC_DA+15: k=LOWORD(wParam)-IDC_DA-8; if (bCheck2[k]) { SendMessage(GetDlgItem(hWnd,wParam), BM_SETCHECK, 0, 0); bCheck2[k]=FALSE; } else { SendMessage(GetDlgItem(hWnd,wParam), BM_SETCHECK, 1, 0); bCheck2[k]=TRUE; } break; case IDC_GAIN: if (HIWORD(wParam) == CBN_CLOSEUP) { if ((i=(int)SendMessage(GetDlgItem(hWnd,IDC_GAIN),CB_GETCURSEL, 0, 0L))>=0 ) { SendMessage(GetDlgItem(hWnd,IDC_GAIN), CB_GETLBTEXT, i, (LPARAM)((LPCSTR)n)); range = range_value[i]; InvalidateRect(hWnd, NULL, FALSE); } } break; default: return(DefWindowProc(hWnd, message, wParam, lParam)); } break; case WM_TIMER: if (card >= 0) { /* Digital Input */ DI_ReadPort(card,0,&input); hDC = GetDC(hWnd); for (i=0; i<16; i++) { if ( ((input>>i)&0x01) != ((oldinput>>i)&0x01) ) { if ((input>>i)&0x01) SelectObject(hDC, hRedBrush); else SelectObject(hDC, GetStockObject(WHITE_BRUSH)); Ellipse(hDC, input_pos[i].x, input_pos[i].y, input_pos[i].x+20, input_pos[i].y+20); } } oldinput=input; /* Analog Input */ BitBlt(hDC,output_pos[15].x+39,io_pos[15].y-2,331,85,hDC,output_pos[15].x+35,io_pos[15].y-2,SRCCOPY); for (i=0;i<8;i++ ) { if (bCheck1[i]) { AI_ReadChannel(card, i, range, &analog_input[i]); switch(i) { case 0: SelectObject(hDC, hYellowPen); break; case 1: SelectObject(hDC, hGreenPen); break; case 2: SelectObject(hDC, hBluePen); break; case 3: SelectObject(hDC, hRedPen); break; case 4: SelectObject(hDC, hLTBluePen); break; case 5: SelectObject(hDC, hLTRedPen); break; case 6: SelectObject(hDC, hLTGreenPen); break; case 7: SelectObject(hDC, hWhitePen); break; } if (Card_Type == PCI_9111DG) { analog_input[i] = analog_input[i] >> 4; adinput[i]=io_pos[0].y+42-(43*analog_input[i])/2048; } else { adinput[i]=io_pos[0].y+42-(43*analog_input[i])/32767; } if (old_adinput1[i]!=-1 ) { MoveToEx(hDC,output_pos[15].x+39,adinput[i],NULL ); LineTo(hDC,output_pos[15].x+43,old_adinput1[i]); } old_adinput1[i]=adinput[i]; } } BitBlt(hDC,output_pos[15].x+39,io_pos[15].y+87,331,85,hDC,output_pos[15].x+35,io_pos[15].y+87,SRCCOPY); for (i=0;i<8;i++ ) { if (bCheck2[i]) { AI_ReadChannel(card, i+8, range, &analog_input[i+8]); switch(i) { case 0: SelectObject(hDC, hYellowPen); break; case 1: SelectObject(hDC, hGreenPen); break; case 2: SelectObject(hDC, hBluePen); break; case 3: SelectObject(hDC, hRedPen); break; case 4: SelectObject(hDC, hLTBluePen); break; case 5: SelectObject(hDC, hLTRedPen); break; case 6: SelectObject(hDC, hLTGreenPen); break; case 7: SelectObject(hDC, hWhitePen); break; } if (Card_Type == PCI_9111DG) { analog_input[i+8] = analog_input[i+8] >> 4; adinput[i+8]=io_pos[0].y+130-(43*analog_input[i+8])/2048; } else { adinput[i+8]=io_pos[0].y+130-(43*analog_input[i+8])/32767; } if (old_adinput2[i]!=-1 ) { MoveToEx(hDC,output_pos[15].x+39,adinput[i+8],NULL); LineTo(hDC,output_pos[15].x+43,old_adinput2[i]); } old_adinput2[i]=adinput[i+8]; } } ReleaseDC(hWnd, hDC); AO_WriteChannel(card, 0, pos); } break; case WM_DESTROY: if (card >= 0) Release_Card(card); DeleteObject(hRedBrush); DeleteObject(hGreenBrush); DeleteObject(hLTGreenBrush); DeleteObject(hYellowBrush); DeleteObject(hBlueBrush) ; DeleteObject(hBlackBrush); DeleteObject(hRedPen); DeleteObject(hYellowPen); DeleteObject(hBluePen); DeleteObject(hGreenPen); DeleteObject(hLTBluePen); DeleteObject(hLTRedPen); DeleteObject(hLTGreenPen); DeleteObject(hWhitePen); PostQuitMessage(0); break; case WM_LBUTTONDOWN: if (card >= 0) { px = LOWORD(lParam); py = HIWORD(lParam); for (i=0; i<16; i++) { if (px>output_pos[i].x && px<output_pos[i].x+17 && py>output_pos[i].y && py<output_pos[i].y+17) { hDC = GetDC(hWnd); if ((output>>i)&0x01) { output -= (((unsigned int)1)<<i); SelectObject(hDC, GetStockObject(WHITE_BRUSH)); } else { output += (((unsigned int)1)<<i); SelectObject(hDC, hRedBrush); } Ellipse(hDC, output_pos[i].x, output_pos[i].y, output_pos[i].x+20, output_pos[i].y+20); DO_WritePort(card,0, output); ReleaseDC(hWnd, hDC); break; } } } break; default: return(DefWindowProc(hWnd, message, wParam, lParam)); } return(NULL); } 
[ "sheepdw@gmail.com" ]
sheepdw@gmail.com
1796721e8ac523a057fddab8f19792523075a7cd
ca50f443920d00966d616317d0c46dd0f2b7f9e1
/client/KMCommon/KMUtilities/KMFrameUtilities/KMFrameUtilities.h
3ddc14dd2d588a0f8d19057cfe68f038d43a240e
[]
no_license
piaoliuchuang/piaoliuchuang
f61ab0bad5fad36c354f15d9d28a9367ed99321b
ae557d95e49f86ebd7be0dd88e9d58513e7d0653
refs/heads/master
2021-01-25T07:35:12.404172
2012-04-24T17:40:54
2012-04-24T17:40:54
4,103,072
0
1
null
null
null
null
UTF-8
C
false
false
820
h
// // KMFrameUtilities.h // Drawus // // Created by Tianhang Yu on 12-4-3. // Copyright (c) 2012年 99fang. All rights reserved. // #ifndef Drawus_KMFrameUtilities_h #define Drawus_KMFrameUtilities_h static inline CGRect rectWithPadding (CGRect rect, CGFloat padding) { return CGRectMake(rect.origin.x + padding, rect.origin.y + padding, rect.size.width - 2*padding, rect.size.height - 2*padding); } static inline CGRect rectWithSizePadding (CGRect rect, CGFloat padding_top, CGFloat padding_left) { return CGRectMake(rect.origin.x + padding_left, rect.origin.y + padding_top, rect.size.width - 2*padding_left, rect.size.height - 2*padding_top); } #endif
[ "yutianhang@songshulin.net" ]
yutianhang@songshulin.net
0f2532147727eca8cb52684aef4e87659227ce5d
d1dd4b53ae028b086ebc5497371e98fd2b9b5dab
/ds/so05.c
baf087dc479bc0172d625f2a108b7c0afa54daac
[]
no_license
lioren/practice
b736760344d56b766b959a598bee281882e8230e
d9545a88b60479fc2c9970318d3149c0f91d40f7
refs/heads/master
2021-01-20T19:18:50.308294
2016-08-09T07:58:09
2016-08-09T07:58:09
65,091,173
0
0
null
null
null
null
UTF-8
C
false
false
566
c
#include<stdio.h> #include<stdlib.h> #include<string.h> main() { int a,b,i,j,k; scanf("%d",&a); while(a>0){ a--; scanf("%d",&b); int c[b]; int d[b]; int e[2*b]; for(i=0;i<b;i++) scanf("%d",&c[i]); for(i=0;i<b;i++) scanf("%d",&d[i]); for(i=0,j=0,k=0;k<b;){ if(c[i]>=d[j]){ e[k]=d[j]; k++; j++; } else { e[k]=c[i]; k++; i++; } } printf("%d\n",e[b-1]); } }
[ "rock881200@gmail.com" ]
rock881200@gmail.com
5ee911231db2849928f00c7b024fabfcaf7da294
5c255f911786e984286b1f7a4e6091a68419d049
/code/395f100a-792a-4a3c-835e-d5ad3c21f9a1.c
732710f31a28a0b01d160caa27d22b23cc65e9cf
[]
no_license
nmharmon8/Deep-Buffer-Overflow-Detection
70fe02c8dc75d12e91f5bc4468cf260e490af1a4
e0c86210c86afb07c8d4abcc957c7f1b252b4eb2
refs/heads/master
2021-09-11T19:09:59.944740
2018-04-06T16:26:34
2018-04-06T16:26:34
125,521,331
0
0
null
null
null
null
UTF-8
C
false
false
230
c
#include <stdio.h> int main() { int i=0; int j=142; int k; int l; k = 53; l = 64; k = i/j; l = i/j; l = l%j; l = j+j; k = k-k*i; printf("vulnerability"); printf("%d%d\n",k,k); return 0; }
[ "nharmon8@gmail.com" ]
nharmon8@gmail.com
3198347718d92689978f9e5d5e5fa01fc00a19ab
b545b68eafbdd6048f1b7ba405915b28512b1db1
/count_width.c
3506cb75cf33cdd7ddc00587af9fbb511a46ebbf
[]
no_license
takuto-suetsugu/ft_printf
407a98b6cc36b936c821d200907260749aa26b95
cdfa57ee2b62d1cb602850304e21a4cd5edf8c01
refs/heads/main
2023-06-11T13:32:43.950307
2021-07-07T05:53:10
2021-07-07T05:53:10
383,687,321
0
0
null
null
null
null
UTF-8
C
false
false
1,085
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* count_width.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tsuetsug < tsuetsug@student.42tokyo.jp> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/04/11 10:45:40 by tsuetsug #+# #+# */ /* Updated: 2021/05/06 15:25:08 by tsuetsug ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf.h" int count_width(char *str) { int i; i = 0; if (*str && *str == '*') return (1); while (*str && ('0' <= *str && *str <= '9')) { str++; i++; } return (i); }
[ "s.tact330@gmail.com" ]
s.tact330@gmail.com
b7d35f6d3090f68f108a0f610bd200072292e8c2
2c9e0541ed8a22bcdc81ae2f9610a118f62c4c4d
/harmony/tests/vts/vm/src/test/vm/jni/object_methods/CallIntMethodVTest/CallIntMethodVTest.c
f1ba963a4ec143e6b362a93dbfbda01f0df195cc
[ "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
JetBrains/jdk8u_tests
774de7dffd513fd61458b4f7c26edd7924c7f1a5
263c74f1842954bae0b34ec3703ad35668b3ffa2
refs/heads/master
2023-08-07T17:57:58.511814
2017-03-20T08:13:25
2017-03-20T08:16:11
70,048,797
11
9
null
null
null
null
UTF-8
C
false
false
5,415
c
/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <jni.h> #define ARG1 ((jint)1000000) #define RES1 ((jint)ARG1) #define ARG22 ((jint)-150012) #define RES2 ((jint)(ARG1 + ARG22)) #define ARG3_LENGTH 2 #define ARG31 ((jint)-327551212) #define ARG32 ((jint)13211143) #define RES3 ((jint)(ARG31 + ARG32)) #define ARG42_LENGTH 3 #define ARG421 ((jint)8814231) #define ARG422 ((jint)-1) #define ARG423 ((jint)327564324) #define RES4 ((jint)((ARG31 + ARG32) + (ARG421 + ARG422 + ARG423))) #define ARG5 ((jint)1002112321) #define RES5 ((jint)ARG5) #define ARG62 ((jint)480091) #define RES6 ((jint)(ARG5 + ARG62)) static jint callNI(JNIEnv *env, jobject obj, jmethodID mid, ...) { va_list args; jint result; va_start(args, mid); result = (*env)->CallIntMethodV(env, obj, mid, args); va_end(args); return result; } /* * Method: org.apache.harmony.vts.test.vm.jni.object_methods.CallIntMethodVTest.nativeExecute(Lorg/apache/harmony/vts/test/vm/jni/object_methods/TestClass;Lorg/apache/harmony/vts/test/vm/jni/object_methods/NativeTestClass;)Z */ JNIEXPORT jboolean JNICALL Java_org_apache_harmony_vts_test_vm_jni_object_1methods_CallIntMethodVTest_nativeExecute (JNIEnv *env, jobject this_object, jobject tc, jobject ntc) { jclass ic, class1, class2; char *sig1 = "(I)I"; char *sig2 = "(II)I"; char *sig3 = "([I)I"; char *sig4 = "([I[I)I"; char *sig5 = "(Ljava/lang/Integer;)I"; char *sig6 = "(Ljava/lang/Integer;Ljava/lang/Integer;)I"; jobject io5, io62; jintArray ar3, ar42; jint *elements3, *elements42; jint result1, result2, result3, result4, result5, result6; jint nresult1, nresult2, nresult3, nresult4, nresult5, nresult6; jmethodID m1, m2, m3, m4, m5, m6; jmethodID nm1, nm2, nm3, nm4, nm5, nm6; jmethodID int_init; ar3 = (*env)->NewIntArray(env, ARG3_LENGTH); ar42 = (*env)->NewIntArray(env, ARG42_LENGTH); if (NULL == ar3 || NULL == ar42) return JNI_FALSE; elements3 = (*env)->GetIntArrayElements(env, ar3, NULL); elements42 = (*env)->GetIntArrayElements(env, ar42, NULL); if (NULL == elements3 || NULL == elements42) return JNI_FALSE; elements3[0] = ARG31; elements3[1] = ARG32; elements42[0] = ARG421; elements42[1] = ARG422; elements42[2] = ARG423; (*env)->ReleaseIntArrayElements(env, ar3, elements3, 0); (*env)->ReleaseIntArrayElements(env, ar42, elements42, 0); ic = (*env)->FindClass(env, "java/lang/Integer"); if (NULL == ic) return JNI_FALSE; int_init = (*env)->GetMethodID(env, ic, "<init>", "(I)V"); if (NULL == int_init) return JNI_FALSE; io5 = (*env)->NewObject(env, ic, int_init, ARG5); io62 = (*env)->NewObject(env, ic, int_init, ARG62); if (NULL == io5 || NULL == io62) return JNI_FALSE; class1 = (*env)->GetObjectClass(env, tc); class2 = (*env)->GetObjectClass(env, ntc); m1 = (*env)->GetMethodID(env, class1, "method", sig1); m2 = (*env)->GetMethodID(env, class1, "method", sig2); m3 = (*env)->GetMethodID(env, class1, "method", sig3); m4 = (*env)->GetMethodID(env, class1, "method", sig4); m5 = (*env)->GetMethodID(env, class1, "method", sig5); m6 = (*env)->GetMethodID(env, class1, "method", sig6); if (NULL == m1 || NULL == m2 || NULL == m3 || NULL == m4 || NULL == m5 || NULL == m6) return JNI_FALSE; nm1 = (*env)->GetMethodID(env, class2, "method", sig1); nm2 = (*env)->GetMethodID(env, class2, "method", sig2); nm3 = (*env)->GetMethodID(env, class2, "method", sig3); nm4 = (*env)->GetMethodID(env, class2, "method", sig4); nm5 = (*env)->GetMethodID(env, class2, "method", sig5); nm6 = (*env)->GetMethodID(env, class2, "method", sig6); if (NULL == nm1 || NULL == nm2 || NULL == nm3 || NULL == nm4 || NULL == nm5 || NULL == nm6) return JNI_FALSE; result1 = callNI(env, tc, m1, ARG1); result2 = callNI(env, tc, m2, ARG1, ARG22); result3 = callNI(env, tc, m3, ar3); result4 = callNI(env, tc, m4, ar3, ar42); result5 = callNI(env, tc, m5, io5); result6 = callNI(env, tc, m6, io5, io62); nresult1 = callNI(env, ntc, nm1, ARG1); nresult2 = callNI(env, ntc, nm2, ARG1, ARG22); nresult3 = callNI(env, ntc, nm3, ar3); nresult4 = callNI(env, ntc, nm4, ar3, ar42); nresult5 = callNI(env, ntc, nm5, io5); nresult6 = callNI(env, ntc, nm6, io5, io62); if (result1 != RES1 || nresult1 != RES1 || result2 != RES2 || nresult2 != RES2 || result3 != RES3 || nresult3 != RES3 || result4 != RES4 || nresult4 != RES4 || result5 != RES5 || nresult5 != RES5 || result6 != RES6 || nresult6 != RES6) return JNI_FALSE; else return JNI_TRUE; }
[ "vitaly.provodin@jetbrains.com" ]
vitaly.provodin@jetbrains.com
45177be3b532880db4c2fb740643a69b44f2156c
a45e9cf2d06f4baac3f3cd50b06e572cfd2fb8fa
/src/level.h
ff98becbfd261b3a1d607b87f04890e7473ad6a6
[ "MIT" ]
permissive
kdiduk/fotd
442b10b9b3a9c1a09363ee9d14ac1860fffa7469
297cd73e6856e72d36222cadd54e556a34d04146
refs/heads/master
2023-01-29T09:05:53.315971
2020-12-13T15:12:43
2020-12-13T15:12:43
289,112,028
1
0
null
null
null
null
UTF-8
C
false
false
168
h
#ifndef LEVEL_H #define LEVEL_H #include <stdint.h> void level_init(void); void level_draw(void); void level_player_move(uint8_t direction); #endif /* LEVEL_H */
[ "kdiduk@tuta.io" ]
kdiduk@tuta.io
e738525a2cfc57654b86b3b957775cb173528e99
2911910bbd05a77ba23c83e6a58e942b7aeccf05
/1-nbiot-liteos-oceanconnect/miniprojects/LiteOS_ThunderSoft_STM32FL476VETx/LiteOS_Kernel/base/include/los_fs.h
16025774d01f16aba1eb89df57ff260425d48b73
[ "BSD-3-Clause", "MIT" ]
permissive
zhangmeiRZ/iot-codelabs
20f85501145852a37fbb78a43e448c678804e04a
36b7b4b3d35949e0223bf4e4d92d7995fcc832c9
refs/heads/master
2020-04-09T02:47:09.391611
2018-01-08T15:22:03
2018-01-08T15:22:03
null
0
0
null
null
null
null
UTF-8
C
false
false
3,258
h
#ifndef __LOS_FS_H #define __LOS_FS_H /* Includes ------------------------------------------------------------------*/ #include <stddef.h> #include "stdint.h" #include "string.h" #define LOS_FS_READ 0x01 #define LOS_FS_OPEN_EXISTING 0x00 #define LOS_FS_WRITE 0x02 #define LOS_FS_CREATE_NEW 0x04 #define LOS_FS_CREATE_ALWAYS 0x08 #define LOS_FS_OPEN_ALWAYS 0x10 #define LOS_FS__WRITTEN 0x20 #define LOS_FS__DIRTY 0x40 /* File function return code (LOS_FRESULT) */ typedef enum { LOS_FS_OK = 0, /* (0) Succeeded */ LOS_FS_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ LOS_FS_INT_ERR, /* (2) Assertion failed */ LOS_FS_NOT_READY, /* (3) The physical drive cannot work */ LOS_FS_NO_FILE, /* (4) Could not find the file */ LOS_FS_NO_PATH, /* (5) Could not find the path */ LOS_FS_INVALID_NAME, /* (6) The path name format is invalid */ LOS_FS_DENIED, /* (7) Access denied due to prohibited access or directory full */ LOS_FS_EXIST, /* (8) Access denied due to prohibited access */ LOS_FS_INVALID_OBJECT, /* (9) The file/directory object is invalid */ LOS_FS_WRITE_PROTECTED, /* (10) The physical drive is write protected */ LOS_FS_INVALID_DRIVE, /* (11) The logical drive number is invalid */ LOS_FS_NOT_ENABLED, /* (12) The volume has no work area */ LOS_FS_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ LOS_FS_MKFS_ABORTED, /* (14) The LOS_fmkfs() aborted due to any parameter error */ LOS_FS_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ LOS_FS_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ LOS_FS_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ LOS_FS_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ LOS_FS_INVALID_PARAMETER /* (19) Given parameter is invalid */ } LOS_FRESULT; /*---------------------------------------------------------------------------*/ /* Fs application interface */ int LOS_fopen (const char * path, unsigned char mode); /* Open or create a file */ LOS_FRESULT LOS_fclose (int fd); /* Close an open file object */ size_t LOS_fread (void* buffer, size_t size, size_t count,int fd); /* Read data from a file */ size_t LOS_fwrite(const void* buffer, size_t size, size_t count, int fd); /* Write data to a file */ LOS_FRESULT LOS_fseek( int fd, long offset); /* Move file pointer of a file object */ LOS_FRESULT LOS_fsync (int fd); /* Flush cached data of a writing file */ LOS_FRESULT LOS_fmount (const char* path, unsigned char opt); /* Mount/Unmount a logical drive */ LOS_FRESULT LOS_fmkfs (const char* path, unsigned char sfd, unsigned int au); /* Create a file system on the volume */ #endif /* __LOS_FS_H */
[ "softbaddog@gmail.com" ]
softbaddog@gmail.com
046ae41d9be30ec714f2bbd38a07bf6f0160339b
d138a598536ac0ef8dea713ac22aae5137f512b8
/Core/Src/stm32g4xx_hal_msp.c
9935f62a54d67a22e91f100becd3dcd3e986f060
[]
no_license
Sen1233/TLE5012_G474_TEST
e082d598e2652f6d0368a8cd62f6ae6d864a058d
20487e8aae2a81aa428883896f5f263edb53762c
refs/heads/main
2023-08-18T20:37:48.430415
2021-09-23T14:03:23
2021-09-23T14:03:23
409,605,631
0
0
null
null
null
null
UTF-8
C
false
false
5,963
c
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file stm32g4xx_hal_msp.c * @brief This file provides code for the MSP Initialization * and de-Initialization codes. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ /* USER CODE END TD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN Define */ /* USER CODE END Define */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN Macro */ /* USER CODE END Macro */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* External functions --------------------------------------------------------*/ /* USER CODE BEGIN ExternalFunctions */ /* USER CODE END ExternalFunctions */ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __HAL_RCC_SYSCFG_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE(); /* System interrupt init*/ /* PendSV_IRQn interrupt configuration */ HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral */ HAL_PWREx_DisableUCPDDeadBattery(); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ } /** * @brief UART MSP Initialization * This function configures the hardware resources used in this example * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspInit(UART_HandleTypeDef* huart) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(huart->Instance==LPUART1) { /* USER CODE BEGIN LPUART1_MspInit 0 */ /* USER CODE END LPUART1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_LPUART1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /**LPUART1 GPIO Configuration PA2 ------> LPUART1_TX PA3 ------> LPUART1_RX */ GPIO_InitStruct.Pin = LPUART1_TX_Pin|LPUART1_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF12_LPUART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USER CODE BEGIN LPUART1_MspInit 1 */ /* USER CODE END LPUART1_MspInit 1 */ } } /** * @brief UART MSP De-Initialization * This function freeze the hardware resources used in this example * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { if(huart->Instance==LPUART1) { /* USER CODE BEGIN LPUART1_MspDeInit 0 */ /* USER CODE END LPUART1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_LPUART1_CLK_DISABLE(); /**LPUART1 GPIO Configuration PA2 ------> LPUART1_TX PA3 ------> LPUART1_RX */ HAL_GPIO_DeInit(GPIOA, LPUART1_TX_Pin|LPUART1_RX_Pin); /* USER CODE BEGIN LPUART1_MspDeInit 1 */ /* USER CODE END LPUART1_MspDeInit 1 */ } } /** * @brief SPI MSP Initialization * This function configures the hardware resources used in this example * @param hspi: SPI handle pointer * @retval None */ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hspi->Instance==SPI2) { /* USER CODE BEGIN SPI2_MspInit 0 */ /* USER CODE END SPI2_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI2_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**SPI2 GPIO Configuration PB13 ------> SPI2_SCK PB15 ------> SPI2_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* USER CODE BEGIN SPI2_MspInit 1 */ /* USER CODE END SPI2_MspInit 1 */ } } /** * @brief SPI MSP De-Initialization * This function freeze the hardware resources used in this example * @param hspi: SPI handle pointer * @retval None */ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { if(hspi->Instance==SPI2) { /* USER CODE BEGIN SPI2_MspDeInit 0 */ /* USER CODE END SPI2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI2_CLK_DISABLE(); /**SPI2 GPIO Configuration PB13 ------> SPI2_SCK PB15 ------> SPI2_MOSI */ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_15); /* USER CODE BEGIN SPI2_MspDeInit 1 */ /* USER CODE END SPI2_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
[ "1065402494@qq.com" ]
1065402494@qq.com
4ed576c7d1cd1428b3daa9fe5946d12b2252c895
c94fae6bc7779ce06e05b60a0753e82430f830b8
/MFC图形绘制/一般函数绘图/Resource.h
1dd0c4d202fe9c143eab9827157b07c67eeae25a
[]
no_license
MrsZ/MFC_VS2012
f4bbfc56f2b89c4c99c2ddc55d77e4138d3db4d0
bc623f1d13cf2fa0eb18b4f2b4f20cb5a762ad96
refs/heads/master
2021-05-29T06:00:47.703364
2015-08-19T13:16:52
2015-08-19T13:16:52
110,326,425
0
1
null
2017-11-11T07:19:09
2017-11-11T07:19:09
null
GB18030
C
false
false
501
h
//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by 一般函数绘图.rc // #define IDD_ABOUTBOX 100 #define IDP_OLE_INIT_FAILED 100 #define IDR_MAINFRAME 128 #define IDR_MyTYPE 130 // 新对象的下一组默认值 // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 310 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 310 #define _APS_NEXT_COMMAND_VALUE 32771 #endif #endif
[ "lixuat2014@gmail.com" ]
lixuat2014@gmail.com
82e1d4fad3ae43acdcae3560f6685246dee19584
727ce0101c312d985d1ad6e92a09c6d34cbe5813
/zipper/zipperFinal.c
5f4e62e2a1ad929ca64a09a34b46352a79977509
[]
no_license
mlotts/van-der-waerden-zipper
0975d71504f99f26e29ca54ec29ea2a0529cfdec
491675737ea04e4a5273f02c396901e99f86b037
refs/heads/master
2021-01-18T16:30:21.186381
2016-01-11T07:35:22
2016-01-11T07:35:22
27,797,413
0
0
null
null
null
null
UTF-8
C
false
false
3,600
c
#include <stdlib.h> #include <stdio.h> #include "vdwheader.h" void zipSequence(char prcolors[], char target[], long long prime, int power); /*int main(){ char target[100]; int i; int prime = 19; //37; int power = 6; char prcolors[] = "011242032503515443"; //"012253234004531415514135400432352210"; //convert ascii chars to byte-long ints for (i = 0; i < prime; i++) prcolors[i] = prcolors[i]-48; zipSequence(prcolors, target, prime, power); return 0; }*/ /* * This function takes a power-residue coloring for a given prime * and power and zips it to an extended coloring. * Parameters: * prcolors - array containing the power-residue coloring * target - array to be filled with the extended coloring * prime - underlying prime used in creating initial coloring * power - power used in deterimining the initial coloring */ void zipSequence(char prcolors[], char target[], long long prime, int power) { int i, j, offset; long m; //SETTING THE GLUE POINTS //the color of the first member of the two parts that compose the zipped //coloring can be arbitrary, but these should be chosen so as not to form a //monochromatic progression amongst themselves target[0] = 1; target[prime] = (1 + (power/2)) % power; //printf("\nOriginal Coloring:\n"); //for(i = 0; i < prime-1; i++) // printf("%d", prcolors[i]); //SPREADING //even indices of the zipped coloring are simply the numbers of //the original coloring j = 2; for(i = 0; i < (prime-1); ++i) { target[j] = prcolors[i]; j += 2; } offset = power / 2; //TURNING, SHIFTING, AND MERGING //odd indices from 1 to the midpoint of the zipped array are the //first half of the original coloring in reverse order j = 1; //printf("\n\nOdd Numbered Entries:\n"); for(i = (prime-1)/2; i < (prime-1); ++i) { target[j] = (prcolors[i] + offset) % power; j += 2; //printf("%d",((prcolors[i] + offset) % power)); } //odd indices from the midpoint of the zipped array to the end are //the second half of the original coloring in reverse order j += 2; //printf("\n"); for(i = 0; i < (prime-1)/2; ++i) { target[j] = (prcolors[i] + offset) % power; j += 2; //printf("%d",((prcolors[i] + offset) % power)); } //printout that is not used, info is simply printed out in the //driver.c file after this method is called //printf("\n\nZipped Sequence:\n"); //for(i = 0; i < (2*prime); ++i) //{ // printf("%d",target[i]); //} //printf("\n\n"); } void rezipSequence(char prcolors[], char target[], long prime, long length, int power) { int i, j; //this code just filled the zipped array with 9's in order to see //how the other parts of the code were working for(i = 0; i < (2*length); ++i) { target[i] = 9; } j = 0; for(i = 0; i < (2*prime); ++i) { target[j] = prcolors[i]; j += 2; } //odd indices from 1 to the midpoint of the zipped array are the //first half of the original coloring in reverse order j = 1; //printf("\n\nOdd Numbered Entries:\n"); for(i = prime - (prime/2); i < (2*prime); ++i) { target[j] = (prcolors[i] + (power/2)) % power; j += 2; // printf("%d",((prcolors[i] + (power/2)) % power)); } //odd indices from the midpoint of the zipped array to the end are //the second half of the original coloring in reverse order //printf("\n"); for(i = 0; i < prime - (prime/2); ++i) { target[j] = (prcolors[i] + (power/2)) % power; j += 2; // printf("%d",((prcolors[i] + (power/2)) % power)); } /*printf("\n\nZipped Sequence: "); for(i = 0; i < (2*prime); ++i) { printf("%d",target[i]); } */ }
[ "mlotts@gmail.com" ]
mlotts@gmail.com
1f95d842703fc8dcafca2b1cd679c1359c84b97c
c7377c3dec984c45e43b3138bd94e5e0abc1f5a4
/includes/components/ty_gpio_base_test.h
e0017fb4e1be50a4ae673f9a8da503181bcaf6b5
[]
no_license
wwpcwzf/TuyaBTSigSDK_Reengineering
6117dce2ea4a41e4052ebdd2695a99e9438c2412
5d56b21019e2dc93c56d6521d9e3e5419492f9d5
refs/heads/master
2023-06-03T03:16:23.541895
2021-06-23T08:07:06
2021-06-23T08:07:06
332,637,793
0
0
null
null
null
null
UTF-8
C
false
false
764
h
/************************************************************************* > File Name: ty_gpio_base_test.h > Author: > Mail: > Created Time: Tue 26 Mar 2019 15:11:13 CST ************************************************************************/ #ifndef _TY_GPIO_BASE_TEST_H #define _TY_GPIO_BASE_TEST_H #include "board.h" #define MAX_GPIO_TEST_PIN 10 #define MAX_GPIO_TEST_PIN_MORE (MAX_GPIO_TEST_PIN + 1) //=8+1 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) typedef struct{ u8 pin_num; u32 pin[MAX_GPIO_TEST_PIN]; u8 map[MAX_GPIO_TEST_PIN]; u8 ret[MAX_GPIO_TEST_PIN_MORE]; }ty_gpio_base_test_s; typedef struct{ u8 num; u32 pin; }num2pin_t; extern u8 ty_gpio_base_test_auto(u8 *para, u8 len); #endif
[ "wwpcwzf@163.com" ]
wwpcwzf@163.com
2da72884387620e47dc22cf1f5fe385da17c0312
1adb9272ee30261882d56e6f955ad482f80b9584
/comp105/HW2/impcore-with-locals/eval.c
7052a4d7e634c49d31f8730b3136c57f3ad4961e
[]
no_license
tomma367/Tufts-Stuffs
45d7b2881e3bfa698c9c5029c08dbf8750ac5872
723bc0902bb246d8650a5d6651bcbf5a453d3ace
refs/heads/master
2020-09-02T10:37:08.816715
2014-08-07T13:22:23
2014-08-07T13:22:23
null
0
0
null
null
null
null
UTF-8
C
false
false
8,844
c
/* eval.c 35e */ /* Jake Austin and Ian Mcconnell, Impcore II */ #include "all.h" /* eval helpers 40a */ /* Included local variable environment as parameter */ /* updated call to mkVL and eval */ static Valuelist evallist(Explist el, Valenv globals, Funenv functions, Valenv formals, Valenv locals) { if (el == NULL) { return NULL; } else { Value v = eval(el->hd, globals, functions, formals, locals); return mkVL(v, evallist(el->tl, globals, functions, formals, locals)); } } /* eval.c 36a */ /* Included local variable environment as parameter in all calls to eval */ Value eval(Exp e, Valenv globals, Funenv functions, Valenv formals, Valenv locals) { checkoverflow(1000000 * sizeof(char *)); /* OMIT */ switch (e->alt) { case LITERAL: /* evaluate [[e->u.literal]] and return the result 36b */ return e->u.literal; case VAR: /* added locals as primary case, hides formals - globals */ /* evaluate [[e->u.var]] and return the result 37a */ if (isvalbound(e->u.var, locals)) return fetchval(e->u.var, locals); else if (isvalbound(e->u.var, formals)) return fetchval(e->u.var, formals); else if (isvalbound(e->u.var, globals)) return fetchval(e->u.var, globals); else error("unbound variable %n", e->u.var); assert(0); /* not reached */ return 0; case SET: /* Local environment preferentially modified */ { Value v = eval(e->u.set.exp, globals, functions, formals, locals); if (isvalbound(e->u.set.name, locals)) bindval(e->u.set.name, v, locals); else if (isvalbound(e->u.set.name, formals)) bindval(e->u.set.name, v, formals); else if (isvalbound(e->u.set.name, globals)) bindval(e->u.set.name, v, globals); else error("set: unbound variable %n", e->u.set.name); return v; } case IFX: /* evaluate [[e->u.ifx]] and return the result 38a */ if (eval(e->u.ifx.cond, globals, functions, formals, locals) != 0) return eval(e->u.ifx.true, globals, functions, formals, locals); else return eval(e->u.ifx.false, globals, functions, formals, locals); case WHILEX: /* evaluate [[e->u.whilex]] and return the result 38b */ while (eval(e->u.whilex.cond, globals, functions, formals, locals) != 0) eval(e->u.whilex.exp, globals, functions, formals, locals); return 0; case BEGIN: /* evaluate [[e->u.begin]] and return the result 39a */ { Explist el; Value v = 0; for (el=e->u.begin; el; el=el->tl) v = eval(el->hd, globals, functions, formals, locals); return v; } case APPLY: /* Case USERDEF: create local environment to pass into eval */ /* evaluate [[e->u.apply]] and return the result 39b */ { Fun f; /* make [[f]] the function denoted by [[e->u.apply.name]], or call [[error]] 39c */ if (!isfunbound(e->u.apply.name, functions)) error("call to undefined function %n", e->u.apply.name); f = fetchfun(e->u.apply.name, functions); switch (f.alt) { case USERDEF: /* apply [[f.u.userdef]] and return the result 40b */ { Namelist n2 = f.u.userdef.locals; Valuelist v2 = NULL; int i = 0; Namelist nl = f.u.userdef.formals; Valuelist vl = evallist(e->u.apply.actuals, globals, functions, formals, locals); checkargc(e, lengthNL(nl), lengthVL(vl)); /* Initialize local values to 0 */ while (i < lengthNL(n2)) { v2 = mkVL(0, v2); i = lengthVL(v2); } checkargc(e, lengthNL(n2), lengthVL(v2)); return eval(f.u.userdef.body, globals, functions, mkValenv( nl, vl), mkValenv(n2, v2)); } case PRIMITIVE: /* apply [[f.u.primitive]] and return the result 41a */ { Valuelist vl = evallist(e->u.apply.actuals, globals, functions, formals, locals); if (f.u.primitive == strtoname("print")) /* apply [[print]] to [[vl]] and return 41b */ { Value v; checkargc(e, 1, lengthVL(vl)); v = nthVL(vl, 0); print("%v\n", v); return v; } else /* apply arithmetic primitive to [[vl]] and return 42a */ { const char *s; Value v, w; checkargc(e, 2, lengthVL(vl)); v = nthVL(vl, 0); w = nthVL(vl, 1); s = nametostr(f.u.primitive); assert(strlen(s) == 1); switch (s[0]) { case '<': return v < w; case '>': return v > w; case '=': return v == w; case '+': return v + w; case '-': return v - w; case '*': return v * w; case '/': if (w == 0) error("division by zero in %e", e); return v / w; default: assert(0); return 0; /* not reached */ } } } default: assert(0); return 0; /* not reached */ } } default: assert(0); return 0; /* not reached */ } } /* eval.c 42b */ void readevalprint(Defreader reader, Valenv globals, Funenv functions, int echo) { Def d; while ((d = readdef(reader))) evaldef(d, globals, functions, echo); } /* eval.c 43a */ void evaldef(Def d, Valenv globals, Funenv functions, int echo) { switch (d->alt) { case VAL: /* evaluate [[d->u.val]], mutating [[globals]] 43b */ /* updated to correct number of parameters*/ { Value v = eval(d->u.val.exp, globals, functions, mkValenv(NULL, NULL), mkValenv(NULL, NULL)); /*if in local environment, bind to locals*/ bindval(d->u.val.name, v, globals); if (echo) print("%v\n", v); } break; case EXP: /* evaluate [[d->u.exp]] and possibly print the result 44a */ { Value v = eval(d->u.exp, globals, functions,mkValenv(NULL,NULL), mkValenv(NULL, NULL)); bindval(strtoname("it"), v, globals); if (echo) print("%v\n", v); } break; case DEFINE: /* evaluate [[d->u.define]], mutating [[functions]] 44b */ /* fail if [[d->u.define]] has duplicate formal parameters 44c */ if (duplicatename(d->u.define.userfun.formals) != NULL) error( "Formal parameter named %n appears twice in definition of function %n", duplicatename(d->u.define.userfun.formals), d->u.define.name); bindfun(d->u.define.name, mkUserdef(d->u.define.userfun), functions); if (echo) print("%n\n", d->u.define.name); break; case USE: /* evaluate [[d->u.use]], possibly mutating [[globals]] and [[functions]] 44d */ { const char *filename = nametostr(d->u.use); FILE *fin = fopen(filename, "r"); if (fin == NULL) error("cannot open file \"%s\"", filename); readevalprint(defreader(filereader(filename, fin), 0), globals, functions, 0); fclose(fin); } break; default: assert(0); } }
[ "jakeaust07@gmail.com" ]
jakeaust07@gmail.com
b354449a08bc06fb0449e12c75107aa518e6a96a
c8e6219a5dbcb4dccdd8ec2a9ff65b5e93dc58a0
/StackCursorBased/StackCursorBased/StackCursorBased.c
b74f1196d52f78f26de9ff0bab83f9f98db95c5f
[]
no_license
AinScruff/Datastruct-C-in-Xcode
6f8b145eaecc027e309438587b7b5c7ec691a06d
2b6926437c9ffdeee6e78a9a1dcd6d800b303b04
refs/heads/main
2023-03-14T09:39:56.258857
2021-03-05T13:49:24
2021-03-05T13:49:24
344,822,828
0
0
null
null
null
null
UTF-8
C
false
false
1,945
c
// // main.c // StackCursorBased // // Created by Dominique Michael Abejar on 13/09/2019. // Copyright © 2019 BSIT. All rights reserved. // #include <stdio.h> #include <stdlib.h> #define SIZE 10 typedef int List; typedef struct{ char data; int link; }Stack; typedef struct{ int availList; Stack stackArray[SIZE]; }VirtualHeap; void StackInit(VirtualHeap *VH, List *L); void StackPush(VirtualHeap *VH, char elem, List *L); void StackPop(VirtualHeap *VH, List *L); char StackTop(VirtualHeap *VH, List *L); void display(VirtualHeap *VH, List L); int main() { VirtualHeap VH; List L; StackInit(&VH, &L); StackPush(&VH, 'a', &L); StackPush(&VH, 'b', &L); StackPush(&VH, 'c', &L); StackPop(&VH, &L); display(&VH, L); return 0; } void StackInit(VirtualHeap *VH, List *L){ List i; VH->availList = 0; *L = -1; for(i = 0; i < (SIZE-1); i++){ VH->stackArray[i].link = i + 1; } VH->stackArray[i].link = -1; } void StackPush(VirtualHeap *VH, char elem, List *L){ List temp; if(VH->availList != -1){ temp = VH->availList; VH->availList = VH->stackArray[temp].link; VH->stackArray[temp].data = elem; VH->stackArray[temp].link = *L; *L = temp; printf("%d\n", *L); } } void StackPop(VirtualHeap *VH, List *L){ List temp; if(*L > -1 && *L < SIZE){ temp = *L; *L = VH->stackArray[temp].link; VH->stackArray[temp].link = VH->availList; VH->availList = temp; } } char StackTop(VirtualHeap *VH, List *L){ char retval; retval = VH->stackArray[*L].data; return retval; } void display(VirtualHeap *VH, List L){ List trav; for(trav = L; trav != -1;trav = VH->stackArray[trav].link) { printf("Elements: %c\n", VH->stackArray[trav].data); } }
[ "noreply@github.com" ]
AinScruff.noreply@github.com
c013f8b2ed55e76d16b7b334c1061c13beb78f62
43b72c43fe549616230242cfc799db85667a14b4
/repeatedString.c
e4d966e2db85239fdbb4266964b6f425eb8c450f
[]
no_license
anjalichourasia/LearnJava
668d98b8f4d58c4d804de5831545c49849d8a060
25430945801e875077c83834cc31ee7692733aa5
refs/heads/master
2020-06-22T23:43:41.568033
2019-08-05T16:21:23
2019-08-05T16:21:23
198,433,956
0
0
null
null
null
null
UTF-8
C
false
false
1,662
c
#include <assert.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char* readline(); // Complete the repeatedString function below. long repeatedString(char* s, long n) { long count = 0, r; int i; r = n / strlen(s); for(i=0;i<strlen(s);i++){ if(s[i]=='a'){ count++; } } count = count * r; r = n % strlen(s); for(i=0;i<r;i++){ if(s[i]=='a') count++; } return count; } int main() { FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w"); char* s = readline(); char* n_endptr; char* n_str = readline(); long n = strtol(n_str, &n_endptr, 10); if (n_endptr == n_str || *n_endptr != '\0') { exit(EXIT_FAILURE); } long result = repeatedString(s, n); fprintf(fptr, "%ld\n", result); fclose(fptr); return 0; } char* readline() { size_t alloc_length = 1024; size_t data_length = 0; char* data = malloc(alloc_length); while (true) { char* cursor = data + data_length; char* line = fgets(cursor, alloc_length - data_length, stdin); if (!line) { break; } data_length += strlen(cursor); if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; } size_t new_length = alloc_length << 1; data = realloc(data, new_length); if (!data) { break; } alloc_length = new_length; } if (data[data_length - 1] == '\n') { data[data_length - 1] = '\0'; } data = realloc(data, data_length); return data; }
[ "noreply@github.com" ]
anjalichourasia.noreply@github.com
45ae5fcebf09a6a1a934abe06730364aaf5dc043
f3b85ae8251c0d32b0b13f5f58896049cdc0f456
/sys/dietlibc/include/signal.h
670b2471fa51a71acf7f933923d6e31f5da39dca
[]
no_license
walafc0/almos-mk
9f8e1540f48bdfee08dd82336687a6555e7dd730
885636fce42faa73f7f9218124d1a40ce2a61907
refs/heads/master
2020-12-30T14:56:07.781381
2015-08-18T15:44:22
2015-08-18T15:44:22
40,980,913
1
0
null
null
null
null
UTF-8
C
false
false
3,690
h
#ifndef _SIGNAL_H #define _SIGNAL_H #include <stdint.h> #include <sys/types.h> /* START COPY FROM KERNEL */ #define SIG_DEFAULT 0L #define SIG_IGNORE 1L #define SIG_ERROR -1L #define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGIOT 6 /* IOT instruction */ #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ #define SIGEMT 7 /* EMT instruction */ #define SIGFPE 8 /* floating point exception */ #define SIGKILL 9 /* kill (cannot be caught or ignored) */ #define SIGBUS 10 /* bus error */ #define SIGSEGV 11 /* segmentation violation */ #define SIGSYS 12 /* bad argument to system call */ #define SIGPIPE 13 /* write on a pipe with no one to read it */ #define SIGALRM 14 /* alarm clock */ #define SIGTERM 15 /* software termination signal from kill */ #define SIGURG 16 /* urgent condition on IO channel */ #define SIGSTOP 17 /* sendable stop signal not from tty */ #define SIGTSTP 18 /* stop signal from tty */ #define SIGCONT 19 /* continue a stopped process */ #define SIGCHLD 20 /* to parent on child stop or exit */ #define SIGCLD 20 /* System V name for SIGCHLD */ #define SIGTTIN 21 /* to readers pgrp upon background tty read */ #define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */ #define SIGIO 23 /* input/output possible signal */ #define SIGPOLL SIGIO /* System V name for SIGIO */ #define SIGXCPU 24 /* exceeded CPU time limit */ #define SIGXFSZ 25 /* exceeded file size limit */ #define SIGVTALRM 26 /* virtual time alarm */ #define SIGPROF 27 /* profiling time alarm */ #define SIGWINCH 28 /* window changed */ #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ #define SIGUSR1 30 /* user defined signal 1 */ #define SIGUSR2 31 /* user defined signal 2 */ #define NSIG 32 /* signal 0 implied */ typedef uint32_t sigval_t; typedef uint32_t sigset_t; typedef struct siginfo_s { int si_signo; /* Signal number */ int si_errno; /* An errno value */ int si_code; /* Signal code */ pid_t si_pid; /* Sending process ID */ uid_t si_uid; /* Real user ID of sending process */ int si_status; /* Exit value or signal */ clock_t si_utime; /* User time consumed */ clock_t si_stime; /* System time consumed */ sigval_t si_value; /* Signal value */ int si_int; /* POSIX.1b signal */ void *si_ptr; /* POSIX.1b signal */ void *si_addr; /* Memory location which caused fault */ int si_band; /* Band event */ int si_fd; /* File descriptor */ }siginfo_t; struct sigaction_s { sigset_t sa_mask; uint32_t sa_flags; union { void (*sa_handler)(int); void (*sa_sigaction)(int, siginfo_t *, void *); }; }; /* END COPY FROM KERNEL */ typedef void (*__sighandler_t)(int); #ifdef _BSD_SOURCE typedef sighandler_t sig_t; #endif #ifdef _GNU_SOURCE typedef __sighandler_t sighandler_t; #endif #define SIG_DFL ((void*)SIG_DEFAULT) /* default signal handling */ #define SIG_IGN ((void*)SIG_IGNORE) /* ignore signal */ #define SIG_ERR ((void*)SIG_ERROR) /* error return from signal */ void* signal(int sig, void (*func)(int)); int kill(pid_t pid, int sig); int raise(int sig); #endif /* _SIGNAL_H_ */
[ "devel@walafc0.org" ]
devel@walafc0.org
62b635934b4cb221806605048b1c31dd7c5a70c6
085d238ad8c986c3bd3032a96a8c936f12419b6f
/C/ClassWork/SecondProgram/main.c
ca49f6a180bac377ffb8c46cabf8b0cfb0c6e5c0
[]
no_license
andrewtroyan/troyandz
26b7340828dc733e8d270b5650ee3aee734a5a98
6b0759d88628d16e92a81111fc1ad2ddff59f0d2
refs/heads/master
2021-01-17T16:05:42.335137
2015-05-21T08:58:28
2015-05-21T08:58:28
27,066,746
0
0
null
null
null
null
UTF-8
C
false
false
132
c
#include <stdio.h> #include <stdlib.h> int main() { int a; scanf("%d", &a); printf("2*%d=%d", a, 2*a); return 0; }
[ "andandrew1333@gmail.com" ]
andandrew1333@gmail.com
e1ebe028362c9ff5d042a9e285febc57ef357948
0a309b00972322cc6dbf28e82e95915bf8eb9577
/MBoot/MstarCore/bsp/edison/include/apiHDMITx.h
0676154f910273820fa5af5ac82f28e339033d0f
[]
no_license
Benjamin-Dobell/kogan-tv-gpl
5a22d84217a1d5ada231f43f3368f22a99b1b9a1
40d86850e1c53a9e687736006816b83e53ac96eb
refs/heads/master
2021-01-17T07:56:42.783716
2016-09-07T23:59:46
2016-09-07T23:59:46
16,887,634
22
9
null
2016-09-07T23:59:46
2014-02-16T15:41:34
C
WINDOWS-1250
C
false
false
20,017
h
//<MStar Software> //****************************************************************************** // MStar Software // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. // All software, firmware and related documentation herein ("MStar Software") are // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by // law, including, but not limited to, copyright law and international treaties. // Any use, modification, reproduction, retransmission, or republication of all // or part of MStar Software is expressly prohibited, unless prior written // permission has been granted by MStar. // // By accessing, browsing and/or using MStar Software, you acknowledge that you // have read, understood, and agree, to be bound by below terms ("Terms") and to // comply with all applicable laws and regulations: // // 1. MStar shall retain any and all right, ownership and interest to MStar // Software and any modification/derivatives thereof. // No right, ownership, or interest to MStar Software and any // modification/derivatives thereof is transferred to you under Terms. // // 2. You understand that MStar Software might include, incorporate or be // supplied together with third party`s software and the use of MStar // Software may require additional licenses from third parties. // Therefore, you hereby agree it is your sole responsibility to separately // obtain any and all third party right and license necessary for your use of // such third party`s software. // // 3. MStar Software and any modification/derivatives thereof shall be deemed as // MStar`s confidential information and you agree to keep MStar`s // confidential information in strictest confidence and not disclose to any // third party. // // 4. MStar Software is provided on an "AS IS" basis without warranties of any // kind. Any warranties are hereby expressly disclaimed by MStar, including // without limitation, any warranties of merchantability, non-infringement of // intellectual property rights, fitness for a particular purpose, error free // and in conformity with any international standard. You agree to waive any // claim against MStar for any loss, damage, cost or expense that you may // incur related to your use of MStar Software. // In no event shall MStar be liable for any direct, indirect, incidental or // consequential damages, including without limitation, lost of profit or // revenues, lost or damage of data, and unauthorized system use. // You agree that this Section 4 shall still apply without being affected // even if MStar Software has been modified by MStar in accordance with your // request or instruction for your use, except otherwise agreed by both // parties in writing. // // 5. If requested, MStar may from time to time provide technical supports or // services in relation with MStar Software to you for your use of // MStar Software in conjunction with your or your customer`s product // ("Services"). // You understand and agree that, except otherwise agreed by both parties in // writing, Services are provided on an "AS IS" basis and the warranty // disclaimer set forth in Section 4 above shall apply. // // 6. Nothing contained herein shall be construed as by implication, estoppels // or otherwise: // (a) conferring any license or right to use MStar name, trademark, service // mark, symbol or any other identification; // (b) obligating MStar or any of its affiliates to furnish any person, // including without limitation, you and your customers, any assistance // of any kind whatsoever, or any information; or // (c) conferring any license or right under any intellectual property right. // // 7. These terms shall be governed by and construed in accordance with the laws // of Taiwan, R.O.C., excluding its conflict of law rules. // Any and all dispute arising out hereof or related hereto shall be finally // settled by arbitration referred to the Chinese Arbitration Association, // Taipei in accordance with the ROC Arbitration Law and the Arbitration // Rules of the Association by three (3) arbitrators appointed in accordance // with the said Rules. // The place of arbitration shall be in Taipei, Taiwan and the language shall // be English. // The arbitration award shall be final and binding to both parties. // //****************************************************************************** //<MStar Software> //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2006-2007 MStar Semiconductor, Inc. // All rights reserved. // // Unless otherwise stipulated in writing, any and all information contained // herein regardless in any format shall remain the sole proprietary of // MStar Semiconductor Inc. and be kept in strict confidence // (ˇ§MStar Confidential Informationˇ¨) by the recipient. // Any unauthorized act including without limitation unauthorized disclosure, // copying, use, reproduction, sale, distribution, modification, disassembling, // reverse engineering and compiling of the contents of MStar Confidential // Information is unlawful and strictly prohibited. MStar hereby reserves the // rights to any and all damages, losses, costs and expenses resulting therefrom. // //////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// /// @file apiHDMITx.h /// @brief HDMITx Interface /// @author MStar Semiconductor Inc. /// /// CL351033++: /// Add CEC function for STB /// CL310477++: /// Open analog setting for the different board condition /// CL309397++: /// Modify apiHDMITx prototype for NDS /// CL308729++: /// Fix AVMUTE problem while HDCP is on /// CL299817++: /// i. Add I2C timeout mechanism in EDID and HDCP /// ii. Add SET_AVMUTE API to avoid transition garbage noise while timing changed ]]> /// CL288415++: /// Add SRM DSA Signature Checking function /// CL283331++: /// Fix HDMI v1.3 deep color mode output unstable problem /// CL282607++: /// i. Fix YUV422 / YUV444 bugs /// ii. Add MApi_HDMITx_GetHdcpKey() to get HDCP key from external storage. /// CL276751++: /// Modify HDMI / HDCP state mechine for NDS /// CL275230++: /// i. MApi_HDMITx_GetRxDCInfoFromEDID() to get Rx's deep color information from EDID /// ii. MApi_HDMITx_SetHDMITxMode_CD() to set output mode and deep color setting /// CL266666++: /// Add event report for NDS /// CL263961++: /// Add CEC init and checkbuffer for NDS /// CL260934++: /// Add some customized APIs for NDS /// CL259645++: /// i. Remove EDID header check. If header is wrong, force to DVI output /// ii. Add force output mode "MApi_HDMITx_ForceHDMIOutputMode()" /////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef _API_HDMITX_H_ #define _API_HDMITX_H_ #include "MsTypes.h" //#include "halHDMITx.h" //#include "drvHDMITx.h" //#include "regHDMITx.h" #ifdef __cplusplus extern "C" { #endif //------------------------------------------------------------------------------------------------- // Macro and Define //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- // Type and Structure //------------------------------------------------------------------------------------------------- #define MSIF_HDMITX_LIB_CODE {'H','D','M','I'} #define MSIF_HDMITX_LIBVER {'0','0'} #define MSIF_HDMITX_BUILDNUM {'2','0'} #define MSIF_HDMITX_CHANGELIST {'0','0','6','7','7','7','7','2'} #define HDMITX_API_VERSION /* Character String for DRV/API version */ \ MSIF_TAG, /* 'MSIF' */ \ MSIF_CLASS, /* '00' */ \ MSIF_CUS, /* 0x0000 */ \ MSIF_MOD, /* 0x0000 */ \ MSIF_CHIP, \ MSIF_CPU, \ MSIF_HDMITX_LIB_CODE, /* IP__ */ \ MSIF_HDMITX_LIBVER, /* 0.0 ~ Z.Z */ \ MSIF_HDMITX_BUILDNUM, /* 00 ~ 99 */ \ MSIF_HDMITX_CHANGELIST, /* CL# */ \ MSIF_OS typedef enum { HDMITX_DVI = 0, // DVI without HDCP HDMITX_DVI_HDCP = 1, // DVI with HDCP HDMITX_HDMI = 2, // HDMI without HDCP HDMITX_HDMI_HDCP = 3, // HDMI with HDCP } HDMITX_OUTPUT_MODE; typedef enum { HDMITX_SEND_PACKET = 0x00, // send packet HDMITX_CYCLIC_PACKET = 0x04, // cyclic packet by frame count HDMITX_STOP_PACKET = 0x80, // stop packet } HDMITX_PACKET_PROCESS; typedef enum { HDMITX_NULL_PACKET = 0x00, HDMITX_ACR_PACKET = 0x01, HDMITX_AS_PACKET = 0x02, HDMITX_GC_PACKET = 0x03, HDMITX_ACP_PACKET = 0x04, HDMITX_ISRC1_PACKET = 0x05, HDMITX_ISRC2_PACKET = 0x06, HDMITX_DSD_PACKET = 0x07, HDMITX_HBR_PACKET = 0x09, HDMITX_GM_PACKET = 0x0A, HDMITX_VS_INFOFRAME = 0x81, HDMITX_AVI_INFOFRAME = 0x82, HDMITX_SPD_INFOFRAME = 0x83, HDMITX_AUDIO_INFOFRAME = 0x84, HDMITX_MPEG_INFOFRAME = 0x85, } HDMITX_PACKET_TYPE; typedef enum { HDMITX_VIDEO_CD_NoID = 0, // DVI mode HDMITX_VIDEO_CD_24Bits = 4, // HDMI 8 bits HDMITX_VIDEO_CD_30Bits = 5, // HDMI 10 bits HDMITX_VIDEO_CD_36Bits = 6, // HDMI 12 bits } HDMITX_VIDEO_COLORDEPTH_VAL; typedef enum { HDMITX_VIDEO_COLOR_RGB444 = 0, HDMITX_VIDEO_COLOR_YUV422 = 1, HDMITX_VIDEO_COLOR_YUV444 = 2, } HDMITX_VIDEO_COLOR_FORMAT; typedef enum { HDMITX_RES_640x480p =0, HDMITX_RES_720x480i = 1, HDMITX_RES_720x576i = 2, HDMITX_RES_720x480p = 3, HDMITX_RES_720x576p = 4, HDMITX_RES_1280x720p_50Hz = 5, HDMITX_RES_1280x720p_60Hz = 6, HDMITX_RES_1920x1080i_50Hz = 7, HDMITX_RES_1920x1080i_60Hz = 8, HDMITX_RES_1920x1080p_24Hz = 9, HDMITX_RES_1920x1080p_25Hz = 10, HDMITX_RES_1920x1080p_30Hz = 11, HDMITX_RES_1920x1080p_50Hz = 12, HDMITX_RES_1920x1080p_60Hz = 13, HDMITX_RES_MAX = 14, } HDMITX_VIDEO_TIMING; typedef enum { HDMITX_VIDEO_AR_Reserved = 0, HDMITX_VIDEO_AR_4_3 = 1, HDMITX_VIDEO_AR_16_9 = 2, } HDMITX_VIDEO_ASPECT_RATIO; typedef enum { HDMITX_VIDEO_SI_NoData = 0, HDMITX_VIDEO_SI_Overscanned = 1, HDMITX_VIDEO_SI_Underscanned = 2, HDMITX_VIDEO_SI_Reserved = 3, } HDMITX_VIDEO_SCAN_INFO; typedef enum { HDMITX_VIDEO_AFD_SameAsPictureAR = 8, // 1000 HDMITX_VIDEO_AFD_4_3_Center = 9, // 1001 HDMITX_VIDEO_AFD_16_9_Center = 10, // 1010 HDMITX_VIDEO_AFD_14_9_Center = 11, // 1011 HDMITx_VIDEO_AFD_Others = 15, // 0000~ 0111, 1100 ~ 1111 } HDMITX_VIDEO_AFD_RATIO; typedef enum { HDMITX_AUDIO_FREQ_NO_SIG = 0, HDMITX_AUDIO_32K = 1, HDMITX_AUDIO_44K = 2, HDMITX_AUDIO_48K = 3, HDMITX_AUDIO_88K = 4, HDMITX_AUDIO_96K = 5, HDMITX_AUDIO_176K = 6, HDMITX_AUDIO_192K = 7, HDMITX_AUDIO_FREQ_MAX_NUM = 8, } HDMITX_AUDIO_FREQUENCY; typedef enum { HDMITX_AUDIO_CH_2 = 2, // 2 channels HDMITX_AUDIO_CH_8 = 8, // 8 channels } HDMITX_AUDIO_CHANNEL_COUNT; typedef enum { HDMITX_AUDIO_PCM = 0, // PCM HDMITX_AUDIO_NONPCM = 1, // non-PCM } HDMITX_AUDIO_CODING_TYPE; typedef struct { MS_U8 Reserved; }HDMI_TX_INFO; typedef struct { MS_BOOL bIsInitialized; MS_BOOL bIsRunning; }HDMI_TX_Status; typedef struct { // HDMI Tx Current, Pre-emphasis and Double termination MS_U8 tm_txcurrent; // TX current control(U4: 0x11302B[13:12], K1: 0x11302B[13:11]) MS_U8 tm_pren2; // pre-emphasis mode control, 0x11302D[5] MS_U8 tm_precon; // TM_PRECON, 0x11302E[7:4] MS_U8 tm_pren; // pre-emphasis enable, 0x11302E[11:8] MS_U8 tm_tenpre; // Double termination pre-emphasis enable, 0x11302F[3:0] MS_U8 tm_ten; // Double termination enable, 0x11302F[7:4] } HDMITX_ANALOG_TUNING; typedef enum { E_HDCP_DISABLE = 0, // HDCP disable E_HDCP_FAIL = 1, // HDCP fail E_HDCP_PASS = 2, // HDCP pass } HDMITX_HDCP_STATUS; typedef enum { E_UNHDCPRX_NORMAL_OUTPUT = 0, // still display normally E_UNHDCPRX_HDCP_ENCRYPTION = 1, // HDCP encryption to show snow screen E_UNHDCPRX_BLUE_SCREEN = 2, // blue screen } HDMITX_UNHDCPRX_CONTROL; typedef enum { E_HDCPRXFail_NORMAL_OUTPUT = 0, // still display normally E_HDCPRXFail_HDCP_ENCRYPTION = 1, // HDCP encryption to show snow screen E_HDCPRXFail_BLUE_SCREEN = 2, // blue screen } HDMITX_HDCPRXFail_CONTROL; //------------------------------------------------------------------------------------------------- // Function and Variable //------------------------------------------------------------------------------------------------- //*********************// // DVI / HDMI // //*********************// MS_BOOL MApi_HDMITx_Init(void); MS_BOOL MApi_HDMITx_Exit(void); // HDMI Tx module On/Off /* Before turn on HDMI TX module, video and audio source should be prepared ready and set the following APIs first. { ... MApi_HDMITx_TurnOnOff(TRUE); MApi_HDMITx_SetRBChannelSwap(TRUE); MApi_HDMITx_SetColorFormat(HDMITX_VIDEO_COLOR_YUV444, HDMITX_VIDEO_COLOR_RGB444); MApi_HDMITx_SetVideoOnOff(TRUE); MApi_HDMITx_SetHDMITxMode_CD(HDMITX_HDMI, HDMITX_VIDEO_CD_24Bits); MApi_HDMITx_SetVideoOutputTiming(HDMITX_RES_1920x1080p_60Hz); MApi_HDMITx_Exhibit(); ... } */ void MApi_HDMITx_TurnOnOff(MS_BOOL state); // HDMI Tx output is DVI / HDMI mode void MApi_HDMITx_SetHDMITxMode(HDMITX_OUTPUT_MODE mode); // HDMI Tx output is DVI / HDMI mode and color depth void MApi_HDMITx_SetHDMITxMode_CD(HDMITX_OUTPUT_MODE mode, HDMITX_VIDEO_COLORDEPTH_VAL val); // HDMI Tx TMDS signal On/Off void MApi_HDMITx_SetTMDSOnOff(MS_BOOL state); // HDMI Tx TMDS control disable/enable void MApi_HDMITx_DisableTMDSCtrl(MS_BOOL bFlag); // HDMI Tx R/B channel swap void MApi_HDMITx_SetRBChannelSwap(MS_BOOL state); // HDMI Tx Exhibit funtcion void MApi_HDMITx_Exhibit(void); // HDMI Tx force output mode void MApi_HDMITx_ForceHDMIOutputMode(MS_BOOL bflag, HDMITX_OUTPUT_MODE output_mode); // HDMI Tx force output color format MS_BOOL MApi_HDMITx_ForceHDMIOutputColorFormat(MS_BOOL bflag, HDMITX_VIDEO_COLOR_FORMAT output_color); // Get the connected HDMI Rx status MS_BOOL MApi_HDMITx_GetRxStatus(void); // Get Rx's deep color definition from EDID MS_BOOL MApi_HDMITx_GetRxDCInfoFromEDID(HDMITX_VIDEO_COLORDEPTH_VAL *val); // Get Rx's support video format from EDID MS_BOOL MApi_HDMITx_GetRxVideoFormatFromEDID(MS_U8 *pu8Buffer, MS_U8 u8BufSize); // Get Rx's ID Manufacturer Name from EDID MS_BOOL MApi_HDMITx_GetRxIDManufacturerName(MS_U8 *pu8Buffer); // Get Rx's EDID data MS_BOOL MApi_HDMITx_GetEDIDData(MS_U8 *pu8Buffer, MS_BOOL BlockIdx); // This function clear settings of user defined packet void MApi_HDMITx_PKT_User_Define_Clear(void); // This function set user defined hdmi packet void MApi_HDMITx_PKT_User_Define(HDMITX_PACKET_TYPE packet_type, MS_BOOL def_flag, HDMITX_PACKET_PROCESS def_process, MS_U8 def_fcnt); // This function let user define hdmi packet content MS_BOOL MApi_HDMITx_PKT_Content_Define(HDMITX_PACKET_TYPE packet_type, MS_U8 *data, MS_U8 length); //*********************// // Video // //*********************// // HDMI Tx video output On/Off void MApi_HDMITx_SetVideoOnOff(MS_BOOL state); // HDMI Tx video color format void MApi_HDMITx_SetColorFormat(HDMITX_VIDEO_COLOR_FORMAT in_color, HDMITX_VIDEO_COLOR_FORMAT out_color); // HDMI Tx video output timing void MApi_HDMITx_SetVideoOutputTiming(HDMITX_VIDEO_TIMING mode); // HDMI Tx video output aspect ratio void MApi_HDMITx_SetVideoOutputAsepctRatio(HDMITX_VIDEO_ASPECT_RATIO out_ar); // HDMI Tx video output Overscan and AFD ratio void MApi_HDMITx_SetVideoOutputOverscan_AFD(MS_BOOL bflag, HDMITX_VIDEO_SCAN_INFO out_scaninfo, MS_U8 out_afd); void MApi_HDMITx_SetVideoOutputOverscan_AFD_II(MS_BOOL bflag, HDMITX_VIDEO_SCAN_INFO out_scaninfo, MS_U8 out_afd, MS_U8 A0 ); //*********************// // Audio // //*********************// // HDMI Tx audio output On/Off void MApi_HDMITx_SetAudioOnOff(MS_BOOL state); // HDMI Tx audio output sampling frequency // For Uranus void MApi_HDMITx_SetAudioFrequency(HDMITX_AUDIO_FREQUENCY freq); // HDMI Tx Module audio output: sampling frequency, channel count and coding type // For Oberon void MApi_HDMITx_SetAudioConfiguration(HDMITX_AUDIO_FREQUENCY freq, HDMITX_AUDIO_CHANNEL_COUNT ch, HDMITX_AUDIO_CODING_TYPE type); // HDMI Tx get audio CTS value. MS_U32 MApi_HDMITx_GetAudioCTS(void); // HDMI Tx mute/unmute audio FIFO. void MApi_HDMITx_MuteAudioFIFO(MS_BOOL bflag); //void MApi_HDMITx_SetAudioFrequencyFromMad(void); //*********************// // HDCP // //*********************// // HDMI Tx Get HDCP key (set internal/external HDCP key) // @param[in] useinternalkey: TRUE -> from internal, FALSE -> from external, like SPI flash void MApi_HDMITx_GetHdcpKey(MS_BOOL useinternalkey, MS_U8 *data); // HDMI Tx HDCP encryption On/Off void MApi_HDMITx_SetHDCPOnOff(MS_BOOL state); // This routine set HDMI Tx AVMUTE void MApi_HDMITx_SetAVMUTE(MS_BOOL bflag); // This routine get HDMI Tx AVMUTE status MS_BOOL MApi_HDMITx_GetAVMUTEStatus(void); // HDMI Tx HDCP status HDMITX_HDCP_STATUS MApi_HDMITx_GetHDCPStatus(void); // HDMI video output or blank or encryption while connected with unsupport HDCP Rx void MApi_HDMITx_UnHDCPRxControl(HDMITX_UNHDCPRX_CONTROL state); // HDMI video output or blank or encryption while HDCP authentication fail void MApi_HDMITx_HDCPRxFailControl(HDMITX_HDCPRXFail_CONTROL state); // Debug MS_BOOL MApi_HDMITx_GetLibVer(const MSIF_Version **ppVersion); MS_BOOL MApi_HDMITx_GetInfo(HDMI_TX_INFO *pInfo); MS_BOOL MApi_HDMITx_GetStatus(HDMI_TX_Status *pStatus); MS_BOOL MApi_HDMITx_HDCP_IsSRMSignatureValid(MS_U8 *data, MS_U32 size); /** * @brief set debug mask * @param[in] u16DbgSwitch DEBUG MASK, * 0x01: Debug HDMITX, 0x02: Debug HDCP */ MS_BOOL MApi_HDMITx_SetDbgLevel(MS_U16 u16DbgSwitch); void MApi_HDMITx_SetHPDGpioPin(MS_U8 u8pin); // Adjust HDMITx analog setting for HDMI test or compliant issue void MApi_HDMITx_AnalogTuning(HDMITX_ANALOG_TUNING *pInfo); void MApi_HDMITx_DisableRegWrite(MS_BOOL bFlag); //*********************// // CEC // //*********************// /// This routine get EDID physical address void MApi_HDMITx_GetEDIDPhyAdr(MS_U8 *pdata); // This routine turn on/off HDMI Tx CEC void MApi_HDMITx_SetCECOnOff(MS_BOOL bflag); // This routine get HDMI Tx CEC On/Off status MS_BOOL MApi_HDMITx_GetCECStatus(void); // This routine force get EDID from reciver MS_BOOL MApi_HDMITx_EdidChecking(void); #ifdef __cplusplus } #endif #endif // _API_HDMITX_H_
[ "aidan.steele@glassechidna.com.au" ]
aidan.steele@glassechidna.com.au
45d3789f4246259b38385bb774fce83a4ece8a59
36d53405ca51df99ed858a84d8d6fbe7360e66b2
/lib.h
4d2abc364f4324b5138728f417d282e24a1d5d52
[]
no_license
ellio-hub/Raise_the_terrain
55352cc54284d83843596732865e08a1d93d69e2
b230a6b7f4b9c8ad86aa9f8aae41fee912595d36
refs/heads/main
2023-03-22T14:11:41.411845
2021-03-15T01:25:37
2021-03-15T01:25:37
347,799,302
0
0
null
null
null
null
UTF-8
C
false
false
263
h
#ifndef _DEMO_H_ #define _DEMO_H_ #include <SDL2/SDL.h> #include <stdio.h> typedef struct SDL_Instance { SDL_Window *window; SDL_Renderer *rendrer; } SDL_Instance; int init_instance(SDL_Instance *); void draw (SDL_Instance instance); int events (void); #endif
[ "1421@holbertonschool.com" ]
1421@holbertonschool.com
b3b78026d356ea5f750b12bb7106d4c4534c8ce9
d8dba5e83bb343224929138a6001665156ea0df9
/c06/ex03/ft_sort_params.c
b07e3695e508c62c8450296d14867b8609048360
[]
no_license
neta123321/pisineCopy
4b8436083617a86676dcd8173eae4ac0c33e31a6
bb9142189028fd9ce1c8e5d068160ad2ca179a44
refs/heads/master
2022-12-18T04:34:09.013127
2020-09-23T13:09:26
2020-09-23T13:09:26
297,970,856
0
0
null
null
null
null
UTF-8
C
false
false
545
c
#include<unistd.h> int t(char *s ) { int x; while(s[x]) x++; return x; } int main(int argc, char *argv[] ) { int i; int j; int c; int x = 0 ; while (argv[x]) { while(argv[x-1]) { if (argv[i] > argv[j]) { c = argv[i]; argv[i] = argv[i+1] argv[i+1] = c; } j++; } i++; } while ( argv[x] ) { write (1, argv[a], t(argv[a])); write (1 ,"\n", 1); x++; } }
[ "https://github.com/neta123321/pisineCopy.git" ]
https://github.com/neta123321/pisineCopy.git
aa42a634a682dc2950bdb29588ad3cf303ecea40
a763f6505331d1c1823d0e8620cc2d5f83048486
/video/ms/3dlabs/perm2/disp/d3dtri.c
fe8635db9fa1c4fa9dec2c8ea55267d430c599e2
[]
no_license
KernelPanic-OpenSource/Win2K3_NT_drivers
1dc9ccd83e38299f6643ecfd996a5df1357cc912
1b5d2672673ff31b60ee4a5b96922ddbcc203749
refs/heads/master
2023-04-11T08:18:29.881663
2021-04-14T04:30:34
2021-04-14T04:30:34
357,772,205
12
5
null
null
null
null
UTF-8
C
false
false
9,681
c
/******************************Module*Header**********************************\ * * ******************* * * D3D SAMPLE CODE * * ******************* * * Module Name: d3dtri.c * * Content: Direct3D hw triangle rasterization code. * * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved. \*****************************************************************************/ #include "precomp.h" #include "d3ddelta.h" #include "d3dhw.h" #include "d3dcntxt.h" #if defined(_ALPHA_) #include <math.h> #endif //----------------------------------------------------------------------------- // // VOID P2_Draw_FVF_Solid_Tri // // Hardware render a single triangle coming from three FVF vertices // //----------------------------------------------------------------------------- VOID P2_Draw_FVF_Solid_Tri(PERMEDIA_D3DCONTEXT *pContext, LPD3DTLVERTEX lpV0, LPD3DTLVERTEX lpV1, LPD3DTLVERTEX lpV2, LPP2FVFOFFSETS lpFVFOff) { DWORD dwFlags = pContext->Hdr.Flags; DWORD dwColorOffs,dwSpecularOffs,dwTexOffs; ULONG ulRenderCmd = pContext->RenderCommand; D3DCOLOR dwColor0, dwColor1, dwColor2; D3DCOLOR dwSpec0, dwSpec1, dwSpec2; D3DVALUE fS0, fS1, fS2, fT0, fT1, fT2, fQ0, fQ1, fQ2; D3DVALUE fKs0, fKs1, fKs2; PERMEDIA_DEFS(pContext->ppdev); DBG_D3D((10,"Entering P2_Draw_FVF_Solid_Tri")); // Set triangle rendering mode RENDER_TRAPEZOID(ulRenderCmd); RESERVEDMAPTR(0x80); // Get FVF structure offsets __SetFVFOffsets(&dwColorOffs,&dwSpecularOffs,&dwTexOffs,lpFVFOff); // Get vertex color value (FVF based) if (dwColorOffs) { dwColor0 = FVFCOLOR(lpV0, dwColorOffs)->color; dwColor1 = FVFCOLOR(lpV1, dwColorOffs)->color; dwColor2 = FVFCOLOR(lpV2, dwColorOffs)->color; if (FAKE_ALPHABLEND_MODULATE & pContext->FakeBlendNum) { dwColor0 |= 0xFF000000; dwColor1 |= 0xFF000000; dwColor2 |= 0xFF000000; } } else { // must set default in case no D3DFVF_DIFFUSE dwColor0 = 0xFFFFFFFF; dwColor1 = 0xFFFFFFFF; dwColor2 = 0xFFFFFFFF; } // Get vertex specular value (FVF based) if necessary if ((dwFlags & (CTXT_HAS_SPECULAR_ENABLED | CTXT_HAS_FOGGING_ENABLED)) && (dwSpecularOffs!=0)) { dwSpec0 = FVFSPEC(lpV0, dwSpecularOffs)->specular; dwSpec1 = FVFSPEC(lpV1, dwSpecularOffs)->specular; dwSpec2 = FVFSPEC(lpV2, dwSpecularOffs)->specular; } if ( (dwFlags & CTXT_HAS_TEXTURE_ENABLED) && (dwTexOffs != 0) ) { // Get s,t texture coordinates (FVF based) fS0 = FVFTEX(lpV0,dwTexOffs)->tu; fT0 = FVFTEX(lpV0,dwTexOffs)->tv; fS1 = FVFTEX(lpV1,dwTexOffs)->tu; fT1 = FVFTEX(lpV1,dwTexOffs)->tv; fS2 = FVFTEX(lpV2,dwTexOffs)->tu; fT2 = FVFTEX(lpV2,dwTexOffs)->tv; // The hw requires us to keep the texture coordinates centered around 0 // and avoid exceeding the texel wrapping limit. RECENTER_TEX_COORDS(pContext->MaxTextureXf, pContext->MaxTextureXi, fS0, fS1, fS2); RECENTER_TEX_COORDS(pContext->MaxTextureYf, pContext->MaxTextureYi, fT0, fT1, fT2); // Wrap texture coordinates if necessary WRAP(fS,dwFlags & CTXT_HAS_WRAPU_ENABLED); WRAP(fT,dwFlags & CTXT_HAS_WRAPV_ENABLED); // Scale s,t coordinate values fS0 *= pContext->DeltaWidthScale; fS1 *= pContext->DeltaWidthScale; fS2 *= pContext->DeltaWidthScale; fT0 *= pContext->DeltaHeightScale; fT1 *= pContext->DeltaHeightScale; fT2 *= pContext->DeltaHeightScale; // Apply perspective corrections if necessary if (dwFlags & CTXT_HAS_PERSPECTIVE_ENABLED) { fQ0 = lpV0->rhw; fQ1 = lpV1->rhw; fQ2 = lpV2->rhw; fS0 *= fQ0; fT0 *= fQ0; fS1 *= fQ1; fT1 *= fQ1; fS2 *= fQ2; fT2 *= fQ2; } else { fQ0 = fQ1 = fQ2 = 1.0; } // Send lines s,t,q,ks (conditionaly),x,y,z values if ((dwFlags & CTXT_HAS_SPECULAR_ENABLED) && (dwSpecularOffs!=0)) { fKs0 = RGB256_TO_LUMA(RGB_GETRED(dwSpec0), RGB_GETGREEN(dwSpec0), RGB_GETBLUE(dwSpec0)); if (dwFlags & CTXT_HAS_GOURAUD_ENABLED) { fKs1 = RGB256_TO_LUMA(RGB_GETRED(dwSpec1), RGB_GETGREEN(dwSpec1), RGB_GETBLUE(dwSpec1)); fKs2 = RGB256_TO_LUMA(RGB_GETRED(dwSpec2), RGB_GETGREEN(dwSpec2), RGB_GETBLUE(dwSpec2)); } else { fKs2 = fKs1 = fKs0; } SEND_VERTEX_STQ_KS_XYZ(__Permedia2TagV0FloatS, fS0, fT0, fQ0, fKs0, lpV0->sx, lpV0->sy, lpV0->sz); SEND_VERTEX_STQ_KS_XYZ(__Permedia2TagV1FloatS, fS1, fT1, fQ1, fKs1, lpV1->sx, lpV1->sy, lpV1->sz); SEND_VERTEX_STQ_KS_XYZ(__Permedia2TagV2FloatS, fS2, fT2, fQ2, fKs2, lpV2->sx, lpV2->sy, lpV2->sz); } else { SEND_VERTEX_STQ_XYZ(__Permedia2TagV0FloatS, fS0, fT0, fQ0, lpV0->sx, lpV0->sy, lpV0->sz); SEND_VERTEX_STQ_XYZ(__Permedia2TagV1FloatS, fS1, fT1, fQ1, lpV1->sx, lpV1->sy, lpV1->sz); SEND_VERTEX_STQ_XYZ(__Permedia2TagV2FloatS, fS2, fT2, fQ2, lpV2->sx, lpV2->sy, lpV2->sz); } } else // not textured triangle { // If specular is enabled, change the colours if ((dwFlags & CTXT_HAS_SPECULAR_ENABLED) && (dwSpecularOffs!=0)) { CLAMP8888(dwColor0, dwColor0, dwSpec0); CLAMP8888(dwColor1, dwColor1, dwSpec1); CLAMP8888(dwColor2, dwColor2, dwSpec2); } // Send triangles x,y,z values SEND_VERTEX_XYZ(__Permedia2TagV0FloatS, lpV0->sx, lpV0->sy, lpV0->sz); SEND_VERTEX_XYZ(__Permedia2TagV1FloatS, lpV1->sx, lpV1->sy, lpV1->sz); SEND_VERTEX_XYZ(__Permedia2TagV2FloatS, lpV2->sx, lpV2->sy, lpV2->sz); } // If fog is set, send the appropriate values if ((dwFlags & CTXT_HAS_FOGGING_ENABLED) && (dwSpecularOffs!=0)) { SEND_VERTEX_FOG(__Permedia2TagV0FixedF, RGB_GET_GAMBIT_FOG(dwSpec0)); SEND_VERTEX_FOG(__Permedia2TagV1FixedF, RGB_GET_GAMBIT_FOG(dwSpec1)); SEND_VERTEX_FOG(__Permedia2TagV2FixedF, RGB_GET_GAMBIT_FOG(dwSpec2)); } // Set alpha stippling if required by context if (dwFlags & CTXT_HAS_ALPHASTIPPLE_ENABLED) { SET_STIPPLED_ALPHA( (RGBA_GETALPHA(lpV0->color) >> 4) ); } // Send appropriate color depending on Gouraud , Mono, & Alpha if (dwFlags & CTXT_HAS_GOURAUD_ENABLED) { // Gouraud shading if (RENDER_MONO) { SEND_VERTEX_RGB_MONO(__Permedia2TagV0FixedS, dwColor0); SEND_VERTEX_RGB_MONO(__Permedia2TagV1FixedS, dwColor1); SEND_VERTEX_RGB_MONO(__Permedia2TagV2FixedS, dwColor2); } else { if (dwFlags & CTXT_HAS_ALPHABLEND_ENABLED) { if (pContext->FakeBlendNum & FAKE_ALPHABLEND_ONE_ONE) { dwColor0 &= 0xFFFFFF; // supress color's alpha value dwColor1 &= 0xFFFFFF; dwColor2 &= 0xFFFFFF; } SEND_VERTEX_RGBA(__Permedia2TagV0FixedS, dwColor0); SEND_VERTEX_RGBA(__Permedia2TagV1FixedS, dwColor1); SEND_VERTEX_RGBA(__Permedia2TagV2FixedS, dwColor2); } else { SEND_VERTEX_RGB(__Permedia2TagV0FixedS, dwColor0); SEND_VERTEX_RGB(__Permedia2TagV1FixedS, dwColor1); SEND_VERTEX_RGB(__Permedia2TagV2FixedS, dwColor2); } } } else // Flat shading { if (RENDER_MONO) { // Get constant color from the blue channel DWORD BlueChannel = RGBA_GETBLUE(dwColor0); SEND_PERMEDIA_DATA( ConstantColor, RGB_MAKE(BlueChannel, BlueChannel, BlueChannel)); } else { if (pContext->FakeBlendNum & FAKE_ALPHABLEND_ONE_ONE) { dwColor0 &= 0xFFFFFF; } SEND_PERMEDIA_DATA( ConstantColor, RGBA_MAKE(RGBA_GETBLUE(dwColor0), RGBA_GETGREEN(dwColor0), RGBA_GETRED(dwColor0), RGBA_GETALPHA(dwColor0))); } } SEND_PERMEDIA_DATA(DrawTriangle, ulRenderCmd); COMMITDMAPTR(); DBG_D3D((10,"Exiting P2_Draw_FVF_Solid_Tri")); } // P2_Draw_FVF_Solid_Tri
[ "polarisdp@gmail.com" ]
polarisdp@gmail.com
e400aa3ebaa3710f32c32c0530c851c4ffa6906b
dd71a0718b058377d83d46ca1ef09bb4a311aa6d
/src/nwpw/nwpwlib/pseudopotential/paw_atom/paw_kinetic_energy.c
b74c60daa82d365a00a4ad769c1b1e30913e3812
[ "ECL-2.0" ]
permissive
wadejong/NWChem-Json
fad5c12663311b9f24ad8e940f3977bd1b6ae335
b33e56edc54b95b003cf8c7a444febd90ce335ac
refs/heads/master
2021-01-10T01:31:59.201471
2017-08-16T01:36:27
2017-08-16T01:36:27
45,052,326
2
2
null
2017-08-14T17:19:21
2015-10-27T15:59:03
Fortran
UTF-8
C
false
false
1,006
c
/* $Id: paw_kinetic_energy.c 19707 2010-10-29 17:59:36Z d3y133 $ */ #include <stdio.h> #include <math.h> #include <stdlib.h> #include "paw_loggrid.h" double paw_get_kinetic_energy(int num_states, int *l, double *fill, double **psi, double **psi_prime) { int i; int k; int Ngrid; double ekin; double ekin_total; double log_amesh; double *f; double *r; Ngrid = paw_N_LogGrid(); log_amesh = paw_log_amesh_LogGrid(); r = paw_r_LogGrid(); f = paw_alloc_LogGrid(); ekin_total = 0.0; for (i=0; i<=num_states-1; i++) { for (k=0; k<=Ngrid-1; k++) { f[k] = 0.5*psi_prime[i][k]/(r[k]*log_amesh)* psi_prime[i][k]/(r[k]*log_amesh) +0.5*l[i]*(l[i]+1)/(r[k]*r[k])*psi[i][k]*psi[i][k]; } ekin = paw_Def_Integr(0.0,f,0.0,Ngrid-1); ekin_total = ekin_total + ekin*fill[i]; } paw_dealloc_LogGrid(f); return ekin_total; }
[ "wadejong@lbl.gov" ]
wadejong@lbl.gov
457d9d8f0720194d952b87c86426989d5c8ca97f
3dd33b18d5e10ccc41f2ccfd0a736ab796d3a25a
/PID.h
4788ae4bacbe557af9d124c3d559dddbcf12eab4
[]
no_license
erfanjazebnikoo/Quala-PID-Pathfinder
b13b4724f5651c0af187f27f8c4d34c5ab7059aa
8aa85da421e8890789fa3c4a3ff6c6d287ee03d4
refs/heads/master
2022-05-26T04:43:17.172754
2022-05-08T16:06:14
2022-05-08T16:06:14
151,771,905
0
0
null
null
null
null
UTF-8
C
false
false
384
h
/********************** QUALA ********************** Project : Quala Speedy Path Finder Main Board Version : 0.1 Date : 4/29/2015 Author : Erfan Jazeb Nikoo Company : Quala ********************** QUALA **********************/ #ifndef PID_H #define PID_H #include "Library.h" #include "Sensor.h" #include "Controller.h" void calculatePIDControllerSpeed(); #endif /* PID_H */
[ "erfan.jazebnikoo@gmail.com" ]
erfan.jazebnikoo@gmail.com
c1352170ae9d3f379147f3e606a10e3bd5d6b941
de4620a726a0e2b4391f51ced025fb7ec1f8f85f
/3_sem/lab_09/lab_09_1/mystring.c
c7b1ec38cff090a7b12a3a230f1f2461073821c5
[]
no_license
Winterpuma/bmstu_C
5b6c3cddaa53370580831b2e80c79b80e38b6994
5b37d836f14ef814dba34e027210dda48a19378d
refs/heads/master
2020-03-21T11:02:04.147940
2019-01-24T22:18:52
2019-01-24T22:18:52
138,485,423
18
0
null
null
null
null
UTF-8
C
false
false
399
c
#include <string.h> /** My realisation of strrchr @param str [in] @param ch [in] - char to find @return index of last ch in str or null */ char *my_strrchr(const char *str, int ch) { char *last_found = 0; while (*str) { if (*str == ch) last_found = (char *)str; str++; } if (ch == '\0') last_found = (char *)str; return last_found; }
[ "32524078+Winterpuma@users.noreply.github.com" ]
32524078+Winterpuma@users.noreply.github.com
5546df0533bec131e3b314255734e611bfbf3a66
b6df166bca4a365f0bab75ccebbbd73956039bf7
/perfect_no_in_range.c
738bf281d2eaeb44fe3dbeeb9f7116ce0a4fb1ef
[]
no_license
aksharamythili/c_programs
399719437de42acb36e84171d9d557d63e6b10c8
1e20655053e873555e9688d695b063b70d0cd8d3
refs/heads/main
2023-06-06T20:52:23.402539
2021-07-09T15:36:48
2021-07-09T15:36:48
382,570,065
0
0
null
null
null
null
UTF-8
C
false
false
784
c
#include <stdio.h> int main() { int i, j, start, end, sum; /* Input lower and upper limit from user */ printf("Enter lower limit: "); scanf("%d", &start); printf("Enter upper limit: "); scanf("%d", &end); printf("All Perfect numbers between %d to %d:\n", start, end); /* Iterate from start to end */ for(i=start; i<=end; i++) { sum = 0; /* Check whether the current number i is Perfect number or not */ for(j=1; j<i; j++) { if(i % j == 0) { sum += j; } } /* If the current number i is Perfect number */ if(sum == i) { printf("%d, ", i); } } return 0; }
[ "noreply@github.com" ]
aksharamythili.noreply@github.com
49e8f6969dabf35565bf4bd973801e1b5952a5d1
caa19c695fe23450e000f265c974dfc1a027bfd9
/testasm/AllenBullet.h
ac51ea51677e691d029fc0dbfe0655a40cd3fb8d
[]
no_license
haidragon/mytrank
7fff70db2044aa405c5b52836d678966f6a19e0f
bf38b6d6ebac49d3efbe6d09875c0c3ea90bfe9e
refs/heads/master
2021-05-02T13:17:44.492443
2018-02-08T12:16:24
2018-02-08T12:16:24
120,757,256
0
0
null
null
null
null
GB18030
C
false
false
1,288
h
#include "AllenUserTrank.h" #include "AllenEnemyTrank.h" typedef struct PBULLET { int x; int y; int dir; int life; }Bullet, *Pbullet; //初始化子弹 void init_User_Bullet(UserTrank userTrank,Pbullet userBullet); //创建子弹 void create_User_Bullet(UserTrank userTrank, Pbullet userBullet); //打印子弹 void print_User_Bullet(Bullet userBullet); //清除子弹 void clear_User_Bullet(Bullet userBullet); //移动所有 void User_Bullet_Move(Pbullet userBullet); //判断子弹是否在home附近 int User_Bullet_home(Pbullet userBullet); ////////////////////////////////////////////////////////////// //初始化子弹 void init_Enemy_Bullet(EnemyTrank enemyTrank, Pbullet userBullet); //创建子弹 void create_Enemy_Bullet(EnemyTrank enemyTrank, Pbullet userBullet); //打印子弹 void print_Enemy_Bullet(Bullet userBullet); //清除子弹 void clear_Enemy_Bullet(Bullet userBullet); //移动所有 void Enemy_Bullet_Move(Pbullet pbullet); //判断子弹是否在home附近 int Enemy_Bullet_home(Pbullet pbullet); //用户 extern Bullet UserBullet[100]; //敌人 extern Bullet EnemyBullet[100]; ////敌人2 //extern Bullet EnemyBullet1[100]; ////敌人3 //extern Bullet EnemyBullet2[100]; //extern list<Bullet> ListBullet;
[ "noreply@github.com" ]
haidragon.noreply@github.com
2a2b0421c84147fa9b840f8f21313eee5e543028
e0548caf7bd8153f8d991b7d7c1bed487402f0bc
/semestr-5/Algorytmy i struktury danych 1/PPR/programy-z-cwiczen/2018-wiosna/dzienne/C05/03_Cz_10_15-P05/Prg_0013.c
d3a84699999135b9609977bccdd90221037a9cce
[]
no_license
Ch3shireDev/WIT-Zajecia
58d9ca03617ba07bd25ce439aeeca79533f0bcb6
3cd4f7dea6abdf7126c44a1d856ca5b6002813ca
refs/heads/master
2023-09-01T11:32:12.636305
2023-08-28T16:48:03
2023-08-28T16:48:03
224,985,239
19
24
null
2023-07-02T20:54:18
2019-11-30T08:57:27
C
UTF-8
C
false
false
693
c
#include <stdio.h> #include <stdlib.h> int main(){ int * myT; int sizeT; int i; /** 2, 3, 4 size ?= 3 T[0] ?= 5 T[1] ?= 6 T[2] ?= 1 **************** T[0] = 5 T[1] = 6 T[2] = 1 */ printf("size ?="); scanf("%d", &sizeT); myT = (int*)malloc(sizeof(int)*sizeT); for(i = 0; i<sizeT; ++i){ printf("T[%2d] ?=", i); scanf("%d", &myT[i]);/** scanf("%d", myT+i); */ } printf("*****************************\n"); for(i = 0; i<sizeT; ++i){ printf("T[%2d] = %2d\n", i, myT[i]); } return 0; }
[ "thesmilingcatofcheshire@gmail.com" ]
thesmilingcatofcheshire@gmail.com
a31595ef23127c6e729bf31764ec35360eee799f
200cd47729ddb59380e39df4600c9c2cb30b09f5
/ExtendedCustomization/ExtendedCustomization/ExhaustFX.h
1c87353dc84b8834ea4b9253edd6de7db5b56675
[]
no_license
ArchieGoldmill/NFSC_ExtendedCustomizationV2
3a04850396b7c32f9dd1b8b9359486ab8ff10b8d
f41248d0eb2afcb60a96f942aeaa05f8122fa68d
refs/heads/master
2023-06-07T10:04:28.074648
2021-07-03T17:46:43
2021-07-03T17:46:43
374,798,028
6
1
null
null
null
null
UTF-8
C
false
false
34
h
#pragma once void InitExhaustFX();
[ "archie.goldmill@gmail.com" ]
archie.goldmill@gmail.com
6f444aa3a05a7b0f7d47e18b4e6446af98040e88
22aa98cf7e1e74e80a62f4097bbc576911776103
/4.c
3e5a77eba11eb2d3a835854391cf225b1ba517ae
[]
no_license
AlexandruPislariu/Concurrent-Programming
b3beb0ac7807781f447d1eee07a72c64e134313b
8890a9b67fd99f23bd25e36c4eb57d332523726f
refs/heads/master
2022-11-19T01:46:00.116763
2020-07-11T09:25:44
2020-07-11T09:25:44
null
0
0
null
null
null
null
UTF-8
C
false
false
1,531
c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> int main(int argc, char** argv) { int a2c,c2b,b2a; // unlink("/tmp/a2c"); // unlink("/tmp/c2b"); // unlink("/tmp/b2a"); mkfifo("/tmp/a2c", 0777); mkfifo("/tmp/c2b", 0777); mkfifo("/tmp/b2a", 0777); int N; scanf("%d", &N); printf("A: %d \n", N); if(fork()==0) {/* Procesul C */ a2c = open("/tmp/a2c", O_RDONLY); c2b = open("/tmp/c2b", O_WRONLY); while(1) { if(read(a2c, &N, sizeof(int))<=0) break; if(N<=0) break; printf("C: %d -> %d \n", N, N+1); N++; write(c2b, &N, sizeof(int)); } close(a2c); close(c2b); exit(0); } if(fork()==0) {/* Procesul B */ c2b = open("/tmp/c2b", O_RDONLY); b2a = open("/tmp/b2a", O_WRONLY); while(1) { if(read(c2b, &N, sizeof(int))<=0) break; if(N<=0) break; printf("B: %d -> %d \n", N, N-2); N = N- 2; write(b2a, &N, sizeof(int)); } close(c2b); close(b2a); exit(0); } a2c = open("/tmp/a2c", O_WRONLY); b2a = open("/tmp/b2a", O_RDONLY); write(a2c, &N, sizeof(int)); while(1) { if(read(b2a, &N, sizeof(int))<=0) break; if(N<=0) break; if(N%2==0) { printf("A: %d -> %d \n", N, N-2); N = N-2; } else { printf("A: %d -> %d \n", N, N-1); N = N-1; } write(a2c, &N, sizeof(int)); } close(a2c); close(b2a); wait(0); wait(0); unlink("/tmp/a2c"); unlink("/tmp/c2b"); unlink("/tmp/b2a"); return 0; }
[ "noreply@github.com" ]
AlexandruPislariu.noreply@github.com
542fefd33320f3ea85fc54181114f0a49c96702b
4bc4ee72f3666eb370ccbd09e145b852d2a28b81
/TP_1_Cascara/TP_1_Cascara/funciones.h
0911f085fb8e9712ed53ab11ffeff906e61fe9ce
[]
no_license
DanisaTuillier/tp_laboratorio_1
9aa64ef498846cee668a09e36a46250ba002f4d0
66f7f63150d5dd147b483121eff1ca84d69a3667
refs/heads/master
2021-01-23T19:11:33.598631
2017-09-22T13:53:34
2017-09-22T13:53:34
101,810,931
0
0
null
null
null
null
UTF-8
C
false
false
1,385
h
#ifndef FUNCIONES_H_INCLUDED #define FUNCIONES_H_INCLUDED /** \brief Realiza la suma entre numero1 y numero2. * * \param Recibe dos numeros flotantes. * * \return Devuelve el resultado flotante de la suma entre numero1 y numero2. * */ float sumar (float numero1, float numero2 ); /** \brief Realiza la resta entre numero1 y numero2. * * \param Recibe dos numeros flotantes . * * \return Devuelve el resultado flotante de la resta entre numero1 y numero2. * */ float restar(float numero1, float numero2); /** \brief Realiza la division entre numero1 y numero2 y verifica que no se divida por 0. * * \param Recibe dos numeros flotantes. * * \return Devuelve el resultado flotante de la division entre numero1 y numero2. * */ float dividir(float numero1, float numero2); /** \brief Realiza la multiplicacion entre numero1 y numero2. * * \param Recibe dos numeros flotantes . * * \return Devuelve el resultado flotante de la multiplicacion entre numero1 y numero2. * */ float multiplicacion (float numero1, float numero2); /** \brief Realiza el calculo factorial del numero1 y verifica que no sea flotante ni negativo. * * \param Recibe un numero flotante. * * \return Devuelve el resultado entero de el factorial. * */ long long int factorial(float numero1); #endif // FUNCIONES_H_INCLUDED
[ "noreply@github.com" ]
DanisaTuillier.noreply@github.com
4ee4721efb44d27e68c95233542051ebc67086c7
fa2e34373e8f1f4261cd4d4991b738ec1fd06ad5
/C Programming/DS_Day5_sol/BubbleSort/BubbleSort.c
3fdc95d3695d512cce8b2a8cb2584d0442d354df
[]
no_license
THLEE-KR/C_Programming_2019
84ba05e3a9c69c11d58f52c39d0cfb3bf9b431f7
323449f95138baf09e1e49bd314863caee78d57b
refs/heads/master
2020-05-16T21:52:54.239478
2019-04-25T06:51:39
2019-04-25T06:51:39
183,320,986
0
0
null
null
null
null
UHC
C
false
false
899
c
#include <stdio.h> #include <time.h> /* time() */ #include <stdlib.h> /* rand(), srand() */ #include "BubbleSort.h" void initArray(int *ary, int n) { int i; for(i=0; i<n; ++i) { ary[i] = rand() % 20 + 1; } } void printArray(int *ary, int n) { int i; printf("배열 내용 : "); for(i=0; i<n; ++i) { printf("%4d", ary[i]); } printf("\n"); } /*---------------------------------------------------------------- Function Name : bubbleSort() - 거품정렬 함수 Argument : ary - 정렬 데이터 저장 배열 n - 배열 원소의 수 Return : 없음 ----------------------------------------------------------------*/ void bubbleSort(int *ary, int n) { /* * TO DO */ int i; int j; int temp; for (i=(n-1) ; i>0 ; --i) { for (j=0 ; j<i ; j++) { if (ary[j] > ary[j+1]) { temp = ary[j]; ary[j] = ary[j + 1]; ary[j + 1] = temp; } } } }
[ "taehui0118@gmail.com" ]
taehui0118@gmail.com
5f77c957a42cb05d5033784e9618cf8dffeddfdd
778043480a3bf17ce33e7e151e251d70b4a8e788
/lib/ft_strncmp.c
d396779acb8fe8e696befc5526ebfb19488d14b3
[]
no_license
wild-crasher/42
8546d4f348c13a981d7a6f7c31deee15193c5547
1239203e4709e30601a7f32542af1884f9752e63
refs/heads/master
2020-09-24T06:17:19.761917
2016-09-09T23:05:48
2016-09-09T23:05:48
67,833,826
0
0
null
null
null
null
UTF-8
C
false
false
24
c
../j05/ex04/ft_strncmp.c
[ "vaysse.a@laposte.net" ]
vaysse.a@laposte.net
0aa6b9114170d82444defe46f5b21aff97d9819d
3bcd6d49c5d776919bea099b049d34093aa48421
/a.c
0df2901ff83cf06a54838ca3b0d08d75523a086b
[]
no_license
mizuki0823/study
d75800980284638c607d323f0549ee5e16ffd623
0efb78a820d2ac94f841feee61cb2a6dae32b42e
refs/heads/master
2021-07-04T22:13:51.082828
2021-02-02T15:18:55
2021-02-02T15:18:55
221,813,711
2
0
null
null
null
null
UTF-8
C
false
false
428
c
#include <stdio.h> #include <string.h> #include <math.h> #define max(a,b) (a>b?a:b) #define min(a,b) (a<b?a:b) #define abs(a) (a>0?a:-a) #define swap(a,b) (a ^= b ^= a ^= b) int main () { char c; int n, k; printf("入力:"); n = 0; k = 0; while (( c = getchar() ) != '\n'){ n *= 10; n += c - '0'; k++; } printf("出力:%d(桁数 = %d)\n", n, k); return 0; }
[ "44769222+mizuki0823@users.noreply.github.co44769222+mizuki0823@users.noreply.github.com" ]
44769222+mizuki0823@users.noreply.github.co44769222+mizuki0823@users.noreply.github.com
1b65d70e57798f44e0fecd06b18eda4942b2885b
5b38518d50beafcc015a9199ae5ac9bb416b1dff
/Week19/12273.c
62a13c7a2500cfc5dd08f1c42704944239a76771
[]
no_license
ngluanhcm/learnC
6a7656ea38b38ed7011c8f0c76410556c3169a77
4a796b7777aed685e40ef4a6cdf2bd46dda16f15
refs/heads/master
2022-09-12T19:36:04.559310
2020-06-01T10:50:24
2020-06-01T10:50:24
262,216,493
0
0
null
null
null
null
UTF-8
C
false
false
94
c
luan@luan-VirtualBox:/lib$ ls -l man 3 sqrt luan@luan-VirtualBox:/usr/lib$ ls -l man 3 sqrt
[ "ngluanhcmus@gmail.com" ]
ngluanhcmus@gmail.com
2b42ca9fa4377e1e27dbf9e601275c870de4aad5
a9381494ca0b5769a3dc4d9851317aa1db96b310
/kernel/tasking/Launchpad.c
0a3fbe9af0fb459b2414c661f4351435ea23685d
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ANSUUVIOUS/skift
0bacfd1ecedb5eb1b802c9c550d091005fa707e6
42c1f50ba2ea67b7576136aad200c0a799dfc3f3
refs/heads/master
2022-08-07T10:24:26.323153
2020-05-26T16:30:09
2020-05-26T16:30:09
null
0
0
null
null
null
null
UTF-8
C
false
false
3,847
c
#include <libfile/elf.h> #include <libsystem/Assert.h> #include <libsystem/CString.h> #include "kernel/tasking.h" Result task_launch_load_elf(Task *parent_task, Task *child_task, Stream *elf_file, elf_program_t *program_header) { if (program_header->vaddr <= 0x100000) { logger_error("ELF program no in user memory (0x%08x)!", program_header->vaddr); return ERR_EXEC_FORMAT_ERROR; } PageDirectory *parent_page_directory = task_switch_pdir(parent_task, child_task->pdir); paging_load_directory(child_task->pdir); task_memory_map(child_task, program_header->vaddr, PAGE_ALIGN_UP(program_header->memsz) / PAGE_SIZE); memset((void *)program_header->vaddr, 0, program_header->memsz); stream_seek(elf_file, program_header->offset, WHENCE_START); size_t read = stream_read(elf_file, (void *)program_header->vaddr, program_header->filesz); if (read != program_header->filesz) { logger_error("Didn't read the right amount from the ELF file!"); task_switch_pdir(parent_task, parent_page_directory); return ERR_EXEC_FORMAT_ERROR; } else { task_switch_pdir(parent_task, parent_page_directory); return SUCCESS; } } void task_launch_passhandle(Task *parent_task, Task *child_task, Launchpad *launchpad) { lock_acquire(parent_task->handles_lock); for (int i = 0; i < PROCESS_HANDLE_COUNT; i++) { int child_handle_id = i; int parent_handle_id = launchpad->handles[i]; if (parent_handle_id >= 0 && parent_handle_id < PROCESS_HANDLE_COUNT && parent_task->handles[parent_handle_id] != NULL) { fshandle_acquire_lock(parent_task->handles[parent_handle_id], scheduler_running_id()); child_task->handles[child_handle_id] = fshandle_clone(parent_task->handles[parent_handle_id]); fshandle_release_lock(parent_task->handles[parent_handle_id], scheduler_running_id()); } } lock_release(parent_task->handles_lock); } Result task_launch(Task *parent_task, Launchpad *launchpad, int *pid) { assert(parent_task == scheduler_running()); *pid = -1; __cleanup(stream_cleanup) Stream *elf_file = stream_open(launchpad->executable, OPEN_READ); if (handle_has_error(elf_file)) { logger_error("Failled to open ELF file %s: %s!", launchpad->executable, handle_error_string(elf_file)); return handle_get_error(elf_file); } elf_header_t elf_header; { size_t elf_header_size = stream_read(elf_file, &elf_header, sizeof(elf_header_t)); if (elf_header_size != sizeof(elf_header_t) || !elf_valid(&elf_header)) { logger_error("Failled to load ELF file %s: bad exec format!", launchpad->executable); return ERR_EXEC_FORMAT_ERROR; } } { Task *child_task = task_spawn_with_argv(parent_task, launchpad->name, (TaskEntry)elf_header.entry, (const char **)launchpad->argv, true); for (int i = 0; i < elf_header.phnum; i++) { elf_program_t elf_program_header; stream_seek(elf_file, elf_header.phoff + (elf_header.phentsize) * i, WHENCE_START); if (stream_read(elf_file, &elf_program_header, sizeof(elf_program_t)) != sizeof(elf_program_t)) { task_destroy(child_task); return ERR_EXEC_FORMAT_ERROR; } Result result = task_launch_load_elf(parent_task, child_task, elf_file, &elf_program_header); if (result != SUCCESS) { task_destroy(child_task); return result; } } task_launch_passhandle(parent_task, child_task, launchpad); *pid = child_task->id; task_go(child_task); } return SUCCESS; }
[ "nicolas.van.bossuyt@gmail.com" ]
nicolas.van.bossuyt@gmail.com
f71439e5076e467c58e189b3016436d1eeb13fdb
052b2b2f37b679547a62153b98157a399faeac54
/0x12-more_singly_linked_lists/7-get_nodeint.c
7b560e4838a2816ca92b57e41785018dbd3a2179
[]
no_license
seleniadelgado/holbertonschool-low_level_programming
2ca76c53a76870347d21f6ba81f3ceb61570f1c5
3cc0c372bc0b93ff691170aea106170866ced8e8
refs/heads/master
2020-03-28T14:58:28.015754
2019-04-19T00:27:18
2019-04-19T00:27:18
148,542,057
0
0
null
null
null
null
UTF-8
C
false
false
477
c
#include "lists.h" #include <stdlib.h> #include <stdio.h> /** * get_nodeint_at_index - function that returns the nth node of a listint_t * linked list. * @head: head of the list. * @index: index of the node. * Return: temp. */ listint_t *get_nodeint_at_index(listint_t *head, unsigned int index) { listint_t *temp = head; unsigned int ct = 0; if (temp == NULL) return (NULL); while (temp != NULL && ct < index) { temp = temp->next; ct++; } return (temp); }
[ "angiedelgado08@gmail.com" ]
angiedelgado08@gmail.com
37670441abba00871b9905ed4c0255d0a738bec7
d1a772d129154bac81b2d1276627c7380fdedf7c
/w5100.c
c7db555f8963c29c81e0f47489f4589b83643f83
[]
no_license
keepmov/stm32-w5100
e6d5929acce8be038e50b72c3a7ef8130a968bdd
32115f6abe5ad6bfb6f72ffde4197bf58f250fd0
refs/heads/master
2021-01-19T21:11:37.544032
2015-06-12T17:33:45
2015-06-12T17:33:45
null
0
0
null
null
null
null
UTF-8
C
false
false
5,261
c
/* Copyright (c) 2015 Carmine Noviello 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 "w5100.h" #ifdef DEBUG #include "stm32f4xx_hal_uart.h" #include <string.h> UART_HandleTypeDef *ghuart; W5100_Handle_TypeDef _hw5100; void W5100_UART_Debug_Init(UART_HandleTypeDef *huart) { ghuart = huart; } void W5100_UART_Debug_Print(char *msg) { HAL_UART_Transmit(ghuart, (uint8_t*)msg, strlen(msg), 100); } #endif //#ifdef DEBUG W5100_StatusTypeDef W5100_GetGWIP(uint8_t *ip) { W5100_StatusTypeDef retval; for(uint16_t addr = GWIP_ADDR_REG; addr <= GWIP_ADDR_REG + GWIP_ADDR_LEN; addr++) retval |= W5100_Read(addr, ip++); return retval; } W5100_StatusTypeDef W5100_GetIP(uint8_t *ip) { W5100_StatusTypeDef retval; for(uint8_t addr = IP_ADDR_REG; addr <= IP_ADDR_REG + IP_ADDR_LEN; addr++) retval |= W5100_Read(addr, ip++); return retval; } W5100_StatusTypeDef W5100_GetMAC(uint8_t *mac) { W5100_StatusTypeDef retval; for(uint8_t addr = MAC_ADDR_REG; addr <= MAC_ADDR_REG + MAC_ADDR_LEN; addr++) retval |= W5100_Read(addr, mac++); } W5100_StatusTypeDef W5100_GetNetMask(uint8_t *nm) { W5100_StatusTypeDef retval; for(uint8_t addr = NET_MASK_REG; addr <= NET_MASK_REG + NET_MASK_LEN; addr++) retval |= W5100_Read(addr, nm++); } W5100_StatusTypeDef W5100_Init(W5100_Handle_TypeDef *hw5100) { W5100_StatusTypeDef retval; /* FIXME: aggiungere i sanity checks */ memcpy((uint8_t*)&_hw5100, (uint8_t*)hw5100, sizeof(W5100_Handle_TypeDef)); retval = W5100_SetIP(_hw5100) && W5100_SetNetMask(_hw5100) && W5100_SetGWIP(_hw5100) && W5100_SetMAC(_hw5100); retval |= W5100_Write(0x001A, 0x55); //FIXME: MEMORIA SOCKET, CAMBIARE retval |= W5100_Write(0x001B, 0x55); //FIXME: MEMORIA SOCKET, CAMBIARE return retval; } /** * @brief Write a single byte inside a given W5100 memory register * @param hw5100: pointer to a W5100_Handle_TypeDef structure that contains * the configuration information for W5100 ic. * @param regaddr: first byte of the address location of memory register * @param regl: second byte of the memory register * @param Size: amount of data to be sent * @param Timeout: Timeout duration * @retval HAL status */ W5100_StatusTypeDef W5100_Write(uint16_t regaddr, uint8_t data) { HAL_StatusTypeDef status = HAL_OK; /* Every W5100 write command starts with 0xF0 byte, followed by the register address (2 bytes) and data (1 byte) */ uint8_t buf[] = {0xF0, regaddr >> 8, regaddr, data}; HAL_GPIO_WritePin(_hw5100.ssGPIOx, _hw5100.ssGPIOpin, GPIO_PIN_RESET); //CS LOW status = HAL_SPI_Transmit(_hw5100.hspi, buf, 4, 0xFFFFFFFF); HAL_GPIO_WritePin(_hw5100.ssGPIOx, _hw5100.ssGPIOpin, GPIO_PIN_SET); //CS HIGH return status; } W5100_StatusTypeDef W5100_Read(uint16_t regaddr, uint8_t *data) { HAL_StatusTypeDef status = HAL_OK; /* Every W5100 read command starts with 0x0F byte, followed by the register address (2 bytes) and data (1 byte) */ uint8_t wbuf[] = {0x0F, regaddr >> 8, regaddr, 0x0}; uint8_t rbuf[4]; HAL_GPIO_WritePin(_hw5100.ssGPIOx, _hw5100.ssGPIOpin, GPIO_PIN_RESET); //CS LOW status = HAL_SPI_TransmitReceive(_hw5100.hspi, wbuf, rbuf, 4, 0xFFFFFFFF); HAL_GPIO_WritePin(_hw5100.ssGPIOx, _hw5100.ssGPIOpin, GPIO_PIN_SET); //CS HIGH *data = rbuf[3]; return status; } W5100_StatusTypeDef W5100_SetGWIP() { W5100_StatusTypeDef retval; for(uint16_t addr = GWIP_ADDR_REG; addr <= GWIP_ADDR_REG + GWIP_ADDR_LEN; addr++) retval |= W5100_Write(addr, _hw5100.gw[addr - GWIP_ADDR_REG]); return retval; } W5100_StatusTypeDef W5100_SetIP() { W5100_StatusTypeDef retval; for(uint16_t addr = IP_ADDR_REG; addr <= IP_ADDR_REG + IP_ADDR_LEN; addr++) retval |= W5100_Write(addr, _hw5100.ip[addr - IP_ADDR_REG]); return retval; } W5100_StatusTypeDef W5100_SetMAC() { W5100_StatusTypeDef retval; for(uint16_t addr = MAC_ADDR_REG; addr <= MAC_ADDR_REG + MAC_ADDR_LEN; addr++) retval |= W5100_Write(addr, _hw5100.mac[addr - MAC_ADDR_REG]); return retval; } W5100_StatusTypeDef W5100_SetNetMask() { W5100_StatusTypeDef retval; for(uint16_t addr = NET_MASK_REG; addr <= NET_MASK_REG + NET_MASK_LEN; addr++) retval |= W5100_Write(addr, _hw5100.nm[addr - NET_MASK_REG]); return retval; }
[ "cnoviello@hotmail.com" ]
cnoviello@hotmail.com
845ec8bc2e0e4e955fb424db9f983cabf774e2f2
36091493998730d5e96c687b8f41cfb08bc631ef
/h/SysCall.h
3ce35ab301dd5a8126edfd803a5ea401737fc2b2
[ "MIT" ]
permissive
Smexey/8086_OS_BCC
5b20f61ef11a53264d9f02077924fed9e09000ab
e8ec277a7c0971da438731bdc869634d054b3304
refs/heads/master
2022-01-06T21:24:48.671355
2019-06-26T13:24:58
2019-06-26T13:24:58
null
0
0
null
null
null
null
UTF-8
C
false
false
216
h
/* * SysCall.h * * Created on: May 16, 2019 * Author: OS1 */ #ifndef OS_H_SYSCALL_H_ #define OS_H_SYSCALL_H_ #include "const.h" void interrupt Timer(...); #endif /* OS_H_SYSCALL_H_ */
[ "noreply@github.com" ]
Smexey.noreply@github.com
a260b8c894be5a09a331abef9834472f873dde13
6f37f529bae8bbcc99244468477f14e9f96ff95c
/wxWidgets-2.8.12/contrib/include/wx/gizmos/statpict.h
63a93162427db38db36671014efc673bc4f8acb3
[]
no_license
darknebuli/darknebuli-RM-graph
13326ddbc9a210605926f7ad4b70672a48b1b2f2
bf169c01f787fdd144e19fae6732a5b58fdbdafd
refs/heads/master
2020-05-16T23:40:56.853727
2012-04-30T22:14:24
2012-04-30T22:14:24
null
0
0
null
null
null
null
UTF-8
C
false
false
4,400
h
U2FsdGVkX19fTms3OENxUoetnOKy1AyJ49jWWmkNc76HrZzistQMiePY1lppDXO+ h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc758g4KpHaB8LwCS1iqVEAa/ Hm5QCwo6MZ/eqi24hkMjqT8n795o+LjO96wsYRCgGCK/H9eB6Qcfvl/3i5bc1Q74 IBVF49f/KCa2wMsUWXEVHBbooUCkMZf9xi4UygPAhG8IqWx9FWgly1MY1MmWQmw1 icpteBeH4WMdDJUQbhb4U48T5rCD8iOIuO7pKiRLb9EnPpUXXKA8/Yoa04Sq5A07 i1GZZfOjOBwT1t2Xv3EHREjF2Nmd8TyjEZA5HkAc4etCcQUAOVdaI6xCeh44aTWL L/q+QFPOOiglkNCmTylW40zrV2CBLlc37ZkcQlS4ppmHrZzistQMiePY1lppDXO+ h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc76HrZzistQMiePY1lppDXO+ PkofRZ6lEnHnOx6kbi2zyMwkyd2FOlclDwBgZxWrQTT0JAaZclCcBlkFhnFV4cuV oPEFeww0wS1eEKaQ3xVHsJNre4sNq+HwQKqysYZnfeljvOtikQhjrkiRJgM5Y1g1 f8+XbBW2TQXHxAewa0RCEMZ5lSka3zVXz7fBph4kjc7F1agJPS7A03EVFRSJ4D8S gHU/EFPs+XhfR4jtHCUlT0FiyumR3aG/GWH6CSZlRCQRqJypgAowCfsiowLHJr/n ZqSpOHxx+ABxRA71FQAa2AgQHmYsEjdm1jwAitWLsea89kiDD/SdXNp0hRICQSRm t/7+vZgvMtT+u/bK4DHSeGQbJxQ8+/PPOhpPEKR2+yivksw5i6lMKEHLAG51Uuad 7/XKAQXw7lamaVJcWimmXb+Jhs0icaHKPpS2hphLYkw+g9QZ7jmZmvQ6cCiqoFWV ioFJ2uNHh8fqmIj+X1lZ0RebFpmkKd4zF6Yxg17ONwJaMQNr+xAa3k+BziYaR1zN 3X6u5bfnRDt0q1Wxyzc7pfG81yNwVoX1dlzuagtgewYrF5DrEVa6/5ZmANOoBMRV y+wyohYCJkZ5YHT/Sx/R/kr3CSUrt9At1Rys9p+EnDblFoUgU9csvX28aRo++s33 B09oDghEGNxHRsLm15hyy0n/VSO95TIBITHEzwJZD0gTkcK0bryb/U4bZioM8eVd xldQ9V3gi7q3DUxU4YBxESbH9v54/szBSckoym0XZDjpFUGCeFY/l0DJDYhKRnhK KPbES+cXeY0lGuPRAUSdqZtN3gwK6U3XB+WSOnIAVDtx4ApqNqX8ptaE2RmRzYhF zZZWsxP6JPS+JVwUJfMTNna8h4LYCWR3qQsVfp4WDPksHd+h/DvdAInIrQvRw+I+ nD6vrcZGm8ZH/mO+fr5sdJ8Ehpkk4oSEvkgSMQTyqpFtkFs5H/RTwm1rxD7ixam1 ZiXUyXumdqppu8jDU2zhZuLzlin6ZmvP53omliLp1jPsUDdwaadpQBO6LPyxP14i X6VeIdDDS1Q5vSVPHU38wTkTHPOqyjEbdk2erYyg0l352RnE/uqclNKEgM0S51xi AmmLcm915o2+hhAI+SKwcdf/RbAhxjpwSKtFM5olVKafzVYY8kGyTUKa1GPUBOYu zWA3MDnA2/wcFdzUoi/axy2HO+j2W9nxmZUWv0PNjGVBGVun0R/M3Aa8ea088voG 8EuV52bVAphSKNR6kINfNMtiwEUm9sOVuZVuCB4vn4N39Al7wO0xOBccjC5ZPYGv AbJcYphCX5GeacTRIZRum6nv4vd4bb7L/7UcC+gFFS8zVx6P0aHAj07AUlaaGf2n vGO0HRQvoFbFUxlJ2oCO5MkABzKIE86e22WUqPmQWbmv8+lV++Wdojq8BBtnGAPd EBgjqT5YeEgk/FNslytOp6L1oG9fb36zabP2NZ71ALca6Q7wFe8xuuTP24SnSsAT 7vWxKAnbn/SIM8puvdC0y5sJ6MVuolSD8PNfRGIKW6n5huN9ekJH6gfl6GxFf2o6 WHPohbLc6lirfPWyKrfEhk7fTQiOM44V8YJ2GKjAEnCbKeKD5CeyzANt/rw+vumo d0bFCtkAPsT4jkRe9AiLiCblx/LtG1T3ENZEe3mD1RWu0ZIdNJh//jKou75jokU8 7tUnQ83RjCDSIm0fpdascdT6jn+2f3U+E5gcdaHGoAVNZ2LEGvbFvn0uh69Gd7T5 AmBvZLy8sLxbPykfOVNH483fLRrmVb6WyCukQ/4OTs2Wue+Uc2/Dv7NSP/secePX c+rpJxToTZUglSx9InlHR7+6k5Gi51OuY0ut91jeaMeXGkVrJU9Ki6HPB9TSC+t/ b2MkiiMx5wjCyhHpOlTq1KtH9sQbgcDfjUdFPa7IUJ2Nrb0pHP2vNEisLAuoIdxA v3BkqZiRCJJ3COnwcbR2IIguUJnuy/WYt79LkTJBfNPPrXxbKL7FpOwPR8NgaxKL zJAfercjTmDy91kR3ccAuTp96TNySUZ+z5IqarNlWEh+c8nAMa1HmdC9LhWK1trd 2C0cXz5Gz1MI+6dZecFC3T0J2Md+tbKVzEBUtqoo0YHrD5nqbqTRCmPnG9pdo1Ny rMu9NYfGF8bDeomBLur4u2pT6JhzhN9llK4hPTT4hrYTAIa2iafHgN8Nk8BpBBTd q4uLnqByA7MjzG7nQwa5zVLZ+MU27a5+eQZa0enYi82BeVfK7eSbuOnwdFIKm3eG wvJrzQl46zhBoaOQU1bREevVDpj1CsLE0KynLqSytYJ1s6m2mpk7Zt9hiehN9yxo buygm48Vrfx7AQt68kk0laR3cwXNWmRba6suzsh6Amm8L2GomuPfXEx4kv34M1OW d+y6nZA0e05St1E6VKh1tLtqm5Hi8LSWXfdBMvcV52cj9+TlDKpTfYjvx4a+tjJN TPTWHpop2i2btZMXZM1bgqBS/LSXJI7bpst2lS1amEJDwfKLpuSR/yF04/DD7oWk a4lQu2aOwgSv92UkfujaM1fnUFqLqy47kGAV2xq3XfHeWcCpvfijAXd7fRG6t0d8 1kW5A0FlrSZmDJEnjCGqUzERTZEU98q09Uy2rQIxfBbIS/dpywkW1PZbRA7i2ib6 F26VFYH7OmmBWpjwI54JDK1jPu5gl+RvF/xv4Zewrr+d/z9a5LFC6FPy2DObCFz2 QrbJOsH5U3V1lPrm1oVK/WlIdgb9hfMfQoMqCslE93gfYTSfbtx+KTm05RTjeI73 JYETjJ7NnLpyGB3H0NcJAa6B1sLDByfBpzI5doocq7e+cV8JAi2f7JW99yl5RvDw +xaU2GWfCfyvE4fPPEmiwoP7zdphxn3HK/R1CYdP7wq9S9aR9iO4OgyU5K74NtYj Ljf6vMDjyJRFnnORS5JyJl3pUjvDXHP2kSkbvZ6TwFPX1Ms6XLDeSMy8Gg5nUnEi HqasyD4qpE/kja0tb9WtsPfcfe+HWZSYoHtrAs6qXkiZ6LEoBBGQFEl3AHMIeNxM UV2ivK/b49nRhVpfiLWH1aZX3aIx90yJdovuYy4SoUHW3TnDeqkaDaB4nE+8Fzdn ndhQsPb+898BcHzK2/n3YjbTEDyOq4ZTIK/pxpTWDVdlMdw7dhSFZIeG5pL6LNWV KaGqj4NntB0y5XF9Q1XSWUDNoN0ugRTUNjHZNTFUtgEYVrbRqt1N+ltrI1OiNu5F dKmQupIbWYBhm5UyFifF8kjomEqyt/I7ngr92ozE9mRd+NYlLL9n5dZTYMZtqL8E Iwe8jSUeRxvcHgYt2Hn9QkgWZEE0xvjRMVsnhDCg/tK/XAIjDrp8WI2qWKox2X+1 uWvJ46vv9Yr4ZH3CTmMpJ7QgFBQ9G0i4sPBlHlZlijnFL11w5odUNZkGHag5DtNh 6t4dy4RuBjyWZBj1wdHgKD3wIJYaojwS6WuUuCkR+6ad/4JS8pnlAY1L4KyqwoSb bqQrVtBkKx/FKRwPRUMqhqcV5AZVP6BJczxSbSeWh7MetnWcOd9Cz6DBR3A5LR/K O/uQPyGz7PT13jJPfIiOCd1iHljnUFH/sjhvThTXMLscYPYnyBPBkLENTGxuxBIR G2uwlPZodVplJ3GE+elbLUTDh1VlkDujqiakPcc4SvhMTwnNceORXSNWhEDNjk6U 6Hoy8WJChYs0HSOnNC02eb5KyAFHiixitHu0jYxR6pPYUlN/1hwHLfPVSrde077A IqBwY2ua7HvuHj3/pyNi1myIzCxOw8zT+tY2NUFAbIw8cDMent1hizqsB+N4w0Wy oj7U9OnMBNIQMl41CHasHgli1FQcivtZWgQfLv4g5o0=
[ "charles@rhizometric.com" ]
charles@rhizometric.com
4fa4b9d43ed3ed8e38e4383db3b72bc1c1abca8e
65eda420a8d95a023060dbf54989ca6887e9737a
/atlasBuild/src/blas/gemm/KERNEL/ATL_zupKBmm17_1_1_b0.c
42a85606eca76e670462e447af5feab60cbf2249
[]
no_license
ApostaC/sc17
91789164cdf334d0b821082625c7959333720290
0c6c5ec9194a3ea2b91973dd405eb679b3e6e31b
refs/heads/master
2020-12-02T22:08:09.557024
2017-09-07T14:21:43
2017-09-07T14:21:43
96,066,822
0
0
null
null
null
null
UTF-8
C
false
false
80,958
c
#define ATL_USERMM ATL_zupKBmm17_1_1_b0 #define ATL_USERMM_b1 ATL_zupKBmm17_1_1_b1 #define ATL_USERMM_bn1 ATL_zupKBmm17_1_1_bn1 #define ATL_USERMM_b0 ATL_zupKBmm17_1_1_b0 #define ATL_USERMM_bX ATL_zupKBmm17_1_1_bX #define BETA0 #define DCPLX #define MB 56 #define NB 56 #define KB 17 #define MBMB 3136 #define NBNB 3136 #define KBKB 289 #define MB2 112 #define NB2 112 #define KB2 34 #define MB3 168 #define NB3 168 #define KB3 51 #define MB4 224 #define NB4 224 #define KB4 68 #define MB5 280 #define NB5 280 #define KB5 85 #define MB6 336 #define NB6 336 #define KB6 102 #define MB7 392 #define NB7 392 #define KB7 119 #define MB8 448 #define NB8 448 #define KB8 136 /* * Automatically Tuned Linear Algebra Software v3.10.3 * (C) Copyright 2006 R. Clint Whaley * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions, and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the ATLAS group or the names of its contributers may * not be used to endorse or promote products derived from this * software without specific written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include "atlas_asm.h" #if !defined(ATL_GAS_x8664) && !defined(ATL_GAS_x8632) #error "This kernel requires x86 assembly!" #endif #if !defined(KB) || (KB == 0) #error "KB must be a compile-time constant!" #endif #if KB > 90 #error "KB can at most be 90!" #endif #ifdef DCPLX #define CMUL(arg_) 2*arg_ #else #define CMUL(arg_) arg_ #endif /* * Prefetch defines */ #if defined(ATL_SSE1) || defined(ATL_SSE2) #define pref2(mem) prefetcht1 mem #define prefB(mem) prefetcht0 mem #ifdef ATL_3DNow #define prefC(mem) prefetchw mem #else #define prefC(mem) prefetchnta mem #endif #elif defined(ATL_3DNow) #define pref2(mem) prefetch mem #define prefB(mem) prefetch mem #define prefC(mem) prefetchw mem #else #define pref2(mem) #define prefB(mem) #define prefC(mem) #endif #ifdef ATL_GAS_x8632 #define movq movl #define addq addl #define subq subl #define shrq shrl #define rsp esp #define STKSIZE 36 #define IOFF STKSIZE-4 #define MOFF IOFF-4 #define JOFF MOFF-4 #define iAOFF JOFF-4 #define iCOFF iAOFF-4 #define BETAOFF STKSIZE+40 #endif /* *Integer register usage shown by these defines */ #ifdef ATL_GAS_x8632 #define pA0 %ecx #define lda %ebx #define lda3 %ebp #define pAE pA0 #define pB0 %eax #define pC0 %esi #define pBE pB0 #define ldb %edi #define pfA %edx #define incAn iAOFF(%esp) #define incCn iCOFF(%esp) #define MM IOFF(%esp) #define NN JOFF(%esp) #define MM0 MOFF(%esp) #else #define pA0 %rcx #define lda %rbx #define lda3 %rbp #define pAE %rdi #define pB0 %rax #define pC0 %rsi #define pBE %rdx #define incAn %r8 #define incCn %r9 #define ldb %r10 #define MM %r11 #define NN %r12 #define pfA %r13 #define MM0 %r14 #endif /* %rdi/4 %rsi/8 %rdx/12 %xmm0/16 void ATL_USERMM(const int M, const int N, const int K, const TYPE alpha, %rcx/24 %r8/28 %r9/32 8/36 const TYPE *A, const int lda, const TYPE *B, const int ldb, %xmm1/40 16/48 24/52 const TYPE beta, TYPE *C, const int ldc) */ .text .global ATL_asmdecor(ATL_USERMM) ALIGN16 ATL_asmdecor(ATL_USERMM): /* * Save callee-saved iregs */ #ifdef ATL_GAS_x8632 sub $STKSIZE, %esp movl %ebp, (%esp) movl %ebx, 4(%esp) movl %esi, 8(%esp) movl %edi, 12(%esp) #else movq %rbp, -8(%rsp) movq %rbx, -16(%rsp) movq %r12, -24(%rsp) movq %r13, -32(%rsp) movq %r14, -40(%rsp) pref2((pA0)) /* movq %r15, -48(%rsp) */ #endif /* * Setup input parameters */ #ifdef ATL_GAS_x8632 movl STKSIZE+4(%esp), lda3 movl lda3, MM0 movl STKSIZE+8(%esp), lda3 movl lda3, NN movl STKSIZE+24(%esp), pA0 pref2((pA0)) movl STKSIZE+28(%esp), lda pref2((pA0,lda)) movl STKSIZE+32(%esp), pB0 pref2((pB0)) movl STKSIZE+36(%esp), ldb pref2((pA0,lda,2)) movl STKSIZE+48(%esp), pC0 pref2(KB*8(pA0,lda,2)) /* * incCn = (ldc - M)*sizeof */ movl STKSIZE+52(%esp), lda3 subl MM0, lda3 #ifdef DCPLX shl $4, lda3 #else shl $3, lda3 #endif movl lda3, incCn /* * pA0 += 128; pB0 += 128 */ sub $-128, pA0 sub $-128, pB0 prefB(-64(pB0)) /* * lda *= sizeof; ldb *= sizeof; lda3 = lda*3 */ shl $3, lda prefB((pB0)) shl $3, ldb prefB(64(pB0)) lea (lda,lda,2), lda3 /* * pfA = A + lda*M; incAn = lda*M */ movl MM0, pfA prefB(128(pB0)) imull lda, pfA prefB(192(pB0)) prefB(256(pB0)) movl pfA, incAn lea -128(pA0, pfA), pfA prefB(320(pB0)) shrl $2, MM0 /* MM0 = MM0 / mu */ #else #ifdef BETAX #define BETAOFF -48 movlpd %xmm1, BETAOFF(%rsp) #endif movq %rdi, MM0 movq %rsi, NN movq %r8, lda pref2((pA0,lda)) movq %r9, pB0 prefB((pB0)) movslq 8(%rsp), ldb pref2((pA0,lda,2)) movq 16(%rsp), pC0 movslq 24(%rsp), incCn pref2(KB*8(pA0,lda,2)) /* * incCn = (ldc-M)*sizeof */ sub MM0, incCn #ifdef DCPLX shl $4, incCn #else shl $3, incCn #endif /* * pA0 += 128; pB0 += 128 */ sub $-128, pA0 sub $-128, pB0 prefB(-64(pB0)) /* * lda = lda*sizeof; lda3 = lda*3 */ shl $3, lda prefB((pB0)) lea (lda,lda,2), lda3 /* * ldb = ldb*sizeof */ shl $3, ldb prefB(64(pB0)) /* * pfA = A + lda*M ; incAn = lda*M, pfB = B + ldb*N */ movq lda, pfA prefB(128(pB0)) imulq MM0, pfA /* prefB(192(pB0)) */ /* prefB(256(pB0)) */ movq pfA, incAn /* movq ldb, pfB */ /* imulq NN, pfB */ lea -128(pA0, pfA), pfA /* prefB(320(pB0)) */ /* lea -128-(MB-8)*KB*8(pA0, pfA), pfA */ /* * pAE (pointer to end of column of A) = pA + lda */ #if KB > 32 /* lea -128(pA0,lda), pAE */ /* lea -128(pB0,ldb), pBE */ lea KB*8-128(pA0), pAE lea KB*8-128(pB0), pBE #endif /* * MM0 = MM0/mu */ shr $2, MM0 #endif ALIGN16 NLOOP: #ifdef ATL_GAS_x8632 movl MM0, lda3 movl lda3, MM lea (lda,lda,2), lda3 #else movq MM0, MM #endif prefB(-128(pB0,ldb,2)) prefB(-64(pB0,ldb,2)) prefB((pB0,ldb,2)) MLOOP: prefC((pC0)) fldl 0-128(pB0) /* st = rB0 */ fldl 0-128(pA0) /* st = rA0, rB0 */ fmul %st(1), %st /* st = rA0*rB0, rB0 */ fldl 0-128(pA0,lda) /* st = rA1, rC0, rB0 */ fmul %st(2), %st /* st = rA1*rB0, rC0, rB0 */ fldl 0-128(pA0,lda,2) /* st = rA2, rC1, rC0, rB0 */ fmul %st(3), %st /* st = rA2*rB0, rC1, rC0, rB0 */ fxch %st(3) /* st = rB0, rC1, rC0, rC2 */ fmull 0-128(pA0,lda3) /* st = rA3*rB0, rC1, rC0, rC2 */ /*KLOOP: */ /* st = rC3, rC1, rC0, rC2 */ #if KB > 1 fldl 8-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 2 fldl 16-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 16-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 16-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 16-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 16-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 3 fldl 24-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 24-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 24-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 24-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 24-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 4 fldl 32-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 32-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 32-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 32-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 32-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 5 fldl 40-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 40-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 40-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 40-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 40-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 6 fldl 48-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 48-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 48-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 48-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 48-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 7 fldl 56-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 56-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 56-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 56-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 56-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 8 fldl 64-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 64-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 64-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 64-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 64-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 9 fldl 72-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 72-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 72-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 72-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 72-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 10 fldl 80-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 80-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 80-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 80-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 80-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 11 fldl 88-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 88-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 88-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 88-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 88-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 12 fldl 96-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 96-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 96-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 96-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 96-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 13 fldl 104-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 104-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 104-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 104-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 104-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 14 fldl 112-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 112-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 112-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 112-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 112-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 15 fldl 120-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 120-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 120-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 120-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 120-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 16 fldl 128-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 128-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 128-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 128-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 128-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 17 fldl 136-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 136-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 136-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 136-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 136-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 18 fldl 144-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 144-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 144-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 144-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 144-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 19 fldl 152-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 152-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 152-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 152-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 152-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 20 fldl 160-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 160-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 160-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 160-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 160-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 21 fldl 168-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 168-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 168-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 168-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 168-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 22 fldl 176-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 176-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 176-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 176-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 176-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 23 fldl 184-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 184-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 184-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 184-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 184-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 24 fldl 192-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 192-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 192-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 192-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 192-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 25 fldl 200-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 200-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 200-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 200-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 200-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 26 fldl 208-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 208-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 208-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 208-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 208-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 27 fldl 216-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 216-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 216-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 216-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 216-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 28 fldl 224-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 224-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 224-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 224-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 224-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 29 fldl 232-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 232-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 232-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 232-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 232-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 30 fldl 240-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 240-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 240-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 240-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 240-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 31 fldl 248-128(pB0) /* st = rB0, rC3, rC1, rC0, rC2 */ #if KB > 32 && defined(ATL_GAS_x8632) addl $KB*8-128, pB0 #endif fldl 248-128(pA0) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 248-128(pA0,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 248-128(pA0,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 248-128(pA0,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ #if KB > 32 && defined(ATL_GAS_x8632) addl $KB*8-128, pA0 #endif faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if (KB > 32) #ifdef ATL_GAS_x8632 ALIGN8 #endif fldl 8*(32-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(32-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(32-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(32-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(32-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 33 fldl 8*(33-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(33-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(33-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(33-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(33-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 34 fldl 8*(34-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(34-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(34-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(34-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(34-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 35 fldl 8*(35-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(35-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(35-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(35-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(35-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 36 fldl 8*(36-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(36-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(36-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(36-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(36-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 37 fldl 8*(37-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(37-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(37-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(37-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(37-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 38 fldl 8*(38-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(38-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(38-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(38-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(38-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 39 fldl 8*(39-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(39-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(39-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(39-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(39-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 40 fldl 8*(40-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(40-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(40-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(40-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(40-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 41 fldl 8*(41-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(41-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(41-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(41-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(41-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 42 fldl 8*(42-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(42-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(42-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(42-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(42-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 43 fldl 8*(43-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(43-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(43-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(43-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(43-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 44 fldl 8*(44-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(44-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(44-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(44-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(44-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 45 fldl 8*(45-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(45-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(45-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(45-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(45-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 46 fldl 8*(46-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(46-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(46-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(46-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(46-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 47 fldl 8*(47-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(47-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(47-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(47-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(47-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 48 fldl 8*(48-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(48-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(48-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(48-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(48-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 49 fldl 8*(49-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(49-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(49-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(49-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(49-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 50 fldl 8*(50-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(50-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(50-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(50-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(50-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 51 fldl 8*(51-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(51-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(51-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(51-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(51-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 52 fldl 8*(52-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(52-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(52-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(52-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(52-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 53 fldl 8*(53-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(53-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(53-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(53-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(53-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 54 fldl 8*(54-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(54-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(54-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(54-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(54-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 55 fldl 8*(55-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(55-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(55-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(55-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(55-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 56 fldl 8*(56-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(56-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(56-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(56-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(56-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 57 fldl 8*(57-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(57-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(57-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(57-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(57-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 58 fldl 8*(58-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(58-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(58-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(58-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(58-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 59 fldl 8*(59-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(59-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(59-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(59-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(59-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 60 fldl 8*(60-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(60-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(60-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(60-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(60-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 61 fldl 8*(61-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(61-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(61-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(61-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(61-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 62 fldl 8*(62-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(62-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(62-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(62-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(62-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 63 fldl 8*(63-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(63-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(63-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(63-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(63-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 64 fldl 8*(64-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(64-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(64-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(64-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(64-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 65 fldl 8*(65-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(65-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(65-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(65-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(65-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 66 fldl 8*(66-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(66-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(66-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(66-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(66-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 67 fldl 8*(67-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(67-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(67-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(67-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(67-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 68 fldl 8*(68-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(68-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(68-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(68-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(68-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 69 fldl 8*(69-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(69-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(69-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(69-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(69-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 70 fldl 8*(70-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(70-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(70-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(70-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(70-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 71 fldl 8*(71-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(71-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(71-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(71-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(71-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 72 fldl 8*(72-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(72-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(72-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(72-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(72-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 73 fldl 8*(73-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(73-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(73-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(73-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(73-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 74 fldl 8*(74-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(74-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(74-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(74-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(74-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 75 fldl 8*(75-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(75-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(75-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(75-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(75-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 76 fldl 8*(76-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(76-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(76-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(76-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(76-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 77 fldl 8*(77-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(77-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(77-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(77-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(77-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 78 fldl 8*(78-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(78-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(78-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(78-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(78-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 79 fldl 8*(79-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(79-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(79-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(79-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(79-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 80 fldl 8*(80-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(80-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(80-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(80-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(80-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 81 fldl 8*(81-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(81-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(81-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(81-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(81-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 82 fldl 8*(82-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(82-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(82-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(82-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(82-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 83 fldl 8*(83-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(83-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(83-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(83-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(83-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 84 fldl 8*(84-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(84-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(84-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(84-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(84-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 85 fldl 8*(85-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(85-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(85-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(85-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(85-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 86 fldl 8*(86-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(86-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(86-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(86-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(86-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 87 fldl 8*(87-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(87-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(87-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(87-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(87-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 88 fldl 8*(88-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(88-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(88-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(88-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(88-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif #if KB > 89 fldl 8*(89-KB)(pBE) /* st = rB0, rC3, rC1, rC0, rC2 */ fldl 8*(89-KB)(pAE) /* st = rA0, rB0, rC3, rC1, rC0, rC2 */ fmul %st(1), %st /* st = rA0*rB0, rB0, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = rB0, rC3, rC1, rC0+, rC2 */ fldl 8*(89-KB)(pAE,lda) /* st = rA1, rB0, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = rA1*rB0, rB0, rC3, rC1, rC0+, rC2 */ faddp %st, %st(3) /* st = rA1*rB0, rB0, rC3, rC1+, rC0+, rC2 */ fldl 8*(89-KB)(pAE,lda,2) /* st = rA2, rB0, rC3, rC1+, rC0+,rC2 */ fmul %st(1), %st /* st = rA2*rB0, rB0, rC3, rC1+, rC0+, rC2 */ faddp %st, %st(5) /* st = rB0, rC3, rC1+, rC0+, rC2+ */ fmull 8*(89-KB)(pAE,lda3) /* st = rA3*rB0, rC3, rC1+, rC0+, rC2+ */ faddp %st, %st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ #endif /* jnz KLOOP */ #DONEK: #ifdef BETA0 fstpl CMUL(24)(pC0) fstpl CMUL(8)(pC0) fstpl (pC0) fstpl CMUL(16)(pC0) #elif defined(BETA1) || defined(BETAN1) #ifdef BETAN1 #define faddl fsubl #endif /* st = rC3, rC1, rC0, rC2 */ fxch %st(2) /* st = rC0, rC1, rC3, rC2 */ faddl (pC0) /* st = rC0+,rC1, rC3, rC2 */ fstpl (pC0) /* st = rC1, rC3, rC2 */ faddl CMUL(8)(pC0) /* st = rC1+,rC3, rC2 */ fstpl CMUL(8)(pC0) /* st = rC3, rC2 */ fxch %st(1) /* st = rC2, rC3 */ faddl CMUL(16)(pC0) /* st = rC2+,rC3 */ fstpl CMUL(16)(pC0) /* st = rC3 */ faddl CMUL(24)(pC0) /* st = rC3+ */ fstpl CMUL(24)(pC0) /* st = null */ #ifdef BETAN1 #undef faddl #endif #else /* st = rC3, rC1, rC0, rC2 */ fldl BETAOFF(%rsp) /* st = bet, rC3, rC1, rC0, rC2 */ fldl (pC0) /* st = c0, bet, rC3, rC1, rC0, rC2 */ fmul %st(1),%st /* st = c0*bet, bet, rC3, rC1, rC0, rC2 */ faddp %st, %st(4) /* st = bet, rC3, rC1, rC0+, rC2 */ fldl CMUL(8)(pC0) /* st = c1, bet, rC3, rC1, rC0+, rC2 */ fmul %st(1),%st /* st = c1*bet, bet, rC3, rC1, rC0+, rC2 */ faddp %st,%st(3) /* st = bet, rC3, rC1+, rC0+, rC2 */ fldl CMUL(16)(pC0) /* st = c2, bet, rC3, rC1+, rC0+, rC2 */ fmul %st(1),%st /* st = bet*c2, bet, rC3, rC1+, rC0+, rC2 */ faddp %st,%st(5) /* st = bet, rC3, rC1+, rC0+, rC2+ */ fmull CMUL(24)(pC0) /* st = bet*c3, rC3, rC1+, rC0+, rC2+ */ faddp %st,%st(1) /* st = rC3+, rC1+, rC0+, rC2+ */ fstpl CMUL(24)(pC0) fstpl CMUL(8)(pC0) fstpl (pC0) fstpl CMUL(16)(pC0) #endif add $4*CMUL(8), pC0 pref2((pfA)) add $32, pfA #if KB > 32 && defined(ATL_GAS_x8632) lea 128-KB*8(pA0,lda,4), pA0 subl $KB*8-128, pB0 #else lea 0(pA0,lda,4), pA0 #if KB > 32 lea 0(pAE,lda,4), pAE #endif #endif sub $1, MM jnz MLOOP sub incAn, pA0 prefB(64(pB0,ldb,2)) #if KB > 32 && !defined(ATL_GAS_x8632) sub incAn, pAE add ldb, pBE #endif prefB(128(pB0,ldb,2)) add incCn, pC0 prefB(192(pB0,ldb,2)) add ldb, pB0 prefB(256(pB0,ldb,2)) prefB(320(pB0,ldb,2)) sub $1, NN jnz NLOOP DONE: #ifdef ATL_GAS_x8632 movl (%esp), %ebp movl 4(%esp), %ebx movl 8(%esp), %esi movl 12(%esp), %edi add $STKSIZE, %esp #else movq -8(%rsp), %rbp movq -16(%rsp), %rbx movq -24(%rsp), %r12 movq -32(%rsp), %r13 movq -40(%rsp), %r14 /* movq -48(%rsp), %r15 */ #endif ret
[ "Aposta@pku.edu.cn" ]
Aposta@pku.edu.cn
13e419aeb7ddbae07a8bf56fd3cc0f20a8dd5173
1fabbdfd1ca9ea1b6808893e12bd907eb74de414
/xcode/Classes/Native/mscorlib_System_Collections_Generic_Comparer_1_gen_216.h
eefb5518122044f137a8343a05c6ee9af7d968dd
[]
no_license
Klanly/TutorialPackageClient
6f889e96c40ab13c97d107708ae8f3c71a484301
b9d61ba2f287c491c9565b432f852980ec3fee28
refs/heads/master
2020-12-03T01:42:35.256114
2016-11-01T02:40:21
2016-11-01T02:40:21
null
0
0
null
null
null
null
UTF-8
C
false
false
460
h
#pragma once #include <stdint.h> // System.Collections.Generic.Comparer`1<EventDelegate> struct Comparer_1_t16729; // System.Object #include "mscorlib_System_Object.h" // System.Collections.Generic.Comparer`1<EventDelegate> struct Comparer_1_t16729 : public Object_t { }; struct Comparer_1_t16729_StaticFields{ // System.Collections.Generic.Comparer`1<T> System.Collections.Generic.Comparer`1<EventDelegate>::_default Comparer_1_t16729 * ____default; };
[ "bu213200@gmail.com" ]
bu213200@gmail.com
f9189ff66a8b990d33ab1f6ef99c2f2a179e7c3c
03a9c30ba546f13d6747b021cfe0d7cce2fe642b
/Lose.c
6ca5e376534532953edcfe101bc015fa2bc16eed
[]
no_license
eahn2016/FullStomach
f92449b4c943d33563780ff1ce78f07829c4ac2f
1d03f42f6f822c68aeb8873d6b24486793ca10b0
refs/heads/master
2021-04-28T16:40:37.318807
2018-02-19T05:10:21
2018-02-19T05:10:21
122,020,199
1
0
null
null
null
null
UTF-8
C
false
false
32,875
c
//{{BLOCK(Lose) //====================================================================== // // Lose, 256x256@4, // + palette 256 entries, not compressed // + 191 tiles (t|f|p reduced) not compressed // + regular map (in SBBs), not compressed, 32x32 // Total size: 512 + 6112 + 2048 = 8672 // // Time-stamp: 2017-12-05, 17:02:29 // Exported by Cearn's GBA Image Transmogrifier, v0.8.3 // ( http://www.coranac.com/projects/#grit ) // //====================================================================== const unsigned short LoseTiles[3056] __attribute__((aligned(4)))= { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0xBBBB,0xBBBB, 0x5555,0x5555,0x5555,0x5555,0xF555,0x555F,0xF555,0xF55F, 0xF555,0xF555,0xF555,0xFFFF,0xFF55,0xFF55,0xBFFB,0xFFBB, 0x5555,0x5555,0x5555,0x5555,0x555F,0x5555,0x555F,0x5555, 0x5555,0xFFF5,0xF555,0xF55F,0xF555,0xFF5F,0xFBBB,0xBFFB, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0xF555,0x5F55,0xFF55,0x5FF5,0x5F55,0x55F5,0xBFBB,0xFBFF, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x55F5,0x5555, 0x55FF,0x5555,0x555F,0x5555,0x555F,0x5555,0xBBBB,0xBBBB, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0x5FFF,0xFF55,0x555F,0xF555,0x55FF,0x5FF5,0xBFBB,0xFBFB, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0x555F,0xF555,0x55F5,0xFFF5,0x55FF,0xF55F,0xFBBF,0xFFBF, 0x5555,0x5555,0x5555,0x5555,0x555F,0x5555,0x55FF,0x5555, 0x555F,0x5555,0x5555,0x5555,0x5555,0x5555,0xBBBB,0xFBBF, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555, 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0xBFBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0x7777,0x7777, 0xBFFB,0xFFBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0x7777,0x7777, 0xFBBB,0xBBFF,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0x7777,0x7777, 0xFFBB,0xBFFB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBFBB,0xFFBB,0xBFBB,0xBFBB,0xBFBB,0xBFFB,0x7F77,0x77F7, 0xBBBB,0xFBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xFBBB,0xBBFF,0x7FF7,0x77F7, 0xBBFF,0xBFFB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xFBFB,0xBBBB,0xF7FF,0x777F, 0xBBFF,0xFBFF,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBFB,0xBBBB,0xBFFB,0xBBBB,0xBBFF,0xFF77,0x777F, 0xBBBB,0xFBFF,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBFBB,0xBBBB,0xBBBB,0xFBBB,0x7F77,0x7F77, 0xFFBF,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xFBBB,0xBBBB,0xFBBB,0xBBFF,0xFFBB,0x77F7,0x7FFF, 0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB,0xBBBB, 0xBBBB,0xBBBB,0xBBBF,0xBBBB,0xBBBB,0xBBBB,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xAAAA,0xAAAA, 0x7F77,0x777F,0xFF77,0x7777,0x7FF7,0x7777,0xF7FF,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xAAAA,0xAAAA, 0x7FF7,0x77FF,0xF7F7,0x777F,0xFFF7,0x7777,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xAAAA,0xAAAA, 0xF77F,0x7777,0xFF7F,0x7777,0xF7FF,0x7777,0x7777,0x7777, 0x7777,0x7777,0x7777,0x777F,0xF777,0x777F,0xAFAA,0xAAAF, 0x77F7,0x777F,0xF7FF,0x777F,0x7FF7,0x777F,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xFFAA,0xAAFF, 0x77F7,0xFFF7,0x77F7,0x77F7,0x77F7,0xFFF7,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xFFFA,0xAAAA, 0xF77F,0x7F77,0xFFF7,0x7FF7,0xF77F,0x7F7F,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x777F,0x7777,0xAAAA,0xFFAF, 0x7777,0x7777,0xF777,0x7F77,0xF777,0xFF7F,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xAAAF,0xAAAA, 0x7777,0x7777,0x77F7,0x7777,0x7FF7,0x7777,0x7777,0x7777, 0x7777,0x7777,0x7777,0x7777,0x7777,0x7777,0xAAAA,0xAAAA, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xFAAA,0xAAAA,0xFAAA, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAFAA,0xAAAF,0xFFFA,0xAAAF,0xAAAF,0xAAAF,0xAAAA,0xAAFF, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAAFA,0xAAFF,0xFFFA,0xAAAF,0xAFAA,0xAAAA,0xFAAA,0xAAFF, 0xAAAF,0xAAFF,0xFFFF,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAFAA,0xAAAF,0xFAFF,0xFAAF,0xFFAF,0xFAAA,0xFAFF,0xFAAF, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAAAF,0xFAFF,0xAAAA,0xFAAF,0xFAAA,0xFAAF,0xAAAA,0xAFAA, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAFAA,0xAAFA,0xFFAA,0xAFFA, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAF,0xAAAA,0xAAFF,0xAAAA, 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xDDDD,0xDDDD, 0xDDDD,0xDDDD,0xDDDD,0xDDDD,0xDDDD,0xDDDD,0xDDDD,0xDDDD, 0xDDDD,0xDDDD,0xDDDD,0xDDDD,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x99EE,0x999E,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2922,0x9999,0x9999,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x9922,0x9999,0x99E9,0x9EE9,0x9999, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x9222,0x22EE,0x2222,0x9999,0x9E99,0x9999,0x9999, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x9999,0x9999,0x2222,0x2222,0x2999,0x2222,0x9999,0x2229, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0xE999,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0xE992, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x9999,0x9999, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0xE999,0x222E, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x0222,0x0000, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222, 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2000,0x2020, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0xE999,0xE99E, 0xE9E9,0x999E,0xEE8E,0x9E99,0x9989,0x9889,0x9999,0x9999, 0x9999,0x9999,0x9999,0xE999,0x88E9,0x999E,0x9999,0x9999, 0x9999,0x9999,0x9999,0x999E,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x888E,0xE9E8,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0xEEEE,0xEE8E,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x8EEE,0x88E8,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x8E99,0x8EE8,0x9999,0x9999,0x9999, 0x99EE,0x9999,0x9999,0xE8EE,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0xEEE8,0xEE99,0x9999,0x99EE,0x9999,0x9999, 0x9999,0x9999,0x999E,0x9999,0x9999,0xEE99,0xEE99,0x88E8, 0x9999,0x9999,0x9E99,0x99E9,0x9999,0xE99E,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9989,0x9999,0x9998,0x9999, 0x9999,0x9899,0x9E99,0x999E,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9EE9,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x8999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x99EE,0x9999,0xEEE8,0xEEEE,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0xEEEE,0x8EEE,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0xEEEE,0x9999,0x999E,0x9999,0x9999,0x9999,0x9999,0x99E9, 0x9999,0xEE99,0x9EE9,0xEEEE,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9E99,0x9999, 0x9EEE,0x9999,0x9E8E,0xEE99,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0xEE99,0x9999,0x9999,0xEE99,0x9999,0x9999, 0x9999,0x9999,0xEEEE,0x88E8,0x9999,0x9999,0x9999,0x9999, 0x9999,0xEEE9,0x9999,0x9999,0x8898,0xEE8E,0x9999,0x9999, 0x9999,0x9999,0x9E8E,0x9999,0x9999,0x9999,0x9999,0x9999, 0x99E9,0x9999,0x9999,0xE999,0x8E99,0x8E88,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x8E8E,0x999E,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x9999,0x0099,0x9999,0x0009,0x9999,0x0909, 0x9099,0x0000,0x0999,0x0000,0x0099,0x0000,0x0099,0x0000, 0x0009,0x0000,0x0900,0x0090,0x0000,0x0000,0x0000,0x0000, 0x0900,0x0000,0x0000,0x0900,0x0000,0x0000,0x0090,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9999,0x9999,0x9999,0xE444,0x4499,0x88EE,0x9999,0xE999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9999,0x9999,0x9999,0x9999,0x49EE,0x9944,0x8E8E,0x888E, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9E99,0xEE99,0x9999,0x9999,0x9999,0xEE99,0x8888,0xEEEE, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9999,0x9999,0x4999,0x999E,0x9EEE,0x9999,0x9994,0x9999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9999,0xE99E,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9999,0xE899,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9998,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x0999,0x9999,0x0999,0x9999,0x9999,0x9999,0x9999,0x9999, 0x9999,0x9999,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x9999,0x9999,0x9909,0x0999,0x9909,0x9999,0x9909,0x9999, 0x9909,0x9999,0x4404,0x4444,0x4404,0x4444,0x4404,0x4444, 0x9999,0x0999,0x9999,0x0999,0x9999,0x0000,0x0999,0x0000, 0x0099,0x0000,0x4044,0x0000,0x0444,0x0004,0x4444,0x0004, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0x8EEE,0x8888, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xE88E,0xEEEE,0xEEE8,0x8888, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x8848,0x88EE,0xEEEE,0xE888,0xEEEE,0xEEEE,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEE88,0xEEEE,0x8EEE,0x8888,0xE88E,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0x8888,0x8888,0xEEEE,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEE1E, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0x1EEE,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0x88EE,0xEEEE,0xEEEE,0xE88E, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0x88EE,0x8888, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0x888E, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0x888E,0xEEE8,0x888E,0x888E, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0x8EEE,0xEEEE,0x8888,0xE888, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0x8888,0xE88E,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0x88EE,0x8EE8,0xEEEE,0xE88E, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEE8E,0xEEEE,0xEEEE,0xEEEE, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0xEEEE,0xEEEE,0xEEEE,0x00EE,0xEEEE,0x0000, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4044,0x4444,0x0000, 0x0044,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4404,0x0444,0x4404,0x0000,0x0404,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x4440,0x0000,0x4400,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4044,0x0000,0x0044,0x0000,0x0000,0x0400,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8088,0x8888,0x888E,0xEE88,0xEEEE,0xE00E, 0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x08EE,0xE888,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0xE8EE,0x8888,0xEEEE,0x0EEE, 0xEEEE,0x88EE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x88EE,0x8888,0xEEE0,0xEEEE, 0xE448,0xE8E8,0xEEEE,0x8888,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8EEE,0x88E8, 0xEEEE,0xEEEE,0x8EEE,0xE888,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x0008,0x088E,0x0000, 0xEEEE,0xEEEE,0xE88E,0x8888,0xEEE8,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8880,0x8888,0x8000,0x8888,0x0000,0x8800, 0xEEEE,0xE888,0x88E8,0xEE88,0xEEEE,0x8EEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x888E,0xEEE8,0xEEEE,0x8E8E,0x8888,0x8888,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x888E,0x8888,0xEEEE,0xEEEE,0x8888,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0xEEE8,0xEEEE,0xEEE1,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0xEEEE,0x1EEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0xEEEE,0x88EE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE, 0xEEEE,0xEEEE,0x8888,0x0888,0x8888,0x0008,0x8888,0x0000, 0xEEEE,0xEEEE,0xEEEE,0xEEEE,0xEEEE,0x00EE,0x0EEE,0x0000, 0x00EE,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x00EE,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xEEEE,0xEEEE,0x888E,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8888,0x0088,0x8888,0x0000, 0xEEEE,0xEEEE,0x8888,0x8E88,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x0088,0x8888,0x0000,0x0080,0x0000,0x0000, 0xEEEE,0x00EE,0x8888,0xE888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8000,0x8800,0x0000,0x8000, 0xEE00,0xEEEE,0xEEEE,0x8EEE,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x0888,0x8088,0x0888,0x8888,0x0888, 0xEEEE,0x00EE,0xE888,0xEEEE,0x8888,0x0888,0x8888,0x0088, 0x8088,0x0088,0x8888,0x0088,0x8000,0x0888,0x0000,0x0000, 0x0000,0x8000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x8888,0x8888,0x8880,0x8888,0x8880,0x8888,0x8000,0x8888, 0x0000,0x8800,0x0000,0x8000,0x0000,0x8880,0x0000,0x8880, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x3888, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x3888,0x8883,0x3833,0x3383,0x3333,0x3383,0x3333,0x3333, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x3383,0x8888,0x3383,0x8338,0x3383,0x3333,0x3383,0x3333, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8883,0x8888,0x3333,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8338,0x8888, 0x8338,0x8888,0x8338,0x8888,0x8338,0x8888,0x8333,0x8338, 0x8888,0x8888,0x3888,0x8888,0x3888,0x8883,0x8888,0x8888, 0x8888,0x8888,0x8888,0x8888,0x8833,0x8888,0x3833,0x8833, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0x3338,0x8888,0x3338,0x8888,0x3338, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8338,0x8888,0x8338,0x8833,0x8338,0x8833,0x8338,0x8333, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888,0x8888, 0x8888,0x8888,0x8888,0xCCC8,0xCC88,0xCCCC,0xCC83,0xCCCC, 0x8888,0x8888,0x8888,0x8888,0x8888,0x8CC8,0x8888,0xCCCC, 0xCCC8,0xCCCC,0xCCC8,0x00CC,0xCCCC,0x0000,0xCCCC,0x0000, 0x8888,0x0088,0x8888,0x0088,0x888C,0x0088,0x888C,0x0088, 0xCCCC,0x00CC,0xCC00,0x00CC,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0800,0x0088,0x0800,0x0088,0x0800,0x0088,0x0800, 0x0088,0x0800,0x00CC,0x0800,0x00CC,0x0800,0x00CC,0x0C00, 0x0888,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x8880,0x0888,0x8000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x8888,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x8888,0x8818,0x8888,0x3388,0x3000,0x3333,0x3000,0x3333, 0x0000,0x3333,0x0000,0x3333,0x0000,0x3330,0xC000,0x1C11, 0x8888,0x8888,0x3888,0x3333,0x3333,0x3333,0x3333,0x3333, 0x1333,0x3331,0x1333,0x3331,0x3333,0x3111,0x1311,0x1111, 0x8888,0x3888,0x3333,0x3333,0x3333,0x3333,0x3333,0x3333, 0x3333,0x3333,0x1133,0x1111,0x3333,0x1131,0x1111,0x1111, 0x3333,0x3333,0x3333,0x3333,0x3333,0x3333,0x3333,0x3333, 0x3333,0x3333,0x1111,0x3111,0x3313,0x3333,0x1111,0x1111, 0x3383,0x3333,0x3333,0x3333,0x3333,0x3333,0x3333,0x3333, 0x3333,0x3133,0x3333,0x1133,0x3333,0x3333,0x1111,0x3311, 0x3333,0x8888,0x3333,0x8888,0x3333,0x3338,0x3333,0x3333, 0x1313,0x3333,0x3311,0x3333,0x1111,0x3333,0x3331,0x3111, 0x8333,0x8338,0x3333,0x8338,0x3333,0x3333,0x3333,0x3333, 0x3333,0x3333,0x3333,0x1113,0x1111,0x3331,0x1111,0x1111, 0x3833,0x3833,0x3833,0x3833,0x3333,0x3333,0x3333,0x3333, 0x3333,0x3333,0x1111,0x3311,0x3333,0x3331,0x1111,0x1111, 0x3883,0x3333,0x3333,0x3338,0x3333,0x3333,0x3333,0x3333, 0x3333,0x3333,0x3333,0x3333,0x3333,0x1333,0x1111,0x1111, 0x3333,0x8333,0x3333,0x3333,0x3333,0x0333,0x3333,0x0033, 0x3333,0x0033,0x3333,0x0033,0x1111,0x0033,0x1111,0x0001, 0x0333,0x0000,0x0003,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0CCC,0x0000,0x00C0,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x00CC,0x0C00,0x00CC,0x0C00,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xCC00,0xCCCC,0xCC00,0xCCCC,0xCC00,0xCCCC,0xCCCC,0xCCCC, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x1111,0x1111,0x66CC,0x6666,0x6CCC,0x6666,0xCCCC,0x6666, 0xC000,0x6666,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x6111,0x6666,0x6666,0x6666,0x6666,0x6666,0x6666,0x6666, 0x6666,0x0006,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x1666,0x1111,0x6666,0x1116,0x6666,0x6666,0x6666,0x6666, 0x0000,0x0000,0x0000,0xCCCC,0x0000,0x0000,0x0000,0x0000, 0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1166,0x6116, 0xC000,0xCC00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1161,0x1116, 0x116C,0x1116,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111, 0x1111,0x1111,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x1111,0x1111,0x1111,0x1111,0x1111,0xC1C1,0xC111,0xCCCC, 0x1111,0x000C,0x0000,0xC000,0x0000,0x0000,0x0000,0x0000, 0xCCCC,0x0000,0xCCCC,0x0000,0x0CCC,0x0000,0xCCCC,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x000F,0x0000,0x00FF, 0x0000,0x0FFF,0xFFFF,0xFFFF,0x0000,0x0FFF,0x0000,0x00FF, 0x0000,0x0000,0x0000,0x0000,0xF000,0xFFF0,0xF000,0xF00F, 0xF000,0x0F00,0xF000,0xFFFF,0x0F00,0xFF00,0x0FF0,0x0F00, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF000,0x00FF,0x0000,0x0F0F,0xFF00,0x0FF0,0x0F00,0x00FF, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF000,0x00FF,0x0F00,0x00F0,0x0FF0,0xF000,0x0FF0,0xF0F0, 0x0000,0x0000,0x0000,0x0000,0x00F0,0x0000,0x00FF,0x0000, 0x000F,0x0000,0xFFFF,0x0000,0x0FFF,0x0000,0x0FF0,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0F00,0x0000,0xFFF0,0xFF00,0x00F0,0xFF00,0x00F0,0x0F00, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0FFF,0x0000,0x0F00,0x0000,0x0FF0,0x0000,0x00FF,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xFFF0,0xF000,0x00F0,0xFF00,0x0FF0,0x0F00,0xF000,0x0F00, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0FFF,0x000F,0xF0F0,0xF000,0xFF0F,0xF000,0x0FF0, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0F00,0x000F,0xFF00,0xF00F,0x0F00,0xF000,0x0FF0,0xF000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x000F,0x0000,0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x000F,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xFF00,0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xFF00,0x0FF0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xFF00,0xF00F,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0FF0,0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x000F,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0FFF,0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0xF000,0xFF0F,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0F00,0xF000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; const unsigned short LoseMap[1024] __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,0x0000,0x0000, 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, 0x0002,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008, 0x0009,0x000A,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0000,0x0000, 0x000B,0x000B,0x000B,0x000B,0x000B,0x000B,0x000B,0x000B, 0x000B,0x000B,0x000C,0x000D,0x000E,0x000F,0x0010,0x0011, 0x0012,0x0013,0x0014,0x000B,0x000B,0x000B,0x000B,0x000B, 0x000B,0x000B,0x000B,0x000B,0x000B,0x000B,0x0000,0x0000, 0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015, 0x0015,0x0015,0x0015,0x0015,0x0016,0x0017,0x0018,0x0019, 0x001A,0x001B,0x001C,0x001D,0x0015,0x0015,0x0015,0x0015, 0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0000,0x0000, 0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x001E, 0x001E,0x001E,0x001E,0x001E,0x001E,0x001F,0x0020,0x0021, 0x0022,0x0023,0x0024,0x0025,0x001E,0x001E,0x001E,0x001E, 0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x0000,0x0000, 0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0026, 0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0026, 0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0026, 0x0026,0x0026,0x0026,0x0026,0x0026,0x0026,0x0000,0x0000, 0x0027,0x0027,0x0027,0x0027,0x0027,0x0027,0x0028,0x0029, 0x002A,0x002B,0x002C,0x002D,0x0027,0x0027,0x0027,0x0027, 0x002E,0x002F,0x0030,0x0027,0x0027,0x0027,0x0027,0x0027, 0x0027,0x0027,0x0027,0x0027,0x0031,0x0032,0x0000,0x0000, 0x0033,0x0033,0x0033,0x0033,0x0033,0x0034,0x0035,0x0036, 0x0037,0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E, 0x003F,0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046, 0x0033,0x0033,0x0033,0x0047,0x0048,0x0049,0x0000,0x0000, 0x004A,0x004A,0x004A,0x004A,0x004A,0x004A,0x004A,0x004B, 0x004C,0x004D,0x004E,0x004A,0x004A,0x004F,0x0050,0x0051, 0x004A,0x004A,0x004A,0x004A,0x004A,0x004A,0x004A,0x004A, 0x0052,0x0053,0x004A,0x0054,0x0000,0x0000,0x0000,0x0000, 0x0055,0x0055,0x0055,0x0055,0x0056,0x0057,0x0058,0x0059, 0x005A,0x005B,0x005C,0x005D,0x005E,0x0055,0x005F,0x0060, 0x0061,0x0062,0x0063,0x0064,0x0055,0x0055,0x0065,0x0066, 0x0067,0x0068,0x0069,0x006A,0x0000,0x0000,0x0000,0x0000, 0x006B,0x006C,0x006D,0x006E,0x006F,0x0070,0x0071,0x0072, 0x0073,0x0074,0x0075,0x0076,0x0077,0x0077,0x0077,0x0078, 0x0079,0x0079,0x0079,0x0077,0x007A,0x007B,0x007C,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x007D,0x007E,0x007F,0x0080,0x0081,0x0000,0x0082,0x0083, 0x0084,0x0084,0x0085,0x0086,0x0087,0x0088,0x0089,0x008A, 0x008B,0x008C,0x008D,0x008E,0x008F,0x0090,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0091,0x0000,0x0000,0x0092,0x0000,0x0000,0x0000,0x0093, 0x0094,0x0095,0x0096,0x0097,0x0098,0x0099,0x009A,0x009B, 0x009C,0x009D,0x009E,0x009F,0x0000,0x00A0,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x00A1,0x00A2,0x00A3,0x00A4,0x00A5,0x00A6,0x00A7,0x00A7, 0x00A8,0x00A9,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x00AA,0x00AB,0x00AC,0x00AD,0x00AE,0x00AF,0x00B0, 0x00B1,0x00B2,0x00B3,0x00B4,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x00B5,0x00B6,0x00B7,0x00B8,0x00B9,0x00BA,0x00BB, 0x00BC,0x00BD,0x00BE,0x00BB,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; const unsigned short LosePal[256] __attribute__((aligned(4)))= { 0x14C6,0x3E10,0x5AD6,0x4E94,0x5F19,0x5A70,0x318C,0x5A93, 0x5F3B,0x5EF8,0x5AB4,0x5A92,0x2108,0x5AD5,0x5F3A,0x7FFF, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; //}}BLOCK(Lose)
[ "noreply@github.com" ]
eahn2016.noreply@github.com
6eeb241bcacaad231a9f817da29367f9a8926f7f
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/linux/sound/pci/nm256/extr_nm256.c_snd_nm256_writel.c
681b50c7f8ff86667793710309241206b7ce35a7
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
664
c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ /* Type definitions */ typedef int /*<<< orphan*/ u32 ; struct nm256 {scalar_t__ cport; } ; /* Variables and functions */ int /*<<< orphan*/ writel (int /*<<< orphan*/ ,scalar_t__) ; __attribute__((used)) static inline void snd_nm256_writel(struct nm256 *chip, int offset, u32 val) { writel(val, chip->cport + offset); }
[ "brenocfg@gmail.com" ]
brenocfg@gmail.com
24b33e4e36088205f376662fa776d27e04eb25f0
71b935c6363593cbca813ac3068b1f6591cf35b9
/Backup/usr/lib/arm-linux-gnueabihf/perl/5.20.2/CORE/patchlevel-debian.h
c1be1c688292d5aba78ddad0aae85fc7013c53db
[]
no_license
Kreedols/Koostetehnoloogiaprojekt
a2f41970732c0d0913a5aa1b0b21825b9d7d3adb
0b739c381efbf649470c314d39c60fd32ae1cbf9
refs/heads/master
2020-05-21T05:26:37.922579
2019-01-09T22:41:49
2019-01-09T22:41:49
84,576,993
3
0
null
null
null
null
UTF-8
C
false
false
11,420
h
,"DEBPKG:debian/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN." ,"DEBPKG:debian/db_file_ver - http://bugs.debian.org/340047 Remove overly restrictive DB_File version check." ,"DEBPKG:debian/doc_info - Replace generic man(1) instructions with Debian-specific information." ,"DEBPKG:debian/enc2xs_inc - http://bugs.debian.org/290336 Tweak enc2xs to follow symlinks and ignore missing @INC directories." ,"DEBPKG:debian/errno_ver - http://bugs.debian.org/343351 Remove Errno version check due to upgrade problems with long-running processes." ,"DEBPKG:debian/libperl_embed_doc - http://bugs.debian.org/186778 Note that libperl-dev package is required for embedded linking" ,"DEBPKG:fixes/respect_umask - Respect umask during installation" ,"DEBPKG:debian/writable_site_dirs - Set umask approproately for site install directories" ,"DEBPKG:debian/extutils_set_libperl_path - EU:MM: set location of libperl.a under /usr/lib" ,"DEBPKG:debian/no_packlist_perllocal - Don't install .packlist or perllocal.pod for perl or vendor" ,"DEBPKG:debian/prefix_changes - Fiddle with *PREFIX and variables written to the makefile" ,"DEBPKG:debian/fakeroot - Postpone LD_LIBRARY_PATH evaluation to the binary targets." ,"DEBPKG:debian/instmodsh_doc - Debian policy doesn't install .packlist files for core or vendor." ,"DEBPKG:debian/ld_run_path - Remove standard libs from LD_RUN_PATH as per Debian policy." ,"DEBPKG:debian/libnet_config_path - Set location of libnet.cfg to /etc/perl/Net as /usr may not be writable." ,"DEBPKG:debian/mod_paths - Tweak @INC ordering for Debian" ,"DEBPKG:debian/module_build_man_extensions - http://bugs.debian.org/479460 Adjust Module::Build manual page extensions for the Debian Perl policy" ,"DEBPKG:debian/prune_libs - http://bugs.debian.org/128355 Prune the list of libraries wanted to what we actually need." ,"DEBPKG:fixes/net_smtp_docs - [rt.cpan.org #36038] http://bugs.debian.org/100195 Document the Net::SMTP 'Port' option" ,"DEBPKG:debian/perlivp - http://bugs.debian.org/510895 Make perlivp skip include directories in /usr/local" ,"DEBPKG:debian/deprecate-with-apt - http://bugs.debian.org/747628 Point users to Debian packages of deprecated core modules" ,"DEBPKG:debian/squelch-locale-warnings - http://bugs.debian.org/508764 Squelch locale warnings in Debian package maintainer scripts" ,"DEBPKG:debian/skip-upstream-git-tests - Skip tests specific to the upstream Git repository" ,"DEBPKG:debian/patchlevel - http://bugs.debian.org/567489 List packaged patches for 5.20.2-3+deb8u6 in patchlevel.h" ,"DEBPKG:debian/skip-kfreebsd-crash - http://bugs.debian.org/628493 [perl #96272] Skip a crashing test case in t/op/threads.t on GNU/kFreeBSD" ,"DEBPKG:fixes/document_makemaker_ccflags - http://bugs.debian.org/628522 [rt.cpan.org #68613] Document that CCFLAGS should include $Config{ccflags}" ,"DEBPKG:debian/find_html2text - http://bugs.debian.org/640479 Configure CPAN::Distribution with correct name of html2text" ,"DEBPKG:debian/perl5db-x-terminal-emulator.patch - http://bugs.debian.org/668490 Invoke x-terminal-emulator rather than xterm in perl5db.pl" ,"DEBPKG:debian/cpan-missing-site-dirs - http://bugs.debian.org/688842 Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable" ,"DEBPKG:fixes/memoize_storable_nstore - [rt.cpan.org #77790] http://bugs.debian.org/587650 Memoize::Storable: respect 'nstore' option not respected" ,"DEBPKG:debian/regen-skip - Skip a regeneration check in unrelated git repositories" ,"DEBPKG:fixes/regcomp-mips-optim - [perl #122817] http://bugs.debian.org/754054 Downgrade the optimization of regcomp.c on mips and mipsel due to a gcc-4.9 bug" ,"DEBPKG:debian/makemaker-pasthru - http://bugs.debian.org/758471 Pass LD settings through to subdirectories" ,"DEBPKG:fixes/perldoc-less-R - [rt.cpan.org #98636] http://bugs.debian.org/758689 Tell the 'less' pager to allow terminal escape sequences" ,"DEBPKG:fixes/pod_man_reproducible_date - http://bugs.debian.org/759405 Support POD_MAN_DATE in Pod::Man for the left-hand footer" ,"DEBPKG:fixes/io_uncompress_gunzip_inmemory - http://bugs.debian.org/747363 [rt.cpan.org #95494] Fix gunzip to in-memory file handle" ,"DEBPKG:fixes/socket_test_recv_fix - http://bugs.debian.org/758718 [perl #122657] Compare recv return value to peername in socket test" ,"DEBPKG:fixes/hurd_socket_recv_todo - http://bugs.debian.org/758718 [perl #122657] TODO checking the result of recv() on hurd" ,"DEBPKG:fixes/regexp-performance - [0fa70a0] http://bugs.debian.org/777556 [perl #123743] simpify and speed up /.*.../ handling" ,"DEBPKG:fixes/failed_require_diagnostics - http://bugs.debian.org/781120 [perl #123270] Report inaccesible file on failed require" ,"DEBPKG:fixes/array-cloning - http://bugs.debian.org/779357 [perl #124127] [902d169] fix cloning arrays with unused elements" ,"DEBPKG:fixes/perldb-threads - http://bugs.debian.org/779357 [perl #124127] [41ef2c6] lib/perl5db.pl: Restore noop lock prototype" ,"DEBPKG:fixes/CVE-2015-8607_file_spec_taint_fix - ensure File::Spec::canonpath() preserves taint" ,"DEBPKG:fixes/encode-unicode-bom - http://bugs.debian.org/798727 [rt.cpan.org #107043] Address https://rt.cpan.org/Public/Bug/Display.html?id=107043" ,"DEBPKG:debian/encode-unicode-bom-doc - http://bugs.debian.org/798727 Document Debian backport of Encode::Unicode fix" ,"DEBPKG:debian/kfreebsd-softupdates - http://bugs.debian.org/796798 Work around Debian Bug#796798" ,"DEBPKG:fixes/CVE-2016-2381_duplicate_env - remove duplicate environment variables from environ" ,"DEBPKG:debian/debugperl-compat-fix - [perl #127212] http://bugs.debian.org/810326 Disable PERL_TRACK_MEMPOOL for debugging builds" ,"DEBPKG:fixes/CVE-2015-8853_regexp_hang - http://bugs.debian.org/821848 [perl #123562] PATCH [perl #123562] Regexp-matching \"hangs\"" ,"DEBPKG:fixes/utf8_regexp_crash - http://bugs.debian.org/820328 [perl #124109] save_re_context(): do \"local $n\" with no PL_curpm" ,"DEBPKG:fixes/regcomp_whitespace_fix - http://bugs.debian.org/820328 [perl #124109] Perl_save_re_context(): re-indent after last commit" ,"DEBPKG:fixes/5.20.3/eval_label_crash - http://bugs.debian.org/822336 [perl #123652] eval {label:} crash" ,"DEBPKG:fixes/5.20.3/preserve_record_separator - http://bugs.debian.org/822336 [perl #123218] \"preserve\" $/ if set to a bad value" ,"DEBPKG:fixes/5.20.3/test_count_base_rs - http://bugs.debian.org/822336 Fix test count in t/base/rs.t" ,"DEBPKG:fixes/5.20.3/remove_get_magic - http://bugs.debian.org/822336 [perl #123739] Remove get-magic from $/" ,"DEBPKG:fixes/5.20.3/speed_up_scalar_g - http://bugs.debian.org/822336 [perl #123202] speed up scalar //g against tainted strings" ,"DEBPKG:fixes/5.20.3/accidental_all_features - http://bugs.debian.org/822336 Stop $^H |= 0x1c020000 from enabling all features" ,"DEBPKG:fixes/5.20.3/multidimensional_arrays_utf8 - http://bugs.debian.org/822336 [perl #124113] Make check for multi-dimensional arrays be UTF8-aware" ,"DEBPKG:fixes/5.20.3/unquoted_utf8_heredoc_terminators - http://bugs.debian.org/822336 Allow unquoted UTF-8 HERE-document terminators" ,"DEBPKG:fixes/5.20.3/parentheses_ambiguous_warning_utf8_functions - http://bugs.debian.org/822336 Fix \"...without parentheses is ambuguous\" warning for UTF-8 function names" ,"DEBPKG:fixes/5.20.3/leak_namepv_copy - http://bugs.debian.org/822336 [perl #123786] don't leak the temp utf8 copy of namepv" ,"DEBPKG:fixes/5.20.3/h2ph_hex_constants - http://bugs.debian.org/822336 h2ph: correct handling of hex constants for the preamble" ,"DEBPKG:fixes/5.20.3/leftbracket_XTERMORDORDOR - http://bugs.debian.org/822336 [perl #123711] Fix crash with 0-5x-l{0}" ,"DEBPKG:fixes/5.20.3/fatalize_warnings_unwinding - http://bugs.debian.org/822336 [perl #123398] don't fatalize warnings during unwinding (#123398)" ,"DEBPKG:fixes/5.20.3/setpgrp - http://bugs.debian.org/822336 =?UTF-8?q?Don=E2=80=99t=20treat=20setpgrp($nonzero)=20as=20setpgr?= =?UTF-8?q?p(1)?=" ,"DEBPKG:fixes/5.20.3/death_unwinding_crash - http://bugs.debian.org/822336 [perl #124156] RT #124156: death during unwinding causes crash" ,"DEBPKG:fixes/5.20.3/stashpvn_crash - http://bugs.debian.org/822336 [perl #125541] Fix crash with %::=(); J->${\\\"::\"}" ,"DEBPKG:fixes/5.20.3/possessive_quantifier - http://bugs.debian.org/822336 [perl #125825] PATCH: [perl 125825] {n}+ possessive quantifier broken" ,"DEBPKG:fixes/5.20.3/quoted_code_crash - http://bugs.debian.org/822336 [perl #123712] Fix /$a[/ parsing" ,"DEBPKG:fixes/5.20.3/checking_sub_inwhat - http://bugs.debian.org/822336 [perl #123712] Don't check sub_inwhat" ,"DEBPKG:fixes/5.20.3/yylex_loop - http://bugs.debian.org/822336 Fix hang with \"@{\"" ,"DEBPKG:fixes/5.20.3/docs/op - http://bugs.debian.org/822336 Fix apidocs for OP_TYPE_IS(_OR_WAS) - arguments separated by |, not ,." ,"DEBPKG:fixes/5.20.3/docs/encoding - http://bugs.debian.org/822336 perlpodspec: Corrections/adds to detecting =encoding" ,"DEBPKG:fixes/5.20.3/docs/SvPV_set - http://bugs.debian.org/822336 improve SvPV_set's docs, it really shouldn't be public API" ,"DEBPKG:fixes/5.20.3/docs/autodie - http://bugs.debian.org/822336 Fix warning message regarding \"use autodie\" and \"use open\"." ,"DEBPKG:fixes/5.20.3/docs/autodie_2_26 - http://bugs.debian.org/822336 perlunicook: Note that autodie >= 2.26 should be okay with \"use open\"." ,"DEBPKG:fixes/5.20.3/docs/setenv - http://bugs.debian.org/822336 Fix setenv() replacement documentation in perlclib" ,"DEBPKG:fixes/5.20.3/docs/clib_caution - http://bugs.debian.org/822336 perlhacktips: Add caution about clib ptr returns to static memory" ,"DEBPKG:fixes/5.20.3/docs/perlunicook_typos - http://bugs.debian.org/822336 Fix minor code typos in perlunicook" ,"DEBPKG:fixes/5.20.3/docs/ook_example - http://bugs.debian.org/822336 [perl #122322] Update OOK example in perlguts" ,"DEBPKG:fixes/5.20.3/docs/study_noop - http://bugs.debian.org/822336 perlfunc: mention that study() is currently a noop" ,"DEBPKG:fixes/CVE-2016-1238/remove-dot-when-loading - [perl #127834] (perl #127834) remove . from the end of @INC if complex modules are loaded" ,"DEBPKG:fixes/CVE-2016-1238/remove-dot-in-padwalker - [perl #127834] perl5db.pl: ensure PadWalker is loaded from standard paths" ,"DEBPKG:fixes/CVE-2016-1238/remove-dot-in-dist - [perl #127834] dist/: remove . from @INC when loading optional modules" ,"DEBPKG:fixes/CVE-2016-1238/remove-dot-in-cpan - [perl #127834] cpan/: remove . from @INC when loading optional modules" ,"DEBPKG:fixes/CVE-2016-1238/customized-encode - Update customized.dat for cpan/Encode/Encode.pm" ,"DEBPKG:debian/CVE-2016-1238/test-suite-without-dot - [perl #127810] Patch unit tests to explicitly insert \".\" into @INC when needed." ,"DEBPKG:debian/CVE-2016-1238/eumm-without-dot - [perl #127810] Add PERL_USE_UNSAFE_INC support to EU::MM for fortify_inc support." ,"DEBPKG:debian/CVE-2016-1238/cpan-without-dot - [perl #127810] Set PERL_USE_UNSAFE_INC for cpan usage" ,"DEBPKG:debian/CVE-2016-1238/mb-without-dot - Make Module::Build set PERL_USE_UNSAFE_INC" ,"DEBPKG:debian/CVE-2016-1238/sitecustomize-in-etc - Look for sitecustomize.pl in /etc/perl rather than sitelib on Debian systems" ,"DEBPKG:fixes/xsloader-eval - [rt.cpan.org #115808] http://bugs.debian.org/829578 =?UTF-8?q?Don=E2=80=99t=20let=20XSLoader=20load=20relative=20path?= =?UTF-8?q?s?="
[ "kermo.lukas@khk.ee" ]
kermo.lukas@khk.ee
2b0e3c1c22a932aa3eebb4554898a995572ed12d
6fe1d7b5fedd758032da59557ac63bcc8ece5573
/Info-001/wolf3d/libft/srcs/ft_strdup.c
929ae117e1f0b7375fb6be35ad6c6524ea455d9a
[]
no_license
atipex/Projets
21d1759ff7877fd91cdd3247ba782dd4c19d7d68
fa105ff869f273799ea7554951a9951e79b1b547
refs/heads/master
2021-01-02T09:02:29.606143
2014-07-07T16:09:42
2014-07-07T16:09:42
null
0
0
null
null
null
null
UTF-8
C
false
false
1,186
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mrebours <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2014/04/27 03:49:35 by mrebours #+# #+# */ /* Updated: 2014/04/27 03:49:36 by mrebours ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdlib.h> #include "libft.h" char *ft_strdup(const char *s) { int i; char *dest; i = 0; dest = (char*)malloc(sizeof(*dest) * ft_strlen(s) + 1); if (dest) { while (s[i]) { dest[i] = s[i]; i++; } dest[i] = '\0'; } else return (NULL); return (dest); }
[ "wandre@student.42.fr" ]
wandre@student.42.fr
55e9cb863c5c92fc09788b4a54a3faa5746a8837
7b547837a47490684bf6d998662dc5f91b5f169f
/sdr_utils.h
49dd773ee66564ffec4738f4614ac3f4b90222f3
[]
no_license
Sawndip/Multilayer_HTM
10e048ea9f55811b01b7016ab1503d89a499a095
94978066bff814357e2e7f1972401229cf794e64
refs/heads/master
2021-09-18T14:25:56.264106
2018-07-15T18:53:16
2018-07-15T18:53:16
null
0
0
null
null
null
null
UTF-8
C
false
false
2,263
h
#ifndef SDR_UTILS_H #define SDR_UTILS_H #include <stdlib.h> #include <stdio.h> #include "struct_utils.h" //based on the following sources: //http://numenta.com/biological-and-machine-intelligence/ //http://numenta.com/assets/pdf/biological-and-machine-intelligence/0.4/BaMI-SDR.pdf //http://numenta.com/assets/pdf/biological-and-machine-intelligence/0.4/BaMI-Encoders.pdf int SDR_BASE; //amount of different values that can be represented int SDR_SET; //amount of set bits typedef struct SDR { int len; char* bits; } SDR; //deallocates the input SDR void free_sdr(SDR* sdr) { free(sdr->bits); free(sdr); } //returns a new SDR representing the input integer, integer must be >= 0 and < SDR_BASE SDR* int_to_sdr(int i) { if (i < 0 || i >= SDR_BASE) { printf("INVALID INTEGER: %d\n", i); return NULL; } SDR* sdr = malloc(sizeof(SDR)); sdr->len = SDR_BASE + SDR_SET; sdr->bits = malloc(sdr->len * sizeof(char)); int a; for (a = 0; a < sdr->len; a++) { sdr->bits[a] = a < i || a >= i + SDR_SET ? 0 : 1; //sets bits at indices between i and i + SDR_SET to 1, rest to 0 } return sdr; } SDR* bits_to_sdr(char* bits, int len) { SDR* sdr = malloc(sizeof(SDR)); sdr->len = len; sdr->bits = bits; return sdr; } void print_sdr(SDR* sdr) { int a; for (a = 0; a < sdr->len; a++) { printf("%d", sdr->bits[a]); } printf("\n"); } //returns 1 if bit at index is set, otherwise 0, index must be >= 0 and < SDR_BASE + SDR_SET char is_set(SDR* sdr, int index) { if (index < 0 || index >= SDR_BASE + SDR_SET) { printf("INVALID INDEX: %d\n", index); fflush(stdout); return 0; } return sdr->bits[index]; } //returns the overlap of both input SDRs int sdr_overlap(SDR* sdr1, SDR* sdr2) { int overlap = 0; int a; for (a = 0; a < sdr1->len && a < sdr2->len; a++) { if (sdr1->bits[a] == 1 && sdr2->bits[a] == 1) { overlap++; } } return overlap; } //returns a new SDR that is the union of input SDRs SDR* sdr_union(SDR* sdr1, SDR* sdr2) { SDR* sdr = malloc(sizeof(SDR)); sdr->len = sdr1->len >= sdr2->len ? sdr1->len : sdr2->len; sdr->bits = malloc(sdr->len * sizeof(char)); int a; for (a = 0; a < sdr->len; a++) { sdr->bits[a] = sdr1->bits[a] == 1 || sdr2->bits[a] == 1 ? 1 : 0; } return sdr; } #endif // SDR_UTILS_H
[ "sharru.moeller@gmail.com" ]
sharru.moeller@gmail.com
b58376cc411abaef6ce5318e942f32bb030413d5
da1bb34fdb8d93e8e909010d50b701e023a983f2
/petsc/convect/convect.c
f230952989eab9ad3a6161a6436b278272b18f35
[]
no_license
zzyatlantise/cfdlab
cbb795c48ac3a0751179d561c3e7f2e44dd810d6
db2cffd3d3ac4b447e1f83ca15399f8ce9fac768
refs/heads/master
2021-01-23T02:16:32.599910
2016-12-28T06:21:22
2016-12-28T06:21:22
null
0
0
null
null
null
null
UTF-8
C
false
false
6,446
c
static char help[] = "Solves u_t + u_x = 0.\n\n"; #include <petscsys.h> #include <petscdm.h> #include <petscdmda.h> #include <petscvec.h> const double ark[] = {0.0, 3.0/4.0, 1.0/3.0}; const double xmin = -1.0; const double xmax = +1.0; double initcond(double x) { if(x >= -0.8 && x <= -0.6) return exp(-log(2)*pow(x+0.7,2)/0.0009); else if(x >= -0.4 && x <= -0.2) return 1.0; else if(x >= 0.0 && x <= 0.2) return 1.0 - fabs(10*(x-0.1)); else if(x>= 0.4 && x <= 0.6) return sqrt(1 - 100*pow(x-0.5,2)); else return 0.0; } //------------------------------------------------------------------------------ // Weno reconstruction // Return left value for face between u0, up1 //------------------------------------------------------------------------------ double weno5(double um2, double um1, double u0, double up1, double up2) { double eps = 1.0e-6; double gamma1=1.0/10.0, gamma2=3.0/5.0, gamma3=3.0/10.0; double beta1, beta2, beta3; double u1, u2, u3; double w1, w2, w3; beta1 = (13.0/12.0)*pow((um2 - 2.0*um1 + u0),2) + (1.0/4.0)*pow((um2 - 4.0*um1 + 3.0*u0),2); beta2 = (13.0/12.0)*pow((um1 - 2.0*u0 + up1),2) + (1.0/4.0)*pow((um1 - up1),2); beta3 = (13.0/12.0)*pow((u0 - 2.0*up1 + up2),2) + (1.0/4.0)*pow((3.0*u0 - 4.0*up1 + up2),2); w1 = gamma1 / pow(eps+beta1, 2); w2 = gamma2 / pow(eps+beta2, 2); w3 = gamma3 / pow(eps+beta3, 2); u1 = (1.0/3.0)*um2 - (7.0/6.0)*um1 + (11.0/6.0)*u0; u2 = -(1.0/6.0)*um1 + (5.0/6.0)*u0 + (1.0/3.0)*up1; u3 = (1.0/3.0)*u0 + (5.0/6.0)*up1 - (1.0/6.0)*up2; return (w1 * u1 + w2 * u2 + w3 * u3)/(w1 + w2 + w3); } //------------------------------------------------------------------------------ // Save solution to file //------------------------------------------------------------------------------ PetscErrorCode savesol(int nx, double dx, Vec ug) { int i, rank; static int count = 0; PetscErrorCode ierr; MPI_Comm_rank(PETSC_COMM_WORLD, &rank); // Gather entire solution on rank=0 process. This is bad thing to do // in a real application. VecScatter ctx; Vec uall; ierr = VecScatterCreateToZero(ug,&ctx,&uall); CHKERRQ(ierr); // scatter as many times as you need ierr = VecScatterBegin(ctx,ug,uall,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr); ierr = VecScatterEnd(ctx,ug,uall,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr); // destroy scatter context and local vector when no longer needed ierr = VecScatterDestroy(&ctx); CHKERRQ(ierr); if(rank==0) { PetscScalar *uarray; ierr = VecGetArray(uall, &uarray); CHKERRQ(ierr); FILE *f; f = fopen("sol.dat","w"); for(i=0; i<nx; ++i) fprintf(f, "%e %e\n", xmin+i*dx, uarray[i]); fclose(f); printf("Wrote solution into sol.dat\n"); ierr = VecRestoreArray(uall, &uarray); CHKERRQ(ierr); if(count==0) { // Initial solution is copied to sol0.dat system("cp sol.dat sol0.dat"); count = 1; } } ierr = VecDestroy(&uall); CHKERRQ(ierr); return(0); } //------------------------------------------------------------------------------ int main(int argc, char *argv[]) { PetscErrorCode ierr; DM da; Vec ug, ul; PetscInt i, ibeg, nloc, nx=200; const PetscInt sw = 3, ndof = 1; // stencil width PetscMPIInt rank, size; double cfl = 0.4; ierr = PetscInitialize(&argc, &argv, (char*)0, help); CHKERRQ(ierr); MPI_Comm_rank(PETSC_COMM_WORLD, &rank); MPI_Comm_size(PETSC_COMM_WORLD, &size); ierr = DMDACreate1d(PETSC_COMM_WORLD, DM_BOUNDARY_PERIODIC, -nx, ndof, sw, NULL, &da); CHKERRQ(ierr); ierr = DMCreateGlobalVector(da, &ug); CHKERRQ(ierr); ierr = DMDAGetCorners(da, &ibeg, 0, 0, &nloc, 0, 0); CHKERRQ(ierr); ierr = DMDAGetInfo(da,0,&nx,0,0,0,0,0,0,0,0,0,0,0); CHKERRQ(ierr); PetscReal dx = (xmax - xmin) / (PetscReal)(nx); PetscPrintf(PETSC_COMM_WORLD,"nx = %d, dx = %e\n", nx, dx); for(i=ibeg; i<ibeg+nloc; ++i) { PetscReal x = xmin + i*dx; PetscReal v = initcond(x); ierr = VecSetValues(ug,1,&i,&v,INSERT_VALUES); CHKERRQ(ierr); } ierr = VecAssemblyBegin(ug); CHKERRQ(ierr); ierr = VecAssemblyEnd(ug); CHKERRQ(ierr); savesol(nx, dx, ug); // Get local view ierr = DMGetLocalVector(da, &ul); CHKERRQ(ierr); PetscInt il, nl; ierr = DMDAGetGhostCorners(da,&il,0,0,&nl,0,0); CHKERRQ(ierr); double res[nloc], uold[nloc]; double dt = cfl * dx; double lam= dt/dx; double tfinal = 2.0, t = 0.0; while(t < tfinal) { if(t+dt > tfinal) { dt = tfinal - t; lam = dt/dx; } for(int rk=0; rk<3; ++rk) { ierr = DMGlobalToLocalBegin(da, ug, INSERT_VALUES, ul); CHKERRQ(ierr); ierr = DMGlobalToLocalEnd(da, ug, INSERT_VALUES, ul); CHKERRQ(ierr); PetscScalar *u; ierr = DMDAVecGetArrayRead(da, ul, &u); CHKERRQ(ierr); PetscScalar *unew; ierr = DMDAVecGetArray(da, ug, &unew); CHKERRQ(ierr); if(rk==0) for(i=ibeg; i<ibeg+nloc; ++i) uold[i-ibeg] = u[i]; for(i=0; i<nloc; ++i) res[i] = 0.0; // Loop over faces and compute flux for(i=0; i<nloc+1; ++i) { // face between j-1, j int j = il+sw+i; int jm1 = j-1; int jm2 = j-2; int jm3 = j-3; int jp1 = j+1; double uleft = weno5(u[jm3],u[jm2],u[jm1],u[j],u[jp1]); double flux = uleft; if(i==0) { res[i] -= flux; } else if(i==nloc) { res[i-1] += flux; } else { res[i] -= flux; res[i-1] += flux; } } // Update solution for(i=ibeg; i<ibeg+nloc; ++i) unew[i] = ark[rk]*uold[i-ibeg] + (1-ark[rk])*(u[i] - lam * res[i-ibeg]); ierr = DMDAVecRestoreArrayRead(da, ul, &u); CHKERRQ(ierr); ierr = DMDAVecRestoreArray(da, ug, &unew); CHKERRQ(ierr); } t += dt; PetscPrintf(PETSC_COMM_WORLD,"t = %f\n", t); } savesol(nx, dx, ug); // Destroy everything before finishing ierr = DMDestroy(&da); CHKERRQ(ierr); ierr = VecDestroy(&ug); CHKERRQ(ierr); ierr = PetscFinalize(); CHKERRQ(ierr); }
[ "cpraveen@gmail.com" ]
cpraveen@gmail.com
315ab20000a823c4fecf1eb5b6f9c7d97696e907
b862223de5129e5ae57cd7b18a87ee082551afda
/test/manual/Test_Aper.c
6c3dd6d27f843253d8f6a3c535b4e5d17d1f6444
[ "MIT" ]
permissive
asnautogen/easyasn_ngap
897f5052b8740bc2dc4ffb4a06bbe63d0f826e8f
e0f772b794a3ee7c54c838950e3879c788a42e3a
refs/heads/master
2020-07-21T08:25:28.988745
2020-02-25T14:22:49
2020-02-25T14:22:49
206,796,546
1
1
null
2020-02-25T14:22:50
2019-09-06T13:10:29
C
UTF-8
C
false
false
19,453
c
#include <memory.h> #include "Test_Aper.h" #include <sys/time.h> #include "../ngap_codes/LTE_NGAP_TST.h" int TestAll(FILE *fp, int run_times) { /* TEST HandoverRequest */ //LTE_APER_TST_HandoverRequest(fp, run_times); /* TEST HandoverRequestAcknowledge */ LTE_APER_TST_HandoverRequestAcknowledge(fp, run_times); #if 0 LTE_APER_TST_PDUSessionResourceSetupRequest(fp, run_times); LTE_APER_TST_PDUSessionResourceSetupResponse(fp, run_times); LTE_APER_TST_PDUSessionResourceReleaseCommand(fp, run_times); LTE_APER_TST_PDUSessionResourceReleaseResponse(fp, run_times); LTE_APER_TST_PDUSessionResourceModifyRequest(fp, run_times); LTE_APER_TST_PDUSessionResourceModifyResponse(fp, run_times); LTE_APER_TST_PDUSessionResourceNotify(fp, run_times); LTE_APER_TST_PDUSessionResourceModifyIndication(fp, run_times); LTE_APER_TST_PDUSessionResourceModifyConfirm(fp, run_times); LTE_APER_TST_InitialContextSetupRequest(fp, run_times); LTE_APER_TST_InitialContextSetupResponse(fp, run_times); LTE_APER_TST_InitialContextSetupFailure(fp, run_times); LTE_APER_TST_UEContextReleaseRequest(fp, run_times); LTE_APER_TST_UEContextReleaseCommand(fp, run_times); LTE_APER_TST_UEContextReleaseComplete(fp, run_times); LTE_APER_TST_UEContextModificationRequest(fp, run_times); LTE_APER_TST_UEContextModificationResponse(fp, run_times); LTE_APER_TST_UEContextModificationFailure(fp, run_times); LTE_APER_TST_HandoverRequired(fp, run_times); LTE_APER_TST_HandoverCommand(fp, run_times); LTE_APER_TST_HandoverPreparationFailure(fp, run_times); LTE_APER_TST_HandoverRequest(fp, run_times); LTE_APER_TST_HandoverRequestAcknowledge(fp, run_times); LTE_APER_TST_HandoverFailure(fp, run_times); LTE_APER_TST_HandoverNotify(fp, run_times); LTE_APER_TST_PathSwitchRequest(fp, run_times); LTE_APER_TST_PathSwitchRequestAcknowledge(fp, run_times); LTE_APER_TST_PathSwitchRequestFailure(fp, run_times); LTE_APER_TST_HandoverCancel(fp, run_times); LTE_APER_TST_HandoverCancelAcknowledge(fp, run_times); LTE_APER_TST_UplinkRANStatusTransfer(fp, run_times); LTE_APER_TST_DownlinkRANStatusTransfer(fp, run_times); LTE_APER_TST_Paging(fp, run_times); LTE_APER_TST_InitialUEMessage(fp, run_times); LTE_APER_TST_DownlinkNASTransport(fp, run_times); LTE_APER_TST_UplinkNASTransport(fp, run_times); LTE_APER_TST_NASNonDeliveryIndication(fp, run_times); LTE_APER_TST_RerouteNASRequest(fp, run_times); LTE_APER_TST_NGSetupRequest(fp, run_times); LTE_APER_TST_NGSetupResponse(fp, run_times); LTE_APER_TST_NGSetupFailure(fp, run_times); LTE_APER_TST_RANConfigurationUpdate(fp, run_times); LTE_APER_TST_RANConfigurationUpdateAcknowledge(fp, run_times); LTE_APER_TST_RANConfigurationUpdateFailure(fp, run_times); LTE_APER_TST_AMFConfigurationUpdate(fp, run_times); LTE_APER_TST_AMFConfigurationUpdateAcknowledge(fp, run_times); LTE_APER_TST_AMFConfigurationUpdateFailure(fp, run_times); LTE_APER_TST_AMFStatusIndication(fp, run_times); LTE_APER_TST_NGReset(fp, run_times); LTE_APER_TST_NGResetAcknowledge(fp, run_times); LTE_APER_TST_ErrorIndication(fp, run_times); LTE_APER_TST_UplinkRANConfigurationTransfer(fp, run_times); LTE_APER_TST_DownlinkRANConfigurationTransfer(fp, run_times); LTE_APER_TST_WriteReplaceWarningRequest(fp, run_times); LTE_APER_TST_WriteReplaceWarningResponse(fp, run_times); LTE_APER_TST_PWSCancelRequest(fp, run_times); LTE_APER_TST_PWSCancelResponse(fp, run_times); LTE_APER_TST_PWSRestartIndication(fp, run_times); LTE_APER_TST_PWSFailureIndication(fp, run_times); LTE_APER_TST_DownlinkUEAssociatedNRPPaTransport(fp, run_times); LTE_APER_TST_UplinkUEAssociatedNRPPaTransport(fp, run_times); LTE_APER_TST_DownlinkNonUEAssociatedNRPPaTransport(fp, run_times); LTE_APER_TST_UplinkNonUEAssociatedNRPPaTransport(fp, run_times); LTE_APER_TST_TraceStart(fp, run_times); LTE_APER_TST_TraceFailureIndication(fp, run_times); LTE_APER_TST_DeactivateTrace(fp, run_times); LTE_APER_TST_CellTrafficTrace(fp, run_times); LTE_APER_TST_LocationReportingControl(fp, run_times); LTE_APER_TST_LocationReportingFailureIndication(fp, run_times); LTE_APER_TST_LocationReport(fp, run_times); LTE_APER_TST_UETNLABindingReleaseRequest(fp, run_times); LTE_APER_TST_UECapabilityInfoIndication(fp, run_times); LTE_APER_TST_UERadioCapabilityCheckRequest(fp, run_times); LTE_APER_TST_UERadioCapabilityCheckResponse(fp, run_times); #endif #if 0 LTE_APER_TST_HandoverRequired(fp, run_times); /* TEST HandoverCommand */ LTE_APER_TST_HandoverCommand(fp, run_times); /* TEST HandoverPreparationFailure */ LTE_APER_TST_HandoverPreparationFailure(fp, run_times); /* TEST HandoverRequest */ LTE_APER_TST_HandoverRequest(fp, run_times); /* TEST HandoverRequestAcknowledge */ LTE_APER_TST_HandoverRequestAcknowledge(fp, run_times); /* TEST HandoverFailure */ LTE_APER_TST_HandoverFailure(fp, run_times); /* TEST HandoverNotify */ LTE_APER_TST_HandoverNotify(fp, run_times); /* TEST PathSwitchRequest */ LTE_APER_TST_PathSwitchRequest(fp, run_times); /* TEST PathSwitchRequestAcknowledge */ LTE_APER_TST_PathSwitchRequestAcknowledge(fp, run_times); /* TEST PathSwitchRequestFailure */ LTE_APER_TST_PathSwitchRequestFailure(fp, run_times); /* TEST HandoverCancel */ LTE_APER_TST_HandoverCancel(fp, run_times); /* TEST HandoverCancelAcknowledge */ LTE_APER_TST_HandoverCancelAcknowledge(fp, run_times); /* TEST E-RABSetupRequest */ LTE_APER_TST_E_RABSetupRequest(fp, run_times); /* TEST E-RABSetupResponse */ LTE_APER_TST_E_RABSetupResponse(fp, run_times); /* TEST E-RABModifyRequest */ LTE_APER_TST_E_RABModifyRequest(fp, run_times); /* TEST E-RABModifyResponse */ LTE_APER_TST_E_RABModifyResponse(fp, run_times); /* TEST E-RABReleaseCommand */ LTE_APER_TST_E_RABReleaseCommand(fp, run_times); /* TEST E-RABReleaseResponse */ LTE_APER_TST_E_RABReleaseResponse(fp, run_times); /* TEST E-RABReleaseIndication */ LTE_APER_TST_E_RABReleaseIndication(fp, run_times); /* TEST InitialContextSetupRequest */ LTE_APER_TST_InitialContextSetupRequest(fp, run_times); /* TEST InitialContextSetupResponse */ LTE_APER_TST_InitialContextSetupResponse(fp, run_times); /* TEST InitialContextSetupFailure */ LTE_APER_TST_InitialContextSetupFailure(fp, run_times); /* TEST Paging */ LTE_APER_TST_Paging(fp, run_times); /* TEST UEContextReleaseRequest */ LTE_APER_TST_UEContextReleaseRequest(fp, run_times); /* TEST UEContextReleaseCommand */ LTE_APER_TST_UEContextReleaseCommand(fp, run_times); /* TEST UEContextReleaseComplete */ LTE_APER_TST_UEContextReleaseComplete(fp, run_times); /* TEST UEContextModificationRequest */ LTE_APER_TST_UEContextModificationRequest(fp, run_times); /* TEST UEContextModificationResponse */ LTE_APER_TST_UEContextModificationResponse(fp, run_times); /* TEST UEContextModificationFailure */ LTE_APER_TST_UEContextModificationFailure(fp, run_times); /* TEST UERadioCapabilityMatchRequest */ LTE_APER_TST_UERadioCapabilityMatchRequest(fp, run_times); /* TEST UERadioCapabilityMatchResponse */ LTE_APER_TST_UERadioCapabilityMatchResponse(fp, run_times); /* TEST DownlinkNASTransport */ LTE_APER_TST_DownlinkNASTransport(fp, run_times); /* TEST InitialUEMessage */ LTE_APER_TST_InitialUEMessage(fp, run_times); /* TEST UplinkNASTransport */ LTE_APER_TST_UplinkNASTransport(fp, run_times); /* TEST NASNonDeliveryIndication */ LTE_APER_TST_NASNonDeliveryIndication(fp, run_times); LTE_APER_TST_RerouteNASRequest(fp, run_times); /* TEST Reset */ LTE_APER_TST_Reset(fp, run_times); /* TEST ResetAcknowledge */ LTE_APER_TST_ResetAcknowledge(fp, run_times); /* TEST ErrorIndication */ LTE_APER_TST_ErrorIndication(fp, run_times); /* TEST S1SetupRequest */ LTE_APER_TST_S1SetupRequest(fp, run_times); /* TEST S1SetupResponse */ LTE_APER_TST_S1SetupResponse(fp, run_times); /* TEST S1SetupFailure */ LTE_APER_TST_S1SetupFailure(fp, run_times); /* TEST ENBConfigurationUpdate */ LTE_APER_TST_ENBConfigurationUpdate(fp, run_times); /* TEST ENBConfigurationUpdateAcknowledge */ LTE_APER_TST_ENBConfigurationUpdateAcknowledge(fp, run_times); /* TEST ENBConfigurationUpdateFailure */ LTE_APER_TST_ENBConfigurationUpdateFailure(fp, run_times); /* TEST MMEConfigurationUpdate */ LTE_APER_TST_MMEConfigurationUpdate(fp, run_times); /* TEST MMEConfigurationUpdateAcknowledge */ LTE_APER_TST_MMEConfigurationUpdateAcknowledge(fp, run_times); /* TEST MMEConfigurationUpdateFailure */ LTE_APER_TST_MMEConfigurationUpdateFailure(fp, run_times); /* TEST DownlinkS1cdma2000tunneling */ LTE_APER_TST_DownlinkS1cdma2000tunnelling(fp, run_times); /* TEST UplinkS1cdma2000tunneling */ LTE_APER_TST_UplinkS1cdma2000tunnelling(fp, run_times); /* TEST UECapabilityInfoIndication */ LTE_APER_TST_UECapabilityInfoIndication(fp, run_times); /* TEST ENBStatusTransfer */ LTE_APER_TST_ENBStatusTransfer(fp, run_times); /* TEST MMEStatusTransfer */ LTE_APER_TST_MMEStatusTransfer(fp, run_times); /* TEST TraceStart */ LTE_APER_TST_TraceStart(fp, run_times); /* TEST TraceFailureIndication */ LTE_APER_TST_TraceFailureIndication(fp, run_times); /* TEST DeactivateTrace */ LTE_APER_TST_DeactivateTrace(fp, run_times); /* TEST CellTrafficTrace */ LTE_APER_TST_CellTrafficTrace(fp, run_times); /* TEST LocationReportingControl */ LTE_APER_TST_LocationReportingControl(fp, run_times); /* TEST LocationReportingFailureIndication */ LTE_APER_TST_LocationReportingFailureIndication(fp, run_times); /* TEST LocationReport */ LTE_APER_TST_LocationReport(fp, run_times); /* TEST OverloadStart */ LTE_APER_TST_OverloadStart(fp, run_times); /* TEST OverloadStop */ LTE_APER_TST_OverloadStop(fp, run_times); /* TEST WriteReplaceWarningRequest */ LTE_APER_TST_WriteReplaceWarningRequest(fp, run_times); /* TEST WriteReplaceWarningResponse */ LTE_APER_TST_WriteReplaceWarningResponse(fp, run_times); /* TEST ENBDirectInformationTransfer */ LTE_APER_TST_ENBDirectInformationTransfer(fp, run_times); /* TEST MMEDirectInformationTransfer */ LTE_APER_TST_MMEDirectInformationTransfer(fp, run_times); /* TEST ENBConfigurationTransfer */ LTE_APER_TST_ENBConfigurationTransfer(fp, run_times); /* TEST MMEConfigurationTransfer */ LTE_APER_TST_MMEConfigurationTransfer(fp, run_times); /* TEST KillRequest */ LTE_APER_TST_KillRequest(fp, run_times); /* TEST KillResponse */ LTE_APER_TST_KillResponse(fp, run_times); LTE_APER_TST_PWSRestartIndication(fp, run_times); LTE_APER_TST_PWSFailureIndication(fp, run_times); /* TEST DownlinkUEAssociatedLPPaTransport */ LTE_APER_TST_DownlinkUEAssociatedLPPaTransport(fp, run_times); /* TEST UplinkUEAssociatedLPPaTransport */ LTE_APER_TST_UplinkUEAssociatedLPPaTransport(fp, run_times); /* TEST DownlinkNonUEAssociatedLPPaTransport */ LTE_APER_TST_DownlinkNonUEAssociatedLPPaTransport(fp, run_times); /* TEST UplinkNonUEAssociatedLPPaTransport */ LTE_APER_TST_UplinkNonUEAssociatedLPPaTransport(fp, run_times); LTE_APER_TST_E_RABModificationIndication(fp, run_times); LTE_APER_TST_E_RABModificationConfirm(fp, run_times); LTE_APER_TST_UEContextModificationIndication(fp, run_times); LTE_APER_TST_UEContextModificationConfirm(fp, run_times); LTE_APER_TST_UEContextSuspendRequest(fp, run_times); LTE_APER_TST_UEContextSuspendResponse(fp, run_times); LTE_APER_TST_UEContextResumeRequest(fp, run_times); LTE_APER_TST_UEContextResumeResponse(fp, run_times); LTE_APER_TST_UEContextResumeFailure(fp, run_times); LTE_APER_TST_ConnectionEstablishmentIndication(fp, run_times); LTE_APER_TST_RetrieveUEInformation(fp, run_times); LTE_APER_TST_UEInformationTransfer(fp, run_times); LTE_APER_TST_ENBCPRelocationIndication(fp, run_times); LTE_APER_TST_MMECPRelocationIndication(fp, run_times); #endif return 0; } #ifdef _SCTP_CAP_ON_ int CreateSctpSock(char *server, int port) { int connSock, ret, on = 1; struct sockaddr_in servaddr; struct sctp_initmsg initmsg; struct sctp_event_subscribe events; connSock = socket( AF_INET, SOCK_STREAM, IPPROTO_SCTP ); if(connSock == -1) { printf(" >> CreateSctpSock: Error creating socket.\n"); return -1; } memset( &initmsg, 0, sizeof(initmsg) ); initmsg.sinit_num_ostreams = 2; initmsg.sinit_max_instreams = 2; initmsg.sinit_max_attempts = 4; ret = setsockopt( connSock, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, sizeof(initmsg) ); if (ret) { printf(" >> CreateSctpSock: Error setting socket option SCTP_INITMSG.\n"); close(connSock); return -3; } /* set reuse addr */ if(setsockopt(connSock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) { printf(" >> CreateSctpSock: Error setting socket option SO_REUSEADDR.\n"); close(connSock); return -1; } /* Enable receipt of SCTP Snd/Rcv Data via sctp_recvmsg */ memset( (void *)&events, 0, sizeof(events) ); events.sctp_data_io_event = 1; ret = setsockopt( connSock, IPPROTO_SCTP, SCTP_EVENTS, (const void *)&events, sizeof(events) ); if (ret) { printf(" >> CreateSctpSock: Error setting socket option SCTP_EVENTS.\n"); close(connSock); return -3; } bzero( (void *)&servaddr, sizeof(servaddr) ); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(port); servaddr.sin_addr.s_addr = inet_addr(server); ret = connect( connSock, (struct sockaddr *)&servaddr, sizeof(servaddr) ); if(ret == -1) { printf(" >> CreateSctpSock: Error connecting server.\n"); close(connSock); return -2; } return connSock; } // wrapper that is used to replace PrintBufferToFile int SendBufferToServer(FILE *fp, unsigned char *buff, int len_ret) { return SendToSctpServer(sctp_client, buff, len_ret, SCTP_PPID); } // ppid = 18 (for S1AP), 60 (NGAP) int SendToSctpServer(int connSock, unsigned char *msg_buff, int msg_len, int ppid) { int ret, flags; char buffer[4096]; struct sctp_sndrcvinfo sndrcvinfo; if (msg_len <= 0) return 0; /* int sctp_sendmsg(int sd, const void * msg, size_t len, struct sockaddr *to, socklen_t tolen, uint32_t ppid, uint32_t flags, uint16_t stream_no, uint32_t timetolive, uint32_t context); */ ret = sctp_sendmsg( connSock, (void *)msg_buff, msg_len, NULL, 0, htonl(ppid), 0, 1, 0, 0 ); if (ret < 0) { printf(" >> SendToSctpServer: Error sending message: Len = %d, ret = %d\n", msg_len, ret); return -1; } ret = sctp_recvmsg( connSock, buffer, sizeof(buffer), (struct sockaddr *)NULL, 0, &sndrcvinfo, &flags ); if (ret < 0) { printf(" >> SendToSctpServer: Error waiting for reply message.\n"); return -2; } usleep(10000); return ret; } void* SctpServerEchoThread(void *par) { int listenSock, connSock, ret, in , flags; struct sockaddr_in servaddr; struct sockaddr_in client_addr; struct sctp_initmsg initmsg; struct sctp_sndrcvinfo sndrcvinfo; struct sctp_event_subscribe events; SctpServerPar *sctp_par = (SctpServerPar*)par; char buffer[SCTP_BUFFER_LEN]; unsigned int addr_len = sizeof(client_addr); int client_ip; int port = sctp_par->server_port; char reply_msg[] = "OK OK OK"; fd_set rfds, read_fds; struct timeval tv; int fdmax; FD_ZERO(&rfds); //* Wait up to five seconds. tv.tv_sec = 2; tv.tv_usec = 0; listenSock = socket( AF_INET, SOCK_STREAM, IPPROTO_SCTP ); if (listenSock < 0) { printf(" >> SctpServerEchoThread: Error creating socket.\n"); return NULL; } bzero( (void *)&servaddr, sizeof(servaddr) ); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); //servaddr.sin_addr.s_addr = inet_addr( "127.0.0.1" ); servaddr.sin_port = htons(port); ret = bind( listenSock, (struct sockaddr *)&servaddr, sizeof(servaddr) ); if (ret) { printf(" >> SctpServerEchoThread: Error bind().\n"); close(listenSock); return NULL; } /* Specify that a maximum of 5 streams will be available per socket */ memset( &initmsg, 0, sizeof(initmsg) ); initmsg.sinit_num_ostreams = 2; initmsg.sinit_max_instreams = 2; initmsg.sinit_max_attempts = 4; ret = setsockopt( listenSock, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, sizeof(initmsg) ); if (ret) { printf(" >> SctpServerEchoThread: Error setting socket option.\n"); close(listenSock); return NULL; } /* Enable receipt of SCTP Snd/Rcv Data via sctp_recvmsg */ memset( (void *)&events, 0, sizeof(events) ); events.sctp_data_io_event = 1; ret = setsockopt( listenSock, IPPROTO_SCTP, SCTP_EVENTS, (const void *)&events, sizeof(events) ); if (ret) { printf(" >> CreateSctpSock: Error setting socket option SCTP_EVENTS.\n"); close(listenSock); return NULL; } ret = listen( listenSock, 5 ); if (ret) { printf(" >> SctpServerEchoThread: Error Listen().\n"); close(listenSock); return NULL; } // Main loop to wait for connection and read message. FD_SET(listenSock, &rfds); fdmax = listenSock + 1; while(sctp_par->running) { bzero(buffer, MAX_BUFFER + 1); // socket to aaa (from either hss or pdg) read_fds = rfds; ret = select(fdmax, &read_fds, NULL, NULL, &tv); if (ret < 0 ) { printf(" >> SctpServerEchoThread: select() failed !\n"); close(listenSock); return NULL; } else if (ret == 0) { continue; // nothing happens before timeout } printf(">> SctpServerEchoThread: new connection ...\n"); memset(&client_addr, 0, addr_len); connSock = accept( listenSock, (struct sockaddr *)&client_addr, &addr_len); if(connSock == -1) { printf(" >> SctpServerEchoThread: Error accept().\n"); close(listenSock); return NULL; } else { client_ip = ntohl(client_addr.sin_addr.s_addr); printf(">> SctpServerEchoThread: Info - New client connected from %d.%d.%d.%d:%d ...\n", (client_ip >> 24)&0xff, (client_ip >> 16)&0xff, (client_ip >> 8)&0xff,(client_ip)&0xff, ntohs(client_addr.sin_port)); while (1) { in = sctp_recvmsg( connSock, buffer, sizeof(buffer), (struct sockaddr *)NULL, 0, &sndrcvinfo, &flags ); if (in > 0) { ret = sctp_sendmsg( connSock, (void *)reply_msg, (size_t)strlen(reply_msg), NULL, 0, htonl(SCTP_PPID), 0, 1, 0, 0 ); //ret = sctp_sendmsg( connSock, (void *)buffer, in, NULL, 0, htonl(18), 0, 1, 0, 0 ); // Check if exit instruction is received if (memcmp(buffer, "Bye", 3) == 0) { printf(">> SctpServerEchoThread: Info - Client %d closed as instructed!\n", connSock); close(connSock); connSock = -100; break; } } } } if (connSock == -100) { break; } } printf(">> SctpServerEchoThread: Info - Exit with status %d !\n", sctp_par->running); close(listenSock); return NULL; } #endif
[ "easyasn@sina.com" ]
easyasn@sina.com
63760b7ad999d39a66955a5ecc04865f088300a6
110b235080393481d4c8d2e0bf47ceafe0402be1
/libft/ft_memchr.c
91ba20460ad94dc3c460603adb9dcb4d0ca88b55
[]
no_license
dkarthus/myshell
e66244bf29e3fe7dc185aaf500bf941c89ca64db
fde48de048c7d8ae8eff43fc73bf71ff36e9cb1e
refs/heads/main
2023-07-18T10:02:10.237533
2021-09-02T18:46:13
2021-09-02T18:46:13
388,801,758
0
0
null
2021-08-11T11:37:10
2021-07-23T12:56:20
C
UTF-8
C
false
false
1,138
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memchr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dkarthus <dkarthus@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/11/02 13:56:41 by dkarthus #+# #+# */ /* Updated: 2020/12/02 20:03:43 by dkarthus ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void *ft_memchr(const void *s, int c, size_t n) { const unsigned char *ptr; ptr = (const unsigned char *)s; while (n != 0) { if (*ptr == (unsigned char)c) return ((void *)(ptr)); ptr++; n--; } return (NULL); }
[ "dkarthus@student.21-school.ru" ]
dkarthus@student.21-school.ru
700f167bbff8d1cd93416200539de0dacc01b164
32b023084aebf4dbcb7ce8c915faa465a9ebf057
/modules/core/src/cmd/debug.c
c3d377a98f5584a25e2d55b1d78613fcc0a5a6d6
[]
no_license
JustYarka/yVKBot
0769d3d32b151d0aa56dcd608dfa91f0222a718c
a5e29e594c4ea97fb252645dbfc199438bc1ccb3
refs/heads/master
2022-04-11T14:44:24.825519
2020-01-04T18:07:35
2020-01-04T18:07:35
null
0
0
null
null
null
null
UTF-8
C
false
false
1,141
c
#include <enginecallbacks.h> #include "va_utils.h" int vkapi_get_id_from(char *str); void cmd_debug(vkapi_message_object *message, int argc, char **argv, const char *args) { // if(argv[1]) // VKAPI_SEND_MESSAGE(message->peer_id, va("ID: %i", vkapi_get_id_from(argv[1])), NULL, 0); // if(argv[1]) // { // if(argv[2]) // { // string_t s = STRING_INIT(); // for( int c = 2; c < argc + 1; c++ ) // { // if( !argv[c] ) // break; // if(c > 2) // STRING_STRNCAT( s, " ", 1 ); // STRING_STRNCAT( s, argv[c], strlen(argv[c]) ); // } // MEMCACHE_PUSH(argv[1], s->ptr); // VKAPI_SEND_MESSAGE( message->peer_id, va("Memcache: push key \"%s\" value \"%s\"\n", argv[1], s->ptr), NULL, 0); // return; // } // const char *value = MEMCACHE_GET(argv[1]); // if(value) // VKAPI_SEND_MESSAGE( message->peer_id, va("Memcache: key is \"%s\" value is \"%s\"\n", argv[1], value), NULL, 0); // else // VKAPI_SEND_MESSAGE( message->peer_id, va("Memcache: value for key \"%s\" not found\n", argv[1]), NULL, 0); // } }
[ "mr.maks0443@gmail.com" ]
mr.maks0443@gmail.com
e3b40acd401ef1b302dd4a5cd63bc3beae6c319e
be79bec46a532a2d059c03f59f67a1f501c2e371
/math/single/rredf.c
d5af5344473c68db4e84d78b51f43b20c931fea8
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
sycomix/optimized-routines
5987a6a4cab10c469cc147d1d8e667fd4d8ae94a
e875f40f0b2ad71c5381a431e6d71829770c7ab7
refs/heads/master
2020-03-30T22:15:08.212539
2018-09-18T09:36:04
2018-09-18T09:36:04
null
0
0
null
null
null
null
UTF-8
C
false
false
10,964
c
/* * rredf.c - trigonometric range reduction function * * Copyright (c) 2009-2015, Arm Limited. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * This code is intended to be used as the second half of a range * reducer whose first half is an inline function defined in * rredf.h. Each trig function performs range reduction by invoking * that, which handles the quickest and most common cases inline * before handing off to this function for everything else. Thus a * reasonable compromise is struck between speed and space. (I * hope.) In particular, this approach avoids a function call * overhead in the common case. */ #include "math_private.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* * Input values to this function: * - x is the original user input value, unchanged by the * first-tier reducer in the case where it hands over to us. * - q is still the place where the caller expects us to leave the * quadrant code. * - k is the IEEE bit pattern of x (which it would seem a shame to * recompute given that the first-tier reducer already went to * the effort of extracting it from the VFP). FIXME: in softfp, * on the other hand, it's unconscionably wasteful to replicate * this value into a second register and we should change the * prototype! */ float __mathlib_rredf2(float x, int *q, unsigned k) { /* * First, weed out infinities and NaNs, and deal with them by * returning a negative q. */ if ((k << 1) >= 0xFF000000) { *q = -1; return x; } /* * We do general range reduction by multiplying by 2/pi, and * retaining the bottom two bits of the integer part and an * initial chunk of the fraction below that. The integer bits * are directly output as *q; the fraction is then multiplied * back up by pi/2 before returning it. * * To get this right, we don't have to multiply by the _whole_ * of 2/pi right from the most significant bit downwards: * instead we can discard any bit of 2/pi with a place value * high enough that multiplying it by the LSB of x will yield a * place value higher than 2. Thus we can bound the required * work by a reasonably small constant regardless of the size of * x (unlike, for instance, the IEEE remainder operation). * * At the other end, however, we must take more care: it isn't * adequate just to acquire two integer bits and 24 fraction * bits of (2/pi)x, because if a lot of those fraction bits are * zero then we will suffer significance loss. So we must keep * computing fraction bits as far down as 23 bits below the * _highest set fraction bit_. * * The immediate question, therefore, is what the bound on this * end of the job will be. In other words: what is the smallest * difference between an integer multiple of pi/2 and a * representable IEEE single precision number larger than the * maximum size handled by rredf.h? * * The most difficult cases for each exponent can readily be * found by Tim Peters's modular minimisation algorithm, and are * tabulated in mathlib/tests/directed/rredf.tst. The single * worst case is the IEEE single-precision number 0x6F79BE45, * whose numerical value is in the region of 7.7*10^28; when * reduced mod pi/2, it attains the value 0x30DDEEA9, or about * 0.00000000161. The highest set bit of this value is the one * with place value 2^-30; so its lowest is 2^-53. Hence, to be * sure of having enough fraction bits to output at full single * precision, we must be prepared to collect up to 53 bits of * fraction in addition to our two bits of integer part. * * To begin with, this means we must store the value of 2/pi to * a precision of 128+53 = 181 bits. That's six 32-bit words. * (Hardly a chore, unlike the equivalent problem in double * precision!) */ { static const unsigned twooverpi[] = { /* We start with a zero word, because that takes up less * space than the array bounds checking and special-case * handling that would have to occur in its absence. */ 0, /* 2/pi in hex is 0.a2f9836e... */ 0xa2f9836e, 0x4e441529, 0xfc2757d1, 0xf534ddc0, 0xdb629599, 0x3c439041, /* Again, to avoid array bounds overrun, we store a spare * word at the end. And it would be a shame to fill it * with zeroes when we could use more bits of 2/pi... */ 0xfe5163ab }; /* * Multiprecision multiplication of this nature is more * readily done in integers than in VFP, since we can use * UMULL (on CPUs that support it) to multiply 32 by 32 bits * at a time whereas the VFP would only be able to do 12x12 * without losing accuracy. * * So extract the mantissa of the input number as a 32-bit * integer. */ unsigned mantissa = 0x80000000 | (k << 8); /* * Now work out which part of our stored value of 2/pi we're * supposed to be multiplying by. * * Let the IEEE exponent field of x be e. With its bias * removed, (e-127) is the index of the set bit at the top * of 'mantissa' (i.e. that set bit has real place value * 2^(e-127)). So the lowest set bit in 'mantissa', 23 bits * further down, must have place value 2^(e-150). * * We begin taking an interest in the value of 2/pi at the * bit which multiplies by _that_ to give something with * place value at most 2. In other words, the highest bit of * 2/pi we're interested in is the one with place value * 2/(2^(e-150)) = 2^(151-e). * * The bit at the top of the first (zero) word of the above * array has place value 2^31. Hence, the bit we want to put * at the top of the first word we extract from that array * is the one at bit index n, where 31-n = 151-e and hence * n=e-120. */ int topbitindex = ((k >> 23) & 0xFF) - 120; int wordindex = topbitindex >> 5; int shiftup = topbitindex & 31; int shiftdown = 32 - shiftup; unsigned word1, word2, word3; if (shiftup) { word1 = (twooverpi[wordindex] << shiftup) | (twooverpi[wordindex+1] >> shiftdown); word2 = (twooverpi[wordindex+1] << shiftup) | (twooverpi[wordindex+2] >> shiftdown); word3 = (twooverpi[wordindex+2] << shiftup) | (twooverpi[wordindex+3] >> shiftdown); } else { word1 = twooverpi[wordindex]; word2 = twooverpi[wordindex+1]; word3 = twooverpi[wordindex+2]; } /* * Do the multiplications, and add them together. */ unsigned long long mult1 = (unsigned long long)word1 * mantissa; unsigned long long mult2 = (unsigned long long)word2 * mantissa; unsigned long long mult3 = (unsigned long long)word3 * mantissa; unsigned /* bottom3 = (unsigned)mult3, */ top3 = (unsigned)(mult3 >> 32); unsigned bottom2 = (unsigned)mult2, top2 = (unsigned)(mult2 >> 32); unsigned bottom1 = (unsigned)mult1, top1 = (unsigned)(mult1 >> 32); unsigned out3, out2, out1, carry; out3 = top3 + bottom2; carry = (out3 < top3); out2 = top2 + bottom1 + carry; carry = carry ? (out2 <= top2) : (out2 < top2); out1 = top1 + carry; /* * The two words we multiplied to get mult1 had their top * bits at (respectively) place values 2^(151-e) and * 2^(e-127). The value of those two bits multiplied * together will have ended up in bit 62 (the * topmost-but-one bit) of mult1, i.e. bit 30 of out1. * Hence, that bit has place value 2^(151-e+e-127) = 2^24. * So the integer value that we want to output as q, * consisting of the bits with place values 2^1 and 2^0, * must be 23 and 24 bits below that, i.e. in bits 7 and 6 * of out1. * * Or, at least, it will be once we add 1/2, to round to the * _nearest_ multiple of pi/2 rather than the next one down. */ *q = (out1 + (1<<5)) >> 6; /* * Now we construct the output fraction, which is most * simply done in the VFP. We just extract three consecutive * bit strings from our chunk of binary data, convert them * to integers, equip each with an appropriate FP exponent, * add them together, and (don't forget) multiply back up by * pi/2. That way we don't have to work out ourselves where * the highest fraction bit ended up. * * Since our displacement from the nearest multiple of pi/2 * can be positive or negative, the topmost of these three * values must be arranged with its 2^-1 bit at the very top * of the word, and then treated as a _signed_ integer. */ { int i1 = (out1 << 26) | ((out2 >> 19) << 13); unsigned i2 = out2 << 13; unsigned i3 = out3; float f1 = i1, f2 = i2 * (1.0f/524288.0f), f3 = i3 * (1.0f/524288.0f/524288.0f); /* * Now f1+f2+f3 is a representation, potentially to * twice double precision, of 2^32 times ((2/pi)*x minus * some integer). So our remaining job is to multiply * back down by (pi/2)*2^-32, and convert back to one * single-precision output number. */ /* Normalise to a prec-and-a-half representation... */ float ftop = CLEARBOTTOMHALF(f1+f2+f3), fbot = f3-((ftop-f1)-f2); /* ... and multiply by a prec-and-a-half value of (pi/2)*2^-32. */ float ret = (ftop * 0x1.92p-32F) + (ftop * 0x1.fb5444p-44F + fbot * 0x1.921fb6p-32F); /* Just before we return, take the input sign into account. */ if (k & 0x80000000) { *q = 0x10000000 - *q; ret = -ret; } return ret; } } } #ifdef __cplusplus } /* end of extern "C" */ #endif /* __cplusplus */ /* end of rredf.c */
[ "szabolcs.nagy@arm.com" ]
szabolcs.nagy@arm.com
831f944430e5452274fa0b522a04855501ccf47c
f0fad43ff962fe361b0e493e0ee4e2475c6e84a0
/int/net/ip/sockcrc.c
b93c51b1834750fb80748ac6f9130dfa13e760f1
[]
no_license
jawit-kien/loglan
3c64cc703f4db9609b791091e0eda2a081b81e52
a3f10789b5d4f72b7ef1cad12b79f3b5ae0471cf
refs/heads/master
2021-05-27T16:13:24.775256
2011-07-15T22:45:30
2011-07-15T22:45:30
109,334,116
1
0
null
2017-11-03T00:46:58
2017-11-03T00:46:58
null
UTF-8
C
false
false
1,995
c
#include "sock.h" #ifndef NO_PROTOTYPES static int get_crc( char *data, int data_size ); #else static int get_crc(); #endif static char buffer[8192]; /* shouldn't be bigger message */ int sock_cli_crc_send( sock, m, size ) int sock,size; void *m; { *(int *)buffer = htonl(get_crc( m, size )); bcopy( m, buffer+sizeof(int), size ); return sock_cli_send( sock, buffer, size+sizeof(int) ); } int sock_cli_crc_recv( sock, m, size ) int sock,size; void *m; { int recv_size; recv_size = sock_cli_recv(sock, buffer, size+sizeof(int) ); if( recv_size == 0 ) return 0; else if( recv_size < sizeof(int) ) return -1; else{ recv_size-=sizeof(int); bcopy( buffer+sizeof(int), m, recv_size ); if( get_crc(m,recv_size)!=ntohl(*(int *)buffer) ) return -1; /* error */ else return recv_size; } } int sock_srv_crc_send( sock, m, size, addr, namelen ) int sock,size,namelen; void *m; struct sockaddr_in *addr; { *(int *)buffer = htonl(get_crc( m, size )); bcopy( m, buffer+sizeof(int), size ); return sock_srv_send( sock, buffer, size+sizeof(int) , addr, namelen ); } int sock_srv_crc_recv( sock, m, size, addr, namelen ) int sock,size,*namelen; void *m; struct sockaddr_in *addr; { int recv_size; recv_size = sock_srv_recv(sock, buffer, size+sizeof(int), addr, namelen ); if( recv_size == 0 ) return -1; else if( recv_size < sizeof(int) ) return -1; else{ recv_size-=sizeof(int); bcopy( buffer+sizeof(int), m, recv_size ); if( get_crc(m,recv_size)!=ntohl(*(int *)buffer) ) return -1; /* error */ else return recv_size; } } static int get_crc( data, data_size ) char *data; int data_size; { int i; unsigned long crc=0L; for( i=0; i<data_size; i++,data++ ){ crc ^= (unsigned long)(unsigned char)(*(char *)data); if( crc&1 ) crc = ( crc<<1 ) | 1; else crc = ( crc<<1 ); } return crc; }
[ "karol@maxdata" ]
karol@maxdata
e0ea6026c3299dd5751ee0d3bac9a4f0de3d05df
11c1a008abe02cb72591fd2b639715f171e7a878
/MotateProject/motate/cmsis/TARGET_Atmel/sam4l/include/component/component_dacc.h
b4df1a0f4052ea9550e50e0d652ee138243f0f7f
[]
no_license
synthetos/Motate
101203d3013068d06174dd24d07b057cb16b4e29
3ad4fc0a2366416ba41eaef5f8d4e70e59905550
refs/heads/master
2023-08-15T06:29:33.895021
2023-07-20T18:18:42
2023-07-20T18:18:42
21,837,909
49
50
null
2019-11-04T21:06:27
2014-07-14T22:26:34
C
UTF-8
C
false
false
10,979
h
/** * \file * * \brief Component description for DACC * * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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. * * \asf_license_stop * */ /* * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */ #ifndef _SAM4L_DACC_COMPONENT_ #define _SAM4L_DACC_COMPONENT_ /* ========================================================================== */ /** SOFTWARE API DEFINITION FOR DACC */ /* ========================================================================== */ /** \addtogroup SAM4L_DACC DAC Controller */ /*@{*/ #define REV_DACC 0x111 /* -------- DACC_CR : (DACC Offset: 0x00) ( /W 32) Control Register -------- */ #define DACC_CR_OFFSET 0x00 /**< \brief (DACC_CR offset) Control Register */ #define DACC_CR_RESETVALUE 0x00000000 /**< \brief (DACC_CR reset_value) Control Register */ #define DACC_CR_SWRST_Pos 0 /**< \brief (DACC_CR) Software Reset */ #define DACC_CR_SWRST (0x1u << DACC_CR_SWRST_Pos) #define DACC_CR_MASK 0x00000001u /**< \brief (DACC_CR) MASK Register */ /* -------- DACC_MR : (DACC Offset: 0x04) (R/W 32) Mode Register -------- */ #define DACC_MR_OFFSET 0x04 /**< \brief (DACC_MR offset) Mode Register */ #define DACC_MR_RESETVALUE 0x00000000 /**< \brief (DACC_MR reset_value) Mode Register */ #define DACC_MR_TRGEN_Pos 0 /**< \brief (DACC_MR) Trigger Enable */ #define DACC_MR_TRGEN (0x1u << DACC_MR_TRGEN_Pos) #define DACC_MR_TRGSEL_Pos 1 /**< \brief (DACC_MR) Trigger Selection */ #define DACC_MR_TRGSEL_Msk (0x7u << DACC_MR_TRGSEL_Pos) #define DACC_MR_TRGSEL(value) ((DACC_MR_TRGSEL_Msk & ((value) << DACC_MR_TRGSEL_Pos))) #define DACC_MR_DACEN_Pos 4 /**< \brief (DACC_MR) DAC Enable */ #define DACC_MR_DACEN (0x1u << DACC_MR_DACEN_Pos) #define DACC_MR_WORD_Pos 5 /**< \brief (DACC_MR) Word Transfer */ #define DACC_MR_WORD (0x1u << DACC_MR_WORD_Pos) #define DACC_MR_STARTUP_Pos 8 /**< \brief (DACC_MR) Startup Time Selection */ #define DACC_MR_STARTUP_Msk (0xFFu << DACC_MR_STARTUP_Pos) #define DACC_MR_STARTUP(value) ((DACC_MR_STARTUP_Msk & ((value) << DACC_MR_STARTUP_Pos))) #define DACC_MR_CLKDIV_Pos 16 /**< \brief (DACC_MR) Clock Divider for Internal Trigger */ #define DACC_MR_CLKDIV_Msk (0xFFFFu << DACC_MR_CLKDIV_Pos) #define DACC_MR_CLKDIV(value) ((DACC_MR_CLKDIV_Msk & ((value) << DACC_MR_CLKDIV_Pos))) #define DACC_MR_MASK 0xFFFFFF3Fu /**< \brief (DACC_MR) MASK Register */ /* -------- DACC_CDR : (DACC Offset: 0x08) ( /W 32) Conversion Data Register -------- */ #define DACC_CDR_OFFSET 0x08 /**< \brief (DACC_CDR offset) Conversion Data Register */ #define DACC_CDR_RESETVALUE 0x00000000 /**< \brief (DACC_CDR reset_value) Conversion Data Register */ #define DACC_CDR_DATA_Pos 0 /**< \brief (DACC_CDR) Data to Convert */ #define DACC_CDR_DATA_Msk (0xFFFFFFFFu << DACC_CDR_DATA_Pos) #define DACC_CDR_DATA(value) ((DACC_CDR_DATA_Msk & ((value) << DACC_CDR_DATA_Pos))) #define DACC_CDR_MASK 0xFFFFFFFFu /**< \brief (DACC_CDR) MASK Register */ /* -------- DACC_IER : (DACC Offset: 0x0C) ( /W 32) Interrupt Enable Register -------- */ #define DACC_IER_OFFSET 0x0C /**< \brief (DACC_IER offset) Interrupt Enable Register */ #define DACC_IER_RESETVALUE 0x00000000 /**< \brief (DACC_IER reset_value) Interrupt Enable Register */ #define DACC_IER_TXRDY_Pos 0 /**< \brief (DACC_IER) Transmit Ready Interrupt Enable */ #define DACC_IER_TXRDY (0x1u << DACC_IER_TXRDY_Pos) #define DACC_IER_MASK 0x00000001u /**< \brief (DACC_IER) MASK Register */ /* -------- DACC_IDR : (DACC Offset: 0x10) ( /W 32) Interrupt Disable Register -------- */ #define DACC_IDR_OFFSET 0x10 /**< \brief (DACC_IDR offset) Interrupt Disable Register */ #define DACC_IDR_TXRDY_Pos 0 /**< \brief (DACC_IDR) Transmit Ready Interrupt Disable */ #define DACC_IDR_TXRDY (0x1u << DACC_IDR_TXRDY_Pos) #define DACC_IDR_MASK 0x00000001u /**< \brief (DACC_IDR) MASK Register */ /* -------- DACC_IMR : (DACC Offset: 0x14) (R/ 32) Interrupt Mask Register -------- */ #define DACC_IMR_OFFSET 0x14 /**< \brief (DACC_IMR offset) Interrupt Mask Register */ #define DACC_IMR_RESETVALUE 0x00000000 /**< \brief (DACC_IMR reset_value) Interrupt Mask Register */ #define DACC_IMR_TXRDY_Pos 0 /**< \brief (DACC_IMR) Transmit Ready Interrupt Mask */ #define DACC_IMR_TXRDY (0x1u << DACC_IMR_TXRDY_Pos) #define DACC_IMR_MASK 0x00000001u /**< \brief (DACC_IMR) MASK Register */ /* -------- DACC_ISR : (DACC Offset: 0x18) (R/ 32) Interrupt Status Register -------- */ #define DACC_ISR_OFFSET 0x18 /**< \brief (DACC_ISR offset) Interrupt Status Register */ #define DACC_ISR_RESETVALUE 0x00000000 /**< \brief (DACC_ISR reset_value) Interrupt Status Register */ #define DACC_ISR_TXRDY_Pos 0 /**< \brief (DACC_ISR) Transmit Ready Interrupt Status */ #define DACC_ISR_TXRDY (0x1u << DACC_ISR_TXRDY_Pos) #define DACC_ISR_MASK 0x00000001u /**< \brief (DACC_ISR) MASK Register */ /* -------- DACC_WPMR : (DACC Offset: 0xE4) (R/W 32) Write Protect Mode Register -------- */ #define DACC_WPMR_OFFSET 0xE4 /**< \brief (DACC_WPMR offset) Write Protect Mode Register */ #define DACC_WPMR_RESETVALUE 0x00000000 /**< \brief (DACC_WPMR reset_value) Write Protect Mode Register */ #define DACC_WPMR_WPEN_Pos 0 /**< \brief (DACC_WPMR) Write Protect Enable */ #define DACC_WPMR_WPEN (0x1u << DACC_WPMR_WPEN_Pos) #define DACC_WPMR_WPKEY_Pos 8 /**< \brief (DACC_WPMR) Write Protect Key */ #define DACC_WPMR_WPKEY_Msk (0xFFFFFFu << DACC_WPMR_WPKEY_Pos) #define DACC_WPMR_WPKEY(value) ((DACC_WPMR_WPKEY_Msk & ((value) << DACC_WPMR_WPKEY_Pos))) #define DACC_WPMR_MASK 0xFFFFFF01u /**< \brief (DACC_WPMR) MASK Register */ /* -------- DACC_WPSR : (DACC Offset: 0xE8) (R/ 32) Write Protect Status Register -------- */ #define DACC_WPSR_OFFSET 0xE8 /**< \brief (DACC_WPSR offset) Write Protect Status Register */ #define DACC_WPSR_RESETVALUE 0x00000000 /**< \brief (DACC_WPSR reset_value) Write Protect Status Register */ #define DACC_WPSR_WPROTERR_Pos 0 /**< \brief (DACC_WPSR) Write Protection Error */ #define DACC_WPSR_WPROTERR (0x1u << DACC_WPSR_WPROTERR_Pos) #define DACC_WPSR_WPROTADDR_Pos 8 /**< \brief (DACC_WPSR) Write Protection Error Address */ #define DACC_WPSR_WPROTADDR_Msk (0xFFu << DACC_WPSR_WPROTADDR_Pos) #define DACC_WPSR_WPROTADDR(value) ((DACC_WPSR_WPROTADDR_Msk & ((value) << DACC_WPSR_WPROTADDR_Pos))) #define DACC_WPSR_MASK 0x0000FF01u /**< \brief (DACC_WPSR) MASK Register */ /* -------- DACC_VERSION : (DACC Offset: 0xFC) (R/ 32) Version Register -------- */ #define DACC_VERSION_OFFSET 0xFC /**< \brief (DACC_VERSION offset) Version Register */ #define DACC_VERSION_RESETVALUE 0x00000111 /**< \brief (DACC_VERSION reset_value) Version Register */ #define DACC_VERSION_VERSION_Pos 0 /**< \brief (DACC_VERSION) Version Number */ #define DACC_VERSION_VERSION_Msk (0xFFFu << DACC_VERSION_VERSION_Pos) #define DACC_VERSION_VERSION(value) ((DACC_VERSION_VERSION_Msk & ((value) << DACC_VERSION_VERSION_Pos))) #define DACC_VERSION_VARIANT_Pos 16 /**< \brief (DACC_VERSION) Variant Number */ #define DACC_VERSION_VARIANT_Msk (0x7u << DACC_VERSION_VARIANT_Pos) #define DACC_VERSION_VARIANT(value) ((DACC_VERSION_VARIANT_Msk & ((value) << DACC_VERSION_VARIANT_Pos))) #define DACC_VERSION_MASK 0x00070FFFu /**< \brief (DACC_VERSION) MASK Register */ /** \brief DACC hardware registers */ #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) typedef struct { WoReg DACC_CR; /**< \brief (DACC Offset: 0x00) Control Register */ RwReg DACC_MR; /**< \brief (DACC Offset: 0x04) Mode Register */ WoReg DACC_CDR; /**< \brief (DACC Offset: 0x08) Conversion Data Register */ WoReg DACC_IER; /**< \brief (DACC Offset: 0x0C) Interrupt Enable Register */ WoReg DACC_IDR; /**< \brief (DACC Offset: 0x10) Interrupt Disable Register */ RoReg DACC_IMR; /**< \brief (DACC Offset: 0x14) Interrupt Mask Register */ RoReg DACC_ISR; /**< \brief (DACC Offset: 0x18) Interrupt Status Register */ RoReg8 Reserved1[0xC8]; RwReg DACC_WPMR; /**< \brief (DACC Offset: 0xE4) Write Protect Mode Register */ RoReg DACC_WPSR; /**< \brief (DACC Offset: 0xE8) Write Protect Status Register */ RoReg8 Reserved2[0x10]; RoReg DACC_VERSION; /**< \brief (DACC Offset: 0xFC) Version Register */ } Dacc; #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ /*@}*/ #endif /* _SAM4L_DACC_COMPONENT_ */
[ "giseburt@gmail.com" ]
giseburt@gmail.com
56ea94e12e94327d5869bd27f344f9c00e05f13a
a145eaa2df3b662efc7c810121bc6a5821d6b652
/week7/ex4.c
1e8a5f4ecaa4af62b3fb9292f713ae709cae43c3
[]
no_license
Denisalik/innopolis_homework
66be18dff4141767fb9e36e125cf7bd9714fd91e
7a0598a05650ea49a92d7b0b37a6972712d03c19
refs/heads/master
2023-01-12T10:20:33.810353
2020-11-18T14:03:42
2020-11-18T14:03:42
288,467,695
0
0
null
null
null
null
UTF-8
C
false
false
663
c
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <malloc.h> void* myRealloc(void* ptr, size_t size){ if(ptr==NULL)return malloc(size); if(size==0){ free(ptr); return; } void* ptrnew = malloc(size); size_t oldsize = malloc_usable_size(ptr); if(size>=oldsize){ memcpy(ptrnew,ptr,oldsize); } else { memcpy(ptrnew,ptr,size); } free(ptr); return ptrnew; } int main(){ int* arr = malloc(sizeof(int)*5); int i; for(i=0;i<5;i++){ arr[i]=i; printf("%d\n",arr[i]); } arr = myRealloc(arr,2*sizeof(int)); printf("After reallocation:\n"); for(i=0;i<5;i++)printf("%d\n",arr[i]); return 0; }
[ "noreply@github.com" ]
Denisalik.noreply@github.com
8274ed7a75b359e651b99c352dbf4921ffb7c1e4
b6de03d101fcfdb83f6b16f1783385e48bfdb584
/thirdparty/gRPC/third_party/nanopb/pb_encode.c
3e43e5630a77b819446e88ccea0fbf5fed287746
[ "Zlib", "Apache-2.0" ]
permissive
Romantic-LiXuefeng/StudyProgram
b173308171895e118ae27bab96566a9d6b38f1e5
03a36009c8917cdc9f6dde39bc681d263bc1b3cc
refs/heads/master
2021-12-23T06:02:12.776062
2017-11-05T08:56:52
2017-11-05T08:56:52
null
0
0
null
null
null
null
UTF-8
C
false
false
21,215
c
/* pb_encode.c -- encode a protobuf using minimal resources * * 2011 Petteri Aimonen <jpa@kapsi.fi> */ #include "pb.h" #include "pb_encode.h" #include "pb_common.h" /* Use the GCC warn_unused_result attribute to check that all return values * are propagated correctly. On other compilers and gcc before 3.4.0 just * ignore the annotation. */ #if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) #define checkreturn #else #define checkreturn __attribute__((warn_unused_result)) #endif /************************************** * Declarations internal to this file * **************************************/ typedef bool (*pb_encoder_t)(pb_ostream_t *stream, const pb_field_t *field, const void *src) checkreturn; static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pData, size_t count, pb_encoder_t func); static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension); static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src); static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src); /* --- Function pointers to field encoders --- * Order in the array must match pb_action_t LTYPE numbering. */ static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = { &pb_enc_varint, &pb_enc_uvarint, &pb_enc_svarint, &pb_enc_fixed32, &pb_enc_fixed64, &pb_enc_bytes, &pb_enc_string, &pb_enc_submessage, NULL, /* extensions */ &pb_enc_bytes /* PB_LTYPE_FIXED_LENGTH_BYTES */ }; /******************************* * pb_ostream_t implementation * *******************************/ static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count) { pb_byte_t *dest = (pb_byte_t*)stream->state; stream->state = dest + count; while (count--) *dest++ = *buf++; return true; } pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize) { pb_ostream_t stream; #ifdef PB_BUFFER_ONLY stream.callback = (void*)1; /* Just a marker value */ #else stream.callback = &buf_write; #endif stream.state = buf; stream.max_size = bufsize; stream.bytes_written = 0; #ifndef PB_NO_ERRMSG stream.errmsg = NULL; #endif return stream; } bool checkreturn pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count) { if (stream->callback != NULL) { if (stream->bytes_written + count > stream->max_size) PB_RETURN_ERROR(stream, "stream full"); #ifdef PB_BUFFER_ONLY if (!buf_write(stream, buf, count)) PB_RETURN_ERROR(stream, "io error"); #else if (!stream->callback(stream, buf, count)) PB_RETURN_ERROR(stream, "io error"); #endif } stream->bytes_written += count; return true; } /************************* * Encode a single field * *************************/ /* Encode a static array. Handles the size calculations and possible packing. */ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pData, size_t count, pb_encoder_t func) { size_t i; const void *p; size_t size; if (count == 0) return true; if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size) PB_RETURN_ERROR(stream, "array max size exceeded"); /* We always pack arrays if the datatype allows it. */ if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE) { if (!pb_encode_tag(stream, PB_WT_STRING, field->tag)) return false; /* Determine the total size of packed array. */ if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32) { size = 4 * count; } else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64) { size = 8 * count; } else { pb_ostream_t sizestream = PB_OSTREAM_SIZING; p = pData; for (i = 0; i < count; i++) { if (!func(&sizestream, field, p)) return false; p = (const char*)p + field->data_size; } size = sizestream.bytes_written; } if (!pb_encode_varint(stream, (uint64_t)size)) return false; if (stream->callback == NULL) return pb_write(stream, NULL, size); /* Just sizing.. */ /* Write the data */ p = pData; for (i = 0; i < count; i++) { if (!func(stream, field, p)) return false; p = (const char*)p + field->data_size; } } else { p = pData; for (i = 0; i < count; i++) { if (!pb_encode_tag_for_field(stream, field)) return false; /* Normally the data is stored directly in the array entries, but * for pointer-type string and bytes fields, the array entries are * actually pointers themselves also. So we have to dereference once * more to get to the actual data. */ if (PB_ATYPE(field->type) == PB_ATYPE_POINTER && (PB_LTYPE(field->type) == PB_LTYPE_STRING || PB_LTYPE(field->type) == PB_LTYPE_BYTES)) { if (!func(stream, field, *(const void* const*)p)) return false; } else { if (!func(stream, field, p)) return false; } p = (const char*)p + field->data_size; } } return true; } /* Encode a field with static or pointer allocation, i.e. one whose data * is available to the encoder directly. */ static bool checkreturn encode_basic_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData) { pb_encoder_t func; const void *pSize; bool implicit_has = true; func = PB_ENCODERS[PB_LTYPE(field->type)]; if (field->size_offset) pSize = (const char*)pData + field->size_offset; else pSize = &implicit_has; if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) { /* pData is a pointer to the field, which contains pointer to * the data. If the 2nd pointer is NULL, it is interpreted as if * the has_field was false. */ pData = *(const void* const*)pData; implicit_has = (pData != NULL); } switch (PB_HTYPE(field->type)) { case PB_HTYPE_REQUIRED: if (!pData) PB_RETURN_ERROR(stream, "missing required field"); if (!pb_encode_tag_for_field(stream, field)) return false; if (!func(stream, field, pData)) return false; break; case PB_HTYPE_OPTIONAL: if (*(const bool*)pSize) { if (!pb_encode_tag_for_field(stream, field)) return false; if (!func(stream, field, pData)) return false; } break; case PB_HTYPE_REPEATED: if (!encode_array(stream, field, pData, *(const pb_size_t*)pSize, func)) return false; break; case PB_HTYPE_ONEOF: if (*(const pb_size_t*)pSize == field->tag) { if (!pb_encode_tag_for_field(stream, field)) return false; if (!func(stream, field, pData)) return false; } break; default: PB_RETURN_ERROR(stream, "invalid field type"); } return true; } /* Encode a field with callback semantics. This means that a user function is * called to provide and encode the actual data. */ static bool checkreturn encode_callback_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData) { const pb_callback_t *callback = (const pb_callback_t*)pData; #ifdef PB_OLD_CALLBACK_STYLE const void *arg = callback->arg; #else void * const *arg = &(callback->arg); #endif if (callback->funcs.encode != NULL) { if (!callback->funcs.encode(stream, field, arg)) PB_RETURN_ERROR(stream, "callback error"); } return true; } /* Encode a single field of any callback or static type. */ static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData) { switch (PB_ATYPE(field->type)) { case PB_ATYPE_STATIC: case PB_ATYPE_POINTER: return encode_basic_field(stream, field, pData); case PB_ATYPE_CALLBACK: return encode_callback_field(stream, field, pData); default: PB_RETURN_ERROR(stream, "invalid field type"); } } /* Default handler for extension fields. Expects to have a pb_field_t * pointer in the extension->type->arg field. */ static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension) { const pb_field_t *field = (const pb_field_t*)extension->type->arg; if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) { /* For pointer extensions, the pointer is stored directly * in the extension structure. This avoids having an extra * indirection. */ return encode_field(stream, field, &extension->dest); } else { return encode_field(stream, field, extension->dest); } } /* Walk through all the registered extensions and give them a chance * to encode themselves. */ static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData) { const pb_extension_t *extension = *(const pb_extension_t* const *)pData; PB_UNUSED(field); while (extension) { bool status; if (extension->type->encode) status = extension->type->encode(stream, extension); else status = default_extension_encoder(stream, extension); if (!status) return false; extension = extension->next; } return true; } /********************* * Encode all fields * *********************/ static void *remove_const(const void *p) { /* Note: this casts away const, in order to use the common field iterator * logic for both encoding and decoding. */ union { void *p1; const void *p2; } t; t.p2 = p; return t.p1; } bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) { pb_field_iter_t iter; if (!pb_field_iter_begin(&iter, fields, remove_const(src_struct))) return true; /* Empty message type */ do { if (PB_LTYPE(iter.pos->type) == PB_LTYPE_EXTENSION) { /* Special case for the extension field placeholder */ if (!encode_extension_field(stream, iter.pos, iter.pData)) return false; } else { /* Regular field */ if (!encode_field(stream, iter.pos, iter.pData)) return false; } } while (pb_field_iter_next(&iter)); return true; } bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) { return pb_encode_submessage(stream, fields, src_struct); } bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct) { pb_ostream_t stream = PB_OSTREAM_SIZING; if (!pb_encode(&stream, fields, src_struct)) return false; *size = stream.bytes_written; return true; } /******************** * Helper functions * ********************/ bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value) { pb_byte_t buffer[10]; size_t i = 0; if (value <= 0x7F) { pb_byte_t v = (pb_byte_t)value; return pb_write(stream, &v, 1); } while (value) { buffer[i] = (pb_byte_t)((value & 0x7F) | 0x80); value >>= 7; i++; } buffer[i-1] &= 0x7F; /* Unset top bit on last byte */ return pb_write(stream, buffer, i); } bool checkreturn pb_encode_svarint(pb_ostream_t *stream, int64_t value) { uint64_t zigzagged; if (value < 0) zigzagged = ~((uint64_t)value << 1); else zigzagged = (uint64_t)value << 1; return pb_encode_varint(stream, zigzagged); } bool checkreturn pb_encode_fixed32(pb_ostream_t *stream, const void *value) { uint32_t val = *(const uint32_t*)value; pb_byte_t bytes[4]; bytes[0] = (pb_byte_t)(val & 0xFF); bytes[1] = (pb_byte_t)((val >> 8) & 0xFF); bytes[2] = (pb_byte_t)((val >> 16) & 0xFF); bytes[3] = (pb_byte_t)((val >> 24) & 0xFF); return pb_write(stream, bytes, 4); } bool checkreturn pb_encode_fixed64(pb_ostream_t *stream, const void *value) { uint64_t val = *(const uint64_t*)value; pb_byte_t bytes[8]; bytes[0] = (pb_byte_t)(val & 0xFF); bytes[1] = (pb_byte_t)((val >> 8) & 0xFF); bytes[2] = (pb_byte_t)((val >> 16) & 0xFF); bytes[3] = (pb_byte_t)((val >> 24) & 0xFF); bytes[4] = (pb_byte_t)((val >> 32) & 0xFF); bytes[5] = (pb_byte_t)((val >> 40) & 0xFF); bytes[6] = (pb_byte_t)((val >> 48) & 0xFF); bytes[7] = (pb_byte_t)((val >> 56) & 0xFF); return pb_write(stream, bytes, 8); } bool checkreturn pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number) { uint64_t tag = ((uint64_t)field_number << 3) | wiretype; return pb_encode_varint(stream, tag); } bool checkreturn pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field) { pb_wire_type_t wiretype; switch (PB_LTYPE(field->type)) { case PB_LTYPE_VARINT: case PB_LTYPE_UVARINT: case PB_LTYPE_SVARINT: wiretype = PB_WT_VARINT; break; case PB_LTYPE_FIXED32: wiretype = PB_WT_32BIT; break; case PB_LTYPE_FIXED64: wiretype = PB_WT_64BIT; break; case PB_LTYPE_BYTES: case PB_LTYPE_STRING: case PB_LTYPE_SUBMESSAGE: case PB_LTYPE_FIXED_LENGTH_BYTES: wiretype = PB_WT_STRING; break; default: PB_RETURN_ERROR(stream, "invalid field type"); } return pb_encode_tag(stream, wiretype, field->tag); } bool checkreturn pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size) { if (!pb_encode_varint(stream, (uint64_t)size)) return false; return pb_write(stream, buffer, size); } bool checkreturn pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) { /* First calculate the message size using a non-writing substream. */ pb_ostream_t substream = PB_OSTREAM_SIZING; size_t size; bool status; if (!pb_encode(&substream, fields, src_struct)) { #ifndef PB_NO_ERRMSG stream->errmsg = substream.errmsg; #endif return false; } size = substream.bytes_written; if (!pb_encode_varint(stream, (uint64_t)size)) return false; if (stream->callback == NULL) return pb_write(stream, NULL, size); /* Just sizing */ if (stream->bytes_written + size > stream->max_size) PB_RETURN_ERROR(stream, "stream full"); /* Use a substream to verify that a callback doesn't write more than * what it did the first time. */ substream.callback = stream->callback; substream.state = stream->state; substream.max_size = size; substream.bytes_written = 0; #ifndef PB_NO_ERRMSG substream.errmsg = NULL; #endif status = pb_encode(&substream, fields, src_struct); stream->bytes_written += substream.bytes_written; stream->state = substream.state; #ifndef PB_NO_ERRMSG stream->errmsg = substream.errmsg; #endif if (substream.bytes_written != size) PB_RETURN_ERROR(stream, "submsg size changed"); return status; } /* Field encoders */ static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src) { int64_t value = 0; if (field->data_size == sizeof(int_least8_t)) value = *(const int_least8_t*)src; else if (field->data_size == sizeof(int_least16_t)) value = *(const int_least16_t*)src; else if (field->data_size == sizeof(int32_t)) value = *(const int32_t*)src; else if (field->data_size == sizeof(int64_t)) value = *(const int64_t*)src; else PB_RETURN_ERROR(stream, "invalid data_size"); return pb_encode_varint(stream, (uint64_t)value); } static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *src) { uint64_t value = 0; if (field->data_size == sizeof(uint_least8_t)) value = *(const uint_least8_t*)src; else if (field->data_size == sizeof(uint_least16_t)) value = *(const uint_least16_t*)src; else if (field->data_size == sizeof(uint32_t)) value = *(const uint32_t*)src; else if (field->data_size == sizeof(uint64_t)) value = *(const uint64_t*)src; else PB_RETURN_ERROR(stream, "invalid data_size"); return pb_encode_varint(stream, value); } static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src) { int64_t value = 0; if (field->data_size == sizeof(int_least8_t)) value = *(const int_least8_t*)src; else if (field->data_size == sizeof(int_least16_t)) value = *(const int_least16_t*)src; else if (field->data_size == sizeof(int32_t)) value = *(const int32_t*)src; else if (field->data_size == sizeof(int64_t)) value = *(const int64_t*)src; else PB_RETURN_ERROR(stream, "invalid data_size"); return pb_encode_svarint(stream, value); } static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src) { PB_UNUSED(field); return pb_encode_fixed64(stream, src); } static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src) { PB_UNUSED(field); return pb_encode_fixed32(stream, src); } static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src) { const pb_bytes_array_t *bytes = NULL; if (PB_LTYPE(field->type) == PB_LTYPE_FIXED_LENGTH_BYTES) return pb_encode_string(stream, (const pb_byte_t*)src, field->data_size); bytes = (const pb_bytes_array_t*)src; if (src == NULL) { /* Treat null pointer as an empty bytes field */ return pb_encode_string(stream, NULL, 0); } if (PB_ATYPE(field->type) == PB_ATYPE_STATIC && PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) > field->data_size) { PB_RETURN_ERROR(stream, "bytes size exceeded"); } return pb_encode_string(stream, bytes->bytes, bytes->size); } static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src) { size_t size = 0; size_t max_size = field->data_size; const char *p = (const char*)src; if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) max_size = (size_t)-1; if (src == NULL) { size = 0; /* Treat null pointer as an empty string */ } else { /* strnlen() is not always available, so just use a loop */ while (size < max_size && *p != '\0') { size++; p++; } } return pb_encode_string(stream, (const pb_byte_t*)src, size); } static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src) { if (field->ptr == NULL) PB_RETURN_ERROR(stream, "invalid field descriptor"); return pb_encode_submessage(stream, (const pb_field_t*)field->ptr, src); }
[ "529647632@qq.com" ]
529647632@qq.com
995b31f05ca04fc691d26e7bdb7b8579bfec9cd4
04d7b4ef1e825652262932dfe20666eb0fa53993
/engine/include/Defines.h
8067006fbbc12a13c71aa5fcb8793a9e14d57983
[]
no_license
MadJayQ/Project-Nebula
7f815db85b5df18c571c2250efde70cf2ff8c80a
a556a1b726bd1634f961d756bc61497667034ada
refs/heads/master
2021-06-30T18:16:00.878171
2017-09-20T18:54:48
2017-09-20T18:54:48
103,562,944
0
0
null
null
null
null
UTF-8
C
false
false
100
h
#pragma once #define LOCAL_PERSISTENT static #define GLOBAL static #define OPERATOR(x) operator x
[ "jthornton3030@floridapoly.edu" ]
jthornton3030@floridapoly.edu
7f3052203f82ea71c2e4c3ba83b83aba2aa85a2a
425dae4c4118ce6cf3c030469b4fb9846592e164
/docker/02_bonus/Fillit_in_Docker/app/libft/ft_memset.c
a07bf80de4f38c6bcd498b2f07f82825bc5b427e
[]
no_license
khanzhin/Clang_network_docker
05c0fedb3c235ee6ffe15a7e5adf994c4dc4fc98
6f52d2bdb7f69f71715f64a07eb8f591acec5b43
refs/heads/master
2020-08-06T21:01:06.079639
2019-12-22T13:30:08
2019-12-22T13:30:08
null
0
0
null
null
null
null
UTF-8
C
false
false
1,076
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memset.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: wtodd <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/09/11 11:27:07 by wtodd #+# #+# */ /* Updated: 2019/09/17 17:38:08 by wtodd ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void *ft_memset(void *b, int c, size_t len) { int i; char *s; s = b; i = 0; while (len != 0) { s[i] = (unsigned char)c; i++; len--; } return (s); }
[ "wtodd@at-r8.21-school.ru" ]
wtodd@at-r8.21-school.ru
dfd3734be55693cf0797e4735c586cc6e0c456f4
10f0b89e7cc9c362786ad6bf0466c6f40bf5e4f4
/utils/stb_image.h
c3b6614462c20260a65c128a1245d3d38286f7b3
[]
no_license
FilipMasar/Neural-net
1a2055dd0b3c6b23b386ac0b4916c30875e70d44
f1d748c9f30cfafdbc88e173c98541426ef92223
refs/heads/master
2022-08-21T22:59:44.955888
2020-05-22T16:54:44
2020-05-22T16:54:44
259,602,667
0
0
null
null
null
null
UTF-8
C
false
false
277,902
h
/* stb_image - v2.25 - public domain image loader - http://nothings.org/stb no warranty implied; use at your own risk Do this: #define STB_IMAGE_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #include ... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) PNG 1/2/4/8/16-bit-per-channel TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels, 8/16 bit-per-channel) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) PNM (PPM and PGM binary only) Animated GIF still needs a proper API, but here's one way to do it: http://gist.github.com/urraka/685d9a6340b26b830d49 - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) Full documentation under "DOCUMENTATION" below. LICENSE See end of file for license information. RECENT REVISION HISTORY: 2.25 (2020-02-02) fix warnings 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically 2.23 (2019-08-11) fix clang static analysis warning 2.22 (2019-03-04) gif fixes, fix warnings 2.21 (2019-02-25) fix typo in comment 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 RGB-format JPEG; remove white matting in PSD; allocate large structures on the stack; correct channel count for PNG & BMP 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED See end of file for full revision history. ============================ Contributors ========================= Image formats Extensions, features Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) github:urraka (animated gif) Junggon Kim (PNM comments) Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) socks-the-fox (16-bit PNG) Jeremy Sawicki (handle all ImageNet JPGs) Optimizations & bugfixes Mikhail Morozov (1-bit BMP) Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) Arseny Kapoulkine John-Mark Allen Carmelo J Fdez-Aguera Bug & warning fixes Marc LeBlanc David Woo Guillaume George Martins Mozeiko Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan Dave Moore Roy Eltham Hayaki Saito Nathan Reed Won Chun Luke Graham Johan Duparc Nick Verigakis the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh Janez Zemva John Bartholomew Michal Cichon github:romigrou Jonathan Blow Ken Hamada Tero Hanninen github:svdijk Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo Christian Floisand Kevin Schmidt JR Smith github:darealshinji Brad Weinberger Matvey Cherevko github:Michaelangel007 Blazej Dariusz Roszkowski Alexander Veselov */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // DOCUMENTATION // // Limitations: // - no 12-bit-per-channel JPEG // - no JPEGs with arithmetic coding // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below for HDR usage): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *channels_in_file -- outputs # of image components in image file // int desired_channels -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is // corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'desired_channels' if desired_channels is non-zero, or // *channels_in_file otherwise. If desired_channels is non-zero, // *channels_in_file has the number of components that _would_ have been // output otherwise. E.g. if you set desired_channels to 4, you will always // get RGBA output, but you can check *channels_in_file to see if it's trivially // opaque because e.g. there were only 3 channels in the source image. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *channels_in_file will be unchanged. The function // stbi_failure_reason() can be queried for an extremely brief, end-user // unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS // to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // =========================================================================== // // UNICODE: // // If compiling for Windows and you wish to use Unicode filenames, compile // with // #define STBI_WINDOWS_UTF8 // and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert // Windows wchar_t filenames to utf8. // // =========================================================================== // // Philosophy // // stb libraries are designed with the following priorities: // // 1. easy to use // 2. easy to maintain // 3. good performance // // Sometimes I let "good performance" creep up in priority over "easy to maintain", // and for best performance I may provide less-easy-to-use APIs that give higher // performance, in addition to the easy-to-use ones. Nevertheless, it's important // to keep in mind that from the standpoint of you, a client of this library, // all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // provide more explicit reasons why performance can't be emphasized. // // - Portable ("ease of use") // - Small source code footprint ("easy to maintain") // - No dependencies ("ease of use") // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). // // =========================================================================== // // SIMD support // // The JPEG decoder will try to automatically use SIMD kernels on x86 when // supported by the compiler. For ARM Neon support, you must explicitly // request it. // // (The old do-it-yourself SIMD API is no longer supported in the current // code.) // // On x86, SSE2 will automatically be used when available based on a run-time // test; if not, the generic C versions are used as a fall-back. On ARM targets, // the typical path is to have separate builds for NEON and non-NEON devices // (at least this is true for iOS and Android). Therefore, the NEON support is // toggled by a build flag: define STBI_NEON to get NEON loops. // // If for some reason you do not want to use any of SIMD code, or if // you have issues compiling it, you can disable it entirely by // defining STBI_NO_SIMD. // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image supports loading HDR images in general, and currently the Radiance // .HDR file format specifically. You can still load any file through the existing // interface; if you attempt to load an HDR file, it will be automatically remapped // to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // iPhone PNG support: // // By default we convert iphone-formatted PNGs back to RGB, even though // they are internally encoded differently. You can disable this conversion // by calling stbi_convert_iphone_png_to_rgb(0), in which case // you will always just get the native iphone "format" through (which // is BGR stored in RGB). // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // // =========================================================================== // // ADDITIONAL CONFIGURATION // // - You can suppress implementation of any of the decoders to reduce // your code footprint by #defining one or more of the following // symbols before creating the implementation. // // STBI_NO_JPEG // STBI_NO_PNG // STBI_NO_BMP // STBI_NO_PSD // STBI_NO_TGA // STBI_NO_GIF // STBI_NO_HDR // STBI_NO_PIC // STBI_NO_PNM (.ppm and .pgm) // // - You can request *only* certain decoders and suppress all other ones // (this will be more forward-compatible, as addition of new decoders // doesn't require you to disable them explicitly): // // STBI_ONLY_JPEG // STBI_ONLY_PNG // STBI_ONLY_BMP // STBI_ONLY_PSD // STBI_ONLY_TGA // STBI_ONLY_GIF // STBI_ONLY_HDR // STBI_ONLY_PIC // STBI_ONLY_PNM (.ppm and .pgm) // // - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB // #ifndef STBI_NO_STDIO #include <stdio.h> #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for desired_channels STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; #include <stdlib.h> typedef unsigned char stbi_uc; typedef unsigned short stbi_us; #ifdef __cplusplus extern "C" { #endif #ifndef STBIDEF #ifdef STB_IMAGE_STATIC #define STBIDEF static #else #define STBIDEF extern #endif #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; //////////////////////////////////// // // 8-bits-per-channel interface // STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); #endif #ifdef STBI_WINDOWS_UTF8 STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif //////////////////////////////////// // // 16-bits-per-channel interface // STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif //////////////////////////////////// // // float-per-channel interface // #ifndef STBI_NO_LINEAR STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif #endif #ifndef STBI_NO_HDR STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename); STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // on most compilers (and ALL modern mainstream compilers) this is threadsafe STBIDEF const char *stbi_failure_reason (void); // free the loaded image -- this is just free() STBIDEF void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); #ifndef STBI_NO_STDIO STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit (char const *filename); STBIDEF int stbi_is_16_bit_from_file(FILE *f); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // flip the image vertically, so the first pixel in the output array is the bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // as above, but only applies to images loaded on the thread that calls the function // this function is only available if your compiler supports thread-local variables; // calling it will fail to link if your compiler doesn't STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifdef STB_IMAGE_IMPLEMENTATION #if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ || defined(STBI_ONLY_ZLIB) #ifndef STBI_ONLY_JPEG #define STBI_NO_JPEG #endif #ifndef STBI_ONLY_PNG #define STBI_NO_PNG #endif #ifndef STBI_ONLY_BMP #define STBI_NO_BMP #endif #ifndef STBI_ONLY_PSD #define STBI_NO_PSD #endif #ifndef STBI_ONLY_TGA #define STBI_NO_TGA #endif #ifndef STBI_ONLY_GIF #define STBI_NO_GIF #endif #ifndef STBI_ONLY_HDR #define STBI_NO_HDR #endif #ifndef STBI_ONLY_PIC #define STBI_NO_PIC #endif #ifndef STBI_ONLY_PNM #define STBI_NO_PNM #endif #endif #if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif #include <stdarg.h> #include <stddef.h> // ptrdiff_t on osx #include <stdlib.h> #include <string.h> #include <limits.h> #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include <math.h> // ldexp, pow #endif #ifndef STBI_NO_STDIO #include <stdio.h> #endif #ifndef STBI_ASSERT #include <assert.h> #define STBI_ASSERT(x) assert(x) #endif #ifdef __cplusplus #define STBI_EXTERN extern "C" #else #define STBI_EXTERN extern #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifndef STBI_NO_THREAD_LOCALS #if defined(__cplusplus) && __cplusplus >= 201103L #define STBI_THREAD_LOCAL thread_local #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define STBI_THREAD_LOCAL _Thread_local #elif defined(__GNUC__) #define STBI_THREAD_LOCAL __thread #elif defined(_MSC_VER) #define STBI_THREAD_LOCAL __declspec(thread) #endif #endif #ifdef _MSC_VER typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include <stdint.h> typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok #elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,newsz) realloc(p,newsz) #define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED #define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) #endif // x86/x64 detection #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET #endif #if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // which in turn means it gets to use SSE2 everywhere. This is unfortunate, // but previous attempts to provide the SSE2 functions with runtime // detection caused numerous issues. The way architecture extensions are // exposed in GCC/Clang is, sadly, not really suited for one-file libs. // New behavior: if compiled with -msse2, we use SSE2 without any // detection; if not, we don't use it at all. #define STBI_NO_SIMD #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) // Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. // As a result, enabling SSE2 on 32-bit MinGW is dangerous when not // simultaneously enabling "-mstackrealign". // // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added // -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif #if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #define STBI_SSE2 #include <emmintrin.h> #ifdef _MSC_VER #if _MSC_VER >= 1400 // not VC6 #include <intrin.h> // __cpuid static int stbi__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else static int stbi__cpuid3(void) { int res; __asm { mov eax,1 cpuid mov res,edx } return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; } #endif #else // assume GCC-style if not VC++ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { // If we're even attempting to compile this on GCC/Clang, that means // -msse2 is on, which means the compiler is allowed to use SSE2 // instructions at will, and so are we. return 1; } #endif #endif #endif // ARM NEON #if defined(STBI_NO_SIMD) && defined(STBI_NEON) #undef STBI_NEON #endif #ifdef STBI_NEON #include <arm_neon.h> // assume GCC or Clang on ARM targets #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif #ifndef STBI_SIMD_ALIGN #define STBI_SIMD_ALIGN(type, name) type name #endif /////////////////////////////////////////////// // // stbi__context struct and start_xxx functions // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi_uc buffer_start[128]; stbi_uc *img_buffer, *img_buffer_end; stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; } // initialize a callback-based context static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->img_buffer_original = s->buffer_start; stbi__refill_buffer(s); s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO static int stbi__stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stbi__stdio_skip(void *user, int n) { fseek((FILE*) user, n, SEEK_CUR); } static int stbi__stdio_eof(void *user) { return feof((FILE*) user); } static stbi_io_callbacks stbi__stdio_callbacks = { stbi__stdio_read, stbi__stdio_skip, stbi__stdio_eof, }; static void stbi__start_file(stbi__context *s, FILE *f) { stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); } //static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO static void stbi__rewind(stbi__context *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; s->img_buffer_end = s->img_buffer_original_end; } enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; typedef struct { int bits_per_channel; int num_channels; int channel_order; } stbi__result_info; #ifndef STBI_NO_JPEG static int stbi__jpeg_test(stbi__context *s); static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG static int stbi__png_test(stbi__context *s); static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__png_is16(stbi__context *s); #endif #ifndef STBI_NO_BMP static int stbi__bmp_test(stbi__context *s); static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA static int stbi__tga_test(stbi__context *s); static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s); static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__psd_is16(stbi__context *s); #endif #ifndef STBI_NO_HDR static int stbi__hdr_test(stbi__context *s); static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC static int stbi__pic_test(stbi__context *s); static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF static int stbi__gif_test(stbi__context *s); static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s); static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); #endif static #ifdef STBI_THREAD_LOCAL STBI_THREAD_LOCAL #endif const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } #ifndef STBI_NO_FAILURE_STRINGS static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } #endif static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stb_image uses ints pervasively, including for offset calculations. // therefore the largest decoded image size we can support with the // current code, even on 64-bit targets, is INT_MAX. this is not a // significant limitation for the intended use case. // // we do, however, need to make sure our size calculations don't // overflow. hence a few helper functions for size calculations that // multiply integers together, making sure that they're non-negative // and no overflow occurs. // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. static int stbi__addsizes_valid(int a, int b) { if (b < 0) return 0; // now 0 <= b <= INT_MAX, hence also // 0 <= INT_MAX - b <= INTMAX. // And "a + b <= INT_MAX" (which might overflow) is the // same as a <= INT_MAX - b (no overflow) return a <= INT_MAX - b; } // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. static int stbi__mul2sizes_valid(int a, int b) { if (a < 0 || b < 0) return 0; if (b == 0) return 1; // mul-by-0 is always safe // portable way to check for no overflows in a*b return a <= INT_MAX/b; } #if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow static int stbi__mad2sizes_valid(int a, int b, int add) { return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); } #endif // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow static int stbi__mad3sizes_valid(int a, int b, int c, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__addsizes_valid(a*b*c, add); } // returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); } #endif #if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) // mallocs with size overflow checking static void *stbi__malloc_mad2(int a, int b, int add) { if (!stbi__mad2sizes_valid(a, b, add)) return NULL; return stbi__malloc(a*b + add); } #endif static void *stbi__malloc_mad3(int a, int b, int c, int add) { if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; return stbi__malloc(a*b*c + add); } #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; return stbi__malloc(a*b*c*d + add); } #endif // stbi__err - error // stbi__errpf - error returning pointer to float // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define stbi__err(x,y) stbi__err(y) #else #define stbi__err(x,y) stbi__err(x) #endif #define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load_global = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load_global = flag_true_if_should_flip; } #ifndef STBI_THREAD_LOCAL #define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global #else static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) { stbi__vertically_flip_on_load_local = flag_true_if_should_flip; stbi__vertically_flip_on_load_set = 1; } #define stbi__vertically_flip_on_load (stbi__vertically_flip_on_load_set \ ? stbi__vertically_flip_on_load_local \ : stbi__vertically_flip_on_load_global) #endif // STBI_THREAD_LOCAL static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order ri->num_channels = 0; #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNG if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_BMP if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_GIF if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PSD if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); #else STBI_NOTUSED(bpc); #endif #ifndef STBI_NO_PIC if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNM if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif #ifndef STBI_NO_TGA // test tga last because it's a crappy test! if (stbi__tga_test(s)) return stbi__tga_load(s,x,y,comp,req_comp, ri); #endif return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi_uc *reduced; reduced = (stbi_uc *) stbi__malloc(img_len); if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling STBI_FREE(orig); return reduced; } static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi__uint16 *enlarged; enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff STBI_FREE(orig); return enlarged; } static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) { int row; size_t bytes_per_row = (size_t)w * bytes_per_pixel; stbi_uc temp[2048]; stbi_uc *bytes = (stbi_uc *)image; for (row = 0; row < (h>>1); row++) { stbi_uc *row0 = bytes + row*bytes_per_row; stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; // swap row0 with row1 size_t bytes_left = bytes_per_row; while (bytes_left) { size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); memcpy(temp, row0, bytes_copy); memcpy(row0, row1, bytes_copy); memcpy(row1, temp, bytes_copy); row0 += bytes_copy; row1 += bytes_copy; bytes_left -= bytes_copy; } } } #ifndef STBI_NO_GIF static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) { int slice; int slice_size = w * h * bytes_per_pixel; stbi_uc *bytes = (stbi_uc *)image; for (slice = 0; slice < z; ++slice) { stbi__vertical_flip(bytes, w, h, bytes_per_pixel); bytes += slice_size; } } #endif static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); if (result == NULL) return NULL; if (ri.bits_per_channel != 8) { STBI_ASSERT(ri.bits_per_channel == 16); result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 8; } // @TODO: move stbi__convert_format to here if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); } return (unsigned char *) result; } static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); if (result == NULL) return NULL; if (ri.bits_per_channel != 16) { STBI_ASSERT(ri.bits_per_channel == 8); result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 16; } // @TODO: move stbi__convert_format16 to here // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); } return (stbi__uint16 *) result; } #if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); } } #endif #ifndef STBI_NO_STDIO #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); #endif #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbi__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__uint16 *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); stbi__uint16 *result; if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file_16(f,x,y,comp,req_comp); fclose(f); return result; } #endif //!STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_mem(&s,buffer,len); result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); if (stbi__vertically_flip_on_load) { stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); } return result; } #endif #ifndef STBI_NO_LINEAR static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { stbi__result_info ri; float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); if (hdr_data) stbi__float_postprocess(hdr_data,x,y,comp,req_comp); return hdr_data; } #endif data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); if (data) return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); if (!f) return stbi__errpf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_file(&s,f); return stbi__loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_LINEAR // these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } STBIDEF int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR long pos = ftell(f); int res; stbi__context s; stbi__start_file(&s,f); res = stbi__hdr_test(&s); fseek(f, pos, SEEK_SET); return res; #else STBI_NOTUSED(f); return 0; #endif } #endif // !STBI_NO_STDIO STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__hdr_test(&s); #else STBI_NOTUSED(clbk); STBI_NOTUSED(user); return 0; #endif } #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { STBI__SCAN_load=0, STBI__SCAN_type, STBI__SCAN_header }; static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static stbi_uc stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { stbi__refill_buffer(s); return *s->img_buffer++; } return 0; } #if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else stbi_inline static int stbi__at_eof(stbi__context *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } #endif #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) // nothing #else static void stbi__skip(stbi__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; return; } if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) // nothing #else static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } #endif #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) // nothing #else static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) // nothing #else static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #endif #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else static int stbi__get16le(stbi__context *s) { int z = stbi__get8(s); return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP static stbi__uint32 stbi__get32le(stbi__context *s) { stbi__uint32 z = stbi__get16le(s); return z + (stbi__get16le(s) << 16); } #endif #define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi_uc stbi__compute_y(int r, int g, int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); if (good == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) // nothing #else static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) // nothing #else static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; stbi__uint16 *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { stbi__uint16 *src = data + j * x * img_n ; stbi__uint16 *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } #endif #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output; if (!data) return NULL; output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } } if (n < comp) { for (i=0; i < x*y; ++i) { output[i*comp + n] = data[i*comp + n]/255.0f; } } STBI_FREE(data); return output; } #endif #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output; if (!data) return NULL; output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } } STBI_FREE(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder // // simple implementation // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - some SIMD kernels for common paths on targets with SSE2/NEON // - uses a lot of intermediate memory, could cache poorly #ifndef STBI_NO_JPEG // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi_uc fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi_uc values[256]; stbi_uc size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; typedef struct { stbi__context *s; stbi__huffman huff_dc[4]; stbi__huffman huff_ac[4]; stbi__uint16 dequant[4][64]; stbi__int16 fast_ac[4][1 << FAST_BITS]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi_uc *data; void *raw_data, *raw_coeff; stbi_uc *linebuf; short *coeff; // progressive only int coeff_w, coeff_h; // number of 8x8 coefficient blocks } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int progressive; int spec_start; int spec_end; int succ_high; int succ_low; int eob_run; int jfif; int app14_color_transform; // Adobe APP14 tag int rgb; int scan_n, order[4]; int restart_interval, todo; // kernels void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); } stbi__jpeg; static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0; unsigned int code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (stbi_uc) (i+1); h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi_uc) i; } } } return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { int i; for (i=0; i < (1 << FAST_BITS); ++i) { stbi_uc fast = h->fast[i]; fast_ac[i] = 0; if (fast < 255) { int rs = h->values[fast]; int run = (rs >> 4) & 15; int magbits = rs & 15; int len = h->size[fast]; if (magbits && len + magbits <= FAST_BITS) { // magnitude code followed by receive_extend code int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (~0U << magbits) + 1; // if the result is small enough, we can fit it in fast_ac table if (k >= -128 && k <= 127) fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); } } } } static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { do { unsigned int b = j->nomore ? 0 : stbi__get8(j->s); if (b == 0xff) { int c = stbi__get8(j->s); while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // bias[n] = (-1<<n) + 1 static const int stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767}; // combined JPEG 'receive' and JPEG 'extend', since baseline // always extends everything it receives. stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n) { unsigned int k; int sgn; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB k = stbi_lrot(j->code_buffer, n); STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k + (stbi__jbias[n] & ~sgn); } // get some unsigned bits stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k; } stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { unsigned int k; if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static const stbi_uc stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) { int diff,dc,k; int t; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); t = stbi__jpeg_huff_decode(j, hdc); if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); // decode AC components, see JPEG spec k = 1; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) { int diff,dc; int t; if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); if (j->succ_high == 0) { // first scan for DC coefficient, must be first memset(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc << j->succ_low); } else { // refinement scan for DC coefficient if (stbi__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) { int k; if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; if (j->eob_run) { --j->eob_run; return 1; } k = j->spec_start; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) << shift); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) j->eob_run += stbi__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) << shift); } } } while (k <= j->spec_end); } else { // refinement scan for these AC coefficients short bit = (short) (1 << j->succ_low); if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { short *p = &data[stbi__jpeg_dezigzag[k]]; if (*p != 0) if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } } else { k = j->spec_start; do { int r,s; int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) j->eob_run += stbi__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do // a run of 15 0s and then write s (which is 0), // so we don't have to do anything special here } } else { if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); // sign bit if (stbi__jpeg_get_bit(j)) s = bit; else s = -bit; } // advance by r while (k <= j->spec_end) { short *p = &data[stbi__jpeg_dezigzag[k++]]; if (*p != 0) { if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } else { if (r == 0) { *p = (short) s; break; } --r; } } } while (k <= j->spec_end); } } return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 stbi_inline static stbi_uc stbi__clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi_uc) x; } #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) * 4096) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * stbi__f2f(0.5411961f); \ t2 = p1 + p3*stbi__f2f(-1.847759065f); \ t3 = p1 + p2*stbi__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = stbi__fsh(p2+p3); \ t1 = stbi__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ t0 = t0*stbi__f2f( 0.298631336f); \ t1 = t1*stbi__f2f( 2.053119869f); \ t2 = t2*stbi__f2f( 3.072711026f); \ t3 = t3*stbi__f2f( 1.501321110f); \ p1 = p5 + p1*stbi__f2f(-0.899976223f); \ p2 = p5 + p2*stbi__f2f(-2.562915447f); \ p3 = p3*stbi__f2f(-1.961570560f); \ p4 = p4*stbi__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { int i,val[64],*v=val; stbi_uc *o; short *d = data; // columns for (i=0; i < 8; ++i,++d, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0]*4; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = stbi__clamp((x0+t3) >> 17); o[7] = stbi__clamp((x0-t3) >> 17); o[1] = stbi__clamp((x1+t2) >> 17); o[6] = stbi__clamp((x1-t2) >> 17); o[2] = stbi__clamp((x2+t1) >> 17); o[5] = stbi__clamp((x2-t1) >> 17); o[3] = stbi__clamp((x3+t0) >> 17); o[4] = stbi__clamp((x3-t0) >> 17); } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; __m128i tmp; // dot product constant: even elems=x, odd elems=y #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) // out(1) = c1[even]*x + c1[odd]*y #define dct_rot(out0,out1, x,y,c0,c1) \ __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) // out = in << 12 (in 16-bit, out 32-bit) #define dct_widen(out, in) \ __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) // wide add #define dct_wadd(out, a, b) \ __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_add_epi32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) // butterfly a/b, add bias, then shift by "s" and pack #define dct_bfly32o(out0, out1, a,b,bias,s) \ { \ __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ dct_wadd(sum, abiased, b); \ dct_wsub(dif, abiased, b); \ out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ } // 8-bit interleave step (for transposes) #define dct_interleave8(a, b) \ tmp = a; \ a = _mm_unpacklo_epi8(a, b); \ b = _mm_unpackhi_epi8(tmp, b) // 16-bit interleave step (for transposes) #define dct_interleave16(a, b) \ tmp = a; \ a = _mm_unpacklo_epi16(a, b); \ b = _mm_unpackhi_epi16(tmp, b) #define dct_pass(bias,shift) \ { \ /* even part */ \ dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ __m128i sum04 = _mm_add_epi16(row0, row4); \ __m128i dif04 = _mm_sub_epi16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ __m128i sum17 = _mm_add_epi16(row1, row7); \ __m128i sum35 = _mm_add_epi16(row3, row5); \ dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ dct_wadd(x4, y0o, y4o); \ dct_wadd(x5, y1o, y5o); \ dct_wadd(x6, y2o, y5o); \ dct_wadd(x7, y3o, y4o); \ dct_bfly32o(row0,row7, x0,x7,bias,shift); \ dct_bfly32o(row1,row6, x1,x6,bias,shift); \ dct_bfly32o(row2,row5, x2,x5,bias,shift); \ dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // rounding biases in column/row passes, see stbi__idct_block for explanation. __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); // load row0 = _mm_load_si128((const __m128i *) (data + 0*8)); row1 = _mm_load_si128((const __m128i *) (data + 1*8)); row2 = _mm_load_si128((const __m128i *) (data + 2*8)); row3 = _mm_load_si128((const __m128i *) (data + 3*8)); row4 = _mm_load_si128((const __m128i *) (data + 4*8)); row5 = _mm_load_si128((const __m128i *) (data + 5*8)); row6 = _mm_load_si128((const __m128i *) (data + 6*8)); row7 = _mm_load_si128((const __m128i *) (data + 7*8)); // column pass dct_pass(bias_0, 10); { // 16bit 8x8 transpose pass 1 dct_interleave16(row0, row4); dct_interleave16(row1, row5); dct_interleave16(row2, row6); dct_interleave16(row3, row7); // transpose pass 2 dct_interleave16(row0, row2); dct_interleave16(row1, row3); dct_interleave16(row4, row6); dct_interleave16(row5, row7); // transpose pass 3 dct_interleave16(row0, row1); dct_interleave16(row2, row3); dct_interleave16(row4, row5); dct_interleave16(row6, row7); } // row pass dct_pass(bias_1, 17); { // pack __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 __m128i p1 = _mm_packus_epi16(row2, row3); __m128i p2 = _mm_packus_epi16(row4, row5); __m128i p3 = _mm_packus_epi16(row6, row7); // 8bit 8x8 transpose pass 1 dct_interleave8(p0, p2); // a0e0a1e1... dct_interleave8(p1, p3); // c0g0c1g1... // transpose pass 2 dct_interleave8(p0, p1); // a0c0e0g0... dct_interleave8(p2, p3); // b0d0f0h0... // transpose pass 3 dct_interleave8(p0, p2); // a0b0c0d0... dct_interleave8(p1, p3); // a4b4c4d4... // store _mm_storel_epi64((__m128i *) out, p0); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p2); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p1); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p3); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); } #undef dct_const #undef dct_rot #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_interleave8 #undef dct_interleave16 #undef dct_pass } #endif // STBI_SSE2 #ifdef STBI_NEON // NEON integer IDCT. should produce bit-identical // results to the generic C version. static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) #define dct_long_mac(out, acc, inq, coeff) \ int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) #define dct_widen(out, inq) \ int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add #define dct_wadd(out, a, b) \ int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack #define dct_bfly32o(out0,out1, a,b,shiftop,s) \ { \ dct_wadd(sum, a, b); \ dct_wsub(dif, a, b); \ out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ } #define dct_pass(shiftop, shift) \ { \ /* even part */ \ int16x8_t sum26 = vaddq_s16(row2, row6); \ dct_long_mul(p1e, sum26, rot0_0); \ dct_long_mac(t2e, p1e, row6, rot0_1); \ dct_long_mac(t3e, p1e, row2, rot0_2); \ int16x8_t sum04 = vaddq_s16(row0, row4); \ int16x8_t dif04 = vsubq_s16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ int16x8_t sum15 = vaddq_s16(row1, row5); \ int16x8_t sum17 = vaddq_s16(row1, row7); \ int16x8_t sum35 = vaddq_s16(row3, row5); \ int16x8_t sum37 = vaddq_s16(row3, row7); \ int16x8_t sumodd = vaddq_s16(sum17, sum35); \ dct_long_mul(p5o, sumodd, rot1_0); \ dct_long_mac(p1o, p5o, sum17, rot1_1); \ dct_long_mac(p2o, p5o, sum35, rot1_2); \ dct_long_mul(p3o, sum37, rot2_0); \ dct_long_mul(p4o, sum15, rot2_1); \ dct_wadd(sump13o, p1o, p3o); \ dct_wadd(sump24o, p2o, p4o); \ dct_wadd(sump23o, p2o, p3o); \ dct_wadd(sump14o, p1o, p4o); \ dct_long_mac(x4, sump13o, row7, rot3_0); \ dct_long_mac(x5, sump24o, row5, rot3_1); \ dct_long_mac(x6, sump23o, row3, rot3_2); \ dct_long_mac(x7, sump14o, row1, rot3_3); \ dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ } // load row0 = vld1q_s16(data + 0*8); row1 = vld1q_s16(data + 1*8); row2 = vld1q_s16(data + 2*8); row3 = vld1q_s16(data + 3*8); row4 = vld1q_s16(data + 4*8); row5 = vld1q_s16(data + 5*8); row6 = vld1q_s16(data + 6*8); row7 = vld1q_s16(data + 7*8); // add DC bias row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); // column pass dct_pass(vrshrn_n_s32, 10); // 16bit 8x8 transpose { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. #define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } #define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } // pass 1 dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 dct_trn16(row2, row3); dct_trn16(row4, row5); dct_trn16(row6, row7); // pass 2 dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 dct_trn32(row1, row3); dct_trn32(row4, row6); dct_trn32(row5, row7); // pass 3 dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 dct_trn64(row1, row5); dct_trn64(row2, row6); dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 } // row pass // vrshrn_n_s32 only supports shifts up to 16, we need // 17. so do a non-rounding shift of 16 first then follow // up with a rounding shift by 1. dct_pass(vshrn_n_s32, 16); { // pack and round uint8x8_t p0 = vqrshrun_n_s16(row0, 1); uint8x8_t p1 = vqrshrun_n_s16(row1, 1); uint8x8_t p2 = vqrshrun_n_s16(row2, 1); uint8x8_t p3 = vqrshrun_n_s16(row3, 1); uint8x8_t p4 = vqrshrun_n_s16(row4, 1); uint8x8_t p5 = vqrshrun_n_s16(row5, 1); uint8x8_t p6 = vqrshrun_n_s16(row6, 1); uint8x8_t p7 = vqrshrun_n_s16(row7, 1); // again, these can translate into one instruction, but often don't. #define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } #define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } // sadly can't use interleaved stores here since we only write // 8 bytes to each scan line! // 8x8 8-bit transpose pass 1 dct_trn8_8(p0, p1); dct_trn8_8(p2, p3); dct_trn8_8(p4, p5); dct_trn8_8(p6, p7); // pass 2 dct_trn8_16(p0, p2); dct_trn8_16(p1, p3); dct_trn8_16(p4, p6); dct_trn8_16(p5, p7); // pass 3 dct_trn8_32(p0, p4); dct_trn8_32(p1, p5); dct_trn8_32(p2, p6); dct_trn8_32(p3, p7); // store vst1_u8(out, p0); out += out_stride; vst1_u8(out, p1); out += out_stride; vst1_u8(out, p2); out += out_stride; vst1_u8(out, p3); out += out_stride; vst1_u8(out, p4); out += out_stride; vst1_u8(out, p5); out += out_stride; vst1_u8(out, p6); out += out_stride; vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 } #undef dct_long_mul #undef dct_long_mac #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_pass } #endif // STBI_NEON #define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi_uc stbi__get_marker(stbi__jpeg *j) { stbi_uc x; if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } x = stbi__get8(j->s); if (x != 0xff) return STBI__MARKER_none; while (x == 0xff) x = stbi__get8(j->s); // consume repeated 0xff fill bytes return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction static void stbi__jpeg_reset(stbi__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { stbi__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; STBI_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } else { if (z->scan_n == 1) { int i,j; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } } static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } static void stbi__jpeg_finish(stbi__jpeg *z) { if (z->progressive) { // dequantize and idct the data int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } } } } static int stbi__process_marker(stbi__jpeg *z, int m) { int L; switch (m) { case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); case 0xDD: // DRI - specify restart interval if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; case 0xDB: // DQT - define quantization table L = stbi__get16be(z->s)-2; while (L > 0) { int q = stbi__get8(z->s); int p = q >> 4, sixteen = (p != 0); int t = q & 15,i; if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); L -= (sixteen ? 129 : 65); } return L==0; case 0xC4: // DHT - define huffman table L = stbi__get16be(z->s)-2; while (L > 0) { stbi_uc *v; int sizes[16],i,n=0; int q = stbi__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = stbi__get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = stbi__get8(z->s); if (tc != 0) stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { L = stbi__get16be(z->s); if (L < 2) { if (m == 0xFE) return stbi__err("bad COM len","Corrupt JPEG"); else return stbi__err("bad APP len","Corrupt JPEG"); } L -= 2; if (m == 0xE0 && L >= 5) { // JFIF APP0 segment static const unsigned char tag[5] = {'J','F','I','F','\0'}; int ok = 1; int i; for (i=0; i < 5; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 5; if (ok) z->jfif = 1; } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; int ok = 1; int i; for (i=0; i < 6; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 6; if (ok) { stbi__get8(z->s); // version stbi__get16be(z->s); // flags0 stbi__get16be(z->s); // flags1 z->app14_color_transform = stbi__get8(z->s); // color transform L -= 6; } } stbi__skip(z->s, L); return 1; } return stbi__err("unknown marker","Corrupt JPEG"); } // after we see SOS static int stbi__process_scan_header(stbi__jpeg *z) { int i; int Ls = stbi__get16be(z->s); z->scan_n = stbi__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = stbi__get8(z->s), which; int q = stbi__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; // no match z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; z->spec_start = stbi__get8(z->s); z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 aa = stbi__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) return stbi__err("bad SOS", "Corrupt JPEG"); } else { if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } return 1; } static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { int i; for (i=0; i < ncomp; ++i) { if (z->img_comp[i].raw_data) { STBI_FREE(z->img_comp[i].raw_data); z->img_comp[i].raw_data = NULL; z->img_comp[i].data = NULL; } if (z->img_comp[i].raw_coeff) { STBI_FREE(z->img_comp[i].raw_coeff); z->img_comp[i].raw_coeff = 0; z->img_comp[i].coeff = 0; } if (z->img_comp[i].linebuf) { STBI_FREE(z->img_comp[i].linebuf); z->img_comp[i].linebuf = NULL; } } return why; } static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static const unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define stbi__DNL(x) ((x) == 0xdc) #define stbi__SOI(x) ((x) == 0xd8) #define stbi__EOI(x) ((x) == 0xd9) #define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) #define stbi__SOS(x) ((x) == 0xda) #define stbi__SOF_progressive(x) ((x) == 0xc2) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; z->jfif = 0; z->app14_color_transform = -1; // valid values are 0,1,2 z->marker = STBI__MARKER_none; // initialize cached marker to empty m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; m = stbi__get_marker(z); while (!stbi__SOF(m)) { if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } } z->progressive = stbi__SOF_progressive(m); if (!stbi__process_frame_header(z, scan)) return 0; return 1; } // decode image to YCbCr format static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; for (m = 0; m < 4; m++) { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); while (!stbi__EOI(m)) { if (stbi__SOS(m)) { if (!stbi__process_scan_header(j)) return 0; if (!stbi__parse_entropy_coded_data(j)) return 0; if (j->marker == STBI__MARKER_none ) { // handle 0s at the end of image data from IP Kamera 9060 while (!stbi__at_eof(j->s)) { int x = stbi__get8(j->s); if (x == 255) { j->marker = stbi__get8(j->s); break; } } // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } } else if (stbi__DNL(m)) { int Ld = stbi__get16be(j->s); stbi__uint32 NL = stbi__get16be(j->s); if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); } else { if (!stbi__process_marker(j, m)) return 0; } m = stbi__get_marker(j); } if (j->progressive) stbi__jpeg_finish(j); return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi_uc *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = stbi__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = stbi__div4(n+input[i-1]); out[i*2+1] = stbi__div4(n+input[i+1]); } out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = stbi__div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i=0,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; // process groups of 8 pixels for as long as we can. // note we can't handle the last pixel in a row in this loop // because we need to handle the filter boundary conditions. for (; i < ((w-1) & ~7); i += 8) { #if defined(STBI_SSE2) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) __m128i zero = _mm_setzero_si128(); __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); __m128i farw = _mm_unpacklo_epi8(farb, zero); __m128i nearw = _mm_unpacklo_epi8(nearb, zero); __m128i diff = _mm_sub_epi16(farw, nearw); __m128i nears = _mm_slli_epi16(nearw, 2); __m128i curr = _mm_add_epi16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. __m128i prv0 = _mm_slli_si128(curr, 2); __m128i nxt0 = _mm_srli_si128(curr, 2); __m128i prev = _mm_insert_epi16(prv0, t1, 0); __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. __m128i bias = _mm_set1_epi16(8); __m128i curs = _mm_slli_epi16(curr, 2); __m128i prvd = _mm_sub_epi16(prev, curr); __m128i nxtd = _mm_sub_epi16(next, curr); __m128i curb = _mm_add_epi16(curs, bias); __m128i even = _mm_add_epi16(prvd, curb); __m128i odd = _mm_add_epi16(nxtd, curb); // interleave even and odd pixels, then undo scaling. __m128i int0 = _mm_unpacklo_epi16(even, odd); __m128i int1 = _mm_unpackhi_epi16(even, odd); __m128i de0 = _mm_srli_epi16(int0, 4); __m128i de1 = _mm_srli_epi16(int1, 4); // pack and write output __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); int16x8_t curr = vaddq_s16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. int16x8_t curs = vshlq_n_s16(curr, 2); int16x8_t prvd = vsubq_s16(prev, curr); int16x8_t nxtd = vsubq_s16(next, curr); int16x8_t even = vaddq_s16(curs, prvd); int16x8_t odd = vaddq_s16(curs, nxtd); // undo scaling and round, then store with even/odd phases interleaved uint8x8x2_t o; o.val[0] = vqrshrun_n_s16(even, 4); o.val[1] = vqrshrun_n_s16(odd, 4); vst2_u8(out + i*2, o); #endif // "previous" value for next iter t1 = 3*in_near[i+7] + in_far[i+7]; } t0 = t1; t1 = 3*in_near[i] + in_far[i]; out[i*2] = stbi__div16(3*t1 + t0 + 8); for (++i; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #endif static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #if defined(STBI_SSE2) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) { int i = 0; #ifdef STBI_SSE2 // step == 3 is pretty ugly on the final interleave, and i'm not convinced // it's useful in practice (you wouldn't use it for textures, for example). // so just accelerate step == 4 case. if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. __m128i signflip = _mm_set1_epi8(-0x80); __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); __m128i xw = _mm_set1_epi16(255); // alpha channel for (; i+7 < count; i += 8) { // load __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 // unpack to short (and left-shift cr, cb by 8) __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); // color transform __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); __m128i rws = _mm_add_epi16(cr0, yws); __m128i gwt = _mm_add_epi16(cb0, yws); __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); // descale __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); // back to byte, set up for transpose __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); // transpose to interleave channels __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); // store _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; } } #endif #ifdef STBI_NEON // in this version, step=3 support would be easy to add. but is there demand? if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); for (; i+7 < count; i += 8) { // load uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); // expand to s16 int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); // color transform int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); int16x8_t rws = vaddq_s16(yws, cr0); int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); // undo scaling, round, convert to byte uint8x8x4_t o; o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); // store, interleaving r/g/b/a vst4_u8(out, o); out += 8*4; } } #endif for (; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif // set up the kernels static void stbi__setup_jpeg(stbi__jpeg *j) { j->idct_block_kernel = stbi__idct_block; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 if (stbi__sse2_available()) { j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers static void stbi__cleanup_jpeg(stbi__jpeg *j) { stbi__free_jpeg_components(j, j->s->img_n, 0); } typedef struct { resample_row_func resample; stbi_uc *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { unsigned int t = x*y + 128; return (stbi_uc) ((t + (t >>8)) >> 8); } static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n, is_rgb; z->s->img_n = 0; // make stbi__cleanup_jpeg safe // validate req_comp if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); // load a jpeg image from whichever source, but leave in YCbCr format if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); if (z->s->img_n == 3 && n < 3 && !is_rgb) decode_n = 1; else decode_n = z->s->img_n; // resample and color-convert { int k; unsigned int i,j; stbi_uc *output; stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; stbi__resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; else r->resample = stbi__resample_row_generic; } // can't error after this so, this is safe output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi_uc *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi_uc *y = coutput[0]; if (z->s->img_n == 3) { if (is_rgb) { for (i=0; i < z->s->img_x; ++i) { out[0] = y[i]; out[1] = coutput[1][i]; out[2] = coutput[2][i]; out[3] = 255; out += n; } } else { z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else if (z->s->img_n == 4) { if (z->app14_color_transform == 0) { // CMYK for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(coutput[0][i], m); out[1] = stbi__blinn_8x8(coutput[1][i], m); out[2] = stbi__blinn_8x8(coutput[2][i], m); out[3] = 255; out += n; } } else if (z->app14_color_transform == 2) { // YCCK z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(255 - out[0], m); out[1] = stbi__blinn_8x8(255 - out[1], m); out[2] = stbi__blinn_8x8(255 - out[2], m); out += n; } } else { // YCbCr + alpha? Ignore the fourth channel for now z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { if (is_rgb) { if (n == 1) for (i=0; i < z->s->img_x; ++i) *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); else { for (i=0; i < z->s->img_x; ++i, out += 2) { out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); out[1] = 255; } } } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); out[0] = stbi__compute_y(r, g, b); out[1] = 255; out += n; } } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { for (i=0; i < z->s->img_x; ++i) { out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); out[1] = 255; out += n; } } else { stbi_uc *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } } } } stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output return output; } } static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { unsigned char* result; stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); STBI_NOTUSED(ri); j->s = s; stbi__setup_jpeg(j); result = load_jpeg_image(j, x,y,comp,req_comp); STBI_FREE(j); return result; } static int stbi__jpeg_test(stbi__context *s) { int r; stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); j->s = s; stbi__setup_jpeg(j); r = stbi__decode_jpeg_header(j, STBI__SCAN_type); stbi__rewind(s); STBI_FREE(j); return r; } static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { stbi__rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; return 1; } static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { int result; stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); j->s = s; result = stbi__jpeg_info_raw(j, x, y, comp); STBI_FREE(j); return result; } #endif // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables #define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << STBI__ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi_uc size[288]; stbi__uint16 value[288]; } stbi__zhuffman; stbi_inline static int stbi__bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int stbi__bit_reverse(int v, int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return stbi__bitreverse16(v) >> (16-bits); } static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 0, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) if (sizes[i] > (1 << i)) return stbi__err("bad sizes", "Corrupt PNG"); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { int j = stbi__bit_reverse(next_code[s],s); while (j < (1 << STBI__ZFAST_BITS)) { z->fast[j] = fastv; j += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi_uc *zbuffer, *zbuffer_end; int num_bits; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; stbi__zhuffman z_length, z_distance; } stbi__zbuf; stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { if (z->zbuffer >= z->zbuffer_end) return 0; return *z->zbuffer++; } static void stbi__fill_bits(stbi__zbuf *z) { do { STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { int b,s,k; // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = stbi__bit_reverse(a->code_buffer, 16); for (s=STBI__ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; STBI_ASSERT(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { int b,s; if (a->num_bits < 16) stbi__fill_bits(a); b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; if (b) { s = b >> 9; a->code_buffer >>= s; a->num_bits -= s; return b & 511; } return stbi__zhuffman_decode_slowpath(a, z); } static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); limit = old_limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); STBI_NOTUSED(old_limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static const int stbi__zlength_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static const int stbi__zlength_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static const int stbi__zdist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int stbi__parse_huffman_block(stbi__zbuf *a) { char *zout = a->zout; for(;;) { int z = stbi__zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes if (zout >= a->zout_end) { if (!stbi__zexpand(a, zout, 1)) return 0; zout = a->zout; } *zout++ = (char) z; } else { stbi_uc *p; int len,dist; if (z == 256) { a->zout = zout; return 1; } z -= 257; len = stbi__zlength_base[z]; if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); z = stbi__zhuffman_decode(a, &a->z_distance); if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); dist = stbi__zdist_base[z]; if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); if (zout + len > a->zout_end) { if (!stbi__zexpand(a, zout, len)) return 0; zout = a->zout; } p = (stbi_uc *) (zout - dist); if (dist == 1) { // run of one byte; common in images. stbi_uc v = *p; if (len) { do *zout++ = v; while (--len); } } else { if (len) { do *zout++ = *p++; while (--len); } } } } } static int stbi__compute_huffman_codes(stbi__zbuf *a) { static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; stbi__zhuffman z_codelength; stbi_uc lencodes[286+32+137];//padding for maximum single op stbi_uc codelength_sizes[19]; int i,n; int hlit = stbi__zreceive(a,5) + 257; int hdist = stbi__zreceive(a,5) + 1; int hclen = stbi__zreceive(a,4) + 4; int ntot = hlit + hdist; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = stbi__zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; } if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < ntot) { int c = stbi__zhuffman_decode(a, &z_codelength); if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); if (c < 16) lencodes[n++] = (stbi_uc) c; else { stbi_uc fill = 0; if (c == 16) { c = stbi__zreceive(a,2)+3; if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); fill = lencodes[n-1]; } else if (c == 17) c = stbi__zreceive(a,3)+3; else { STBI_ASSERT(c == 18); c = stbi__zreceive(a,7)+11; } if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); memset(lencodes+n, fill, c); n += c; } } if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int stbi__parse_uncompressed_block(stbi__zbuf *a) { stbi_uc header[4]; int len,nlen,k; if (a->num_bits & 7) stbi__zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check a->code_buffer >>= 8; a->num_bits -= 8; } STBI_ASSERT(a->num_bits == 0); // now fill header the normal way while (k < 4) header[k++] = stbi__zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!stbi__zexpand(a, a->zout, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int stbi__parse_zlib_header(stbi__zbuf *a) { int cmf = stbi__zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = stbi__zget8(a); if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } static const stbi_uc stbi__zdefault_length[288] = { 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 }; static const stbi_uc stbi__zdefault_distance[32] = { 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 }; /* Init algorithm: { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; } */ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { int final, type; if (parse_header) if (!stbi__parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; do { final = stbi__zreceive(a,1); type = stbi__zreceive(a,2); if (type == 0) { if (!stbi__parse_uncompressed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; } else { if (!stbi__compute_huffman_codes(a)) return 0; } if (!stbi__parse_huffman_block(a)) return 0; } } while (!final); return 1; } static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return stbi__parse_zlib(a, parse_header); } STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer+len; if (stbi__do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } #endif // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG typedef struct { stbi__uint32 length; stbi__uint32 type; } stbi__pngchunk; static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { stbi__pngchunk c; c.length = stbi__get32be(s); c.type = stbi__get32be(s); return c; } static int stbi__check_png_header(stbi__context *s) { static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); return 1; } typedef struct { stbi__context *s; stbi_uc *idata, *expanded, *out; int depth; } stbi__png; enum { STBI__F_none=0, STBI__F_sub=1, STBI__F_up=2, STBI__F_avg=3, STBI__F_paeth=4, // synthetic filters used for first scanline to avoid needing a dummy row of 0s STBI__F_avg_first, STBI__F_paeth_first }; static stbi_uc first_row_filter[5] = { STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, STBI__F_paeth_first }; static int stbi__paeth(int a, int b, int c) { int p = a + b - c; int pa = abs(p-a); int pb = abs(p-b); int pc = abs(p-c); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; // create the png data from post-deflated data static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) { int bytes = (depth == 16? 2 : 1); stbi__context *s = a->s; stbi__uint32 i,j,stride = x*out_n*bytes; stbi__uint32 img_len, img_width_bytes; int k; int img_n = s->img_n; // copy it into a local for later int output_bytes = out_n*bytes; int filter_bytes = img_n*bytes; int width = x; STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into if (!a->out) return stbi__err("outofmem", "Out of memory"); if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); img_width_bytes = (((img_n * x * depth) + 7) >> 3); img_len = (img_width_bytes + 1) * y; // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), // so just check for raw_len < img_len always. if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *prior; int filter = *raw++; if (filter > 4) return stbi__err("invalid filter","Corrupt PNG"); if (depth < 8) { STBI_ASSERT(img_width_bytes <= x); cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place filter_bytes = 1; width = img_width_bytes; } prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // handle first byte explicitly for (k=0; k < filter_bytes; ++k) { switch (filter) { case STBI__F_none : cur[k] = raw[k]; break; case STBI__F_sub : cur[k] = raw[k]; break; case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; case STBI__F_avg_first : cur[k] = raw[k]; break; case STBI__F_paeth_first: cur[k] = raw[k]; break; } } if (depth == 8) { if (img_n != out_n) cur[img_n] = 255; // first pixel raw += img_n; cur += out_n; prior += out_n; } else if (depth == 16) { if (img_n != out_n) { cur[filter_bytes] = 255; // first pixel top byte cur[filter_bytes+1] = 255; // first pixel bottom byte } raw += filter_bytes; cur += output_bytes; prior += output_bytes; } else { raw += 1; cur += 1; prior += 1; } // this is a little gross, so that we don't switch per-pixel or per-component if (depth < 8 || img_n == out_n) { int nk = (width - 1)*filter_bytes; #define STBI__CASE(f) \ case f: \ for (k=0; k < nk; ++k) switch (filter) { // "none" filter turns into a memcpy here; make that explicit. case STBI__F_none: memcpy(cur, raw, nk); break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; } #undef STBI__CASE raw += nk; } else { STBI_ASSERT(img_n+1 == out_n); #define STBI__CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ for (k=0; k < filter_bytes; ++k) switch (filter) { STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; } #undef STBI__CASE // the loop above sets the high byte of the pixels' alpha, but for // 16 bit png files we also need the low byte set. we'll do that here. if (depth == 16) { cur = a->out + stride*j; // start at the beginning of the row again for (i=0; i < x; ++i,cur+=output_bytes) { cur[filter_bytes+1] = 255; } } } } // we make a separate pass to expand bits to pixels; for performance, // this could run two scanlines behind the above code, so it won't // intefere with filtering but will still be in the cache. if (depth < 8) { for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range // note that the final byte might overshoot and write more data than desired. // we can allocate enough data that this never writes out of memory, but it // could also overwrite the next scanline. can it overwrite non-empty data // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. // so we need to explicitly clamp the final ones if (depth == 4) { for (k=x*img_n; k >= 2; k-=2, ++in) { *cur++ = scale * ((*in >> 4) ); *cur++ = scale * ((*in ) & 0x0f); } if (k > 0) *cur++ = scale * ((*in >> 4) ); } else if (depth == 2) { for (k=x*img_n; k >= 4; k-=4, ++in) { *cur++ = scale * ((*in >> 6) ); *cur++ = scale * ((*in >> 4) & 0x03); *cur++ = scale * ((*in >> 2) & 0x03); *cur++ = scale * ((*in ) & 0x03); } if (k > 0) *cur++ = scale * ((*in >> 6) ); if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); } else if (depth == 1) { for (k=x*img_n; k >= 8; k-=8, ++in) { *cur++ = scale * ((*in >> 7) ); *cur++ = scale * ((*in >> 6) & 0x01); *cur++ = scale * ((*in >> 5) & 0x01); *cur++ = scale * ((*in >> 4) & 0x01); *cur++ = scale * ((*in >> 3) & 0x01); *cur++ = scale * ((*in >> 2) & 0x01); *cur++ = scale * ((*in >> 1) & 0x01); *cur++ = scale * ((*in ) & 0x01); } if (k > 0) *cur++ = scale * ((*in >> 7) ); if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); } if (img_n != out_n) { int q; // insert alpha = 255 cur = a->out + stride*j; if (img_n == 1) { for (q=x-1; q >= 0; --q) { cur[q*2+1] = 255; cur[q*2+0] = cur[q]; } } else { STBI_ASSERT(img_n == 3); for (q=x-1; q >= 0; --q) { cur[q*4+3] = 255; cur[q*4+2] = cur[q*3+2]; cur[q*4+1] = cur[q*3+1]; cur[q*4+0] = cur[q*3+0]; } } } } } else if (depth == 16) { // force the image data from big-endian to platform-native. // this is done in a separate pass due to the decoding relying // on the data being untouched, but could probably be done // per-line during decode if care is taken. stbi_uc *cur = a->out; stbi__uint16 *cur16 = (stbi__uint16*)cur; for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { *cur16 = (cur[0] << 8) | cur[1]; } } return 1; } static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) { int bytes = (depth == 16 ? 2 : 1); int out_bytes = out_n * bytes; stbi_uc *final; int p; if (!interlaced) return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); // de-interlacing final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { STBI_FREE(final); return 0; } for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, a->out + (j*x+i)*out_bytes, out_bytes); } } STBI_FREE(a->out); image_data += img_len; image_data_len -= img_len; } } a->out = final; return 1; } static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint16 *p = (stbi__uint16*) z->out; // compute color-based transparency, assuming we've // already got 65535 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i = 0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 65535); p += 2; } } else { for (i = 0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); if (p == NULL) return stbi__err("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } STBI_FREE(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi__unpremultiply_on_load = 0; static int stbi__de_iphone_flag = 0; STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; } STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi__de_iphone_flag = flag_true_if_should_convert; } static void stbi__de_iphone(stbi__png *z) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { STBI_ASSERT(s->img_out_n == 4); if (stbi__unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi_uc a = p[3]; stbi_uc t = p[0]; if (a) { stbi_uc half = a / 2; p[0] = (p[2] * 255 + half) / a; p[1] = (p[1] * 255 + half) / a; p[2] = ( t * 255 + half) / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } #define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]={0}; stbi__uint16 tc16[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, color=0, is_iphone=0; stbi__context *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!stbi__check_png_header(s)) return 0; if (scan == STBI__SCAN_type) return 1; for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch (c.type) { case STBI__PNG_TYPE('C','g','B','I'): is_iphone = 1; stbi__skip(s, c.length); break; case STBI__PNG_TYPE('I','H','D','R'): { int comp,filter; if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); if (scan == STBI__SCAN_header) return 1; } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); // if SCAN_header, have to scan to see if we have a tRNS } break; } case STBI__PNG_TYPE('P','L','T','E'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = stbi__get8(s); palette[i*4+1] = stbi__get8(s); palette[i*4+2] = stbi__get8(s); palette[i*4+3] = 255; } break; } case STBI__PNG_TYPE('t','R','N','S'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = stbi__get8(s); } else { if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); has_trans = 1; if (z->depth == 16) { for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is } else { for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger } } break; } case STBI__PNG_TYPE('I','D','A','T'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; STBI_NOTUSED(idata_limit_old); p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); ioff += c.length; break; } case STBI__PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len, bpl; if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (scan != STBI__SCAN_load) return 1; if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); // initial guess for decoded data size to avoid unnecessary reallocs bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); if (z->expanded == NULL) return 0; // zlib should set error STBI_FREE(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; if (has_trans) { if (z->depth == 16) { if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; } else { if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; } } if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) stbi__de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) return 0; } else if (has_trans) { // non-paletted image with tRNS -> source image has (constant) alpha ++s->img_n; } STBI_FREE(z->expanded); z->expanded = NULL; // end of PNG chunk, read and skip CRC stbi__get32be(s); return 1; } default: // if critical, fail if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX PNG chunk not known"; invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); #endif return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); } stbi__skip(s, c.length); break; } // end of PNG chunk, read and skip CRC stbi__get32be(s); } } static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) { void *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { if (p->depth < 8) ri->bits_per_channel = 8; else ri->bits_per_channel = p->depth; result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { if (ri->bits_per_channel == 8) result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); else result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_n; } STBI_FREE(p->out); p->out = NULL; STBI_FREE(p->expanded); p->expanded = NULL; STBI_FREE(p->idata); p->idata = NULL; return result; } static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi__png p; p.s = s; return stbi__do_png(&p, x,y,comp,req_comp, ri); } static int stbi__png_test(stbi__context *s) { int r; r = stbi__check_png_header(s); stbi__rewind(s); return r; } static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { stbi__rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { stbi__png p; p.s = s; return stbi__png_info_raw(&p, x, y, comp); } static int stbi__png_is16(stbi__context *s) { stbi__png p; p.s = s; if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) return 0; if (p.depth != 16) { stbi__rewind(p.s); return 0; } return 1; } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP static int stbi__bmp_test_raw(stbi__context *s) { int r; int sz; if (stbi__get8(s) != 'B') return 0; if (stbi__get8(s) != 'M') return 0; stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved stbi__get32le(s); // discard data offset sz = stbi__get32le(s); r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); return r; } static int stbi__bmp_test(stbi__context *s) { int r = stbi__bmp_test_raw(s); stbi__rewind(s); return r; } // returns 0..31 for the highest set bit static int stbi__high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) { n += 16; z >>= 16; } if (z >= 0x00100) { n += 8; z >>= 8; } if (z >= 0x00010) { n += 4; z >>= 4; } if (z >= 0x00004) { n += 2; z >>= 2; } if (z >= 0x00002) { n += 1;/* >>= 1;*/ } return n; } static int stbi__bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } // extract an arbitrarily-aligned N-bit value (N=bits) // from v, and then make it 8-bits long and fractionally // extend it to full full range. static int stbi__shiftsigned(unsigned int v, int shift, int bits) { static unsigned int mul_table[9] = { 0, 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, }; static unsigned int shift_table[9] = { 0, 0,0,1,0,2,4,6,0, }; if (shift < 0) v <<= -shift; else v >>= shift; STBI_ASSERT(v < 256); v >>= (8-bits); STBI_ASSERT(bits >= 0 && bits <= 8); return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; } typedef struct { int bpp, offset, hsz; unsigned int mr,mg,mb,ma, all_a; int extra_read; } stbi__bmp_data; static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { int hsz; if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved info->offset = stbi__get32le(s); info->hsz = hsz = stbi__get32le(s); info->mr = info->mg = info->mb = info->ma = 0; info->extra_read = 14; if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = stbi__get16le(s); s->img_y = stbi__get16le(s); } else { s->img_x = stbi__get32le(s); s->img_y = stbi__get32le(s); } if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); info->bpp = stbi__get16le(s); if (hsz != 12) { int compress = stbi__get32le(s); if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); stbi__get32le(s); // discard sizeof stbi__get32le(s); // discard hres stbi__get32le(s); // discard vres stbi__get32le(s); // discard colorsused stbi__get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); } if (info->bpp == 16 || info->bpp == 32) { if (compress == 0) { if (info->bpp == 32) { info->mr = 0xffu << 16; info->mg = 0xffu << 8; info->mb = 0xffu << 0; info->ma = 0xffu << 24; info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 } else { info->mr = 31u << 10; info->mg = 31u << 5; info->mb = 31u << 0; } } else if (compress == 3) { info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->extra_read += 12; // not documented, but generated by photoshop and handled by mspaint if (info->mr == info->mg && info->mg == info->mb) { // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); } } else return stbi__errpuc("bad BMP", "bad BMP"); } } else { int i; if (hsz != 108 && hsz != 124) return stbi__errpuc("bad BMP", "bad BMP"); info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->ma = stbi__get32le(s); stbi__get32le(s); // discard color space for (i=0; i < 12; ++i) stbi__get32le(s); // discard color space parameters if (hsz == 124) { stbi__get32le(s); // discard rendering intent stbi__get32le(s); // discard offset of profile data stbi__get32le(s); // discard size of profile data stbi__get32le(s); // discard reserved } } } return (void *) 1; } static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; unsigned int mr=0,mg=0,mb=0,ma=0, all_a; stbi_uc pal[256][4]; int psize=0,i,j,width; int flip_vertically, pad, target; stbi__bmp_data info; STBI_NOTUSED(ri); info.all_a = 255; if (stbi__bmp_parse_header(s, &info) == NULL) return NULL; // error code already set flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); mr = info.mr; mg = info.mg; mb = info.mb; ma = info.ma; all_a = info.all_a; if (info.hsz == 12) { if (info.bpp < 24) psize = (info.offset - info.extra_read - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - info.extra_read - info.hsz) >> 2; } if (psize == 0) { STBI_ASSERT(info.offset == (s->img_buffer - s->buffer_start)); } if (info.bpp == 24 && ma == 0xff000000) s->img_n = 3; else s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert // sanity-check size if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "Corrupt BMP"); out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (info.bpp < 16) { int z=0; if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); if (info.hsz != 12) stbi__get8(s); pal[i][3] = 255; } stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); if (info.bpp == 1) width = (s->img_x + 7) >> 3; else if (info.bpp == 4) width = (s->img_x + 1) >> 1; else if (info.bpp == 8) width = s->img_x; else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; if (info.bpp == 1) { for (j=0; j < (int) s->img_y; ++j) { int bit_offset = 7, v = stbi__get8(s); for (i=0; i < (int) s->img_x; ++i) { int color = (v>>bit_offset)&0x1; out[z++] = pal[color][0]; out[z++] = pal[color][1]; out[z++] = pal[color][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; if((--bit_offset) < 0) { bit_offset = 7; v = stbi__get8(s); } } stbi__skip(s, pad); } } else { for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=stbi__get8(s),v2=0; if (info.bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (info.bpp == 8) ? stbi__get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } stbi__skip(s, pad); } } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; stbi__skip(s, info.offset - info.extra_read - info.hsz); if (info.bpp == 24) width = 3 * s->img_x; else if (info.bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (info.bpp == 24) { easy = 1; } else if (info.bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { unsigned char a; out[z+2] = stbi__get8(s); out[z+1] = stbi__get8(s); out[z+0] = stbi__get8(s); z += 3; a = (easy == 2 ? stbi__get8(s) : 255); all_a |= a; if (target == 4) out[z++] = a; } } else { int bpp = info.bpp; for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); unsigned int a; out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); all_a |= a; if (target == 4) out[z++] = STBI__BYTECAST(a); } } stbi__skip(s, pad); } } // if alpha channel is all 0s, replace with all 255s if (target == 4 && all_a == 0) for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) out[i] = 255; if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i]; p1[i] = p2[i]; p2[i] = t; } } } if (req_comp && req_comp != target) { out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } #endif // Targa Truevision - TGA // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if (is_rgb16) *is_rgb16 = 0; switch(bits_per_pixel) { case 8: return STBI_grey; case 16: if(is_grey) return STBI_grey_alpha; // fallthrough case 15: if(is_rgb16) *is_rgb16 = 1; return STBI_rgb; case 24: // fallthrough case 32: return bits_per_pixel/8; default: return 0; } } static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; int sz, tga_colormap_type; stbi__get8(s); // discard Offset tga_colormap_type = stbi__get8(s); // colormap type if( tga_colormap_type > 1 ) { stbi__rewind(s); return 0; // only RGB or indexed allowed } tga_image_type = stbi__get8(s); // image type if ( tga_colormap_type == 1 ) { // colormapped (paletted) image if (tga_image_type != 1 && tga_image_type != 9) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip image x and y origin tga_colormap_bpp = sz; } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { stbi__rewind(s); return 0; // only RGB or grey allowed, +/- RLE } stbi__skip(s,9); // skip colormap specification and image x/y origin tga_colormap_bpp = 0; } tga_w = stbi__get16le(s); if( tga_w < 1 ) { stbi__rewind(s); return 0; // test width } tga_h = stbi__get16le(s); if( tga_h < 1 ) { stbi__rewind(s); return 0; // test height } tga_bits_per_pixel = stbi__get8(s); // bits per pixel stbi__get8(s); // ignore alpha bits if (tga_colormap_bpp != 0) { if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { // when using a colormap, tga_bits_per_pixel is the size of the indexes // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); } else { tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); } if(!tga_comp) { stbi__rewind(s); return 0; } if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp; return 1; // seems to have passed everything } static int stbi__tga_test(stbi__context *s) { int res = 0; int sz, tga_color_type; stbi__get8(s); // discard Offset tga_color_type = stbi__get8(s); // color type if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed sz = stbi__get8(s); // image type if ( tga_color_type == 1 ) { // colormapped (paletted) image if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; stbi__skip(s,4); // skip image x and y origin } else { // "normal" image w/o colormap if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE stbi__skip(s,9); // skip colormap specification and image x/y origin } if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height sz = stbi__get8(s); // bits per pixel if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; res = 1; // if we got this far, everything's good and we can return 1 instead of 0 errorEnd: stbi__rewind(s); return res; } // read 16bit value and convert to 24bit RGB static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) { stbi__uint16 px = (stbi__uint16)stbi__get16le(s); stbi__uint16 fiveBitMask = 31; // we have 3 channels with 5bits each int r = (px >> 10) & fiveBitMask; int g = (px >> 5) & fiveBitMask; int b = px & fiveBitMask; // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later out[0] = (stbi_uc)((r * 255)/31); out[1] = (stbi_uc)((g * 255)/31); out[2] = (stbi_uc)((b * 255)/31); // some people claim that the most significant bit might be used for alpha // (possibly if an alpha-bit is set in the "image descriptor byte") // but that only made 16bit test images completely translucent.. // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { // read in the TGA header stuff int tga_offset = stbi__get8(s); int tga_indexed = stbi__get8(s); int tga_image_type = stbi__get8(s); int tga_is_RLE = 0; int tga_palette_start = stbi__get16le(s); int tga_palette_len = stbi__get16le(s); int tga_palette_bits = stbi__get8(s); int tga_x_origin = stbi__get16le(s); int tga_y_origin = stbi__get16le(s); int tga_width = stbi__get16le(s); int tga_height = stbi__get16le(s); int tga_bits_per_pixel = stbi__get8(s); int tga_comp, tga_rgb16=0; int tga_inverted = stbi__get8(s); // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4] = {0}; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; STBI_NOTUSED(ri); STBI_NOTUSED(tga_x_origin); // @TODO STBI_NOTUSED(tga_y_origin); // @TODO // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } tga_inverted = 1 - ((tga_inverted >> 5) & 1); // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) return stbi__errpuc("too large", "Corrupt TGA"); tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) stbi__skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { for (i=0; i < tga_height; ++i) { int row = tga_inverted ? tga_height -i - 1 : i; stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { // any data to skip? (offset usually = 0) stbi__skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); if (!tga_palette) { STBI_FREE(tga_data); return stbi__errpuc("outofmem", "Out of memory"); } if (tga_rgb16) { stbi_uc *pal_entry = tga_palette; STBI_ASSERT(tga_comp == STBI_rgb); for (i=0; i < tga_palette_len; ++i) { stbi__tga_read_rgb16(s, pal_entry); pal_entry += tga_comp; } } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { STBI_FREE(tga_data); STBI_FREE(tga_palette); return stbi__errpuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = stbi__get8(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in index, then perform the lookup int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_comp; for (j = 0; j < tga_comp; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else if(tga_rgb16) { STBI_ASSERT(tga_comp == STBI_rgb); stbi__tga_read_rgb16(s, raw_data); } else { // read in the data raw for (j = 0; j < tga_comp; ++j) { raw_data[j] = stbi__get8(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * tga_comp; int index2 = (tga_height - 1 - j) * tga_width * tga_comp; for (i = tga_width * tga_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { STBI_FREE( tga_palette ); } } // swap RGB - if the source data was RGB16, it already is in the right order if (tga_comp >= 3 && !tga_rgb16) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; STBI_NOTUSED(tga_palette_start); // OK, done return tga_data; } #endif // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s) { int r = (stbi__get32be(s) == 0x38425053); stbi__rewind(s); return r; } static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { int count, nleft, len; count = 0; while ((nleft = pixelCount - count) > 0) { len = stbi__get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; if (len > nleft) return 0; // corrupt data count += len; while (len) { *p = stbi__get8(s); p += 4; len--; } } else if (len > 128) { stbi_uc val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len = 257 - len; if (len > nleft) return 0; // corrupt data val = stbi__get8(s); count += len; while (len) { *p = val; p += 4; len--; } } } return 1; } static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { int pixelCount; int channelCount, compression; int channel, i; int bitdepth; int w,h; stbi_uc *out; STBI_NOTUSED(ri); // Check identifier if (stbi__get32be(s) != 0x38425053) // "8BPS" return stbi__errpuc("not PSD", "Corrupt PSD image"); // Check file type version. if (stbi__get16be(s) != 1) return stbi__errpuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. stbi__skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = stbi__get32be(s); w = stbi__get32be(s); // Make sure the depth is 8 bits. bitdepth = stbi__get16be(s); if (bitdepth != 8 && bitdepth != 16) return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (stbi__get16be(s) != 3) return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) stbi__skip(s,stbi__get32be(s) ); // Skip the image resources. (resolution, pen tool paths, etc) stbi__skip(s, stbi__get32be(s) ); // Skip the reserved data. stbi__skip(s, stbi__get32be(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = stbi__get16be(s); if (compression > 1) return stbi__errpuc("bad compression", "PSD has an unknown compression format"); // Check size if (!stbi__mad3sizes_valid(4, w, h, 0)) return stbi__errpuc("too large", "Corrupt PSD"); // Create the destination image. if (!compression && bitdepth == 16 && bpc == 16) { out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); ri->bits_per_channel = 16; } else out = (stbi_uc *) stbi__malloc(4 * w*h); if (!out) return stbi__errpuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++, p += 4) *p = (channel == 3 ? 255 : 0); } else { // Read the RLE data. if (!stbi__psd_decode_rle(s, p, pixelCount)) { STBI_FREE(out); return stbi__errpuc("corrupt", "bad RLE data"); } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { if (channel >= channelCount) { // Fill this channel with default data. if (bitdepth == 16 && bpc == 16) { stbi__uint16 *q = ((stbi__uint16 *) out) + channel; stbi__uint16 val = channel == 3 ? 65535 : 0; for (i = 0; i < pixelCount; i++, q += 4) *q = val; } else { stbi_uc *p = out+channel; stbi_uc val = channel == 3 ? 255 : 0; for (i = 0; i < pixelCount; i++, p += 4) *p = val; } } else { if (ri->bits_per_channel == 16) { // output bpc stbi__uint16 *q = ((stbi__uint16 *) out) + channel; for (i = 0; i < pixelCount; i++, q += 4) *q = (stbi__uint16) stbi__get16be(s); } else { stbi_uc *p = out+channel; if (bitdepth == 16) { // input bpc for (i = 0; i < pixelCount; i++, p += 4) *p = (stbi_uc) (stbi__get16be(s) >> 8); } else { for (i = 0; i < pixelCount; i++, p += 4) *p = stbi__get8(s); } } } } } // remove weird white matte from PSD if (channelCount >= 4) { if (ri->bits_per_channel == 16) { for (i=0; i < w*h; ++i) { stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; if (pixel[3] != 0 && pixel[3] != 65535) { float a = pixel[3] / 65535.0f; float ra = 1.0f / a; float inv_a = 65535.0f * (1 - ra); pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); } } } else { for (i=0; i < w*h; ++i) { unsigned char *pixel = out + 4*i; if (pixel[3] != 0 && pixel[3] != 255) { float a = pixel[3] / 255.0f; float ra = 1.0f / a; float inv_a = 255.0f * (1 - ra); pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); } } } } // convert to desired output format if (req_comp && req_comp != 4) { if (ri->bits_per_channel == 16) out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); else out = stbi__convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // stbi__convert_format frees input on failure } if (comp) *comp = 4; *y = h; *x = w; return out; } #endif // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC static int stbi__pic_is4(stbi__context *s,const char *str) { int i; for (i=0; i<4; ++i) if (stbi__get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int stbi__pic_test_core(stbi__context *s) { int i; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) stbi__get8(s); if (!stbi__pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } stbi__pic_packet; static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); dest[i]=stbi__get8(s); } } return dest; } static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return stbi__errpuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; y<height; ++y) { int packet_idx; for(packet_idx=0; packet_idx < num_packets; ++packet_idx) { stbi__pic_packet *packet = &packets[packet_idx]; stbi_uc *dest = result+y*width*4; switch (packet->type) { default: return stbi__errpuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;x<width;++x, dest+=4) if (!stbi__readval(s,packet->channel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=stbi__get8(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi_uc) left; if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0; i<count; ++i,dest+=4) stbi__copyval(packet->channel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = stbi__get8(s), i; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; if (count==128) count = stbi__get16be(s); else count -= 127; if (count > left) return stbi__errpuc("bad file","scanline overrun"); if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0;i<count;++i, dest += 4) stbi__copyval(packet->channel,dest,value); } else { // Raw ++count; if (count>left) return stbi__errpuc("bad file","scanline overrun"); for(i=0;i<count;++i, dest+=4) if (!stbi__readval(s,packet->channel,dest)) return 0; } left-=count; } break; } } } } return result; } static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) { stbi_uc *result; int i, x,y, internal_comp; STBI_NOTUSED(ri); if (!comp) comp = &internal_comp; for (i=0; i<92; ++i) stbi__get8(s); x = stbi__get16be(s); y = stbi__get16be(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); stbi__get32be(s); //skip `ratio' stbi__get16be(s); //skip `fields' stbi__get16be(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); memset(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=stbi__convert_format(result,4,req_comp,x,y); return result; } static int stbi__pic_test(stbi__context *s) { int r = stbi__pic_test_core(s); stbi__rewind(s); return r; } #endif // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF typedef struct { stbi__int16 prefix; stbi_uc first; stbi_uc suffix; } stbi__gif_lzw; typedef struct { int w,h; stbi_uc *out; // output buffer (always 4 components) stbi_uc *background; // The current "background" as far as a gif is concerned stbi_uc *history; int flags, bgindex, ratio, transparent, eflags; stbi_uc pal[256][4]; stbi_uc lpal[256][4]; stbi__gif_lzw codes[8192]; stbi_uc *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; int delay; } stbi__gif; static int stbi__gif_test_raw(stbi__context *s) { int sz; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; sz = stbi__get8(s); if (sz != '9' && sz != '7') return 0; if (stbi__get8(s) != 'a') return 0; return 1; } static int stbi__gif_test(stbi__context *s) { int r = stbi__gif_test_raw(s); stbi__rewind(s); return r; } static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); pal[i][3] = transp == i ? 0 : 255; } } static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return stbi__err("not GIF", "Corrupt GIF"); version = stbi__get8(s); if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); stbi__g_failure_reason = ""; g->w = stbi__get16le(s); g->h = stbi__get16le(s); g->flags = stbi__get8(s); g->bgindex = stbi__get8(s); g->ratio = stbi__get8(s); g->transparent = -1; if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); if (!stbi__gif_header(s, g, comp, 1)) { STBI_FREE(g); stbi__rewind( s ); return 0; } if (x) *x = g->w; if (y) *y = g->h; STBI_FREE(g); return 1; } static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { stbi_uc *p, *c; int idx; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi__out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; idx = g->cur_x + g->cur_y; p = &g->out[idx]; g->history[idx / 4] = 1; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] > 128) { // don't render transparent pixels; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { stbi_uc lzw_cs; stbi__int32 len, init_code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi__gif_lzw *p; lzw_cs = stbi__get8(s); if (lzw_cs > 12) return NULL; clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (init_code = 0; init_code < clear; init_code++) { g->codes[init_code].prefix = -1; g->codes[init_code].first = (stbi_uc) init_code; g->codes[init_code].suffix = (stbi_uc) init_code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = stbi__get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; } else if (code <= avail) { if (first) { return stbi__errpuc("no clear code", "Corrupt GIF"); } if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 8192) { return stbi__errpuc("too many codes", "Corrupt GIF"); } p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); stbi__out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } } } } // this function is designed to support animated gifs, although stb_image doesn't support it // two back is the image from two frames ago, used for a very specific disposal format static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) { int dispose; int first_frame; int pi; int pcount; STBI_NOTUSED(req_comp); // on first frame, any non-written pixels get the background colour (non-transparent) first_frame = 0; if (g->out == 0) { if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) return stbi__errpuc("too large", "GIF image is too large"); pcount = g->w * g->h; g->out = (stbi_uc *) stbi__malloc(4 * pcount); g->background = (stbi_uc *) stbi__malloc(4 * pcount); g->history = (stbi_uc *) stbi__malloc(pcount); if (!g->out || !g->background || !g->history) return stbi__errpuc("outofmem", "Out of memory"); // image is treated as "transparent" at the start - ie, nothing overwrites the current background; // background colour is only used for pixels that are not rendered first frame, after that "background" // color refers to the color that was there the previous frame. memset(g->out, 0x00, 4 * pcount); memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) memset(g->history, 0x00, pcount); // pixels that were affected previous frame first_frame = 1; } else { // second frame - how do we dispoase of the previous one? dispose = (g->eflags & 0x1C) >> 2; pcount = g->w * g->h; if ((dispose == 3) && (two_back == 0)) { dispose = 2; // if I don't have an image to revert back to, default to the old background } if (dispose == 3) { // use previous graphic for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); } } } else if (dispose == 2) { // restore what was changed last frame to background before that frame; for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); } } } else { // This is a non-disposal case eithe way, so just // leave the pixels as is, and they will become the new background // 1: do not dispose // 0: not specified. } // background is what out is after the undoing of the previou frame; memcpy( g->background, g->out, 4 * g->w * g->h ); } // clear my history; memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame for (;;) { int tag = stbi__get8(s); switch (tag) { case 0x2C: /* Image Descriptor */ { stbi__int32 x, y, w, h; stbi_uc *o; x = stbi__get16le(s); y = stbi__get16le(s); w = stbi__get16le(s); h = stbi__get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; // if the width of the specified rectangle is 0, that means // we may not see *any* pixels or the image is malformed; // to make sure this is caught, move the current y down to // max_y (which is what out_gif_code checks). if (w == 0) g->cur_y = g->max_y; g->lflags = stbi__get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi_uc *) g->lpal; } else if (g->flags & 0x80) { g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); o = stbi__process_gif_raster(s, g); if (!o) return NULL; // if this was the first frame, pcount = g->w * g->h; if (first_frame && (g->bgindex > 0)) { // if first frame, any pixel not drawn to gets the background color for (pi = 0; pi < pcount; ++pi) { if (g->history[pi] == 0) { g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); } } } return o; } case 0x21: // Comment Extension. { int len; int ext = stbi__get8(s); if (ext == 0xF9) { // Graphic Control Extension. len = stbi__get8(s); if (len == 4) { g->eflags = stbi__get8(s); g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. // unset old transparent if (g->transparent >= 0) { g->pal[g->transparent][3] = 255; } if (g->eflags & 0x01) { g->transparent = stbi__get8(s); if (g->transparent >= 0) { g->pal[g->transparent][3] = 0; } } else { // don't need transparent stbi__skip(s, 1); g->transparent = -1; } } else { stbi__skip(s, len); break; } } while ((len = stbi__get8(s)) != 0) { stbi__skip(s, len); } break; } case 0x3B: // gif stream termination code return (stbi_uc *) s; // using '1' causes warning on some compilers default: return stbi__errpuc("unknown code", "Corrupt GIF"); } } } static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { if (stbi__gif_test(s)) { int layers = 0; stbi_uc *u = 0; stbi_uc *out = 0; stbi_uc *two_back = 0; stbi__gif g; int stride; memset(&g, 0, sizeof(g)); if (delays) { *delays = 0; } do { u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; ++layers; stride = g.w * g.h * 4; if (out) { void *tmp = (stbi_uc*) STBI_REALLOC( out, layers * stride ); if (NULL == tmp) { STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); return stbi__errpuc("outofmem", "Out of memory"); } else out = (stbi_uc*) tmp; if (delays) { *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); } } else { out = (stbi_uc*)stbi__malloc( layers * stride ); if (delays) { *delays = (int*) stbi__malloc( layers * sizeof(int) ); } } memcpy( out + ((layers - 1) * stride), u, stride ); if (layers >= 2) { two_back = out - 2 * stride; } if (delays) { (*delays)[layers - 1U] = g.delay; } } } while (u != 0); // free temp buffer; STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); // do the final conversion after loading everything; if (req_comp && req_comp != 4) out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); *z = layers; return out; } else { return stbi__errpuc("not GIF", "Image was not as a gif type."); } } static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif g; memset(&g, 0, sizeof(g)); STBI_NOTUSED(ri); u = stbi__gif_load_next(s, &g, comp, req_comp, 0); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; // moved conversion to after successful load so that the same // can be done for multiple frames. if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g.w, g.h); } else if (g.out) { // if there was an error and we allocated an image buffer, free it! STBI_FREE(g.out); } // free buffers needed for multiple frame loading; STBI_FREE(g.history); STBI_FREE(g.background); return u; } static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { return stbi__gif_info_raw(s,x,y,comp); } #endif // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int stbi__hdr_test_core(stbi__context *s, const char *signature) { int i; for (i=0; signature[i]; ++i) if (stbi__get8(s) != signature[i]) return 0; stbi__rewind(s); return 1; } static int stbi__hdr_test(stbi__context* s) { int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); stbi__rewind(s); if(!r) { r = stbi__hdr_test_core(s, "#?RGBE\n"); stbi__rewind(s); } return r; } #define STBI__HDR_BUFLEN 1024 static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { int len=0; char c = '\0'; c = (char) stbi__get8(z); while (!stbi__at_eof(z) && c != '\n') { buffer[len++] = c; if (len == STBI__HDR_BUFLEN-1) { // flush to end of line while (!stbi__at_eof(z) && stbi__get8(z) != '\n') ; break; } c = (char) stbi__get8(z); } buffer[len] = 0; return buffer; } static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; const char *headerToken; STBI_NOTUSED(ri); // Check identifier headerToken = stbi__hdr_gettoken(s,buffer); if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) return stbi__errpf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); *x = width; *y = height; if (comp) *comp = 3; if (req_comp == 0) req_comp = 3; if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) return stbi__errpf("too large", "HDR image is too large"); // Read data hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); if (!hdr_data) return stbi__errpf("outofmem", "Out of memory"); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: stbi__getn(s, rgbe, 4); stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = stbi__get8(s); c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi_uc rgbe[4]; rgbe[0] = (stbi_uc) c1; rgbe[1] = (stbi_uc) c2; rgbe[2] = (stbi_uc) len; rgbe[3] = (stbi_uc) stbi__get8(s); stbi__hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; STBI_FREE(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= stbi__get8(s); if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) { scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); if (!scanline) { STBI_FREE(hdr_data); return stbi__errpf("outofmem", "Out of memory"); } } for (k = 0; k < 4; ++k) { int nleft; i = 0; while ((nleft = width - i) > 0) { count = stbi__get8(s); if (count > 128) { // Run value = stbi__get8(s); count -= 128; if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = stbi__get8(s); } } } for (i=0; i < width; ++i) stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } if (scanline) STBI_FREE(scanline); } return hdr_data; } static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int dummy; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__hdr_test(s) == 0) { stbi__rewind( s ); return 0; } for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi__rewind( s ); return 0; } token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi__rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi__rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { void *p; stbi__bmp_data info; info.all_a = 255; p = stbi__bmp_parse_header(s, &info); stbi__rewind( s ); if (p == NULL) return 0; if (x) *x = s->img_x; if (y) *y = s->img_y; if (comp) { if (info.bpp == 24 && info.ma == 0xff000000) *comp = 3; else *comp = info.ma ? 4 : 3; } return 1; } #endif #ifndef STBI_NO_PSD static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { int channelCount, dummy, depth; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } *y = stbi__get32be(s); *x = stbi__get32be(s); depth = stbi__get16be(s); if (depth != 8 && depth != 16) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 3) { stbi__rewind( s ); return 0; } *comp = 4; return 1; } static int stbi__psd_is16(stbi__context *s) { int channelCount, depth; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } (void) stbi__get32be(s); (void) stbi__get32be(s); depth = stbi__get16be(s); if (depth != 16) { stbi__rewind( s ); return 0; } return 1; } #endif #ifndef STBI_NO_PIC static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained,dummy; stbi__pic_packet packets[10]; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { stbi__rewind(s); return 0; } stbi__skip(s, 88); *x = stbi__get16be(s); *y = stbi__get16be(s); if (stbi__at_eof(s)) { stbi__rewind( s); return 0; } if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi__rewind( s ); return 0; } stbi__skip(s, 8); do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) { stbi__rewind( s ); return 0; } if (packet->size != 8) { stbi__rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } #endif // ************************************************************************************************* // Portable Gray Map and Portable Pixel Map loader // by Ken Miller // // PGM: http://netpbm.sourceforge.net/doc/pgm.html // PPM: http://netpbm.sourceforge.net/doc/ppm.html // // Known limitations: // Does not support comments in the header section // Does not support ASCII image data (formats P2 and P3) // Does not support 16-bit-per-channel #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s) { char p, t; p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } return 1; } static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; STBI_NOTUSED(ri); if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) return 0; *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "PNM too large"); out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); stbi__getn(s, out, s->img_n * s->img_x * s->img_y); if (req_comp && req_comp != s->img_n) { out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } return out; } static int stbi__pnm_isspace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { for (;;) { while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) *c = (char) stbi__get8(s); if (stbi__at_eof(s) || *c != '#') break; while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) *c = (char) stbi__get8(s); } } static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } static int stbi__pnm_getinteger(stbi__context *s, char *c) { int value = 0; while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { value = value*10 + (*c - '0'); *c = (char) stbi__get8(s); } return value; } static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { int maxv, dummy; char c, p, t; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; stbi__rewind(s); // Get identifier p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind(s); return 0; } *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm c = (char) stbi__get8(s); stbi__pnm_skip_whitespace(s, &c); *x = stbi__pnm_getinteger(s, &c); // read width stbi__pnm_skip_whitespace(s, &c); *y = stbi__pnm_getinteger(s, &c); // read height stbi__pnm_skip_whitespace(s, &c); maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 255) return stbi__err("max value > 255", "PPM image not 8-bit"); else return 1; } #endif static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); } static int stbi__is_16_main(stbi__context *s) { #ifndef STBI_NO_PNG if (stbi__png_is16(s)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_is16(s)) return 1; #endif return 0; } #ifndef STBI_NO_STDIO STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } STBIDEF int stbi_is_16_bit(char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_is_16_bit_from_file(f); fclose(f); return result; } STBIDEF int stbi_is_16_bit_from_file(FILE *f) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__is_16_main(&s); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__is_16_main(&s); } STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__is_16_main(&s); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug 1-bit BMP *_is_16_bit api avoid warnings 2.16 (2017-07-23) all functions have 16-bit variants; STBI_NO_STDIO works again; compilation fixes; fix rounding in unpremultiply; optimize vertical flip; disable raw_len validation; documentation fixes 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; warning fixes; disable run-time SSE detection on gcc; uniform handling of optional "return" values; thread-safe initialization of zlib tables 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) allocate large structures on the stack remove white matting for transparent PSD fix reported channel count for PNG & BMP re-enable SSE2 in non-gcc 64-bit support RGB-formatted JPEG read 16-bit PNGs (only as 8-bit) 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED 2.09 (2016-01-16) allow comments in PNM files 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse can use STBI_REALLOC_SIZED if allocator doesn't support realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) extra corruption checking (mmozeiko) stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 1.42 (2014-07-09) don't define _CRT_SECURE_NO_WARNINGS (affects user code) fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) fix search&replace from 1.36 that messed up comments/error messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 (2014-06-15) fix to TGA optimization when req_comp != number of components in TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) add support for BMP version 5 (more ignored fields) 1.38 (2014-06-06) suppress MSVC warnings on integer casts truncating values fix accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate typedef 1.36 (2014-06-03) convert to header file single-file library if de-iphone isn't set, load iphone images color-swapped instead of returning NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - stbi__convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 (2006-11-19) first released version */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett 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. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. ------------------------------------------------------------------------------ */
[ "filip.masar99@gmail.com" ]
filip.masar99@gmail.com
4c961332596e4a815b91cd4088b4c74119bd11f7
ac3dc6a3ce54f91d9f7a5361c76c7e0200e84b82
/OS_experiment/prj2/step3/start_code/include/os/sched.h
9146b6bf37399fdf03d05751dcfaf817c5a20001
[]
no_license
liuxianglong17/C_homework
7d96ad232bbd8277237888f6aa928202df1bce02
6a3ff6d86194aed16421ee1b1fcb33eb6392809a
refs/heads/master
2022-07-19T00:29:21.109352
2020-05-17T16:12:04
2020-05-17T16:12:04
null
0
0
null
null
null
null
UTF-8
C
false
false
4,070
h
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2018 Institute of Computing Technology, CAS * Author : Han Shukai (email : hanshukai@ict.ac.cn) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Process scheduling related content, such as: scheduler, process blocking, * process wakeup, process creation, process kill, etc. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef INCLUDE_SCHEDULER_H_ #define INCLUDE_SCHEDULER_H_ #include "type.h" #include "queue.h" #define NUM_MAX_TASK 16 #define STACK_TOP 0xa0f00000 #define STACK_SIZE 0x4000 //2KB // define about kseg1 #define LOWER_BOUND 0xa0000000 #define UPPER_BOUND 0xbfffffff #define NUM_MUTEX_LOCK 1 // number of mutex_lock /* used to save register infomation */ typedef struct regs_context { /* Saved main processor registers.*/ /* 32 * 4B = 128B */ uint32_t regs[32]; /* Saved special registers. */ /* 7 * 4B = 28B */ uint32_t cp0_status; uint32_t hi; uint32_t lo; uint32_t cp0_badvaddr; uint32_t cp0_cause; uint32_t cp0_epc; uint32_t pc; } regs_context_t; /* 128 + 28 = 156B */ typedef enum { TASK_BLOCKED, TASK_RUNNING, TASK_READY, TASK_EXITED, } task_status_t; typedef enum { KERNEL_PROCESS, KERNEL_THREAD, USER_PROCESS, USER_THREAD, } task_type_t; typedef enum { P1, P2, P3, } priority_t; /* Process Control Block */ typedef struct pcb { /* register context */ regs_context_t kernel_context; regs_context_t user_context; uint32_t kernel_stack_top; uint32_t user_stack_top; /* previous, next pointer */ void *prev;//this is a part of linklist of PCBs void *next; /* process id */ pid_t pid; /* kernel/user thread/process */ task_type_t type; /* BLOCK | READY | RUNNING */ task_status_t status; /* cursor position */ int cursor_x; int cursor_y; int first_running; //uint32_t lock_address[NUM_MUTEX_LOCK]; // the address of lock which the process acquired //uint32_t lock_address; priority_t priority; } pcb_t; /* task information, used to init PCB */ typedef struct task_info { uint32_t entry_point; task_type_t type; } task_info_t; /* ready queue to run */ extern queue_t ready_queue; /* block queue to wait */ extern queue_t block_queue; /* current running task PCB */ extern pcb_t *current_running; extern pid_t process_id; extern pcb_t pcb[NUM_MAX_TASK];//task array extern uint32_t initial_cp0_status; void do_scheduler(void); void do_sleep(uint32_t); void do_block(queue_t *); void do_unblock_one(queue_t *); void do_unblock_all(queue_t *); // void unblock(void); // void ready_queue_push(pcb_t * pcb); #endif
[ "we980127@gmail.com" ]
we980127@gmail.com
508d1d776089071dedbd324f753f20377f0c3a45
084d61e99b9901563d2da06204dce50b7e1826be
/array lab-sheet3 1.sum,product,avg,max.c
fc51247f3a9cefa8a183dcb67fef4a9f47882c6b
[]
no_license
subash9860/c-programming
3dcf57bbc6046b3760a3ec0174c66267f72be041
45c92860d12e541587da07ec66c4f43decb3f378
refs/heads/master
2021-01-02T00:11:10.288839
2020-03-16T13:48:09
2020-03-16T13:48:09
239,404,751
0
0
null
null
null
null
UTF-8
C
false
false
529
c
/*1.Write a program that asks user to enter 10 numbers, read them into an array and finds the sum, product, average and maximum of all numbers and prints them. */ #include<stdio.h> int main() { int n[10],i,sum=0,p=1,max; float avg; printf("enter the numbers:\n"); for(i=1;i<=10;i++) { scanf("%d",&n[i]); sum=sum+n[i]; p=p*i; } avg=(float)sum/10; max=n[1]; for(i=1;i<=10;i++) { if(n[i]>max) max=n[i]; } printf("sum=%d\nproduct=%d\naverage=%f\n max=%d",sum,p,avg,max); }
[ "noreply@github.com" ]
subash9860.noreply@github.com
379d1f78ee19974e8d92b004138d5f730717ffdb
ce6dc33bfee278cd96302a1a22a3b41df281fb87
/marathon/race02/src/mx_resultPrinting.c
70aa0664128ae6910f7305910d0d8ee66a2bb739
[]
no_license
EricGolovin/Marathon-C
2c18f1b81619fd862e3e6ec4450397e3917049b4
b64fcd9643f85aaca2accc6b07e5e441b3e0e2ec
refs/heads/master
2020-09-11T23:11:15.611418
2020-02-04T23:52:34
2020-02-04T23:52:34
222,221,302
2
0
null
null
null
null
UTF-8
C
false
false
271
c
#include "../inc/header.h" void mx_resultPrinting(int val1, int val2, char operation, int result) { mx_printint(val1); mx_printchar(' '); mx_printchar(operation); mx_printchar(' '); mx_printint(val2); mx_printchar(' '); mx_printint(result); mx_printchar('\n'); }
[ "ericgolovin@outlook.com" ]
ericgolovin@outlook.com
89357b77b41057afe9cf56bb565d39d5c55e1388
7413c4758b71d0cfe42dc00873036b1fc8cb3a1a
/mtcp/src/include/tcp_ring_buffer.h
70727e4c471bb239913250b3e3e8f80444846ae3
[ "BSD-3-Clause" ]
permissive
yoannd/mtcp
c310f689bf2b2bee62832afbf2f1c234ddc7a8ae
19df23d1c4f7c7851be9f1dfe5b86dc13928bd38
refs/heads/master
2021-01-21T01:43:31.383133
2016-04-27T14:56:48
2016-04-27T14:57:57
42,746,995
4
0
null
2015-09-18T21:05:36
2015-09-18T21:05:35
null
UTF-8
C
false
false
2,694
h
/* * 2010.12.10 Shinae Woo * Ring buffer structure for managing dynamically allocating ring buffer * * put data to the tail * get/pop/remove data from the head * * always garantee physically continuous ready in-memory data from data_offset to the data_offset+len * automatically increase total buffer size when buffer is full * for efficiently managing packet payload and chunking * */ #ifndef __NRE_RING_BUFFER_ #define __NRE_RING_BUFFER_ #include <stdint.h> #include <sys/types.h> /*----------------------------------------------------------------------------*/ enum rb_caller { AT_APP, AT_MTCP }; /*----------------------------------------------------------------------------*/ typedef struct rb_manager* rb_manager_t; /*----------------------------------------------------------------------------*/ struct fragment_ctx { uint32_t seq; uint32_t len : 31; uint32_t is_calloc : 1; struct fragment_ctx *next; }; /*----------------------------------------------------------------------------*/ struct tcp_ring_buffer { u_char* data; /* buffered data */ u_char* head; /* pointer to the head */ uint32_t head_offset; /* offset for the head (head - data) */ uint32_t tail_offset; /* offset fot the last byte (null byte) */ int merged_len; /* contiguously merged length */ uint64_t cum_len; /* cummulatively merged length */ int last_len; /* currently saved data length */ int size; /* total ring buffer size */ /* TCP payload features */ uint32_t head_seq; uint32_t init_seq; struct fragment_ctx* fctx; }; /*----------------------------------------------------------------------------*/ uint32_t RBGetCurnum(rb_manager_t rbm); void RBPrintInfo(struct tcp_ring_buffer* buff); void RBPrintStr(struct tcp_ring_buffer* buff); void RBPrintHex(struct tcp_ring_buffer* buff); /*----------------------------------------------------------------------------*/ rb_manager_t RBManagerCreate(size_t chunk_size, uint32_t cnum); /*----------------------------------------------------------------------------*/ struct tcp_ring_buffer* RBInit(rb_manager_t rbm, uint32_t init_seq); void RBFree(rb_manager_t rbm, struct tcp_ring_buffer* buff); uint32_t RBIsDanger(rb_manager_t rbm); /*----------------------------------------------------------------------------*/ /* data manupulation functions */ int RBPut(rb_manager_t rbm, struct tcp_ring_buffer* buff, void* data, uint32_t len , uint32_t seq); size_t RBGet(rb_manager_t rbm, struct tcp_ring_buffer* buff, size_t len); size_t RBRemove(rb_manager_t rbm, struct tcp_ring_buffer* buff, size_t len, int option); /*----------------------------------------------------------------------------*/ #endif
[ "notav@ndsl.kaist.edu" ]
notav@ndsl.kaist.edu
ace6c65f926942c046672f2bc6bc3371b6d899b5
3748cf9cb8b6944380491f9022ae0d4e90d174ca
/swa.c
885676c0d1922eaa833a2df099eab4b891f53caf
[]
no_license
rajma996/cprograms
b979600024f7a508299f5641c48d855afa2a6c63
7b59d93d12f6fafc3467bb6ff6f0c4292bc3c380
refs/heads/master
2020-03-27T19:01:15.371603
2014-11-24T17:53:21
2014-11-24T17:53:21
null
0
0
null
null
null
null
UTF-8
C
false
false
198
c
#include<stdio.h> void swap(int *p,int *q){ int k; k=*p; *p=*q; *q=k; } int main(){ int n,m; scanf("%d %d",&n,&m); int *p,*q; p=&n; q=&m; swap(p,q); printf("n=%d m=%d",n,m); return 0; }
[ "user@localhost.localdomain" ]
user@localhost.localdomain
760220a91dfa388108f6671813317da657d92105
487e96b2756a614bb8b2b0e68f050f880602930c
/BF5823AM48_v1.0.3_SDK.si4project/Backup/main(5626).c
0d29c49fd3025bfcaabe3bd8202ccd87ca835227
[]
no_license
mmiker/DS08_BF5823AM48
dd6659892c96bf4c542315dcb2ed4af10284fdcd
99392463fb2fa57d0272fae402189df5434f1081
refs/heads/master
2023-05-03T19:49:09.501401
2021-04-28T09:41:07
2021-04-28T09:41:07
null
0
0
null
null
null
null
UTF-8
C
false
false
1,150
c
/*! \file main.c \brief main file */ #include "main.h" #include "dqiot_drv.h" #include "mmi_ms.h" #include "mmi_sys.h" #include "mmi_audio.h" extern uint16_t timer0_count; extern unsigned char uart_get_buf[]; extern unsigned char uart_getbuflen; uint8_t send_head = 0xF1; int main(void) { u8 i = 0; #if MIFARE_EN u8 ret; u8 gbuff[6]; #endif WDT_DISABLE(); byd_init(); WDT_ENABLE(); drv_ext_ldo_on(); drv_key_led_on(); drv_fp_init(); mmi_dq_sys_init(); //mmi_dq_aud_play_with_id(6,NULL); delay_ms(2000); drv_fp_test(); delay_ms(500); dqiot_drv_uart0_sendData(&send_head,1); dqiot_drv_uart0_sendData(&uart_getbuflen,1); dqiot_drv_uart0_sendData(uart_get_buf,uart_getbuflen); delay_ms(5000); dqiot_drv_uart0_sendData(&send_head,1); dqiot_drv_uart0_sendData(&uart_getbuflen,1); dqiot_drv_uart0_sendData(uart_get_buf,uart_getbuflen); while(1) { WDT_CTRL = WDT_TIME_2304MS; //mmi_task_proc(); #if BYD_CTK_EN byd_ctk_work(); #endif #if MIFARE_EN ret = get_card_number(gbuff); if(RETURN_OK == ret) { if(RETURN_OK == M1_Example(gbuff)) { ; } } #endif } }
[ "zchhacker@163.com" ]
zchhacker@163.com
e5b5cd075dbc523bcbf40aa3da38abef403f1c39
70c4558d01eb6f794ce325810758f9a3d7d1281e
/Deg.c
e0767b095c0fb9a817155f91c1ce871cd41e09c4
[]
no_license
UCDCOMP10110/20318381_CPrograms
cdbcb8c900bcac6f71b58082d418cd71a44c7936
2f91dade4b10ea2e4a6dd5d2a5881fbc938ac4b6
refs/heads/main
2023-02-17T01:28:53.384120
2021-01-15T18:27:32
2021-01-15T18:27:32
300,380,281
0
0
null
null
null
null
UTF-8
C
false
false
274
c
#include<stdio.h> #include<math.h> int main(void) { double c; double f; printf("Please enter the temperature in Fahrenheit:\n"); scanf("%lf", &f); c = (f-32.0)*5.0/9.0; printf("%.2lf degrees Fahrenheit is equivalent to %.2lf degrees Celsius\n", f, c); return 0; }
[ "Brian.monoranu@ucdconnect.com" ]
Brian.monoranu@ucdconnect.com
e0136f92071dacd36033df925fa08c118da4ad1d
8d753bb8f19b5b1f526b0688d3cb199b396ed843
/osp_sai_2.1.8/system/lib/libasn1/constr_TYPE.h
37d21f6d9b2e5818af55948e377ad7a2b42914b0
[]
no_license
bonald/vim_cfg
f166e5ff650db9fa40b564d05dc5103552184db8
2fee6115caec25fd040188dda0cb922bfca1a55f
refs/heads/master
2023-01-23T05:33:00.416311
2020-11-19T02:09:18
2020-11-19T02:09:18
null
0
0
null
null
null
null
UTF-8
C
false
false
6,383
h
/*- * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>. * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * This file contains the declaration structure called "ASN.1 Type Definition", * which holds all information necessary for encoding and decoding routines. * This structure even contains pointer to these encoding and decoding routines * for each defined ASN.1 type. */ #ifndef _CONSTR_TYPE_H_ #define _CONSTR_TYPE_H_ #include <ber_tlv_length.h> #include <ber_tlv_tag.h> #ifdef __cplusplus extern "C" { #endif struct asn_TYPE_descriptor_s; /* Forward declaration */ struct asn_TYPE_member_s; /* Forward declaration */ /* * This type provides the context information for various ASN.1 routines, * primarily ones doing decoding. A member _asn_ctx of this type must be * included into certain target language's structures, such as compound types. */ typedef struct asn_struct_ctx_s { short phase; /* Decoding phase */ short step; /* Elementary step of a phase */ int context; /* Other context information */ void *ptr; /* Decoder-specific stuff (stack elements) */ ber_tlv_len_t left; /* Number of bytes left, -1 for indefinite */ } asn_struct_ctx_t; #include <ber_decoder.h> /* Basic Encoding Rules decoder */ #include <der_encoder.h> /* Distinguished Encoding Rules encoder */ #include <xer_decoder.h> /* Decoder of XER (XML, text) */ #include <xer_encoder.h> /* Encoder into XER (XML, text) */ #include <per_decoder.h> /* Packet Encoding Rules decoder */ #include <constraints.h> /* Subtype constraints support */ /* * Free the structure according to its specification. * If (free_contents_only) is set, the wrapper structure itself (struct_ptr) * will not be freed. (It may be useful in case the structure is allocated * statically or arranged on the stack, yet its elements are allocated * dynamically.) */ typedef void (asn_struct_free_f)( struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, int free_contents_only); /* * Print the structure according to its specification. */ typedef int (asn_struct_print_f)( struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, int level, /* Indentation level */ asn_app_consume_bytes_f *callback, void *app_key); /* * Return the outmost tag of the type. * If the type is untagged CHOICE, the dynamic operation is performed. * NOTE: This function pointer type is only useful internally. * Do not use it in your application. */ typedef ber_tlv_tag_t (asn_outmost_tag_f)( struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag); /* The instance of the above function type; used internally. */ asn_outmost_tag_f asn_TYPE_outmost_tag; /* * The definitive description of the destination language's structure. */ typedef struct asn_TYPE_descriptor_s { char *name; /* A name of the ASN.1 type. "" in some cases. */ char *xml_tag; /* Name used in XML tag */ /* * Generalized functions for dealing with the specific type. * May be directly invoked by applications. */ asn_struct_free_f *free_struct; /* Free the structure */ asn_struct_print_f *print_struct; /* Human readable output */ asn_constr_check_f *check_constraints; /* Constraints validator */ ber_type_decoder_f *ber_decoder; /* Generic BER decoder */ der_type_encoder_f *der_encoder; /* Canonical DER encoder */ xer_type_decoder_f *xer_decoder; /* Generic XER decoder */ xer_type_encoder_f *xer_encoder; /* [Canonical] XER encoder */ per_type_decoder_f *uper_decoder; /* Unaligned PER decoder */ /*********************************************************************** * Internally useful members. Not to be used by applications directly. * **********************************************************************/ /* * Tags that are expected to occur. */ asn_outmost_tag_f *outmost_tag; /* <optional, internal> */ ber_tlv_tag_t *tags; /* Effective tags sequence for this type */ int tags_count; /* Number of tags which are expected */ ber_tlv_tag_t *all_tags;/* Every tag for BER/containment */ int all_tags_count; /* Number of tags */ asn_per_constraints_t *per_constraints; /* PER compiled constraints */ /* * An ASN.1 production type members (members of SEQUENCE, SET, CHOICE). */ struct asn_TYPE_member_s *elements; int elements_count; /* * Additional information describing the type, used by appropriate * functions above. */ void *specifics; } asn_TYPE_descriptor_t; /* * This type describes an element of the constructed type, * i.e. SEQUENCE, SET, CHOICE, etc. */ enum asn_TYPE_flags_e { ATF_NOFLAGS, ATF_POINTER = 0x01, /* Represented by the pointer */ ATF_OPEN_TYPE = 0x02 /* ANY type, without meaningful tag */ }; typedef struct asn_TYPE_member_s { enum asn_TYPE_flags_e flags; /* Element's presentation flags */ int optional; /* Following optional members, including current */ int memb_offset; /* Offset of the element */ ber_tlv_tag_t tag; /* Outmost (most immediate) tag */ int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */ asn_TYPE_descriptor_t *type; /* Member type descriptor */ asn_constr_check_f *memb_constraints; /* Constraints validator */ asn_per_constraints_t *per_constraints; /* PER compiled constraints */ int (*default_value)(void **sptr); /* DEFAULT <value> */ char *name; /* ASN.1 identifier of the element */ } asn_TYPE_member_t; /* * BER tag to element number mapping. */ typedef struct asn_TYPE_tag2member_s { ber_tlv_tag_t el_tag; /* Outmost tag of the member */ int el_no; /* Index of the associated member, base 0 */ int toff_first; /* First occurence of the el_tag, relative */ int toff_last; /* Last occurence of the el_tag, relatvie */ } asn_TYPE_tag2member_t; /* * This function is a wrapper around (td)->print_struct, which prints out * the contents of the target language's structure (struct_ptr) into the * file pointer (stream) in human readable form. * RETURN VALUES: * 0: The structure is printed. * -1: Problem dumping the structure. * (See also xer_fprint() in xer_encoder.h) */ int asn_fprint(FILE *stream, /* Destination stream descriptor */ asn_TYPE_descriptor_t *td, /* ASN.1 type descriptor */ const void *struct_ptr); /* Structure to be printed */ #ifdef __cplusplus } #endif #endif /* _CONSTR_TYPE_H_ */
[ "zhwwan@gmail.com" ]
zhwwan@gmail.com
aa86ef102811c14af533f007674455cdaa23f88b
92f785de480914abbc6cd38eb24b50860a8e8f60
/platforms/aliyun/IoT-SDK_V2.0/sample/coap/iotx_coap_client.c
20a58eeb6fd97eb06ffa61abfc324792cba5181a
[ "Apache-2.0" ]
permissive
Poco-Ye/aliyun-iot-hub
ffa22e5ea2ea98f89cb61a30d120c9e88109ea8d
1898633c35a2ac926f03296ac93ca459f270fd5f
refs/heads/master
2021-05-05T10:48:07.135085
2017-12-08T07:30:41
2017-12-08T07:30:41
118,084,148
4
0
null
null
null
null
UTF-8
C
false
false
5,285
c
/* * Copyright (c) 2014-2016 Alibaba Group. All rights reserved. * License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include <stdio.h> #include <arpa/inet.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include "iot_import.h" #include "iot_export.h" #define IOTX_PRE_DTLS_SERVER_URI "coaps://pre.iot-as-coap.cn-shanghai.aliyuncs.com:5684" #define IOTX_PRE_NOSEC_SERVER_URI "coap://pre.iot-as-coap.cn-shanghai.aliyuncs.com:5683" #define IOTX_ONLINE_DTLS_SERVER_URL "coaps://%s.iot-as-coap.cn-shanghai.aliyuncs.com:5684" char m_coap_client_running = 0; static void iotx_response_handler(void * arg, void * p_response) { int len = 0; unsigned char *p_payload = NULL; iotx_coap_resp_code_t resp_code; IOT_CoAP_GetMessageCode(p_response, &resp_code); IOT_CoAP_GetMessagePayload(p_response, &p_payload, &len); printf("[APPL]: Message response code: %d\r\n", resp_code); printf("[APPL]: Len: %d, Payload: %s, \r\n", len, p_payload); } #define IOTX_PRODUCT_KEY "*******************" #define IOTX_DEVICE_NAME "*******************" #define IOTX_DEVICE_SECRET "*******************" #define IOTX_DEVICE_ID "*******************" int iotx_set_devinfo(iotx_deviceinfo_t *p_devinfo) { if(NULL == p_devinfo){ return IOTX_ERR_INVALID_PARAM; } memset(p_devinfo, 0x00, sizeof(iotx_deviceinfo_t)); strncpy(p_devinfo->device_id, IOTX_DEVICE_ID, IOTX_DEVICE_ID_LEN); strncpy(p_devinfo->product_key, IOTX_PRODUCT_KEY, IOTX_PRODUCT_KEY_LEN); strncpy(p_devinfo->device_secret,IOTX_DEVICE_SECRET, IOTX_DEVICE_SECRET_LEN); strncpy(p_devinfo->device_name, IOTX_DEVICE_NAME, IOTX_DEVICE_NAME_LEN); fprintf(stderr, "*****The Product Key : %s *****\r\n", p_devinfo->product_key); fprintf(stderr, "*****The Device Name : %s *****\r\n", p_devinfo->device_name); fprintf(stderr, "*****The Device Secret: %s *****\r\n", p_devinfo->device_secret); fprintf(stderr, "*****The Device ID : %s *****\r\n", p_devinfo->device_id); return IOTX_SUCCESS; } static void iotx_post_data_to_server(void *param) { char path[IOTX_URI_MAX_LEN+1] = {0}; iotx_message_t message; iotx_deviceinfo_t devinfo; message.p_payload = (unsigned char *)"{\"name\":\"hello world\"}"; message.payload_len = strlen("{\"name\":\"hello world\"}"); message.resp_callback = iotx_response_handler; message.msg_type = IOTX_MESSAGE_CON; message.content_type = IOTX_CONTENT_TYPE_JSON; iotx_coap_context_t *p_ctx = (iotx_coap_context_t *)param; iotx_set_devinfo(&devinfo); snprintf(path, IOTX_URI_MAX_LEN, "/topic/%s/%s/update/", (char *)devinfo.product_key, (char *)devinfo.device_name); IOT_CoAP_SendMessage(p_ctx, path, &message); } int main(int argc, char **argv) { int opt; char secur[32] = {0}; char env[32] = {0}; iotx_coap_config_t config; iotx_deviceinfo_t deviceinfo; printf("[COAP-Client]: Enter Coap Client\r\n"); while ((opt = getopt(argc, argv, "e:s:lh")) != -1){ switch(opt){ case 's': strncpy(secur, optarg, strlen(optarg)); break; case 'e': strncpy(env, optarg, strlen(optarg)); break; case 'l': m_coap_client_running = 1; break; case 'h': // TODO: break; default: break; } } memset(&config, 0x00, sizeof(iotx_coap_config_t)); if(0 == strncmp(env, "pre", strlen("pre"))){ if(0 == strncmp(secur, "dtls", strlen("dtls"))){ config.p_url = IOTX_PRE_DTLS_SERVER_URI; } else{ config.p_url = IOTX_PRE_NOSEC_SERVER_URI; } } else if(0 == strncmp(env, "online", strlen("online"))){ if(0 == strncmp(secur, "dtls", strlen("dtls"))){ char url[256] = {0}; snprintf(url, sizeof(url), IOTX_ONLINE_DTLS_SERVER_URL, IOTX_PRODUCT_KEY); config.p_url = url; } else{ printf("Online environment must access with DTLS\r\n"); return -1; } } iotx_set_devinfo(&deviceinfo); config.p_devinfo = &deviceinfo; iotx_coap_context_t *p_ctx = NULL; p_ctx = IOT_CoAP_Init(&config); if(NULL != p_ctx){ IOT_CoAP_DeviceNameAuth(p_ctx); do{ iotx_post_data_to_server((void *)p_ctx); IOT_CoAP_Yield(p_ctx); }while(m_coap_client_running); IOT_CoAP_Deinit(&p_ctx); } else{ printf("IoTx CoAP init failed\r\n"); } return 0; }
[ "1016771083@qq.com" ]
1016771083@qq.com
045be2028f21dbee158687a0d0b31f8fa602cd3e
f5008df5aab5615d39a9847fa09f9581f7b19a5f
/linux-5.4.38/sound/sh/sh_dac_audio.c
7c46494466ff1234f2c7b93779f92f69ea8a88d2
[ "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only" ]
permissive
wenhuizhang/llvm-linux-5.4.38
2f3f44287dbb1445cd7d4670df8bfc9873441558
bd6678fbd3635428a6d594dbb24a87b9308a52ef
refs/heads/main
2023-01-07T09:57:19.452542
2020-11-01T04:20:46
2020-11-01T04:20:46
303,426,734
0
0
Apache-2.0
2020-11-01T04:20:47
2020-10-12T15:00:48
C
UTF-8
C
false
false
10,265
c
// SPDX-License-Identifier: GPL-2.0-or-later /* * sh_dac_audio.c - SuperH DAC audio driver for ALSA * * Copyright (c) 2009 by Rafael Ignacio Zurita <rizurita@yahoo.com> * * Based on sh_dac_audio.c (Copyright (C) 2004, 2005 by Andriy Skulysh) */ #include <linux/hrtimer.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/module.h> #include <sound/core.h> #include <sound/initval.h> #include <sound/pcm.h> #include <sound/sh_dac_audio.h> #include <asm/clock.h> #include <asm/hd64461.h> #include <mach/hp6xx.h> #include <cpu/dac.h> MODULE_AUTHOR("Rafael Ignacio Zurita <rizurita@yahoo.com>"); MODULE_DESCRIPTION("SuperH DAC audio driver"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{SuperH DAC audio support}}"); /* Module Parameters */ static int index = SNDRV_DEFAULT_IDX1; static char *id = SNDRV_DEFAULT_STR1; module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for SuperH DAC audio."); module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for SuperH DAC audio."); /* main struct */ struct snd_sh_dac { struct snd_card *card; struct snd_pcm_substream *substream; struct hrtimer hrtimer; ktime_t wakeups_per_second; int rate; int empty; char *data_buffer, *buffer_begin, *buffer_end; int processed; /* bytes proccesed, to compare with period_size */ int buffer_size; struct dac_audio_pdata *pdata; }; static void dac_audio_start_timer(struct snd_sh_dac *chip) { hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, HRTIMER_MODE_REL); } static void dac_audio_stop_timer(struct snd_sh_dac *chip) { hrtimer_cancel(&chip->hrtimer); } static void dac_audio_reset(struct snd_sh_dac *chip) { dac_audio_stop_timer(chip); chip->buffer_begin = chip->buffer_end = chip->data_buffer; chip->processed = 0; chip->empty = 1; } static void dac_audio_set_rate(struct snd_sh_dac *chip) { chip->wakeups_per_second = 1000000000 / chip->rate; } /* PCM INTERFACE */ static const struct snd_pcm_hardware snd_sh_dac_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_HALF_DUPLEX), .formats = SNDRV_PCM_FMTBIT_U8, .rates = SNDRV_PCM_RATE_8000, .rate_min = 8000, .rate_max = 8000, .channels_min = 1, .channels_max = 1, .buffer_bytes_max = (48*1024), .period_bytes_min = 1, .period_bytes_max = (48*1024), .periods_min = 1, .periods_max = 1024, }; static int snd_sh_dac_pcm_open(struct snd_pcm_substream *substream) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_sh_dac_pcm_hw; chip->substream = substream; chip->buffer_begin = chip->buffer_end = chip->data_buffer; chip->processed = 0; chip->empty = 1; chip->pdata->start(chip->pdata); return 0; } static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); chip->substream = NULL; dac_audio_stop_timer(chip); chip->pdata->stop(chip->pdata); return 0; } static int snd_sh_dac_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } static int snd_sh_dac_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = chip->substream->runtime; chip->buffer_size = runtime->buffer_size; memset(chip->data_buffer, 0, chip->pdata->buffer_size); return 0; } static int snd_sh_dac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: dac_audio_start_timer(chip); break; case SNDRV_PCM_TRIGGER_STOP: chip->buffer_begin = chip->buffer_end = chip->data_buffer; chip->processed = 0; chip->empty = 1; dac_audio_stop_timer(chip); break; default: return -EINVAL; } return 0; } static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, int channel, unsigned long pos, void __user *src, unsigned long count) { /* channel is not used (interleaved data) */ struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); if (copy_from_user_toio(chip->data_buffer + pos, src, count)) return -EFAULT; chip->buffer_end = chip->data_buffer + pos + count; if (chip->empty) { chip->empty = 0; dac_audio_start_timer(chip); } return 0; } static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream, int channel, unsigned long pos, void *src, unsigned long count) { /* channel is not used (interleaved data) */ struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); memcpy_toio(chip->data_buffer + pos, src, count); chip->buffer_end = chip->data_buffer + pos + count; if (chip->empty) { chip->empty = 0; dac_audio_start_timer(chip); } return 0; } static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream, int channel, unsigned long pos, unsigned long count) { /* channel is not used (interleaved data) */ struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); memset_io(chip->data_buffer + pos, 0, count); chip->buffer_end = chip->data_buffer + pos + count; if (chip->empty) { chip->empty = 0; dac_audio_start_timer(chip); } return 0; } static snd_pcm_uframes_t snd_sh_dac_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); int pointer = chip->buffer_begin - chip->data_buffer; return pointer; } /* pcm ops */ static const struct snd_pcm_ops snd_sh_dac_pcm_ops = { .open = snd_sh_dac_pcm_open, .close = snd_sh_dac_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_sh_dac_pcm_hw_params, .hw_free = snd_sh_dac_pcm_hw_free, .prepare = snd_sh_dac_pcm_prepare, .trigger = snd_sh_dac_pcm_trigger, .pointer = snd_sh_dac_pcm_pointer, .copy_user = snd_sh_dac_pcm_copy, .copy_kernel = snd_sh_dac_pcm_copy_kernel, .fill_silence = snd_sh_dac_pcm_silence, .mmap = snd_pcm_lib_mmap_iomem, }; static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) { int err; struct snd_pcm *pcm; /* device should be always 0 for us */ err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm); if (err < 0) return err; pcm->private_data = chip; strcpy(pcm->name, "SH_DAC PCM"); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sh_dac_pcm_ops); /* buffer size=48K */ snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL), 48 * 1024, 48 * 1024); return 0; } /* END OF PCM INTERFACE */ /* driver .remove -- destructor */ static int snd_sh_dac_remove(struct platform_device *devptr) { snd_card_free(platform_get_drvdata(devptr)); return 0; } /* free -- it has been defined by create */ static int snd_sh_dac_free(struct snd_sh_dac *chip) { /* release the data */ kfree(chip->data_buffer); kfree(chip); return 0; } static int snd_sh_dac_dev_free(struct snd_device *device) { struct snd_sh_dac *chip = device->device_data; return snd_sh_dac_free(chip); } static enum hrtimer_restart sh_dac_audio_timer(struct hrtimer *handle) { struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac, hrtimer); struct snd_pcm_runtime *runtime = chip->substream->runtime; ssize_t b_ps = frames_to_bytes(runtime, runtime->period_size); if (!chip->empty) { sh_dac_output(*chip->buffer_begin, chip->pdata->channel); chip->buffer_begin++; chip->processed++; if (chip->processed >= b_ps) { chip->processed -= b_ps; snd_pcm_period_elapsed(chip->substream); } if (chip->buffer_begin == (chip->data_buffer + chip->buffer_size - 1)) chip->buffer_begin = chip->data_buffer; if (chip->buffer_begin == chip->buffer_end) chip->empty = 1; } if (!chip->empty) hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* create -- chip-specific constructor for the cards components */ static int snd_sh_dac_create(struct snd_card *card, struct platform_device *devptr, struct snd_sh_dac **rchip) { struct snd_sh_dac *chip; int err; static struct snd_device_ops ops = { .dev_free = snd_sh_dac_dev_free, }; *rchip = NULL; chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->card = card; hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); chip->hrtimer.function = sh_dac_audio_timer; dac_audio_reset(chip); chip->rate = 8000; dac_audio_set_rate(chip); chip->pdata = devptr->dev.platform_data; chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL); if (chip->data_buffer == NULL) { kfree(chip); return -ENOMEM; } err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) { snd_sh_dac_free(chip); return err; } *rchip = chip; return 0; } /* driver .probe -- constructor */ static int snd_sh_dac_probe(struct platform_device *devptr) { struct snd_sh_dac *chip; struct snd_card *card; int err; err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card); if (err < 0) { snd_printk(KERN_ERR "cannot allocate the card\n"); return err; } err = snd_sh_dac_create(card, devptr, &chip); if (err < 0) goto probe_error; err = snd_sh_dac_pcm(chip, 0); if (err < 0) goto probe_error; strcpy(card->driver, "snd_sh_dac"); strcpy(card->shortname, "SuperH DAC audio driver"); printk(KERN_INFO "%s %s", card->longname, card->shortname); err = snd_card_register(card); if (err < 0) goto probe_error; snd_printk(KERN_INFO "ALSA driver for SuperH DAC audio"); platform_set_drvdata(devptr, card); return 0; probe_error: snd_card_free(card); return err; } /* * "driver" definition */ static struct platform_driver sh_dac_driver = { .probe = snd_sh_dac_probe, .remove = snd_sh_dac_remove, .driver = { .name = "dac_audio", }, }; module_platform_driver(sh_dac_driver);
[ "wenhui@gwmail.gwu.edu" ]
wenhui@gwmail.gwu.edu
c557792bfc4559c867b60089e8d1ba924c9a2a75
57caeba54ba601c112b7b2f353ebeb99a5c917e5
/sys/amiga/cvtsnd.c
cc97d423faad7d6b9b1619fa860f5b152a5127c0
[]
no_license
StatueSurfer/SurferHack
085c25d40c16d7e7e3839cfddde860a5a6dcc04a
ab9afb3ef257b06eb7ce0315c6f45a715f6b9cc3
refs/heads/master
2021-05-04T15:39:18.616421
2018-02-08T21:48:29
2018-02-08T21:48:29
120,233,375
0
0
null
null
null
null
UTF-8
C
false
false
2,556
c
/* NetHack 3.6 cvtsnd.c $NHDT-Date: 1432512794 2015/05/25 00:13:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */ /* Copyright (c) 1995, Andrew Church, Olney, Maryland */ /* NetHack may be freely redistributed. See license for details. */ #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { short namelen; char name[62]; char misc[64]; /* rest of MacBinary header */ long FORM; long flen; long AIFF; long SSND; long sndlen; } AIFF; typedef struct { char FORM[4]; long flen; char _8SVX[4]; char VHDR[4]; long vhlen; long oneshot, repeat; long samples; /* 'samplesPerHiCycle' in the docs - usually 32, so * we'll use that */ short freq; char octaves, compress; long volume; char NAME[4]; long nlen; /* should be 64; see name[] comment */ char name[64]; /* for simplicity, i.e. just fwrite() entiree header */ char BODY[4]; long blen; } IFF; main(int ac, char **av) { FILE *in, *out; AIFF aiff; IFF iff; static char buf[16384]; long n, len; if (ac != 3) { fprintf(stderr, "Usage: %s input-file output-file\n", av[0]); exit(20); } if (!(in = fopen(av[1], "r"))) { fprintf(stderr, "Can't open input file\n"); exit(20); } if (!(out = fopen(av[2], "w"))) { fprintf(stderr, "Can't open output file\n"); exit(20); } fread(&aiff, sizeof(aiff), 1, in); memcpy(iff.FORM, "FORM", 4); iff.flen = sizeof(iff) + aiff.sndlen - 8; memcpy(iff._8SVX, "8SVX", 4); memcpy(iff.VHDR, "VHDR", 4); iff.vhlen = 20; iff.oneshot = aiff.sndlen; iff.repeat = 0; iff.samples = 32; iff.freq = 22000; iff.octaves = 1; iff.compress = 0; iff.volume = 0x10000; memcpy(iff.NAME, "NAME", 4); iff.nlen = 64; strncpy(iff.name, aiff.name, 62); iff.name[aiff.namelen] = 0; memcpy(iff.BODY, "BODY", 4); iff.blen = aiff.sndlen; fwrite(&iff, sizeof(iff), 1, out); len = aiff.sndlen; do { if (len >= sizeof(buf)) n = fread(buf, 1, sizeof(buf), in); else n = fread(buf, 1, len, in); if (n) { fwrite(buf, 1, n, out); len -= n; } } while (len && n); if (len) fprintf(stderr, "Warning: %ld bytes of sample missing\n", len); fclose(in); fclose(out); exit(0); }
[ "noreply@github.com" ]
StatueSurfer.noreply@github.com
6cd0bc2fa9cb0fb74b5a36e1c24d6d92d2ea9314
488378d66dfb12d3292886b160243aa24e27c420
/linux-3.16/tools/perf/ui/gtk/annotate.c
9c7ff8d31b274e32d22147664cb622437db514f1
[ "GPL-1.0-or-later", "Linux-syscall-note", "GPL-2.0-only", "Unlicense" ]
permissive
jj1232727/system_call
3ec72bdecad15a43638cc5eb91ba1ae229d651bb
145315cdf532c45b6aa753d98260d2b1c0b63abc
refs/heads/master
2020-08-11T13:56:16.335620
2019-10-12T11:12:53
2019-10-12T11:12:53
214,575,269
0
0
Unlicense
2019-10-12T04:06:22
2019-10-12T04:06:22
null
UTF-8
C
false
false
6,004
c
#include "gtk.h" #include "util/debug.h" #include "util/annotate.h" #include "util/evsel.h" #include "ui/helpline.h" enum { ANN_COL__PERCENT, ANN_COL__OFFSET, ANN_COL__LINE, MAX_ANN_COLS }; static const char *const col_names[] = { "Overhead", "Offset", "Line" }; static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym, struct disasm_line *dl, int evidx) { struct sym_hist *symhist; double percent = 0.0; const char *markup; int ret = 0; strcpy(buf, ""); if (dl->offset == (s64) -1) return 0; symhist = annotation__histogram(symbol__annotation(sym), evidx); if (!symbol_conf.event_group && !symhist->addr[dl->offset]) return 0; percent = 100.0 * symhist->addr[dl->offset] / symhist->sum; markup = perf_gtk__get_percent_color(percent); if (markup) ret += scnprintf(buf, size, "%s", markup); ret += scnprintf(buf + ret, size - ret, "%6.2f%%", percent); if (markup) ret += scnprintf(buf + ret, size - ret, "</span>"); return ret; } static int perf_gtk__get_offset(char *buf, size_t size, struct symbol *sym, struct map *map, struct disasm_line *dl) { u64 start = map__rip_2objdump(map, sym->start); strcpy(buf, ""); if (dl->offset == (s64) -1) return 0; return scnprintf(buf, size, "%"PRIx64, start + dl->offset); } static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl) { int ret = 0; char *line = g_markup_escape_text(dl->line, -1); const char *markup = "<span fgcolor='gray'>"; strcpy(buf, ""); if (!line) return 0; if (dl->offset != (s64) -1) markup = NULL; if (markup) ret += scnprintf(buf, size, "%s", markup); ret += scnprintf(buf + ret, size - ret, "%s", line); if (markup) ret += scnprintf(buf + ret, size - ret, "</span>"); g_free(line); return ret; } static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct hist_browser_timer *hbt __maybe_unused) { struct disasm_line *pos, *n; struct annotation *notes; GType col_types[MAX_ANN_COLS]; GtkCellRenderer *renderer; GtkListStore *store; GtkWidget *view; int i; char s[512]; notes = symbol__annotation(sym); for (i = 0; i < MAX_ANN_COLS; i++) { col_types[i] = G_TYPE_STRING; } store = gtk_list_store_newv(MAX_ANN_COLS, col_types); view = gtk_tree_view_new(); renderer = gtk_cell_renderer_text_new(); for (i = 0; i < MAX_ANN_COLS; i++) { gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, col_names[i], renderer, "markup", i, NULL); } gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); g_object_unref(GTK_TREE_MODEL(store)); list_for_each_entry(pos, &notes->src->source, node) { GtkTreeIter iter; int ret = 0; gtk_list_store_append(store, &iter); if (perf_evsel__is_group_event(evsel)) { for (i = 0; i < evsel->nr_members; i++) { ret += perf_gtk__get_percent(s + ret, sizeof(s) - ret, sym, pos, evsel->idx + i); ret += scnprintf(s + ret, sizeof(s) - ret, " "); } } else { ret = perf_gtk__get_percent(s, sizeof(s), sym, pos, evsel->idx); } if (ret) gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1); if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos)) gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1); if (perf_gtk__get_line(s, sizeof(s), pos)) gtk_list_store_set(store, &iter, ANN_COL__LINE, s, -1); } gtk_container_add(GTK_CONTAINER(window), view); list_for_each_entry_safe(pos, n, &notes->src->source, node) { list_del(&pos->node); disasm_line__free(pos); } return 0; } static int symbol__gtk_annotate(struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct hist_browser_timer *hbt) { GtkWidget *window; GtkWidget *notebook; GtkWidget *scrolled_window; GtkWidget *tab_label; if (map->dso->annotate_warned) return -1; if (symbol__annotate(sym, map, 0) < 0) { ui__error("%s", ui_helpline__current); return -1; } if (perf_gtk__is_active_context(pgctx)) { window = pgctx->main_window; notebook = pgctx->notebook; } else { GtkWidget *vbox; GtkWidget *infobar; GtkWidget *statbar; signal(SIGSEGV, perf_gtk__signal); signal(SIGFPE, perf_gtk__signal); signal(SIGINT, perf_gtk__signal); signal(SIGQUIT, perf_gtk__signal); signal(SIGTERM, perf_gtk__signal); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "perf annotate"); g_signal_connect(window, "delete_event", gtk_main_quit, NULL); pgctx = perf_gtk__activate_context(window); if (!pgctx) return -1; vbox = gtk_vbox_new(FALSE, 0); notebook = gtk_notebook_new(); pgctx->notebook = notebook; gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); infobar = perf_gtk__setup_info_bar(); if (infobar) { gtk_box_pack_start(GTK_BOX(vbox), infobar, FALSE, FALSE, 0); } statbar = perf_gtk__setup_statusbar(); gtk_box_pack_start(GTK_BOX(vbox), statbar, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); } scrolled_window = gtk_scrolled_window_new(NULL, NULL); tab_label = gtk_label_new(sym->name); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label); perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt); return 0; } int hist_entry__gtk_annotate(struct hist_entry *he, struct perf_evsel *evsel, struct hist_browser_timer *hbt) { return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt); } void perf_gtk__show_annotations(void) { GtkWidget *window; if (!perf_gtk__is_active_context(pgctx)) return; window = pgctx->main_window; gtk_widget_show_all(window); perf_gtk__resize_window(window); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_main(); perf_gtk__deactivate_context(&pgctx); }
[ "jj1232727" ]
jj1232727
6eddec7e5a458058d548e3ffbd4a8002ff45af47
24384c6a5cf62a89e1aa746449df0cc12d4c44bb
/src/libcmd_prompt.c
3c02cc16b43552af4aeec019f429d3e0cd0a6ca2
[]
no_license
fengjixuchui/bluehat-il-2019-slotd
b024ab0498eee38e3f425a8b531a32c1f34ee014
071feca12b63df00ffd9789d20375921a86a7453
refs/heads/master
2021-11-04T01:38:41.026741
2019-04-27T09:53:31
2019-04-27T09:53:31
null
0
0
null
null
null
null
UTF-8
C
false
false
2,008
c
#include "libkv.h" #include "libuser.h" #include <stdlib.h> #include <string.h> #include <stdio.h> #include <unistd.h> // Replace certain escape chars // \w: replace with working directory // \u: replace with current user // \h: replace with 'slotd' // return a new string static char *fill_special(char *str) { char *old = NULL, *new = NULL; const char *rep; char *tok, *saveptr; char *dir = NULL; char buf[2] = {0, 0}; // allocate an empty string old = strdup(""); if (!old) { return NULL; } new = old; // Escape the PS1 string for (tok = strtok_r(str, "\\", &saveptr); tok; tok = strtok_r(NULL, "\\", &saveptr)) { // check the escape character switch (tok[0]) { case 'u': // user rep = user_current(); break; case 'h': // slotd rep = "slotd"; break; case 'w': // working directory if (!dir) { dir = get_current_dir_name(); } rep = dir; break; default: buf[0] = tok[0]; rep = buf; break; } new = NULL; if (asprintf(&new, "%s%s%s", old, rep, (tok[0] != '\0' ? tok + 1 : "")) < 0) { free(new); new = NULL; break; } free(old); old = new; } if (old != new) { free(old); old = NULL; } if (dir) { free(dir); } return new; } void cmd_main(char *param) { char **ref; // get ref to env:PS1 ref = (char **)kv_ref("env", "PS1", free); if (!ref) { return; } if (param[0] == '\0') { puts(*ref ? *ref : "(no prompt set)"); return; } // PROBLEM: why freeing when before you check for NULL..? // Maybe can be used for double free free(*ref); *ref = fill_special(param); }
[ "odamari@paloaltonetworks.com" ]
odamari@paloaltonetworks.com
e5723b51dcbe7803bbf176304254a21a9fdd3af4
d5626fe08a9de469ddf1e4193793df7efd8fe6e3
/src/lib/libform/fty_num.c
646e611da27c8078165942fc4a082caeabf4c1a2
[]
no_license
drt24/openbsd-import
1767ddb9e03bb9a0974c8c0e4237e1edc1cdf67d
0de99edb5131e82e7d249a0c4cd36cf157e03b9b
refs/heads/master
2022-11-16T19:36:52.859427
2020-07-09T07:45:13
2020-07-09T07:45:13
280,720,846
0
0
null
null
null
null
UTF-8
C
false
false
8,190
c
/* $OpenBSD$ */ /**************************************************************************** * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, 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 ABOVE 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. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /*************************************************************************** * * * Author : Juergen Pfeifer * * * ***************************************************************************/ #include "form.priv.h" MODULE_ID("$Id$") #if HAVE_LOCALE_H #include <locale.h> #endif #if HAVE_LOCALE_H #define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.')) #else #define isDecimalPoint(c) ((c) == '.') #endif #if USE_WIDEC_SUPPORT #define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c))) #else #define isDigit(c) isdigit(UChar(c)) #endif #define thisARG numericARG typedef struct { int precision; double low; double high; struct lconv *L; } thisARG; /*--------------------------------------------------------------------------- | Facility : libnform | Function : static void *Make_This_Type(va_list * ap) | | Description : Allocate structure for numeric type argument. | | Return Values : Pointer to argument structure or NULL on error +--------------------------------------------------------------------------*/ static void * Make_This_Type(va_list *ap) { thisARG *argn = typeMalloc(thisARG, 1); if (argn) { T((T_CREATE("thisARG %p"), argn)); argn->precision = va_arg(*ap, int); argn->low = va_arg(*ap, double); argn->high = va_arg(*ap, double); #if HAVE_LOCALE_H argn->L = localeconv(); #else argn->L = NULL; #endif } return (void *)argn; } /*--------------------------------------------------------------------------- | Facility : libnform | Function : static void *Copy_This_Type(const void * argp) | | Description : Copy structure for numeric type argument. | | Return Values : Pointer to argument structure or NULL on error. +--------------------------------------------------------------------------*/ static void * Copy_This_Type(const void *argp) { const thisARG *ap = (const thisARG *)argp; thisARG *result = (thisARG *) 0; if (argp) { result = typeMalloc(thisARG, 1); if (result) { T((T_CREATE("thisARG %p"), result)); *result = *ap; } } return (void *)result; } /*--------------------------------------------------------------------------- | Facility : libnform | Function : static void Free_This_Type(void * argp) | | Description : Free structure for numeric type argument. | | Return Values : - +--------------------------------------------------------------------------*/ static void Free_This_Type(void *argp) { if (argp) free(argp); } /*--------------------------------------------------------------------------- | Facility : libnform | Function : static bool Check_This_Field(FIELD * field, | const void * argp) | | Description : Validate buffer content to be a valid numeric value | | Return Values : TRUE - field is valid | FALSE - field is invalid +--------------------------------------------------------------------------*/ static bool Check_This_Field(FIELD *field, const void *argp) { const thisARG *argn = (const thisARG *)argp; double low = argn->low; double high = argn->high; int prec = argn->precision; unsigned char *bp = (unsigned char *)field_buffer(field, 0); char *s = (char *)bp; double val = 0.0; struct lconv *L = argn->L; char buf[64]; bool result = FALSE; while (*bp && *bp == ' ') bp++; if (*bp) { if (*bp == '-' || *bp == '+') bp++; #if USE_WIDEC_SUPPORT if (*bp) { bool blank = FALSE; int state = 0; int len; int n; wchar_t *list = _nc_Widen_String((char *)bp, &len); if (list != 0) { result = TRUE; for (n = 0; n < len; ++n) { if (blank) { if (list[n] != ' ') { result = FALSE; break; } } else if (list[n] == ' ') { blank = TRUE; } else if (isDecimalPoint(list[n])) { if (++state > 1) { result = FALSE; break; } } else if (!isDigit(list[n])) { result = FALSE; break; } } free(list); } } #else while (*bp) { if (!isdigit(UChar(*bp))) break; bp++; } if (isDecimalPoint(*bp)) { bp++; while (*bp) { if (!isdigit(UChar(*bp))) break; bp++; } } while (*bp && *bp == ' ') bp++; result = (*bp == '\0'); #endif if (result) { val = atof(s); if (low < high) { if (val < low || val > high) result = FALSE; } if (result) { snprintf(buf, sizeof(buf), "%.*f", (prec > 0 ? prec : 0), val); set_field_buffer(field, 0, buf); } } } return (result); } /*--------------------------------------------------------------------------- | Facility : libnform | Function : static bool Check_This_Character( | int c, | const void * argp) | | Description : Check a character for the numeric type. | | Return Values : TRUE - character is valid | FALSE - character is invalid +--------------------------------------------------------------------------*/ static bool Check_This_Character(int c, const void *argp) { const thisARG *argn = (const thisARG *)argp; struct lconv *L = argn->L; return ((isDigit(c) || c == '+' || c == '-' || isDecimalPoint(c)) ? TRUE : FALSE); } static FIELDTYPE typeTHIS = { _HAS_ARGS | _RESIDENT, 1, /* this is mutable, so we can't be const */ (FIELDTYPE *)0, (FIELDTYPE *)0, Make_This_Type, Copy_This_Type, Free_This_Type, Check_This_Field, Check_This_Character, NULL, NULL }; NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS; /* fty_num.c ends here */
[ "" ]
246f0620f687a0f364ed7e7b11e69a1e46ae050c
5d54381a753f48998dbf68d211e08693644265d5
/include/liblaplacian_linux.h
d5b982d6ee216e45ba985a7fb896e7c3e4c5705f
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
xjtdy888/blurry
6242420b79162cf3d61f41ff115370d17adac66c
4cab663c5d9204326accd081417eb29ede1f5973
refs/heads/master
2023-08-06T06:39:11.200877
2021-09-23T10:30:39
2021-09-23T10:30:39
null
0
0
null
null
null
null
UTF-8
C
false
false
1,394
h
#ifndef HALIDE__liblaplacian_linux_h #define HALIDE__liblaplacian_linux_h #include <stdint.h> // Forward declarations of the types used in the interface // to the Halide pipeline. // // For the definitions of these structs, include HalideRuntime.h // Halide's representation of a multi-dimensional array. // Halide::Runtime::Buffer is a more user-friendly wrapper // around this. Its declaration is in HalideBuffer.h struct halide_buffer_t; // Metadata describing the arguments to the generated function. // Used to construct calls to the _argv version of the function. struct halide_filter_metadata_t; #ifndef HALIDE_MUST_USE_RESULT #ifdef __has_attribute #if __has_attribute(nodiscard) #define HALIDE_MUST_USE_RESULT [[nodiscard]] #elif __has_attribute(warn_unused_result) #define HALIDE_MUST_USE_RESULT __attribute__((warn_unused_result)) #else #define HALIDE_MUST_USE_RESULT #endif #else #define HALIDE_MUST_USE_RESULT #endif #endif #ifndef HALIDE_FUNCTION_ATTRS #define HALIDE_FUNCTION_ATTRS #endif #ifdef __cplusplus extern "C" { #endif HALIDE_FUNCTION_ATTRS int laplacian(struct halide_buffer_t *_src_buffer, int32_t _width, int32_t _height, struct halide_buffer_t *_laplacian_buffer); HALIDE_FUNCTION_ATTRS int laplacian_argv(void **args); HALIDE_FUNCTION_ATTRS const struct halide_filter_metadata_t *laplacian_metadata(); #ifdef __cplusplus } // extern "C" #endif #endif
[ "yusuke.hata@mirrativ.co.jp" ]
yusuke.hata@mirrativ.co.jp
fcf22bc6efbf3fd37d33c6fe1604e53679286dff
0ee855f42022c9d550b3a678de0fc4b8c1c24fee
/Libraries/STM8S_StdPeriph_Driver/inc/stm8s_beep.h
b48dd765b2414d4531e3415c835f0d8696c6a977
[ "Apache-2.0" ]
permissive
saurabh-nishad/STM8S_SoftwareUart
19e4034bcce035e86ab977450e7d5d95aa4ec5a6
34780350249eef1de38f9902a252a09baf5d03dd
refs/heads/main
2023-08-13T06:15:29.957979
2021-03-24T11:24:38
2021-03-24T11:24:38
351,045,655
3
1
Apache-2.0
2021-10-17T15:57:05
2021-03-24T10:57:23
C
UTF-8
C
false
false
3,629
h
/** ****************************************************************************** * @file stm8s_beep.h * @author MCD Application Team * @version V2.3.0 * @date 16-June-2017 * @brief This file contains all functions prototype and macros for the BEEP peripheral. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2> * * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 * * 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. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM8S_BEEP_H #define __STM8S_BEEP_H /* Includes ------------------------------------------------------------------*/ #include "stm8s.h" /* Exported types ------------------------------------------------------------*/ /** @addtogroup BEEP_Exported_Types * @{ */ /** * @brief BEEP Frequency selection */ typedef enum { BEEP_FREQUENCY_1KHZ = (uint8_t)0x00, /*!< Beep signal output frequency equals to 1 KHz */ BEEP_FREQUENCY_2KHZ = (uint8_t)0x40, /*!< Beep signal output frequency equals to 2 KHz */ BEEP_FREQUENCY_4KHZ = (uint8_t)0x80 /*!< Beep signal output frequency equals to 4 KHz */ } BEEP_Frequency_TypeDef; /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @addtogroup BEEP_Exported_Constants * @{ */ #define BEEP_CALIBRATION_DEFAULT ((uint8_t)0x0B) /*!< Default value when calibration is not done */ #define LSI_FREQUENCY_MIN ((uint32_t)110000) /*!< LSI minimum value in Hertz */ #define LSI_FREQUENCY_MAX ((uint32_t)150000) /*!< LSI maximum value in Hertz */ /** * @} */ /* Exported macros -----------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup BEEP_Private_Macros * @{ */ /** * @brief Macro used by the assert function to check the different functions parameters. */ /** * @brief Macro used by the assert function to check the BEEP frequencies. */ #define IS_BEEP_FREQUENCY_OK(FREQ) \ (((FREQ) == BEEP_FREQUENCY_1KHZ) || \ ((FREQ) == BEEP_FREQUENCY_2KHZ) || \ ((FREQ) == BEEP_FREQUENCY_4KHZ)) /** * @brief Macro used by the assert function to check the LSI frequency (in Hz). */ #define IS_LSI_FREQUENCY_OK(FREQ) \ (((FREQ) >= LSI_FREQUENCY_MIN) && \ ((FREQ) <= LSI_FREQUENCY_MAX)) /** * @} */ /* Exported functions ------------------------------------------------------- */ /** @addtogroup BEEP_Exported_Functions * @{ */ void BEEP_DeInit(void); void BEEP_Init(BEEP_Frequency_TypeDef BEEP_Frequency); void BEEP_Cmd(FunctionalState NewState); void BEEP_LSICalibrationConfig(uint32_t LSIFreqHz); /** * @} */ #endif /* __STM8S_BEEP_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
[ "noreply@github.com" ]
saurabh-nishad.noreply@github.com
4b938bd0440a564b6ee391a145316a8287d6b36e
241f24e6a837081fd2f3c574c613cfd0b0ab4fb9
/etc/fstat.c
3476ecc5933a998341ac342dca5de6500133f315
[]
no_license
b4/4.3BSD-Quasijarus
9474549f02d468f847adb58c797af650f3b803b9
2e0a87cbd51f1c47d04f3c57f07f6d9e1aa8ec1b
refs/heads/master
2021-01-22T20:07:46.920215
2017-03-17T04:39:43
2017-03-17T04:39:43
85,271,248
1
0
null
2017-03-17T04:36:05
2017-03-17T04:36:05
null
UTF-8
C
false
false
13,593
c
/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1987 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)fstat.c 5.13 (Berkeley) 6/18/88"; #endif /* not lint */ /* * fstat */ #include <machine/pte.h> #include <sys/param.h> #include <sys/dir.h> #include <sys/user.h> #include <sys/proc.h> #include <sys/text.h> #include <sys/stat.h> #include <sys/inode.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/domain.h> #include <sys/protosw.h> #include <sys/unpcb.h> #include <sys/vmmac.h> #define KERNEL #include <sys/file.h> #undef KERNEL #include <net/route.h> #include <netinet/in.h> #include <netinet/in_pcb.h> #include <stdio.h> #include <ctype.h> #include <nlist.h> #include <pwd.h> #ifdef ULTRIX /* UFS -> GFS */ # define inode gnode # define x_iptr x_gptr # define i_dev g_dev # define i_number g_number # define i_mode g_mode # define i_size g_size #endif #define N_KMEM "/dev/kmem" #define N_MEM "/dev/mem" #define N_SWAP "/dev/drum" #define N_UNIX "/vmunix" #define TEXT -2 #define WD -1 typedef struct devs { struct devs *next; dev_t dev; int inum; char *name; } DEVS; DEVS *devs; static struct nlist nl[] = { { "_proc" }, #define X_PROC 0 { "_Usrptmap" }, #define X_USRPTMA 1 { "_nproc" }, #define X_NPROC 2 { "_usrpt" }, #define X_USRPT 3 { "" }, }; struct proc *mproc; struct pte *Usrptma, *usrpt; union { struct user user; char upages[UPAGES][NBPG]; } user; extern int errno; static int fflg, vflg; static int kmem, mem, nproc, swap; static char *uname; off_t lseek(); main(argc, argv) int argc; char **argv; { extern char *optarg; extern int optind; register struct passwd *passwd; register int pflg, pid, uflg, uid; int ch, size; struct passwd *getpwnam(), *getpwuid(); long lgetw(); char *malloc(); pflg = uflg = 0; while ((ch = getopt(argc, argv, "p:u:v")) != EOF) switch((char)ch) { case 'p': if (pflg++) usage(); if (!isdigit(*optarg)) { fputs("fstat: -p option requires a process id.\n", stderr); usage(); } pid = atoi(optarg); break; case 'u': if (uflg++) usage(); if (!(passwd = getpwnam(optarg))) { fprintf(stderr, "%s: unknown uid\n", optarg); exit(1); } uid = passwd->pw_uid; uname = passwd->pw_name; break; case 'v': /* undocumented: print read error messages */ vflg++; break; case '?': default: usage(); } if (*(argv += optind)) { for (; *argv; ++argv) { if (getfname(*argv)) fflg = 1; } if (!fflg) /* file(s) specified, but none accessable */ exit(1); } openfiles(); if (nlist(N_UNIX, nl) == -1 || !nl[0].n_type) { fprintf(stderr, "%s: No namelist\n", N_UNIX); exit(1); } Usrptma = (struct pte *)nl[X_USRPTMA].n_value; usrpt = (struct pte *) nl[X_USRPT].n_value; nproc = (int)lgetw((off_t)nl[X_NPROC].n_value); (void)lseek(kmem, lgetw((off_t)nl[X_PROC].n_value), L_SET); size = nproc * sizeof(struct proc); if ((mproc = (struct proc *)malloc((u_int)size)) == NULL) { fprintf(stderr, "fstat: out of space.\n"); exit(1); } if (read(kmem, (char *)mproc, size) != size) rerr1("proc table", N_KMEM); printf("USER\t CMD\t PID FD\tDEVICE\tINODE\t SIZE TYPE%s\n", fflg ? " NAME" : ""); for (; nproc--; ++mproc) { if (mproc->p_stat == 0) continue; if (pflg && mproc->p_pid != pid) continue; if (uflg) { if (mproc->p_uid != uid) continue; } else uname = (passwd = getpwuid(mproc->p_uid)) ? passwd->pw_name : "unknown"; if (mproc->p_stat != SZOMB && getu() == 0) continue; dotext(); readf(); } exit(0); } static getu() { struct pte *pteaddr, apte; struct pte arguutl[UPAGES+CLSIZE]; register int i; int ncl; if ((mproc->p_flag & SLOAD) == 0) { if (swap < 0) return(0); (void)lseek(swap, (off_t)dtob(mproc->p_swaddr), L_SET); if (read(swap, (char *)&user.user, sizeof(struct user)) != sizeof(struct user)) { fprintf(stderr, "fstat: can't read u for pid %d from %s\n", mproc->p_pid, N_SWAP); return(0); } return(1); } pteaddr = &Usrptma[btokmx(mproc->p_p0br) + mproc->p_szpt - 1]; (void)lseek(kmem, (off_t)pteaddr, L_SET); if (read(kmem, (char *)&apte, sizeof(apte)) != sizeof(apte)) { printf("fstat: can't read indir pte to get u for pid %d from %s\n", mproc->p_pid, N_SWAP); return(0); } (void)lseek(mem, (off_t)ctob(apte.pg_pfnum+1) - (UPAGES+CLSIZE) * sizeof(struct pte), L_SET); if (read(mem, (char *)arguutl, sizeof(arguutl)) != sizeof(arguutl)) { printf("fstat: can't read page table for u of pid %d from %s\n", mproc->p_pid, N_KMEM); return(0); } ncl = (sizeof(struct user) + NBPG*CLSIZE - 1) / (NBPG*CLSIZE); while (--ncl >= 0) { i = ncl * CLSIZE; (void)lseek(mem, (off_t)ctob(arguutl[CLSIZE+i].pg_pfnum), L_SET); if (read(mem, user.upages[i], CLSIZE*NBPG) != CLSIZE*NBPG) { printf("fstat: can't read page %u of u of pid %d from %s\n", arguutl[CLSIZE+i].pg_pfnum, mproc->p_pid, N_MEM); return(0); } } return(1); } static dotext() { struct text text; (void)lseek(kmem, (off_t)mproc->p_textp, L_SET); if (read(kmem, (char *) &text, sizeof(text)) != sizeof(text)) { rerr1("text table", N_KMEM); return; } if (text.x_flag) itrans(DTYPE_INODE, text.x_iptr, TEXT); } static itrans(ftype, g, fno) int ftype, fno; struct inode *g; /* if ftype is inode */ { struct inode inode; dev_t idev; char *comm, *itype(); char *name = (char *)NULL; /* set by devmatch() on a match */ if (g || fflg) { (void)lseek(kmem, (off_t)g, L_SET); if (read(kmem, (char *)&inode, sizeof(inode)) != sizeof(inode)) { rerr2(errno, (int)g, "inode"); return; } idev = inode.i_dev; if (fflg && !devmatch(idev, inode.i_number, &name)) return; } if (mproc->p_pid == 0) comm = "swapper"; else if (mproc->p_pid == 2) comm = "pagedaemon"; else comm = user.user.u_comm; printf("%-8.8s %-10.10s %5d ", uname, comm, mproc->p_pid); switch(fno) { case WD: printf(" wd"); break; case TEXT: printf("text"); break; default: printf("%4d", fno); } if (g == 0) { printf("* (deallocated)\n"); return; } switch(ftype) { case DTYPE_INODE: printf("\t%2d, %2d\t%5lu\t%6ld\t%3s %s\n", major(inode.i_dev), minor(inode.i_dev), inode.i_number, inode.i_mode == IFSOCK ? 0 : inode.i_size, itype(inode.i_mode), name ? name : ""); break; case DTYPE_SOCKET: socktrans((struct socket *)g); break; #ifdef DTYPE_PORT case DTYPE_PORT: printf("* (fifo / named pipe)\n"); break; #endif default: printf("* (unknown file type)\n"); } } static char * itype(mode) u_short mode; { switch(mode & IFMT) { case IFCHR: return("chr"); case IFDIR: return("dir"); case IFBLK: return("blk"); case IFREG: return("reg"); case IFLNK: return("lnk"); case IFSOCK: return("soc"); default: return("unk"); } /*NOTREACHED*/ } static socktrans(sock) struct socket *sock; { static char *stypename[] = { "unused", /* 0 */ "stream", /* 1 */ "dgram", /* 2 */ "raw", /* 3 */ "rdm", /* 4 */ "seqpak" /* 5 */ }; #define STYPEMAX 5 struct socket so; struct protosw proto; struct domain dom; struct inpcb inpcb; struct unpcb unpcb; int len; char dname[32], *strcpy(); /* fill in socket */ (void)lseek(kmem, (off_t)sock, L_SET); if (read(kmem, (char *)&so, sizeof(struct socket)) != sizeof(struct socket)) { rerr2(errno, (int)sock, "socket"); return; } /* fill in protosw entry */ (void)lseek(kmem, (off_t)so.so_proto, L_SET); if (read(kmem, (char *)&proto, sizeof(struct protosw)) != sizeof(struct protosw)) { rerr2(errno, (int)so.so_proto, "protosw"); return; } /* fill in domain */ (void)lseek(kmem, (off_t)proto.pr_domain, L_SET); if (read(kmem, (char *)&dom, sizeof(struct domain)) != sizeof(struct domain)) { rerr2(errno, (int)proto.pr_domain, "domain"); return; } /* * grab domain name * kludge "internet" --> "inet" for brevity */ if (dom.dom_family == AF_INET) (void)strcpy(dname, "inet"); else { (void)lseek(kmem, (off_t)dom.dom_name, L_SET); if ((len = read(kmem, dname, sizeof(dname) - 1)) < 0) { rerr2(errno, (int)dom.dom_name, "char"); dname[0] = '\0'; } else dname[len] = '\0'; } if ((u_short)so.so_type > STYPEMAX) printf("* (%s unk%d %x", dname, so.so_type, so.so_state); else printf("* (%s %s %x", dname, stypename[so.so_type], so.so_state); /* * protocol specific formatting * * Try to find interesting things to print. For tcp, the interesting * thing is the address of the tcpcb, for udp and others, just the * inpcb (socket pcb). For unix domain, its the address of the socket * pcb and the address of the connected pcb (if connected). Otherwise * just print the protocol number and address of the socket itself. * The idea is not to duplicate netstat, but to make available enough * information for further analysis. */ switch(dom.dom_family) { case AF_INET: getinetproto(proto.pr_protocol); if (proto.pr_protocol == IPPROTO_TCP ) { if (so.so_pcb) { (void)lseek(kmem, (off_t)so.so_pcb, L_SET); if (read(kmem, (char *)&inpcb, sizeof(struct inpcb)) != sizeof(struct inpcb)){ rerr2(errno, (int)so.so_pcb, "inpcb"); return; } printf(" %x", (int)inpcb.inp_ppcb); } } else if (so.so_pcb) printf(" %x", (int)so.so_pcb); break; case AF_UNIX: /* print address of pcb and connected pcb */ if (so.so_pcb) { printf(" %x", (int)so.so_pcb); (void)lseek(kmem, (off_t)so.so_pcb, L_SET); if (read(kmem, (char *)&unpcb, sizeof(struct unpcb)) != sizeof(struct unpcb)){ rerr2(errno, (int)so.so_pcb, "unpcb"); return; } if (unpcb.unp_conn) { char shoconn[4], *cp; cp = shoconn; if (!(so.so_state & SS_CANTRCVMORE)) *cp++ = '<'; *cp++ = '-'; if (!(so.so_state & SS_CANTSENDMORE)) *cp++ = '>'; *cp = '\0'; printf(" %s %x", shoconn, (int)unpcb.unp_conn); } } break; default: /* print protocol number and socket address */ printf(" %d %x", proto.pr_protocol, (int)sock); } printf(")\n"); } /* * getinetproto -- * print name of protocol number */ static getinetproto(number) int number; { char *cp; switch(number) { case IPPROTO_IP: cp = "ip"; break; case IPPROTO_ICMP: cp ="icmp"; break; case IPPROTO_GGP: cp ="ggp"; break; case IPPROTO_TCP: cp ="tcp"; break; case IPPROTO_EGP: cp ="egp"; break; case IPPROTO_PUP: cp ="pup"; break; case IPPROTO_UDP: cp ="udp"; break; case IPPROTO_IDP: cp ="idp"; break; case IPPROTO_RAW: cp ="raw"; break; default: printf(" %d", number); return; } printf(" %s", cp); } static readf() { struct file lfile; int i; itrans(DTYPE_INODE, user.user.u_cdir, WD); for (i = 0; i < NOFILE; i++) { if (user.user.u_ofile[i] == 0) continue; (void)lseek(kmem, (off_t)user.user.u_ofile[i], L_SET); if (read(kmem, (char *)&lfile, sizeof(lfile)) != sizeof(lfile)) { rerr1("file", N_KMEM); continue; } itrans(lfile.f_type, (struct inode *)lfile.f_data, i); } } static devmatch(idev, inum, name) dev_t idev; ino_t inum; char **name; { register DEVS *d; for (d = devs; d; d = d->next) if (d->dev == idev && (d->inum == 0 || d->inum == inum)) { *name = d->name; return(1); } return(0); } static getfname(filename) char *filename; { struct stat statbuf; DEVS *cur; char *malloc(); if (stat(filename, &statbuf)) { perror(filename); return(0); } if ((cur = (DEVS *)malloc(sizeof(DEVS))) == NULL) { fprintf(stderr, "fstat: out of space.\n"); exit(1); } cur->next = devs; devs = cur; /* if file is block special, look for open files on it */ if ((statbuf.st_mode & S_IFMT) != S_IFBLK) { cur->inum = statbuf.st_ino; cur->dev = statbuf.st_dev; } else { cur->inum = 0; cur->dev = statbuf.st_rdev; } cur->name = filename; return(1); } static openfiles() { if ((kmem = open(N_KMEM, O_RDONLY, 0)) < 0) { perror(N_KMEM); exit(1); } if ((mem = open(N_MEM, O_RDONLY, 0)) < 0) { perror(N_MEM); exit(1); } if ((swap = open(N_SWAP, O_RDONLY, 0)) < 0) { perror(N_SWAP); exit(1); } } static rerr1(what, fromwhat) char *what, *fromwhat; { if (vflg) printf("fstat: error reading %s from %s", what, fromwhat); } static rerr2(err, address, what) int err, address; char *what; { if (vflg) printf("error %d reading %s at %x from kmem\n", errno, what, address); } static long lgetw(loc) off_t loc; { long word; (void)lseek(kmem, (off_t)loc, L_SET); if (read(kmem, (char *)&word, sizeof(word)) != sizeof(word)) rerr2(errno, (int)loc, "word"); return(word); } static usage() { fputs("usage: fstat [-v] [-u user] [-p pid] [filename ...]\n", stderr); exit(1); }
[ "abs@absd.org" ]
abs@absd.org
b1f3a398c3bdcd94f63a9fcae27a208ce8bc7a59
e5efa7ed7ab5ac45fdb14f9164af203894a32753
/Control/carla-ros-bridge/catkin_ws/devel/include/carla_msgs/CarlaTrafficLightInfoList.h
666b46b08b2b14433c7ff7ebf5a76171179e3dbd
[]
no_license
wngudwls000/2021_Summer_Intern_CARLA
2e43d88efa0fffdb4e7f86bb0e6919b96f0768ad
dfde386c500b9145a12d955937c69d9a64a1dff9
refs/heads/main
2023-07-09T04:52:48.604063
2021-08-19T01:39:49
2021-08-19T01:39:49
397,782,041
0
0
null
null
null
null
UTF-8
C
false
false
112
h
/home/labdog/carla-ros-bridge/catkin_ws/devel/.private/carla_msgs/include/carla_msgs/CarlaTrafficLightInfoList.h
[ "wngudwls000@gmail.com" ]
wngudwls000@gmail.com