blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
250
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
5
107
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
185 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
15.7k
664M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
68 values
src_encoding
stringclasses
27 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
6
9.36M
extension
stringclasses
31 values
content
stringlengths
4
9.36M
authors
sequencelengths
1
1
author
stringlengths
0
73
d3feaa79e326239b0a0d83cc023398d19d8e050f
f4a11c3b79215563a9ff8c4501a0e977c57488e8
/pru/libs/controller/pru_controller.c
28373192cf73f9db91bb74b67857dd6d024a0692
[ "Apache-2.0" ]
permissive
org-mylinuxdrone-project/org.mylinuxdrone.project
67b5a1d67ff8206e01b3f946000fa34faa48c41b
9ddd0a97e52c82cb3569acc05e8e809128c532c9
refs/heads/master
2020-12-01T20:54:56.966487
2020-01-19T18:44:37
2020-01-19T18:44:37
230,766,992
0
0
null
null
null
null
UTF-8
C
false
false
7,752
c
/* * pru_controller.c * Created on: 06 gen 2020 * Author: Andrea Lambruschini <andrea.lambruschini@gmail.com> * * Copyright 2019 Andrea Lambruschini * * 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 <pru_controller.h> /* * +------------+ * |Axis | * +------------+ * | Z Y | * | | / | * | |/ | * | /____ X | * +------------+ * +--------------+ * | Motors | * +--------------+ * | 3(cw) 1(ccw) | * | \ / | * | \/ | * | /\ | * | / \ | * | 2(ccw)4(cw) | * +--------------+ * * +-----------+ * |Dir.Accel | * +--+--+--+--+ * | 1| 2| 3| 4| * +--+--+--+--+--+ * |-1|-1| 1| 1| Y| * A= |-1| 1|-1| 1| P| * |-1| 1| 1|-1| R| * | 1| 1| 1| 1| T| * +--+--+--+--+--+ */ /* TODO: * Input: RC(i), Accel, Gyro tutti in LSB * I dati devono essere forniti in scala e già rispetto agli assi definiti (matrici direzione già applicate) * Stato: F, M, MErr, MIErr, MDErr, Throttle * Parametri: ke, ki, kd * Calcolo: * - MErr(i)=Throttle(i)- Gyro(i) * - MIErr(i)=MIErr(i-1) + MIErr(i) * - MDErr(i)=(MErr(i) - MErr(i-1))*Freq (1KHz) * - M(i)=+ke*MErr(i)) + ki*MIErr(i)+ kd*MDErr(i) * - F(i)=inv(A)*M(i) * Output:F(i) * l'output è inviato direttamente al controller motori. */ struct pru_controller_status pru_controller_status_val = { {0, 0, 0, 0}, // F {0, 0, 0, 0}, // MErr {0, 0, 0, 0}, // MIErr {0, 0, 0, 0}, // MDErr {0, 0, 0, 0} // M }; struct pru_controller_config pru_controller_config_val = { 0x0100, // ke: fix point 8 bits (0x0100 corrisponde a 1) 0x0000, // ki: fix point 8 bits 0x0000, // kd: fix point 8 bits 0x0100, // yke: fix point 8 bits (0x0100 corrisponde a 1) 0x0000, // yki: fix point 8 bits 0x0000, // ykd: fix point 8 bits 0x13, // kgyro: fix point 5 bit 0x04 // mas: num samples accel }; int8_t invA[4][4] = { {-1, -1, -1, 1 }, {-1, 1, 1, 1 }, { 1, -1, 1, 1 }, { 1, 1, -1, 1 } }; uint8_t pru_controller_enabled = 0; struct pru_controller_status* pru_controller_get_status() { return &pru_controller_status_val; } struct pru_controller_config* pru_controller_get_config() { return &pru_controller_config_val; } void pru_controller_init() { uint8_t i = 0; pru_controller_enabled = 0; for(i = 0; i < 4; i++) { pru_controller_status_val.F[i] = 0; pru_controller_status_val.M[i] = 0; pru_controller_status_val.MErr[i] = 0; pru_controller_status_val.MIErr[i] = 0; pru_controller_status_val.MDErr[i] = 0; } } void pru_controller_enable() { pru_controller_init(); pru_controller_enabled = 1; } void pru_controller_disable() { pru_controller_init(); } uint8_t pru_controller_is_enabled() { return pru_controller_enabled; } /* * TODO: il calcolo del pid ha senso solo se si è in volo ... * Come identificare se si è in volo o no? * Approssimare con posizione throttle ... */ void pru_controller_apply(int16_t* rc, int16_t* accel, int16_t* gyro) { uint8_t i = 0; uint8_t j = 0; int16_t prevErr = 0; if(pru_controller_enabled == 0) { return; } prevErr = pru_controller_status_val.MErr[POS_YAW]; pru_controller_status_val.MErr[POS_YAW] = LIMIT(rc[POS_YAW] - gyro[POS_YAW], 10000, -10000); pru_controller_status_val.MDErr[POS_YAW] = pru_controller_status_val.MErr[POS_YAW] - prevErr; pru_controller_status_val.MIErr[POS_YAW] += pru_controller_status_val.MErr[POS_YAW]; // <---TODO: Gestire limiti max, min pru_controller_status_val.M[POS_YAW] = ((pru_controller_config_val.yke*pru_controller_status_val.MErr[POS_YAW]) >> 8)+ ((pru_controller_config_val.yki*pru_controller_status_val.MIErr[POS_YAW]) >> 8) + ((pru_controller_config_val.ykd*pru_controller_status_val.MDErr[POS_YAW]) >> 8); prevErr = pru_controller_status_val.MErr[POS_PITCH]; pru_controller_status_val.MErr[POS_PITCH] = LIMIT(rc[POS_PITCH] - gyro[POS_PITCH], 10000, -10000); pru_controller_status_val.MDErr[POS_PITCH] = pru_controller_status_val.MErr[POS_PITCH] - prevErr; pru_controller_status_val.MIErr[POS_PITCH] += pru_controller_status_val.MErr[POS_PITCH]; // <---TODO: Gestire limiti max, min pru_controller_status_val.M[POS_PITCH] = ((pru_controller_config_val.ke*pru_controller_status_val.MErr[POS_PITCH]) >> 8)+ ((pru_controller_config_val.ki*pru_controller_status_val.MIErr[POS_PITCH]) >> 8) + ((pru_controller_config_val.kd*pru_controller_status_val.MDErr[POS_PITCH]) >> 8); prevErr = pru_controller_status_val.MErr[POS_ROLL]; pru_controller_status_val.MErr[POS_ROLL] = LIMIT(rc[POS_ROLL] - gyro[POS_ROLL], 10000, -10000); pru_controller_status_val.MDErr[POS_ROLL] = pru_controller_status_val.MErr[POS_ROLL] - prevErr; pru_controller_status_val.MIErr[POS_ROLL] += pru_controller_status_val.MErr[POS_ROLL]; // <---TODO: Gestire limiti max, min pru_controller_status_val.M[POS_ROLL] = ((pru_controller_config_val.ke*pru_controller_status_val.MErr[POS_ROLL]) >> 8)+ ((pru_controller_config_val.ki*pru_controller_status_val.MIErr[POS_ROLL]) >> 8) + ((pru_controller_config_val.kd*pru_controller_status_val.MDErr[POS_ROLL]) >> 8); /* TODO: * Per ora non verifico l'accelerazione verticale * sarà implementazione successiva */ pru_controller_status_val.MErr[POS_THROTTLE] = 0; pru_controller_status_val.MDErr[POS_THROTTLE] = 0; pru_controller_status_val.MIErr[POS_THROTTLE] = 0; pru_controller_status_val.M[POS_THROTTLE] = rc[POS_THROTTLE]; for(i = 0; i < 4; i++) { pru_controller_status_val.F[i] = 0; for(j = 0; j < 4; j++) { // invA corrisponde a 4*A^(-1) per questo >> 2 pru_controller_status_val.F[i] += ((invA[i][j]*pru_controller_status_val.M[j]) >> 2); } pru_controller_status_val.F[i] = MAX(0, pru_controller_status_val.F[i]); // non possono essere negative } /* TODO: * Inviare F al controller motori * Motori a 16KHz (duty minimo 5% del periodo, duty massimo 10% del periodo) * periodo circa 63 microsecondi. Verificare la risposta degli ESC. * * */ }
[ "andrea.lambruschini@telecomitalia.it" ]
andrea.lambruschini@telecomitalia.it
fdb1ab0c6698d9fe649d7dbb68845fef034eb4ea
f08bbe3a9406fe3e39aa3c03eb979fdd88ea819a
/Oscillographer/EMWIN/STemWin/inc/GUIDRV_Dist.h
a6e47c4317c3dcb52a234fbdcea32f116e50cc22
[]
no_license
lazode/MCU_Code
e41def826d7b812fe00db76bd288106d7acd37e3
1105eb8f289f9107d97b3dc9de0e50a456570964
refs/heads/master
2020-12-30T15:07:39.352063
2017-08-11T06:11:00
2017-08-11T06:11:00
91,100,444
7
0
null
null
null
null
UTF-8
C
false
false
3,321
h
/********************************************************************* * SEGGER Microcontroller GmbH & Co. KG * * Solutions for real time microcontroller applications * ********************************************************************** * * * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG * * * * Internet: www.segger.com Support: support@segger.com * * * ********************************************************************** ** emWin V5.30 - Graphical user interface for embedded applications ** All Intellectual Property rights in the Software belongs to SEGGER. emWin is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with the following terms: The software has been licensed to ARM LIMITED whose registered office is situated at 110 Fulbourn Road, Cambridge CB1 9NJ, England solely for the purposes of creating libraries for ARM7, ARM9, Cortex-M series, and Cortex-R4 processor-based devices, sublicensed and distributed as part of the MDK-ARM Professional under the terms and conditions of the End User License supplied with the MDK-ARM Professional. Full source code is available at: www.segger.com We appreciate your understanding and fairness. ---------------------------------------------------------------------- Licensing information Licensor: SEGGER Software GmbH Licensed to: ARM Ltd Licensed SEGGER software: emWin License number: GUI-00181 License model: LES-SLA-20007, Agreement, effective since October 1st 2011 Licensed product: MDK-ARM Professional Licensed platform: ARM7/9, Cortex-M/R4 Licensed number of seats: - ---------------------------------------------------------------------- File : GUIDRV_Dist.h Purpose : Interface definition for GUIDRV_Dist driver ---------------------------END-OF-HEADER------------------------------ */ #ifndef GUIDRV_DIST_H #define GUIDRV_DIST_H #if defined(__cplusplus) extern "C" { /* Make sure we have C-declarations in C++ programs */ #endif /********************************************************************* * * Display driver */ // // Address // extern const GUI_DEVICE_API GUIDRV_Dist_API; // // Macros to be used in configuration files // #if defined(WIN32) && !defined(LCD_SIMCONTROLLER) #define GUIDRV_DIST &GUIDRV_Win_API #else #define GUIDRV_DIST &GUIDRV_Dist_API #endif /********************************************************************* * * Public routines */ #if defined(WIN32) && !defined(LCD_SIMCONTROLLER) #define GUIDRV_Dist_AddDriver(pDevice, pDriver, pRect) #else void GUIDRV_Dist_AddDriver(GUI_DEVICE * pDevice, GUI_DEVICE * pDriver, GUI_RECT * pRect); #endif #if defined(__cplusplus) } #endif #endif /* GUIDRV_DIST_H */ /*************************** End of file ****************************/
[ "lanzhuo_@hotmail.com" ]
lanzhuo_@hotmail.com
d58104b278162aaf063c1d3dd1b17f57f82d16ef
d63125caee9b6e9d54a29603da1680321cc884c4
/fibbronacci.c
4e1a528f466f420110501801465b37c8a6f844e7
[]
no_license
Kishankr09/Even-Fibonacci-numbers
dcb2903f10808112f82f335334a0b24de5c76794
e9f9f3d023cebe91b872af250418364634d511cd
refs/heads/master
2022-12-17T04:45:45.396062
2020-09-16T12:46:04
2020-09-16T12:46:04
null
0
0
null
null
null
null
UTF-8
C
false
false
265
c
#include<stdio.h> #include<conio.h> int main() { long n,j,k,s=2; j=2; k=1; do { n=j+k; k=j; j=n; if(n%2==0) s=s+n; }while(n<=4000000); printf("even sum %d",s); getch(); }
[ "noreply@github.com" ]
noreply@github.com
9bbcc951c7d52cde4c38591cb385092b7241a32c
e1704387d3045c8a0d631839fb6e317ffbe01605
/rounding.c
b1cd609a6d89fd24c23ec4c0da25cb5eb5ea80dd
[]
no_license
StevenXL/codeabbey
018f2e8a3e8473e24203313aa6bc74d287c602a6
bb60a78b55af4d364f4dfd880a802c354be99e20
refs/heads/master
2021-01-22T01:05:57.874532
2015-05-25T22:09:46
2015-05-25T22:09:46
27,338,129
1
0
null
null
null
null
UTF-8
C
false
false
1,997
c
#include <math.h> #include <stdio.h> #include <stdlib.h> int main(void) { // open file in read only mode FILE* inFile = fopen("rounding.txt", "r"); if (inFile == NULL) { printf("Unable to open file!\n"); return 1; } // create int var, store first line of file int num_pairs; fscanf(inFile, "%d", &num_pairs); // create array to hold pairs int* pairsArray; pairsArray = malloc (num_pairs * 2 * sizeof(int)); // read each line, add the pairs to our pairsArray int ii; for (ii = 0; ii < (num_pairs * 2); ii = ii + 2) { fscanf(inFile, "%d %d", &pairsArray[ii], &pairsArray[ii + 1]); } // create array to hold answers int* answersArray; answersArray = malloc (num_pairs * sizeof(int)); // find the answers and hold them in the array int jj = 0; int kk = 0; for (jj = 0, kk= 0; jj < (num_pairs * 2); jj = jj + 2, kk++) { float abs_div = fabsf( (float) pairsArray[jj] / pairsArray[jj + 1]); int int_div = abs( pairsArray[jj] / pairsArray[jj + 1] ); if ( (pairsArray[jj] / pairsArray[jj + 1]) > 0 ) { if ( (abs_div - int_div) >= 0.5 ) { answersArray[kk] = (pairsArray[jj] / pairsArray[jj + 1]) + 1; } else { answersArray[kk] = pairsArray[jj] / pairsArray[jj + 1]; } } else { if ( (abs_div - int_div) >= 0.5 ) { answersArray[kk] = (int_div + 1) * -1; } else { answersArray[kk] = int_div * -1; } } } // print answers int ll = 0; for (ll = 0; ll < num_pairs; ll++) { if (ll == (num_pairs - 1)) { printf("%d\n", answersArray[ll]); } else { printf("%d ", answersArray[ll]); } } return 0; }
[ "leiva.steven@gmail.com" ]
leiva.steven@gmail.com
f84b1cf23f444182504ab29826f57e6435b39cac
a70324bf8e5cf644e66b93d002370b0618b4b56f
/includes/move_finger.h
e2ba7681df1bb9a839a6420f835d949d01afd2a4
[]
no_license
bibaswan-bhawal/robotic-hand
7012e3dca7ba5f5fdc1954442a6529a32f4396dd
37212c89b83b8fa70c3220c0560de249c17a735b
refs/heads/main
2023-07-29T08:35:51.006139
2021-09-12T08:21:22
2021-09-12T08:21:22
405,585,248
1
0
null
null
null
null
UTF-8
C
false
false
153
h
#ifndef MOVE_FINGER_H #define MOVE_FINGER_H #include "Arduino.h" #include "var_def.h" void movefinger(Finger finger, int speed, int direction); #endif
[ "bibaswan3600@gmail.com" ]
bibaswan3600@gmail.com
b217cf352fd01dcd53f6d84df5144c03be758dd5
43441cde04695a2bf62a7a5f7db4072aa0a6d366
/vc60/G3D/Stdafx.h
52bd5687350a089aee5d51cb0558126e1952c8f6
[]
no_license
crespo2014/cpp-lib
a8aaf4b963d3bf41f91db3832dd51bcf601d54ee
de6b653bf4c689fc5ceb3e9fe0f4fe47d79acf95
refs/heads/master
2020-12-24T15:23:32.396924
2016-03-21T11:53:37
2016-03-21T11:53:37
26,559,932
0
0
null
null
null
null
UTF-8
C
false
false
1,529
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #if !defined(AFX_STDAFX_H__8FC3CE27_AEEE_11D3_A036_0000E8DE4B3B__INCLUDED_) #define AFX_STDAFX_H__8FC3CE27_AEEE_11D3_A036_0000E8DE4B3B__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #ifndef _AFX_NO_OLE_SUPPORT #include <afxole.h> // MFC OLE classes #include <afxodlgs.h> // MFC OLE dialog classes #include <afxdisp.h> // MFC Automation classes #endif // _AFX_NO_OLE_SUPPORT #ifndef _AFX_NO_DB_SUPPORT #include <afxdb.h> // MFC ODBC database classes #endif // _AFX_NO_DB_SUPPORT #ifndef _AFX_NO_DAO_SUPPORT #include <afxdao.h> // MFC DAO database classes #endif // _AFX_NO_DAO_SUPPORT #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT #include <gl\gl.h> #include <gl\glu.h> #include <afxmt.h> #include "math.h" //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__8FC3CE27_AEEE_11D3_A036_0000E8DE4B3B__INCLUDED_)
[ "lester.crespo.es@gmail.com" ]
lester.crespo.es@gmail.com
f85279fed26ed221e934ec0179c20fbdbd9d1b1d
9bfd1035daefdc9037289089ed4e6d00b208b672
/src/image.h
8f64fd652643b8e2dddbdd1818a34d0c58f41f37
[]
no_license
pjreddie/dl-hw1
bbb2a22e91b37b60a9ba6fb61b0ea2954a1bf63d
8440db1f85807f2fd33b18498a212a5f46619e8a
refs/heads/master
2020-04-01T08:39:07.358248
2018-10-25T19:31:17
2018-10-25T19:31:17
153,040,722
19
28
null
null
null
null
UTF-8
C
false
false
1,274
h
#ifndef IMAGE_H #define IMAGE_H #include <stdio.h> // DO NOT CHANGE THIS FILE #include "matrix.h" #define TWOPI 6.2831853 #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) typedef struct{ int w,h,c; float *data; } image; // Basic operations float get_pixel(image im, int x, int y, int c); void set_pixel(image im, int x, int y, int c, float v); image copy_image(image im); void shift_image(image im, int c, float v); void scale_image(image im, int c, float v); void clamp_image(image im); image get_channel(image im, int c); int same_image(image a, image b); image sub_image(image a, image b); image add_image(image a, image b); // Loading and saving typedef enum{ PNG, BMP, TGA, JPG } IMAGE_TYPE; image make_image(int w, int h, int c); image float_to_image(float *data, int w, int h, int c); image load_image(char *filename); void save_image_options(image im, const char *name, IMAGE_TYPE f, int quality); void save_image(image im, const char *name); void free_image(image im); // Resizing float nn_interpolate(image im, float x, float y, int c); image nn_resize(image im, int w, int h); float bilinear_interpolate(image im, float x, float y, int c); image bilinear_resize(image im, int w, int h); // Used for saving images #endif
[ "pjreddie@gmail.com" ]
pjreddie@gmail.com
93aabd81aeb654a4f0c98886f687b127b3124af7
3d0de0f2549d9025540fcec88624c72c079b406f
/BSW/src/bsw/gen/CanIf/src/CanIf_TriggerTransmit.c
86228e4eb3c6f75359a840610685dce687fba441
[]
no_license
ongbut999/Jenkins_Test
ee19936e1577bd93d2755d21299ed3fbec553db6
abb74480c4ce938dd1c7463627c4074071580af4
refs/heads/master
2023-06-23T21:26:57.794427
2021-07-22T08:05:20
2021-07-22T08:05:20
388,372,287
0
0
null
null
null
null
UTF-8
C
false
false
1,714
c
/* *************************************************************************************************** * Includes *************************************************************************************************** */ #include "CanIf_Prv.h" /* *************************************************************************************************** * used functions *************************************************************************************************** */ #if (CANIF_TRIGGERTRANSMIT_SUPPORT == STD_ON) #define CANIF_START_SEC_CODE #include "CanIf_MemMap.h" Std_ReturnType CanIf_TriggerTransmit(PduIdType TxPduId, PduInfoType* PduInfoPtr) { VAR (Std_ReturnType, AUTOMATIC ) lRetVal_en = E_NOT_OK; #if (CANIF_CFG_TX_FEATURE_ENABLED== STD_ON) /* Pointer to Tx Pdu configuration */ P2CONST(CanIf_Cfg_TxPduConfig_tst, AUTOMATIC, CANIF_CFG_CONST) lTxPduConfig_pst; VAR(uint16, AUTOMATIC) ltxPduCustId_t; /* If CAN Interface is uninitialized, report to DET and return E_NOT_OK */ CANIF_DET_REPORT_ERROR_NOT_OK((FALSE == CanIf_Prv_InitStatus_b), CANIF_TRIGGER_TRANSMIT_SID, CANIF_E_UNINIT) ltxPduCustId_t = CanIf_Prv_ConfigSet_tpst->TxPduIdTable_Ptr[TxPduId]; lTxPduConfig_pst = (CanIf_Prv_ConfigSet_tpst->CanIf_TxPduConfigPtr) + ltxPduCustId_t; /*TxPduId passed is always valid as it is sent by Canif to Can*/ if(lTxPduConfig_pst->TxPduTriggerTransmit == TRUE) { if(NULL_PTR != lTxPduConfig_pst->UserTriggerTransmit) { lRetVal_en = lTxPduConfig_pst->UserTriggerTransmit(TxPduId, PduInfoPtr); } } #endif return lRetVal_en; } #define CANIF_STOP_SEC_CODE #include "CanIf_MemMap.h" #endif
[ "fixed-term.Truong.HuynhQuang@vn.bosch.com" ]
fixed-term.Truong.HuynhQuang@vn.bosch.com
519ccb0190db14fef617c8af9e2ac59b57620731
bcddcbd49bfc9101c05640525b0f32b60ffa0562
/libft/ft_isdigit.c
20e45149f1e564b42b8bdc98b716c2f72d9c5853
[]
no_license
arodiono/lem-in
16169ba9955fb6742d00328b1ac2848847e3198d
9bae77270ae51a636f3b365fe9d7a4295c8416d5
refs/heads/master
2021-01-25T10:56:30.218627
2017-06-09T21:15:52
2017-06-09T21:15:52
93,897,258
0
0
null
null
null
null
UTF-8
C
false
false
978
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isdigit.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: arodiono <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/23 16:53:27 by arodiono #+# #+# */ /* Updated: 2016/11/23 16:57:35 by arodiono ### ########.fr */ /* */ /* ************************************************************************** */ int ft_isdigit(int ch) { if (ch > 47 && ch < 58) return (1); else return (0); }
[ "arodiono@e1r5p7.unit.ua" ]
arodiono@e1r5p7.unit.ua
8dc0d4d3dbded87f4679d55880984f02b50741fc
1c34c2aebd8294cddc9f7600d14d77bd007bffad
/ADC_CONFIGURATIONS_EXAMPLE1/src/asf.h
1d6120e7d5f6930ed7546d84ce894558a1fb7b59
[]
no_license
Hamidreza-k/adc
a9b0b2975ab3ebc820aa4d45904f38115e5ceaed
0f784b20d22fcd5bd6b4badd29f156a0ed8c21cf
refs/heads/master
2020-03-11T07:27:21.885771
2018-04-20T03:50:16
2018-04-20T03:50:16
129,857,224
0
0
null
null
null
null
UTF-8
C
false
false
3,802
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: ADC - Analog-to-Digital Converter (Callback APIs) #include <adc.h> #include <adc_callback.h> // From module: Common SAM0 compiler driver #include <compiler.h> #include <status_codes.h> // From module: Delay routines #include <delay.h> // From module: EVSYS - Event System Common #include <events.h> // From module: EVSYS - Event System with interupt hooks support #include <events_hooks.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 USART - Serial Communications (Callback APIs) #include <usart.h> #include <usart_interrupt.h> // From module: SYSTEM - Clock Management for SAMD21/R21/DA/HA #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: SYSTEM - Power Management for SAM D20/D21/R21/D09/D10/D11/DA/HA #include <power.h> // From module: SYSTEM - Reset Management for SAM D20/D21/R21/D09/D10/D11/DA/HA #include <reset.h> // From module: Standard serial I/O (stdio) #include <stdio_serial.h> // From module: TC - Timer Counter (Callback APIs) #include <tc.h> #include <tc_interrupt.h> // From module: USART - Serial interface- SAM implementation for devices with only USART #include <serial.h> #endif // ASF_H
[ "H.KHISHAVAND@GMAIL.com" ]
H.KHISHAVAND@GMAIL.com
b5241295a36ced51dc6cf50d3ecc9b7eaf3f2140
d4f05d3ce52560b8b91c9ba96f6c6f7324af3314
/main.c
125ab966fbc379db7457e030c5f9f57510e91810
[]
no_license
matheyal/NF16-ABR
04a559728aa438f586cf05398a61dce451b0d55a
adf5b6018a5c54032eb1621d477dcf5ae1bc323b
refs/heads/master
2021-01-01T05:53:59.715354
2015-04-01T14:27:41
2015-04-01T14:27:41
28,718,026
0
1
null
null
null
null
UTF-8
C
false
false
5,694
c
#include "liste.h" #include "arbre.h" #include "outils.h" //outil.c : pb main 6 : avec certains mot. int main() { printf("Bonjour !\n\n"); /*Variables utilisées pour gérer le menu et les appels de fonction*/ int choix, mots_lus, fichier_charge=0; char* filename=(char*)malloc(200*sizeof(char)); char* filename2=(char*)malloc(200*sizeof(char)); char* mot=(char*)malloc(50*sizeof(char)); char* mot1=(char*)malloc(50*sizeof(char)); char* mot2=(char*)malloc(50*sizeof(char)); ArbreBR* a=NULL; /*Affichage de l'en-tete du programme */ printf("\tBienvenue dans votre programme de classement alphabetique de texte\n\n"); while(1) { printf("Menu principal : Veuillez choisir une fonction a effectuer \n"); printf("\t1 - Creer un arbre binaire de recherche\n"); printf("\t2 - Charger un fichier dans l'ABR\n"); printf("\t3 - Afficher les caracteristiques de l'ABR\n"); printf("\t4 - Afficher tous les mots distincts de l'ABR par ordre alphabetique\n"); printf("\t5 - Rechercher un mot dans l'ABR\n"); printf("\t6 - Afficher les phrases contenant les 2 mots saisis\n"); printf("\t7 - Afficher un fichier ligne par ligne\n"); printf("\t8 - Quitter le programme\n"); scanf("%d", &choix); switch (choix) { /*Création ABR*/ case 1: a=creer_abr(); if (a!=NULL) printf("Arbre cree !\n\n"); else printf("Erreur de création de l'arbre.\n\n"); break; /*Charger un fichier*/ case 2: if (a!=NULL) { printf("Veuillez saisir le fichier a charger en chemin relatif ou absolu : "); scanf("%s",filename); mots_lus=charger_fichier(a,filename); if (mots_lus==-1) printf("Veuillez verifier votre saisie de chemin.\n\n"); else { fichier_charge=1; if(mots_lus==0) printf("Aucun mot n'a pu etre lu !\n\n"); else printf("%d mots ont ete lus dans le fichier !\n\n",mots_lus); } } else printf("Impossible ! Arbre non cree !\n\n"); break; /*Afficher caractériqtiques ABR*/ case 3: if (a!=NULL) { printf("Nombre de mots total : %d\nNombre de noeuds : %d\nProfondeur de l'arbre : %d\n",a->nb_mots_total,a->nb_mots_differents,hauteur_arbre(a)); if (est_equilibre(a->racine)) printf("Arbre equilibre.\n\n"); else printf("Arbre non equilibre.\n\n"); } else printf("Impossible ! Arbre non cree !\n\n"); break; /*Afficher mots distincts*/ case 4: if (a!=NULL) { afficher_arbre(*a); printf("\n"); } else printf("Impossible ! Arbre non cree !\n\n"); break; /*Rechercher un mot*/ case 5: if (a!=NULL) { printf("\nVeuillez saisir le mot a rechercher : "); scanf("%s",mot); mot2=StringToLower(mot); char* nom1 = (char*)malloc(strlen(mot2)); memcpy(nom1, mot2, strlen(mot2)+1); NoeudABR* x=rechercher_noeud(a,nom1); afficher_position(x); } else printf("Impossible ! Arbre non cree !\n\n"); break; /*Recherche de phrase à partir de 2 mots*/ case 6: if (a!=NULL) { if(fichier_charge) { printf("Veuillez saisir les mots recherches : "); scanf("%s %s",mot, mot1); afficher_phrases(a,mot,mot1,filename); } else printf("Impossible ! Aucun fichier charge dans l'ABR.\n\n"); } else { printf("Impossible ! Arbre non cree.\n\n"); } break; /*Affichage d'un fichier texte */ case 7: printf("Veuillez saisir le fichier a afficher en chemin relatif ou absolu : "); scanf("%s",filename2); afficher_fichier(filename2); break; /*Quitter le programme et rendre les allocations */ case 8: free(filename); free(filename2); free(mot); free(mot1); free_arbre(a, a->racine); printf("Au revoir !\n"); return 0; default: printf("Commande non reconnue.\n\n"); break; } } }
[ "alex.mathey78@gmail.com" ]
alex.mathey78@gmail.com
9371a19c502fd81fc0b7dc7ba3a570f978387bce
2dbfaaf469b864698c33e1849059a41b76812659
/Phase-2-UAV-Experimental-Platform-June/CAmkES_sel4_VM/slang_libraries/SW_Impl_Instance_RADIO_RadioDriver_Attestation/ext/RadioDriver_Attestation_thr_Impl_Impl_api.h
a6e4e89737d16eb2cc01304a919ce3bc1dcc3c8c
[]
no_license
loonwerks/case-ta6-experimental-platform-models
e12b92aced4841cb6b785718e9af4c8da9a370b6
fe273e2fdbac92b3553a9e9dbf6d5738a5431e17
refs/heads/master
2022-01-20T18:11:30.444037
2022-01-10T17:08:21
2022-01-10T17:12:13
171,710,829
0
2
null
2021-01-27T20:05:53
2019-02-20T16:39:34
C
UTF-8
C
false
false
110
h
../../../../hamr/src/c/ext-c/RadioDriver_Attestation_thr_Impl_Impl/RadioDriver_Attestation_thr_Impl_Impl_api.h
[ "egm@cs.byu.edu" ]
egm@cs.byu.edu
b44fd3b9a001535f1927033ca48a5be1527afbc9
5c255f911786e984286b1f7a4e6091a68419d049
/vulnerable_code/abd0265d-4c43-4805-b898-2b1b1c979923.c
23953ab547c8114b260ca41cdefa2d94afd81f67
[]
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
608
c
#include <string.h> #include <stdio.h> int main() { int i=0; int j=14; int k; int l; k = 53; l = 64; k = i/j; l = i/j; l = i/j; l = l/j; l = k%j; l = k-j; k = k-k*i; //variables //random /* START VULNERABILITY */ int a; int b[69]; int c[47]; a = 0; while (( a - 1 ) > -1) { a--; /* START BUFFER SET */ *((int *)c + ( a - 1 )) = *((int *)b + ( a - 1 )); /* END BUFFER SET */ //random } /* END VULNERABILITY */ //random printf("%d%d\n",k,l); return 0; }
[ "nharmon8@gmail.com" ]
nharmon8@gmail.com
11f27fb7a445127a9afcd94f9d2f85e2f1f703ef
a95227278641ba65e6a09f77c6320bbdc9359886
/130.c
d4c4f6c7ae153190a8b79d2634ab4ce280a46df4
[]
no_license
MANOJTMK/player13
868bb171fd34f14ef4a4787ed1e8d43b308feb71
59b0c76be80745e46af83fbb6970fa6514b1fecc
refs/heads/master
2020-04-27T23:16:03.566539
2019-03-24T09:09:00
2019-03-24T09:09:00
174,768,732
0
0
null
null
null
null
UTF-8
C
false
false
281
c
#include <stdio.h> #include<conio.h> int main(void) { int n; scanf("%d",&n); int a[n],i,sum=0; for(i=0;i<n;i++) { scanf("%d ",&a[i]); } for(i=0;i<n;i++) { sum=sum+a[i]; if(sum%2==0) { printf("%d ",sum); } else { printf("%d ",a[i]); } } return 0; }
[ "noreply@github.com" ]
noreply@github.com
0fb33c31617130aca08fba96332d0338ab13c50c
fa19a9c2e6ca05a67ebb4bf5b1dfa1b00f90fe3b
/src/h4_path_hpm.h
585c025e4349f1ec49f9a10b4439f06ab54663cc
[]
no_license
gwwilburn/HPMHomology
95aa73cfdd9d29db58831b33521814b3143b897f
5b6725bbf29b431983fd581e4b03d2e64cdc1bf0
refs/heads/master
2022-12-17T23:53:04.277739
2020-09-16T21:58:46
2020-09-16T21:58:46
127,052,587
1
0
null
null
null
null
UTF-8
C
false
false
553
h
/* h4_path_hpm.h*/ /* Grey's functions with h4 paths */ #ifndef h4PATHHPM_INCLUDED #define h4PATHHPM_INCLUDED #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include "easel.h" #include "esl_alphabet.h" #include "esl_msa.h" #include "h4_config.h" #include "h4_mode.h" #include "h4_profile.h" #include "h4_path.h" extern int h4_path_FromMSA(ESL_MSA *msa, int8_t *matassign, int optflags, H4_PATH **pi); extern int h4_path_DumpAnnotated(FILE *fp, const H4_PATH *pi, const H4_PROFILE *hmm, const H4_MODE *mo, const ESL_DSQ *dsq); #endif
[ "wilburn@g.harvard.edu" ]
wilburn@g.harvard.edu
cf0612c57b36d6c3644efc482aac3bd55cf2ddac
9a3b9d80afd88e1fa9a24303877d6e130ce22702
/src/Providers/UNIXProviders/StorageRelocationService/UNIX_StorageRelocationServicePrivate.h
9d7da4ab60cb56f61e80e76b7ba21d841b109555
[ "MIT" ]
permissive
brunolauze/openpegasus-providers
3244b76d075bc66a77e4ed135893437a66dd769f
f24c56acab2c4c210a8d165bb499cd1b3a12f222
refs/heads/master
2020-04-17T04:27:14.970917
2015-01-04T22:08:09
2015-01-04T22:08:09
19,707,296
0
0
null
null
null
null
UTF-8
C
false
false
2,554
h
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // 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. // ////////////////////////////////////////////////////////////////////////// // //%///////////////////////////////////////////////////////////////////////// #if defined(PEGASUS_OS_HPUX) # include "UNIX_StorageRelocationServicePrivate_HPUX.h" #elif defined(PEGASUS_OS_LINUX) # include "UNIX_StorageRelocationServicePrivate_LINUX.h" #elif defined(PEGASUS_OS_DARWIN) # include "UNIX_StorageRelocationServicePrivate_DARWIN.h" #elif defined(PEGASUS_OS_AIX) # include "UNIX_StorageRelocationServicePrivate_AIX.h" #elif defined(PEGASUS_OS_FREEBSD) # include "UNIX_StorageRelocationServicePrivate_FREEBSD.h" #elif defined(PEGASUS_OS_SOLARIS) # include "UNIX_StorageRelocationServicePrivate_SOLARIS.h" #elif defined(PEGASUS_OS_ZOS) # include "UNIX_StorageRelocationServicePrivate_ZOS.h" #elif defined(PEGASUS_OS_VMS) # include "UNIX_StorageRelocationServicePrivate_VMS.h" #elif defined(PEGASUS_OS_TRU64) # include "UNIX_StorageRelocationServicePrivate_TRU64.h" #else # include "UNIX_StorageRelocationServicePrivate_STUB.h" #endif
[ "brunolauze@msn.com" ]
brunolauze@msn.com
26516eeb302ec10ec5ccb915df2051c0ec08a920
805666a84218be543410ff5089588f1572dd20ec
/d/quanzhou/yongning.c
405b9906349c5168742a6fa1ccc739e6c54c8adc
[]
no_license
mudchina/xkx2001
d47a9caca686ab7c89fe0b9140fbaf9d3601e1f5
4e8f8a13a72884d5dbe4b589542eb34e29e89d70
refs/heads/master
2021-01-10T06:50:29.517433
2016-02-20T14:09:12
2016-02-20T14:09:12
52,156,038
24
23
null
null
null
null
GB18030
C
false
false
801
c
//Cracked by Roath // yongning.c 永宁港 // qfy Nov 3, 1996 // modified by aln #include <ansi.h> inherit HARBOR; void create() { set("short", "永宁港"); set("long", @LONG 永宁港是泉州三大港口之一。这里港阔水深,风平浪静。极目远眺,海天 一色,蔚蓝无暇。岸边停靠着密密麻麻的各种船只。南边的姑嫂塔流传着一个 感人的故事。 LONG ); set("exits", ([ /* sizeof() == 4 */ "south" : __DIR__"gushao", "northwest" : __DIR__"gangkou2", ])); set("objects", ([ __DIR__"npc/tiao-fu" : 1, __DIR__"npc/kuli" : 1, ])); set("no_clean_up", 0); set("outdoors", "quanzhou"); set("navigate/locx", 0); set("navigate/locy", -280); set("cost", 1); setup(); }
[ "liming.xie@gmail.com" ]
liming.xie@gmail.com
1ab6078efe73ef412931f3ea46d4b43180afd40b
e81220623f8e27b9df4364cd41cd63ed0edf9d72
/NavigationDG/jni/3rdParty/fftw3/dft/scalar/codelets/t2_4.c
75a1fa2547ed0d038a03aebcafea77b6938909a2
[ "Apache-2.0" ]
permissive
jwietrzykowski/DiamentowyGrant
f04514812e7e4f46815f073e3df3820d5f7501cd
490470eff4cacc04102109e25a17044da8273c89
refs/heads/master
2021-05-30T03:49:11.013568
2015-09-16T11:04:29
2015-09-16T11:04:29
null
0
0
null
null
null
null
UTF-8
C
false
false
5,367
c
/* * Copyright (c) 2003, 2007-8 Matteo Frigo * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* This file was automatically generated --- DO NOT EDIT */ /* Generated on Sun Jul 12 06:37:48 EDT 2009 */ #include "../../codelet-dft.h" #ifdef HAVE_FMA /* Generated by: ../../../genfft/gen_twiddle -fma -reorder-insns -schedule-for-pipeline -compact -variables 4 -pipeline-latency 4 -twiddle-log3 -precompute-twiddles -n 4 -name t2_4 -include t.h */ /* * This function contains 24 FP additions, 16 FP multiplications, * (or, 16 additions, 8 multiplications, 8 fused multiply/add), * 33 stack variables, 0 constants, and 16 memory accesses */ #include "../t.h" static void t2_4(float *ri, float *ii, const float *W, stride rs, INT mb, INT me, INT ms) { INT m; for (m = mb, W = W + (mb * 4); m < me; m = m + 1, ri = ri + ms, ii = ii + ms, W = W + 4, MAKE_VOLATILE_STRIDE(rs)) { E Ti, Tq, To, Te, Ty, Tz, Tm, Ts; { E T2, T6, T3, T5; T2 = W[0]; T6 = W[3]; T3 = W[2]; T5 = W[1]; { E T1, Tx, Td, Tw, Tj, Tl, Ta, T4, Tk, Tr; T1 = ri[0]; Ta = T2 * T6; T4 = T2 * T3; Tx = ii[0]; { E T8, Tb, T7, Tc; T8 = ri[WS(rs, 2)]; Tb = FNMS(T5, T3, Ta); T7 = FMA(T5, T6, T4); Tc = ii[WS(rs, 2)]; { E Tf, Th, T9, Tv, Tg, Tp; Tf = ri[WS(rs, 1)]; Th = ii[WS(rs, 1)]; T9 = T7 * T8; Tv = T7 * Tc; Tg = T2 * Tf; Tp = T2 * Th; Td = FMA(Tb, Tc, T9); Tw = FNMS(Tb, T8, Tv); Ti = FMA(T5, Th, Tg); Tq = FNMS(T5, Tf, Tp); } Tj = ri[WS(rs, 3)]; Tl = ii[WS(rs, 3)]; } To = T1 - Td; Te = T1 + Td; Ty = Tw + Tx; Tz = Tx - Tw; Tk = T3 * Tj; Tr = T3 * Tl; Tm = FMA(T6, Tl, Tk); Ts = FNMS(T6, Tj, Tr); } } { E Tn, TA, Tu, Tt; Tn = Ti + Tm; TA = Ti - Tm; Tu = Tq + Ts; Tt = Tq - Ts; ii[WS(rs, 3)] = TA + Tz; ii[WS(rs, 1)] = Tz - TA; ri[0] = Te + Tn; ri[WS(rs, 2)] = Te - Tn; ri[WS(rs, 1)] = To + Tt; ri[WS(rs, 3)] = To - Tt; ii[WS(rs, 2)] = Ty - Tu; ii[0] = Tu + Ty; } } } static const tw_instr twinstr[] = { {TW_CEXP, 0, 1}, {TW_CEXP, 0, 3}, {TW_NEXT, 1, 0} }; static const ct_desc desc = { 4, "t2_4", twinstr, &fftwf_dft_t_genus, {16, 8, 8, 0}, 0, 0, 0 }; void fftwf_codelet_t2_4 (planner *p) { fftwf_kdft_dit_register (p, t2_4, &desc); } #else /* HAVE_FMA */ /* Generated by: ../../../genfft/gen_twiddle -compact -variables 4 -pipeline-latency 4 -twiddle-log3 -precompute-twiddles -n 4 -name t2_4 -include t.h */ /* * This function contains 24 FP additions, 16 FP multiplications, * (or, 16 additions, 8 multiplications, 8 fused multiply/add), * 21 stack variables, 0 constants, and 16 memory accesses */ #include "../t.h" static void t2_4(float *ri, float *ii, const float *W, stride rs, INT mb, INT me, INT ms) { INT m; for (m = mb, W = W + (mb * 4); m < me; m = m + 1, ri = ri + ms, ii = ii + ms, W = W + 4, MAKE_VOLATILE_STRIDE(rs)) { E T2, T4, T3, T5, T6, T8; T2 = W[0]; T4 = W[1]; T3 = W[2]; T5 = W[3]; T6 = FMA(T2, T3, T4 * T5); T8 = FNMS(T4, T3, T2 * T5); { E T1, Tp, Ta, To, Te, Tk, Th, Tl, T7, T9; T1 = ri[0]; Tp = ii[0]; T7 = ri[WS(rs, 2)]; T9 = ii[WS(rs, 2)]; Ta = FMA(T6, T7, T8 * T9); To = FNMS(T8, T7, T6 * T9); { E Tc, Td, Tf, Tg; Tc = ri[WS(rs, 1)]; Td = ii[WS(rs, 1)]; Te = FMA(T2, Tc, T4 * Td); Tk = FNMS(T4, Tc, T2 * Td); Tf = ri[WS(rs, 3)]; Tg = ii[WS(rs, 3)]; Th = FMA(T3, Tf, T5 * Tg); Tl = FNMS(T5, Tf, T3 * Tg); } { E Tb, Ti, Tn, Tq; Tb = T1 + Ta; Ti = Te + Th; ri[WS(rs, 2)] = Tb - Ti; ri[0] = Tb + Ti; Tn = Tk + Tl; Tq = To + Tp; ii[0] = Tn + Tq; ii[WS(rs, 2)] = Tq - Tn; } { E Tj, Tm, Tr, Ts; Tj = T1 - Ta; Tm = Tk - Tl; ri[WS(rs, 3)] = Tj - Tm; ri[WS(rs, 1)] = Tj + Tm; Tr = Tp - To; Ts = Te - Th; ii[WS(rs, 1)] = Tr - Ts; ii[WS(rs, 3)] = Ts + Tr; } } } } static const tw_instr twinstr[] = { {TW_CEXP, 0, 1}, {TW_CEXP, 0, 3}, {TW_NEXT, 1, 0} }; static const ct_desc desc = { 4, "t2_4", twinstr, &fftwf_dft_t_genus, {16, 8, 8, 0}, 0, 0, 0 }; void fftwf_codelet_t2_4 (planner *p) { fftwf_kdft_dit_register(p, t2_4, &desc); } #endif /* HAVE_FMA */
[ "michalsminowicki@gmail.com" ]
michalsminowicki@gmail.com
95e6949088651e36b7b514e5ef9004f89e7e7752
496db11ab732538b6d7f486a3afc3c5593abebc9
/src/guide/FUSION.H
c0e682d8bc2094bff947791b14694047521a68ea
[]
no_license
luckialuo/4rotor
74502a86640e4ae324d9d625ed220246ed2df335
f1993832fd3e32b29949cfff1bd772088a266ca1
refs/heads/code
2021-01-10T07:37:07.587922
2016-03-26T14:25:00
2016-03-26T14:25:00
54,782,318
0
0
null
2016-03-26T14:37:22
2016-03-26T14:18:56
C
GB18030
C
false
false
513
h
#ifndef _FUSION_H_ #define _FUSION_H_ extern FP32 ac_lon, ac_lat; /*[经度/纬度]*/ extern FP32 ac_Vd, /*[地速]*/ ac_psi, /*[真航向][0~360]*/ psi_cat; extern FP32 ac_height; extern INT32S info_alt; /*[高度信息源]*/ extern INT16S dL_mix0, dZ_mix0; void fusion_refresh_gps(FP32 lon, FP32 lat, FP32 psi); void fusion_guide(void); void fusion_slow(void); #endif
[ "luckialuo@gmail.com" ]
luckialuo@gmail.com
98e55fd99cc5141ee22b5e3e008a1b3b9eb21a97
28be9376f20320248283114ca82938b7561a3f76
/PWM_Code/lpc_chip_5411x_m0/inc/spi_common_5411x.h
d50aca447fcd7a889268b10169e67b71d0ecdbce
[]
no_license
ankitjhall/Project_Pixybot
5f08b4c1fea7f4c492fb89d373e1dea706ac6ce7
85bf0f825e1c9fa48516a7ba3ff5b8ff19b8e73d
refs/heads/master
2022-03-15T23:08:49.831199
2022-03-03T05:01:11
2022-03-03T05:01:11
187,408,114
2
0
null
null
null
null
UTF-8
C
false
false
31,896
h
/* * @brief LPC5411X SPI common functions and definitions * * @note * Copyright(C) NXP Semiconductors, 2015 * All rights reserved. * * @par * Software that is described herein is for illustrative purposes only * which provides customers with programming information regarding the * LPC products. This software is supplied "AS IS" without any warranties of * any kind, and NXP Semiconductors and its licensor disclaim any and * all warranties, express or implied, including all implied warranties of * merchantability, fitness for a particular purpose and non-infringement of * intellectual property rights. NXP Semiconductors assumes no responsibility * or liability for the use of the software, conveys no license or rights under any * patent, copyright, mask work right, or any other intellectual property rights in * or to any products. NXP Semiconductors reserves the right to make changes * in the software without notification. NXP Semiconductors also makes no * representation or warranty that such application will be suitable for the * specified use without further testing or modification. * * @par * Permission to use, copy, modify, and distribute this software and its * documentation is hereby granted, under NXP Semiconductors' and its * licensor's relevant copyrights in the software, without fee, provided that it * is used in conjunction with NXP Semiconductors microcontrollers. This * copyright, permission, and disclaimer notice must appear in all copies of * this code. */ #ifndef __SPI_COMMON_5411X_H_ #define __SPI_COMMON_5411X_H_ #ifdef __cplusplus extern "C" { #endif /** @defgroup SPI_COMMON_5411X CHIP: LPC5411X SPI driver * * The SPI interface is provided via FlexCOMM module in the CHIP, to associate a SPI to * a flexcom the source file must add a define like <b>\#define SPI0_FLEXCOMM 5</b> which * will make LPC_SPI0 use LPC_FLEXCOMM5, interrupt service function name and IRQ number * DMA REQUEST number will all be mapped automatically. <b> Note that this define must * be available/visible to all the sources that uses SPI.</b><br><br> The SPI driver * by default will use FIFOs for TX and RX. TX and RX FIFOs has a depth of 8 entries each. * * @ingroup CHIP_5411X_DRIVERS * @{ */ /** * @brief SPI register block structure */ typedef struct { /*!< SPI Structure */ /** SPI registers @endcond */ __I uint32_t RESERVED0[256]; __IO uint32_t CFG; /*!< Offset: 0x400 SPI Configuration register */ __IO uint32_t DLY; /*!< Offset: 0x404 SPI Delay register */ __IO uint32_t STAT; /*!< Offset: 0x408 SPI Status register */ __IO uint32_t INTENSET; /*!< Offset: 0x40c SPI Interrupt Enable Set register */ __IO uint32_t INTENCLR; /*!< Offset: 0x410 SPI Interrupt Enable Clear register */ __I uint32_t RESERVED1[4]; __IO uint32_t DIV; /*!< Offset: 0x424 SPI clock Divider register */ __IO uint32_t INTSTAT; /*!< Offset: 0x428 SPI Interrupt Status register @cond */ __I uint32_t RESERVED2[629]; /** SPI FIFO Specific registers @endcond */ __IO uint32_t FIFOCFG; /*!< Offset: 0xE00 FIFO Configuration register */ __IO uint32_t FIFOSTAT; /*!< Offset: 0xE04 FIFO Status register */ __IO uint32_t FIFOTRIG; /*!< Offset: 0xE08 FIFO Trigger level register @cond */ __I uint32_t RESERVED3; /*!< Offset: 0xE0C Reserved register @endcond */ __IO uint32_t FIFOINTENSET; /*!< Offset: 0xE10 FIFO Interrupt enable SET register */ __IO uint32_t FIFOINTENCLR; /*!< Offset: 0xE14 FIFO Interrupt enable CLEAR register */ __IO uint32_t FIFOINTSTAT; /*!< Offset: 0xE18 FIFO Interrupt Status register @cond */ __I uint32_t RESERVED4; /*!< Offset: 0xE1C Reserved register @endcond */ __O uint32_t FIFOWR; /*!< Offset: 0xE20 FIFO Data write register @cond */ __I uint32_t RESERVED5[3]; /*!< Offset: 0xE24 Reserved register @endcond */ __I uint32_t FIFORD; /*!< Offset: 0xE30 FIFO Data read register @cond */ __I uint32_t RESERVED6[3]; /*!< Offset: 0xE24 Reserved register @endcond */ __I uint32_t FIFORDNOPOP; /*!< Offset: 0xE40 FIFO Data peek (read without popping out of queue) register @cond */ __I uint32_t RESERVED7[109]; /*!< Offset: 0xE44 Reserved register */ /** FLEXCOMM Interface registers @endcond */ __IO uint32_t PSELID; /*!< Offset: 0xFF8 Peripheral select/identification register */ __I uint32_t PID; /*!< Offset: 0xFFC Module identification register */ } LPC_SPI_T; /** * Macro defines for SPI Configuration register */ #define SPI_CFG_BITMASK (0x0FBD) /** SPI register bit mask */ #define SPI_CFG_SPI_EN (1 << 0) /** SPI Slave Mode Select */ #define SPI_CFG_SLAVE_EN (0 << 0) /** SPI Master Mode Select */ #define SPI_CFG_MASTER_EN (1 << 2) /** SPI MSB First mode enable */ #define SPI_CFG_MSB_FIRST_EN (0 << 3) /** SPI LSB First mode enable */ #define SPI_CFG_LSB_FIRST_EN (1 << 3) /** SPI Clock Phase Select */ #define SPI_CFG_CPHA_FIRST (0 << 4) /** Capture data on the first edge, Change data on the following edge */ #define SPI_CFG_CPHA_SECOND (1 << 4) /** SPI Clock Polarity Select */ #define SPI_CFG_CPOL_LO (0 << 5) /** The rest state of the clock (between frames) is low. */ #define SPI_CFG_CPOL_HI (1 << 5) /** The rest state of the clock (between frames) is high. */ #define SPI_CFG_LBM_EN (1 << 7) /** SPI control 1 loopback mode enable */ #define SPI_CFG_SPOL_LO (0 << 8) /** SPI SSEL0 Polarity Select */ #define SPI_CFG_SPOL_HI (1 << 8) /** SSEL0 is active High */ #define SPI_CFG_SPOLNUM_HI(n) (1 << ((n) + 8)) /** SSELN is active High, selects 0 - 3 */ /** * Macro defines for SPI Delay register */ #define SPI_DLY_BITMASK (0xFFFF) /** SPI DLY Register Mask */ #define SPI_DLY_PRE_DELAY(n) (((n) & 0x0F) << 0) /** Time in SPI clocks between SSEL assertion and the beginning of a data frame */ #define SPI_DLY_POST_DELAY(n) (((n) & 0x0F) << 4) /** Time in SPI clocks between the end of a data frame and SSEL deassertion. */ #define SPI_DLY_FRAME_DELAY(n) (((n) & 0x0F) << 8) /** Minimum time in SPI clocks between adjacent data frames. */ #define SPI_DLY_TRANSFER_DELAY(n) (((n) & 0x0F) << 12) /** Minimum time in SPI clocks that the SSEL is deasserted between transfers. */ /** * Macro defines for SPI Status register */ #define SPI_STAT_BITMASK (0x01F0) /** SPI STAT Register BitMask */ #define SPI_STAT_SSA (1 << 4) /** Slave Select Assert */ #define SPI_STAT_SSD (1 << 5) /** Slave Select Deassert */ #define SPI_STAT_STALLED (1 << 6) /** Stalled status flag */ #define SPI_STAT_EOT (1 << 7) /** End Transfer flag */ #define SPI_STAT_MSTIDLE (1 << 8) /** Idle status flag */ /** * Macro defines for SPI interrupt register */ #define SPI_INT_BITMASK (0x0130) /** SPI interrupt Enable/Disable bits */ #define SPI_INT_SSAEN (1 << 4) /** Slave Select is asserted interrupt [BIT-4 of INTENSET/INTENCLR/INTSTAT register] */ #define SPI_INT_SSDEN (1 << 5) /** Slave Select is deasserted interrupt [BIT-5 of INTENSET/INTENCLR/INTSTAT register] */ #define SPI_INT_MSTIDLE (1 << 8) /** SPI master is Idle [BIT-8 of INTENSET/INTENCLR/INTSTAT register] */ /** * @brief SPI FIFO Configuration register bits * @cond */ #define SPI_FIFOCFG_MASK (0x3F033) /*!< Register mask bit @endcond */ #define SPI_FIFOCFG_ENABLETX (1 << 0) /*!< Enable TX FIFO */ #define SPI_FIFOCFG_ENABLERX (1 << 1) /*!< Enable RX FIFO */ #define SPI_FIFOCFG_DMATX (1 << 12) /*!< Enable DMA TX */ #define SPI_FIFOCFG_DMARX (1 << 13) /*!< Enable DMA RX */ #define SPI_FIFOCFG_WAKETX (1 << 14) /*!< Enable wakeup triggered by TX */ #define SPI_FIFOCFG_WAKERX (1 << 15) /*!< Enable wakeup triggered by RX */ #define SPI_FIFOCFG_EMPTYTX (1 << 16) /*!< Empty the TX FIFO */ #define SPI_FIFOCFG_EMPTYRX (1 << 17) /*!< Empty the RX FIFO */ /** * @brief Macro defines for FIFO Status register */ #define SPI_FIFO_DEPTH (8) /** SPI-FIFO How many entries are in the FIFO */ #define SPI_FIFOSTAT_BITMASK (0x1F1FFB) /** SPI-FIFO STAT Register BitMask */ #define SPI_FIFOSTAT_TXERR (1 << 0) /** SPI-FIFO transmit error */ #define SPI_FIFOSTAT_RXERR (1 << 1) /** SPI-FIFO receive error */ #define SPI_FIFOSTAT_PERINT (1 << 3) /** SPI-FIFO peripheral (SPI) interrupt */ #define SPI_FIFOSTAT_TXEMPTY (1 << 4) /** SPI-FIFO transmitter empty */ #define SPI_FIFOSTAT_TXNOTFULL (1 << 5) /** SPI-FIFO transmitter not full */ #define SPI_FIFOSTAT_RXNOTEMPTY (1 << 6) /** SPI-FIFO receiver not empty */ #define SPI_FIFOSTAT_RXFULL (1 << 7) /** SPI-FIFO receiver not full */ #define SPI_FIFOSTAT_TXLVL(val) (((val) >> 8) & 0x1F) /** SPI-FIFO extract transmit level */ #define SPI_FIFOSTAT_RXLVL(val) (((val) >> 16) & 0x1F) /** SPI-FIFO extract receive level */ /** * @brief UART FIFO trigger settings register defines */ #define SPI_FIFOTRIG_BITMASK (0x000f0f03) /** SPI FIFO trigger settings Register BitMask */ #define SPI_FIFOTRIG_TXLVLENA (1 << 0) /*!< TX level enable*/ #define SPI_FIFOTRIG_RXLVLENA (1 << 1) /*!< RX level enable */ #define SPI_FIFOTRIG_TXLVL(lvl) ((lvl & 0x0f) << 8) /*!< Set TX Level trigger */ #define SPI_FIFOTRIG_RXLVL(lvl) ((lvl & 0x0f) << 16) /*!< Set RX Level trigger */ #define SPI_FIFOTRIG_TXLVL_DEFAULT 4 /*!< Set TX default trigger level to half-full */ #define SPI_FIFOTRIG_RXLVL_DEFAULT 0 /*!< Set RX default trigger level to one item */ /** * @brief Macro defines for SPI Interrupt enable/disable/status [INTSET/INTCLR/INTSTAT and FIFOINTSET/FIFOINTCLR/FIFOINTSTAT registers] */ #define SPI_FIFOINT_BITMASK (0x001F) /** FIFO interrupt Bit mask */ #define SPI_FIFOINT_TXERR (1 << 0) /** TX error interrupt [BIT-0 of FIFOINTENSET/FIFOINTENCLR/FIFOINTSTAT register] */ #define SPI_FIFOINT_RXERR (1 << 1) /** RX error interrupt [BIT-1 of FIFOINTENSET/FIFOINTENCLR/FIFOINTSTAT register] */ #define SPI_FIFOINT_TXLVL (1 << 2) /** TX FIFO ready interrupt [BIT-2 of FIFOINTENSET/FIFOINTENCLR/FIFOINTSTAT register] */ #define SPI_FIFOINT_RXLVL (1 << 3) /** RX Data ready interrupt [BIT-3 of FIFOINTENSET/FIFOINTENCLR/FIFOINTSTAT register] */ #define SPI_FIFOINT_PERINT (1 << 4) /** SPI peripheral interrupt [BIT-4 of FIFOINTSTAT register] */ /** * Macro defines for SPI FIFO Receiver Data register */ #define SPI_RXDAT_BITMASK (0x1FFFFF) /** SPI RXDAT Register BitMask */ #define SPI_RXDAT_DATA(n) ((n) & 0xFFFF) /** Receiver Data */ #define SPI_RXDAT_RXSSELN(n) ((~((n >> 16) & 0x0f)) & 0x0f) /** Determine the active SSEL pin */ #define SPI_RXDAT_RXSSELN_ACTIVE (0 << 16) /** The state of SSEL pin is active */ #define SPI_RXDAT_SOT (1 << 20) /** Start of Transfer flag */ /** * Macro defines for SPI FIFO Transmitter Data and Control register */ #define SPI_TXDAT_BITMASK (0xF7FFFFF) /** SPI TXDATCTL Register BitMask */ #define SPI_TXDAT_DATA(n) ((n) & 0xFFFF) /** SPI Transmit Data */ #define SPI_TXDAT_CTRLMASK (0xF7F) /** SPI TXDATCTL Register BitMask for control bits only */ #define SPI_TXDAT_ASSERT_SSEL (0) /** Assert SSEL0 pin */ #define SPI_TXDAT_ASSERTNUM_SSEL(n) ((~(1 << (n))) & 0x0f) /** Assert SSELN pin */ #define SPI_TXDAT_DEASSERT_SSEL (1) /** Deassert SSEL0 pin */ #define SPI_TXDAT_DEASSERTNUM_SSEL(n) (1 << (n)) /** Deassert SSELN pin */ #define SPI_TXDAT_DEASSERT_ALL (0xF) /** Deassert all SSEL pins */ #define SPI_TXDAT_EOT (1 << 4) /** End of Transfer flag (TRANSFER_DELAY is applied after sending the current frame) */ #define SPI_TXDAT_EOF (1 << 5) /** End of Frame flag (FRAME_DELAY is applied after sending the current part) */ #define SPI_TXDAT_RXIGNORE (1 << 6) /** Receive Ignore Flag */ #define SPI_TXDAT_FLEN(n) (((n) & 0x0F) << 8) /** Frame length - 1 */ #define SPI_TXDAT_FLENMASK (0xF << 8) /** Frame length mask */ /** * Macro defines for SPI Transmitter Data Register */ #define SPI_TXDAT_DATA(n) ((n) & 0xFFFF) /** SPI Transmit Data */ /** * Macro defines for SPI Divider register */ #define SPI_DIV_VAL(n) ((n) & 0xFFFF) /** Rate divider value mask (In Master Mode only)*/ /** @brief SPI Clock Mode*/ typedef enum { ROM_SPI_CLOCK_CPHA0_CPOL0 = 0, /**< CPHA = 0, CPOL = 0 */ ROM_SPI_CLOCK_MODE0 = ROM_SPI_CLOCK_CPHA0_CPOL0, /**< Alias for CPHA = 0, CPOL = 0 */ ROM_SPI_CLOCK_CPHA1_CPOL0 = 1, /**< CPHA = 0, CPOL = 1 */ ROM_SPI_CLOCK_MODE1 = ROM_SPI_CLOCK_CPHA1_CPOL0, /**< Alias for CPHA = 0, CPOL = 1 */ ROM_SPI_CLOCK_CPHA0_CPOL1 = 2, /**< CPHA = 1, CPOL = 0 */ ROM_SPI_CLOCK_MODE2 = ROM_SPI_CLOCK_CPHA0_CPOL1, /**< Alias for CPHA = 1, CPOL = 0 */ ROM_SPI_CLOCK_CPHA1_CPOL1 = 3, /**< CPHA = 1, CPOL = 1 */ ROM_SPI_CLOCK_MODE3 = ROM_SPI_CLOCK_CPHA1_CPOL1, /**< Alias for CPHA = 1, CPOL = 1 */ } ROM_SPI_CLOCK_MODE_T; /** * @brief Initialize the SPI * @param pSPI : The base SPI peripheral on the chip * @return Nothing */ int Chip_SPI_Init(LPC_SPI_T *pSPI); /** * @brief Disable SPI operation * @param pSPI : Base on-chip SPI peripheral address * @return Nothing * @note The SPI controller is disabled. */ __STATIC_INLINE void Chip_SPI_DeInit(LPC_SPI_T *pSPI) { Chip_FLEXCOMM_DeInit(pSPI); } /** * @brief Set SPI CFG register values * @param pSPI : Base on-chip SPI peripheral address * @param bits : CFG register bits to set, amd OR'ed value of SPI_CFG_* definitions * @return Nothing * @note This function safely sets only the selected bits in the SPI CFG register. * It can be used to enable multiple bits at once. */ __STATIC_INLINE void Chip_SPI_SetCFGRegBits(LPC_SPI_T *pSPI, uint32_t bits) { pSPI->CFG = (pSPI->CFG & SPI_CFG_BITMASK) | bits; } /** * @brief Clear SPI CFG register values * @param pSPI : Base on-chip SPI peripheral address * @param bits : CFG register bits to clear, amd OR'ed value of SPI_CFG_* definitions * @return Nothing * @note This function safely clears only the selected bits in the SPI CFG register. * It can be used to disable multiple bits at once. */ __STATIC_INLINE void Chip_SPI_ClearCFGRegBits(LPC_SPI_T *pSPI, uint32_t bits) { pSPI->CFG = pSPI->CFG & (~bits & SPI_CFG_BITMASK); } /** * @brief Enable SPI peripheral * @param pSPI : Base on-chip SPI peripheral address * @return Nothing */ __STATIC_INLINE void Chip_SPI_Enable(LPC_SPI_T *pSPI) { Chip_SPI_SetCFGRegBits(pSPI, SPI_CFG_SPI_EN); } /** * @brief Disable SPI peripheral * @param pSPI : Base on-chip SPI peripheral address * @return Nothing */ __STATIC_INLINE void Chip_SPI_Disable(LPC_SPI_T *pSPI) { Chip_SPI_ClearCFGRegBits(pSPI, SPI_CFG_SPI_EN); } /** * @brief Enable SPI slave mode * @param pSPI : Base on-chip SPI peripheral address * @return Nothing * @note SPI master mode will be disabled with this call. */ __STATIC_INLINE void Chip_SPI_EnableSlaveMode(LPC_SPI_T *pSPI) { Chip_SPI_ClearCFGRegBits(pSPI, SPI_CFG_MASTER_EN); } /** * @brief Enable LSB First transfers * @param pSPI : Base on-chip SPI peripheral address * @return Nothing */ __STATIC_INLINE void Chip_SPI_EnableLSBFirst(LPC_SPI_T *pSPI) { Chip_SPI_SetCFGRegBits(pSPI, SPI_CFG_LSB_FIRST_EN); } /** * @brief Enable MSB First transfers * @param pSPI : Base on-chip SPI peripheral address * @return Nothing */ __STATIC_INLINE void Chip_SPI_EnableMSBFirst(LPC_SPI_T *pSPI) { Chip_SPI_ClearCFGRegBits(pSPI, SPI_CFG_LSB_FIRST_EN); } /** @brief SPI Clock Mode*/ typedef enum IP_SPI_CLOCK_MODE { SPI_CLOCK_CPHA0_CPOL0 = SPI_CFG_CPOL_LO | SPI_CFG_CPHA_FIRST, /**< CPHA = 0, CPOL = 0 */ SPI_CLOCK_MODE0 = SPI_CLOCK_CPHA0_CPOL0, /**< Alias for CPHA = 0, CPOL = 0 */ SPI_CLOCK_CPHA1_CPOL0 = SPI_CFG_CPOL_LO | SPI_CFG_CPHA_SECOND, /**< CPHA = 0, CPOL = 1 */ SPI_CLOCK_MODE1 = SPI_CLOCK_CPHA1_CPOL0, /**< Alias for CPHA = 0, CPOL = 1 */ SPI_CLOCK_CPHA0_CPOL1 = SPI_CFG_CPOL_HI | SPI_CFG_CPHA_FIRST, /**< CPHA = 1, CPOL = 0 */ SPI_CLOCK_MODE2 = SPI_CLOCK_CPHA0_CPOL1, /**< Alias for CPHA = 1, CPOL = 0 */ SPI_CLOCK_CPHA1_CPOL1 = SPI_CFG_CPOL_HI | SPI_CFG_CPHA_SECOND, /**< CPHA = 1, CPOL = 1 */ SPI_CLOCK_MODE3 = SPI_CLOCK_CPHA1_CPOL1, /**< Alias for CPHA = 1, CPOL = 1 */ } SPI_CLOCK_MODE_T; /** * @brief Set SPI mode * @param pSPI : Base on-chip SPI peripheral address * @param mode : SPI mode to set the SPI interface to * @return Nothing */ __STATIC_INLINE void Chip_SPI_SetSPIMode(LPC_SPI_T *pSPI, SPI_CLOCK_MODE_T mode) { Chip_SPI_ClearCFGRegBits(pSPI, (SPI_CFG_CPOL_HI | SPI_CFG_CPHA_SECOND)); Chip_SPI_SetCFGRegBits(pSPI, (uint32_t) mode); } /** * @brief Set polarity on the SPI chip select high * @param pSPI : Base on-chip SPI peripheral address * @param csNum : Chip select number, 0 - 3 * @return Nothing * @note SPI chip select polarity is active high. */ __STATIC_INLINE void Chip_SPI_SetCSPolHigh(LPC_SPI_T *pSPI, uint8_t csNum) { Chip_SPI_SetCFGRegBits(pSPI, SPI_CFG_SPOLNUM_HI(csNum)); } /** * @brief Set polarity on the SPI chip select low * @param pSPI : Base on-chip SPI peripheral address * @param csNum : Chip select number, 0 - 3 * @return Nothing * @note SPI chip select polarity is active low. */ __STATIC_INLINE void Chip_SPI_SetCSPolLow(LPC_SPI_T *pSPI, uint8_t csNum) { Chip_SPI_ClearCFGRegBits(pSPI, SPI_CFG_SPOLNUM_HI(csNum)); } /** SPI configuration structure used for setting up master/slave mode, LSB or * MSB first, and SPI mode in a single function call. */ typedef struct { uint32_t master : 8; /* Set to non-0 value to use master mode, 0 for slave */ uint32_t lsbFirst : 8; /* Set to non-0 value to send LSB first, 0 for MSB first */ SPI_CLOCK_MODE_T mode : 8; /* Mode selection */ uint32_t reserved : 8; /* Reserved, for alignment only */ } SPI_CFGSETUP_T; /** * @brief Setup SPI configuration * @param pSPI : Base on-chip SPI peripheral address * @param pCFG : Pointer to SPI configuration structure * @return Nothing */ void Chip_SPI_ConfigureSPI(LPC_SPI_T *pSPI, SPI_CFGSETUP_T *pCFG); /** * @brief Get the current status of SPI controller * @param pSPI : Base on-chip SPI peripheral address * @return SPI Status (Or-ed bit value of SPI_STAT_*) * @note Mask the return value with a value of type SPI_STAT_* to determine * if that status is active. */ __STATIC_INLINE uint32_t Chip_SPI_GetStatus(LPC_SPI_T *pSPI) { return pSPI->STAT; } /** * @brief Clear SPI status * @param pSPI : Base on-chip SPI peripheral address * @param Flag : Clear Flag (Or-ed bit value of SPI_STAT_*) * @return Nothing */ __STATIC_INLINE void Chip_SPI_ClearStatus(LPC_SPI_T *pSPI, uint32_t Flag) { pSPI->STAT = Flag; } /** * @brief Enable a SPI interrupt * @param pSPI : Base on-chip SPI peripheral address * @param intMask : Or'ed value of SPI_INT_* values to enable * @return Nothing */ __STATIC_INLINE void Chip_SPI_EnableInts(LPC_SPI_T *pSPI, uint32_t intMask) { pSPI->INTENSET = intMask & SPI_INT_BITMASK; } /** * @brief Disable a SPI interrupt * @param pSPI : Base on-chip SPI peripheral address * @param intMask : Or'ed value of SPI_INT_* values to disable (See #SPI_INT_BITMASK) * @return Nothing */ __STATIC_INLINE void Chip_SPI_DisableInts(LPC_SPI_T *pSPI, uint32_t intMask) { pSPI->INTENCLR = intMask & SPI_INT_BITMASK; } /** * @brief Return enabled SPI interrupts * @param pSPI : Base on-chip SPI peripheral address * @return An Or'ed value of SPI_INT_* values * @note Mask the return value with a SPI_INT_* value to determine (See #SPI_INT_BITMASK) * if the interrupt is enabled. * @note INTSTAT contains enabled interrupts, not pending interrupts. */ __STATIC_INLINE uint32_t Chip_SPI_GetEnabledInts(LPC_SPI_T *pSPI) { return pSPI->INTSTAT & SPI_INT_BITMASK; } /** * @brief Return pending SPI interrupts * @param pSPI : Base on-chip SPI peripheral address * @return An Or'ed value of SPI_INT_* values */ __STATIC_INLINE uint32_t Chip_SPI_GetPendingInts(LPC_SPI_T *pSPI) { uint32_t stat, mask; mask = pSPI->INTSTAT; stat = pSPI->STAT; stat &= mask; return stat; } //------------------------------------------------------------------------------ // // End SPI functions / Start of FIFO functions // //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // FIFO configuration functions //------------------------------------------------------------------------------ /** * @brief Set FIFO Configuration register * @param pSPI : Base on-chip SPI peripheral address * @param cfg : Configuration value mask (OR'ed SPI_FIFOCFG_* values like #SPI_FIFOCFG_ENABLETX) * @return Nothing */ __STATIC_INLINE void Chip_SPI_SetFIFOCfg(LPC_SPI_T *pSPI, uint32_t cfg) { pSPI->FIFOCFG = (pSPI->FIFOCFG & SPI_FIFOCFG_MASK) | cfg; } /** * @brief Clear FIFO Configuration register * @param pSPI : Base on-chip SPI peripheral address * @param cfg : Configuration value mask (OR'ed SPI_FIFOCFG_* values like #SPI_FIFOCFG_ENABLETX) * @return Nothing */ __STATIC_INLINE void Chip_SPI_ClearFIFOCfg(LPC_SPI_T *pSPI, uint32_t cfg) { pSPI->FIFOCFG = pSPI->FIFOCFG & (SPI_FIFOCFG_MASK & ~cfg); } //------------------------------------------------------------------------------ // FIFO status functions //------------------------------------------------------------------------------ /** * @brief Get the current status of SPI controller FIFO * @param pSPI : Base on-chip SPI peripheral address * @return SPI Status (Or-ed bit value of SPI_FIFOSTAT_*) * @note Mask the return value with a value of type SPI_FIFOSTAT_* to determine * if that status is active. */ __STATIC_INLINE uint32_t Chip_SPI_GetFIFOStatus(LPC_SPI_T *pSPI) { return pSPI->FIFOSTAT; } /** * @brief Clear the FIFO status register * @param pSPI : Base on-chip SPI peripheral address * @param mask : Mask of the status bits that needs to be cleared * @return Nothing */ __STATIC_INLINE void Chip_SPI_ClearFIFOStatus(LPC_SPI_T *pSPI, uint32_t mask) { pSPI->FIFOSTAT = mask; } //------------------------------------------------------------------------------ // FIFO trigger functions //------------------------------------------------------------------------------ /** * @brief Setup SPI FIFO trigger-level * @param pSPI : Base on-chip SPI peripheral address * @param tx_lvl : TX Trigger level [Valid values 0 to 7] * @param rx_lvl : RX Trigger level [Valid values 0 to 7] * @return Nothing * @note When @a tx_lvl = 0; trigger will happen when TX FIFO is empty * if @a tx_lvl = 7; trigger will happen when TX FIFO has at least one free space<br> * When @a rx_lvl = 0; trigger will happen when RX FIFO has at least one data in it, * if @a rx_lvl = 7; trigger will happen when RX FIFO is full and cannot receive anymore data. */ __STATIC_INLINE void Chip_SPI_SetFIFOTrigLevel(LPC_SPI_T *pSPI, uint8_t tx_lvl, uint8_t rx_lvl) { pSPI->FIFOTRIG = SPI_FIFOTRIG_TXLVL(tx_lvl) | SPI_FIFOTRIG_RXLVL(rx_lvl) |SPI_FIFOTRIG_TXLVLENA | SPI_FIFOTRIG_TXLVLENA; } /** * @brief Get SPI FIFO trigger-level * @param pSPI : Base of on-chip SPI peripheral * @return Returns the complete raw trigger register. */ __STATIC_INLINE uint32_t Chip_SPI_GetFIFOTrigLevel(LPC_SPI_T *pSPI) { return pSPI->FIFOTRIG; } //------------------------------------------------------------------------------ // FIFO interrupt functions //------------------------------------------------------------------------------ /** * @brief Enable a SPI FIFO interrupt * @param pSPI : Base on-chip SPI peripheral address * @param intMask : Or'ed value of SPI_FIFOINT_* values to enable * @return Nothing */ __STATIC_INLINE void Chip_SPI_EnableFIFOInts(LPC_SPI_T *pSPI, uint32_t intMask) { pSPI->FIFOINTENSET = intMask & SPI_FIFOINT_BITMASK; } /** * @brief Disable a SPI FIFO interrupt * @param pSPI : Base on-chip SPI peripheral address * @param intMask : Or'ed value of SPI_FIFOINT_* values to disable (See #SPI_FIFOINT_BITMASK) * @return Nothing */ __STATIC_INLINE void Chip_SPI_DisableFIFOInts(LPC_SPI_T *pSPI, uint32_t intMask) { pSPI->FIFOINTENCLR = intMask & SPI_FIFOINT_BITMASK; } /** * @brief Return enabled SPI FIFO interrupts * @param pSPI : Base on-chip SPI peripheral address * @return An Or'ed value of SPI_FIFOINT_* values */ __STATIC_INLINE uint32_t Chip_SPI_GetFIFOEnabledInts(LPC_SPI_T *pSPI) { return pSPI->FIFOINTENSET & SPI_FIFOINT_BITMASK; } /** * @brief Return pending SPI FIFO interrupts * @param pSPI : Base on-chip SPI peripheral address * @return An Or'ed value of SPI_FIFOINT_* values */ __STATIC_INLINE uint32_t Chip_SPI_GetFIFOPendingInts(LPC_SPI_T *pSPI) { return pSPI->FIFOINTSTAT & SPI_FIFOINT_BITMASK; } //------------------------------------------------------------------------------ // FIFO I/O functions //------------------------------------------------------------------------------ /** * @brief Read raw data from receive FIFO with status bits * @param pSPI : Base on-chip SPI peripheral address * @return Current value in receive data FIFO plus status bits */ __STATIC_INLINE uint32_t Chip_SPI_ReadRawRXFifo(LPC_SPI_T *pSPI) { return pSPI->FIFORD; } #define Chip_SPI_ReadFIFO Chip_SPI_ReadRawRXFifo /** * @brief Read data from receive FIFO masking off status bits * @param pSPI : Base on-chip SPI peripheral address * @return Current value in receive data FIFO * @note The entire register is read, but only the low 16-bits * are returned. */ __STATIC_INLINE uint16_t Chip_SPI_ReadRXData(LPC_SPI_T *pSPI) { __I void *ptr = &pSPI->FIFORD; return *((__I uint16_t *) ptr); } #define Chip_SPI_ReadFIFOdata Chip_SPI_ReadRXData /** * @brief Write FIFOWR register: writes 32-bit value to FIFO * @param pSPI : Base on-chip SPI peripheral address * @param data : Control and Data to be transfered * @return Nothing */ __STATIC_INLINE void Chip_SPI_WriteFIFO(LPC_SPI_T *pSPI, uint32_t data) { pSPI->FIFOWR = data; } /** * @brief Write FIFOWR register: writes control options and data * @param pSPI : Base on-chip SPI peripheral address * @param ctrl : Control bits to be set * @param data : Data to be transfered * @return Nothing * @note This function safely sets only set bits in FIFOWR control register. * It can be used to enable multiple options at once. */ __STATIC_INLINE void Chip_SPI_SetTXCTRLData(LPC_SPI_T *pSPI, uint16_t ctrl, uint16_t data) { pSPI->FIFOWR = (ctrl << 16) | data; } #define Chip_SPI_WriteFIFOcd Chip_SPI_SetTXCTRLData /** * @brief Write data to transmit FIFO * @param pSPI : Base on-chip SPI peripheral address * @param data : Data to write * @return Nothing */ __STATIC_INLINE void Chip_SPI_WriteTXData(LPC_SPI_T *pSPI, uint16_t data) { __O void *ptr = &pSPI->FIFOWR; *((__O uint16_t *) ptr) = data; } #define Chip_SPI_WriteFIFOdata Chip_SPI_WriteTXData /** * @brief Flush FIFOs * @param pSPI : Base on-chip SPI peripheral address * @return Nothing */ __STATIC_INLINE void Chip_SPI_FlushFifos(LPC_SPI_T *pSPI) { Chip_SPI_SetFIFOCfg(pSPI, SPI_FIFOCFG_EMPTYTX | SPI_FIFOCFG_EMPTYRX); } #define Chip_SPI_FlushFIFOs Chip_SPI_FlushFifos #ifndef __DOXYGEN__ /* SPI0 Defines */ #define LPC_SPI0_BASE __APPEND3(LPC_FLEXCOMM,SPI0_FLEXCOMM,_BASE) #define LPC_SPI0 ((LPC_SPI_T *) LPC_SPI0_BASE) #define SPI0_IRQHandler __APPEND3(FLEXCOMM,SPI0_FLEXCOMM,_IRQHandler) #define SPI0_IRQn __APPEND3(FLEXCOMM,SPI0_FLEXCOMM,_IRQn) #define DMAREQ_SPI0_RX __APPEND3(DMAREQ_FLEXCOMM,SPI0_FLEXCOMM,_RX) #define DMAREQ_SPI0_TX __APPEND3(DMAREQ_FLEXCOMM,SPI0_FLEXCOMM,_TX) /* SPI1 Defines */ #define LPC_SPI1_BASE __APPEND3(LPC_FLEXCOMM,SPI1_FLEXCOMM,_BASE) #define LPC_SPI1 ((LPC_SPI_T *) LPC_SPI1_BASE) #define SPI1_IRQHandler __APPEND3(FLEXCOMM,SPI1_FLEXCOMM,_IRQHandler) #define SPI1_IRQn __APPEND3(FLEXCOMM,SPI1_FLEXCOMM,_IRQn) #define DMAREQ_SPI1_RX __APPEND3(DMAREQ_FLEXCOMM,SPI1_FLEXCOMM,_RX) #define DMAREQ_SPI1_TX __APPEND3(DMAREQ_FLEXCOMM,SPI1_FLEXCOMM,_TX) /* SPI2 Defines */ #define LPC_SPI2_BASE __APPEND3(LPC_FLEXCOMM,SPI2_FLEXCOMM,_BASE) #define LPC_SPI2 ((LPC_SPI_T *) LPC_SPI2_BASE) #define SPI2_IRQHandler __APPEND3(FLEXCOMM,SPI2_FLEXCOMM,_IRQHandler) #define SPI2_IRQn __APPEND3(FLEXCOMM,SPI2_FLEXCOMM,_IRQn) #define DMAREQ_SPI2_RX __APPEND3(DMAREQ_FLEXCOMM,SPI2_FLEXCOMM,_RX) #define DMAREQ_SPI2_TX __APPEND3(DMAREQ_FLEXCOMM,SPI2_FLEXCOMM,_TX) /* SPI3 Defines */ #define LPC_SPI3_BASE __APPEND3(LPC_FLEXCOMM,SPI3_FLEXCOMM,_BASE) #define LPC_SPI3 ((LPC_SPI_T *) LPC_SPI3_BASE) #define SPI3_IRQHandler __APPEND3(FLEXCOMM,SPI3_FLEXCOMM,_IRQHandler) #define SPI3_IRQn __APPEND3(FLEXCOMM,SPI3_FLEXCOMM,_IRQn) #define DMAREQ_SPI3_RX __APPEND3(DMAREQ_FLEXCOMM,SPI3_FLEXCOMM,_RX) #define DMAREQ_SPI3_TX __APPEND3(DMAREQ_FLEXCOMM,SPI3_FLEXCOMM,_TX) /* SPI4 Defines */ #define LPC_SPI4_BASE __APPEND3(LPC_FLEXCOMM,SPI4_FLEXCOMM,_BASE) #define LPC_SPI4 ((LPC_SPI_T *) LPC_SPI4_BASE) #define SPI4_IRQHandler __APPEND3(FLEXCOMM,SPI4_FLEXCOMM,_IRQHandler) #define SPI4_IRQn __APPEND3(FLEXCOMM,SPI4_FLEXCOMM,_IRQn) #define DMAREQ_SPI4_RX __APPEND3(DMAREQ_FLEXCOMM,SPI4_FLEXCOMM,_RX) #define DMAREQ_SPI4_TX __APPEND3(DMAREQ_FLEXCOMM,SPI4_FLEXCOMM,_TX) /* SPI5 Defines */ #define LPC_SPI5_BASE __APPEND3(LPC_FLEXCOMM,SPI5_FLEXCOMM,_BASE) #define LPC_SPI5 ((LPC_SPI_T *) LPC_SPI5_BASE) #define SPI5_IRQHandler __APPEND3(FLEXCOMM,SPI5_FLEXCOMM,_IRQHandler) #define SPI5_IRQn __APPEND3(FLEXCOMM,SPI5_FLEXCOMM,_IRQn) #define DMAREQ_SPI5_RX __APPEND3(DMAREQ_FLEXCOMM,SPI5_FLEXCOMM,_RX) #define DMAREQ_SPI5_TX __APPEND3(DMAREQ_FLEXCOMM,SPI5_FLEXCOMM,_TX) /* SPI6 Defines */ #define LPC_SPI6_BASE __APPEND3(LPC_FLEXCOMM,SPI6_FLEXCOMM,_BASE) #define LPC_SPI6 ((LPC_SPI_T *) LPC_SPI6_BASE) #define SPI6_IRQHandler __APPEND3(FLEXCOMM,SPI6_FLEXCOMM,_IRQHandler) #define SPI6_IRQn __APPEND3(FLEXCOMM,SPI6_FLEXCOMM,_IRQn) #define DMAREQ_SPI6_RX __APPEND3(DMAREQ_FLEXCOMM,SPI6_FLEXCOMM,_RX) #define DMAREQ_SPI6_TX __APPEND3(DMAREQ_FLEXCOMM,SPI6_FLEXCOMM,_TX) /* SPI7 Defines */ #define LPC_SPI7_BASE __APPEND3(LPC_FLEXCOMM,SPI7_FLEXCOMM,_BASE) #define LPC_SPI7 ((LPC_SPI_T *) LPC_SPI7_BASE) #define SPI7_IRQHandler __APPEND3(FLEXCOMM,SPI7_FLEXCOMM,_IRQHandler) #define SPI7_IRQn __APPEND3(FLEXCOMM,SPI7_FLEXCOMM,_IRQn) #define DMAREQ_SPI7_RX __APPEND3(DMAREQ_FLEXCOMM,SPI7_FLEXCOMM,_RX) #define DMAREQ_SPI7_TX __APPEND3(DMAREQ_FLEXCOMM,SPI7_FLEXCOMM,_TX) #endif /** * @} */ #ifdef __cplusplus } #endif #endif /* __SPI_COMMON_5411X_H_ */
[ "ankitjhall33@gmail.com" ]
ankitjhall33@gmail.com
96863f5fae2e7c1f7dfa5b94409f7f243208783b
d683b22f6b58a5c29350ab8088215f246bf2d184
/admission criteria.c
ece3c24b9ce1570bc1cfa58e7a1b40c5c44a63fb
[]
no_license
hvn4k/C
ff9517000f669b659398fb7ca92b99c1b5b528a9
60b34e2cca333c599b2335dbc7262aa7447bd6aa
refs/heads/main
2023-06-22T05:43:25.714961
2021-05-26T09:21:07
2021-05-26T09:21:07
null
0
0
null
null
null
null
UTF-8
C
false
false
513
c
#include<stdio.h> void func(int m , int p , int c) { if(m>=65 || p>=55 || c>=50) { printf("ADMISSION ACCEPTED"); } else if(m+p+c>=180) { printf("ADMISSION ACCEPTED"); } else if(m+p>=140) { printf("ADMISSION ACCEPTED"); } else { printf("ADMISSION NOT ACCEPTED"); } } main() { int m,p,c; printf("Enter marks in Maths"); scanf("%d",&m); printf("Enter marks in physics"); scanf("%d",&p); printf("Enter marks in Chemistry"); scanf("%d",&c); func(m,p,c); }
[ "noreply@github.com" ]
noreply@github.com
e959db03dfcb3736ed80c3dccc0a5f0d2a6c349f
caf26a8bb8ffe570e699d9c968c2b447b1f399ba
/firmware/Back_FC/MAVLINK/minimal/mavlink_msg_gps_status.h
d8673bd8688814160361437266db9e9adc5182fe
[]
no_license
bygreencn/Oldx_fly_controller
d07bfd00b29b6ebe4d1c76cc7eb02240ca6d47aa
021cd924378f77e56d89289ee5c4e864ea787402
refs/heads/master
2020-04-13T08:44:30.883246
2018-12-25T14:44:50
2018-12-25T14:44:50
163,090,609
1
2
null
2018-12-25T14:45:53
2018-12-25T14:45:52
null
UTF-8
C
false
false
5,040
h
// MESSAGE GPS_STATUS PACKING #ifndef _MAVLINK_MSG_GPS_STATUS_H_ #define _MAVLINK_MSG_GPS_STATUS_H_ #include "../mavlink_helpers.h" #define MAVLINK_MSG_ID_GPS_STATUS 25 typedef struct __mavlink_gps_status_t { uint8_t satellites_visible; /*< Number of satellites visible*/ uint8_t satellite_prn[20]; /*< Global satellite ID*/ uint8_t satellite_used[20]; /*< 0: Satellite not used, 1: used for localization*/ uint8_t satellite_elevation[20]; /*< Elevation (0: right on top of receiver, 90: on the horizon) of satellite*/ uint8_t satellite_azimuth[20]; /*< Direction of satellite, 0: 0 deg, 255: 360 deg.*/ uint8_t satellite_snr[20]; /*< Signal to noise ratio of satellite*/ } mavlink_gps_status_t; #define MAVLINK_MSG_ID_GPS_STATUS_LEN 101 #define MAVLINK_MSG_ID_25_LEN 101 #define MAVLINK_MSG_ID_GPS_STATUS_CRC 23 #define MAVLINK_MSG_ID_25_CRC 23 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_PRN_LEN 20 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_USED_LEN 20 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_ELEVATION_LEN 20 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_AZIMUTH_LEN 20 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_SNR_LEN 20 #define MAVLINK_MESSAGE_INFO_GPS_STATUS { \ "GPS_STATUS", \ 6, \ { { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_status_t, satellites_visible) }, \ { "satellite_prn", NULL, MAVLINK_TYPE_UINT8_T, 20, 1, offsetof(mavlink_gps_status_t, satellite_prn) }, \ { "satellite_used", NULL, MAVLINK_TYPE_UINT8_T, 20, 21, offsetof(mavlink_gps_status_t, satellite_used) }, \ { "satellite_elevation", NULL, MAVLINK_TYPE_UINT8_T, 20, 41, offsetof(mavlink_gps_status_t, satellite_elevation) }, \ { "satellite_azimuth", NULL, MAVLINK_TYPE_UINT8_T, 20, 61, offsetof(mavlink_gps_status_t, satellite_azimuth) }, \ { "satellite_snr", NULL, MAVLINK_TYPE_UINT8_T, 20, 81, offsetof(mavlink_gps_status_t, satellite_snr) }, \ } \ } /** * @brief Pack a gps_status message * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * * @param satellites_visible Number of satellites visible * @param satellite_prn Global satellite ID * @param satellite_used 0: Satellite not used, 1: used for localization * @param satellite_elevation Elevation (0: right on top of receiver, 90: on the horizon) of satellite * @param satellite_azimuth Direction of satellite, 0: 0 deg, 255: 360 deg. * @param satellite_snr Signal to noise ratio of satellite * @return length of the message in bytes (excluding serial stream start sign) */ uint16_t mavlink_msg_gps_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr); uint16_t mavlink_msg_gps_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t satellites_visible,const uint8_t *satellite_prn,const uint8_t *satellite_used,const uint8_t *satellite_elevation,const uint8_t *satellite_azimuth,const uint8_t *satellite_snr); uint16_t mavlink_msg_gps_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_status_t* gps_status); uint16_t mavlink_msg_gps_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_gps_status_t* gps_status); #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS void mavlink_msg_gps_status_send(mavlink_channel_t chan, uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr); #if MAVLINK_MSG_ID_GPS_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN void mavlink_msg_gps_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr); #endif #endif // MESSAGE GPS_STATUS UNPACKING uint8_t mavlink_msg_gps_status_get_satellites_visible(const mavlink_message_t* msg); uint16_t mavlink_msg_gps_status_get_satellite_prn(const mavlink_message_t* msg, uint8_t *satellite_prn); uint16_t mavlink_msg_gps_status_get_satellite_used(const mavlink_message_t* msg, uint8_t *satellite_used); uint16_t mavlink_msg_gps_status_get_satellite_elevation(const mavlink_message_t* msg, uint8_t *satellite_elevation); uint16_t mavlink_msg_gps_status_get_satellite_azimuth(const mavlink_message_t* msg, uint8_t *satellite_azimuth); uint16_t mavlink_msg_gps_status_get_satellite_snr(const mavlink_message_t* msg, uint8_t *satellite_snr); void mavlink_msg_gps_status_decode(const mavlink_message_t* msg, mavlink_gps_status_t* gps_status); #endif /*_xx_h_*/
[ "golaced@163.com" ]
golaced@163.com
0607cf2828108a7cebc58f556610ed3b27a33c22
3636d82c2e754fbd60c6e1b48387165ecde79726
/C_Plus/Learning_C/NUMTST.C
6df0e709e530d52dc0ea6a0a9ae46109b8b0a1db
[ "MIT" ]
permissive
MCLifeLeader/MiscProjects
2762fa69ea55a91cc668e7be7e29b178ed6fa6c1
335d7dc0f5819e4aff19860a71d65653aecee2d6
refs/heads/master
2023-08-04T22:08:32.016662
2023-07-08T05:53:45
2023-07-08T05:53:45
115,904,264
0
0
null
null
null
null
UTF-8
C
false
false
415
c
#include "stdio.h" main() { int s, w, x, y, z; unsigned char inpt; w = 0; do { w++; if(w>=255) { w = 0; } inpt = w; printf("%d\n", inpt); x = ((w+x+y)/3)+z; inpt = x; printf("%d\n", inpt); y = ((w+x+y)/3)+x; inpt = y; printf("%d\n", inpt); z = ((w+x+y)/3)+y; inpt = z; printf("%d\n", inpt); } while(s != 1); }
[ "kb7ppb@hotmail.com" ]
kb7ppb@hotmail.com
89426255b0ddd889d9ebfac0aa89ef5284842875
3523b5bae2f818f65275d73780c0bb69f8640249
/hmcu_timer.h
c63ca16aa6af30b5afee5ed93c25e9c63f249089
[]
no_license
LucianaMarques/soft_timer
7ebd2fee22f54641edd6357e22fca0cad7a15d97
b4b354dd8e7e6670d28bf1d9369d5781fb64e658
refs/heads/master
2020-03-28T21:49:09.699040
2018-09-23T14:26:48
2018-09-23T14:26:48
149,184,576
0
0
null
null
null
null
UTF-8
C
false
false
1,500
h
/** * @file hmcu_timer.h * * @brief Hypothetical MCU Timer register addresses and IRQ handler. */ #ifndef __HMCU_TIMER_H__ #define __HMCU_TIMER_H__ #include <stdio.h> #include <stdint.h> #include <stdbool.h> /***************************************************************************** * Timer clock frequency. *****************************************************************************/ #define TIMER_CLK_HZ (1000) /***************************************************************************** * Timer register addresses. *****************************************************************************/ #define TIMER_CTRL_REG_ADDR (&timer_ctrl) #define TIMER_CNT_REG_ADDR (&timer_cnt) #define TIMER_RLD_REG_ADDR (&timer_rld) /***************************************************************************** * Timer IRQ handler prototype. *****************************************************************************/ /** * @brief Timeout IRQ handler. * * @details This function will be called by our hypothetical MCU interrupt * vector when timer countdown reaches zero. */ void hmcu_timer_irq_handler(void); /***************************************************************************** * For test purposes: variables abstracting hypothetical MCU registers. *****************************************************************************/ extern uint16_t timer_ctrl; extern uint16_t timer_cnt; extern uint16_t timer_rld; #endif /** __HMCU_TIMER_H__ */
[ "lucianadacostamarques@gmail.com" ]
lucianadacostamarques@gmail.com
224de462e5906a73e4333232f3c940cdba1b2130
4dcf7947fabb231588487532c067c38b822871a8
/cw04/zad4/zad4b/sender.c
881d435bf1db2246d6c4d2ffd1ba24538f84668b
[]
no_license
PKopel/Unix-Linux-programming
7152422594f8ae20c17b7385b1061738ce48860e
9c4692f40cbdf21ed65d8c1e7d2d27b7ac307184
refs/heads/master
2022-10-22T15:14:05.492095
2020-06-10T14:10:40
2020-06-10T14:10:40
null
0
0
null
null
null
null
UTF-8
C
false
false
2,386
c
#define _XOPEN_SOURCE 700 #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> #include <string.h> int counter = 0; pid_t catcher = -1; void (*send)(int); int sig1,sig2,confirmation = 0; void handler(int sig, siginfo_t *info, void *ucontext){ if(sig == sig1){ if(info->si_value.sival_int) printf("sender received %d-th sig1\n",info->si_value.sival_int); if(!confirmation) counter++; } else if(sig == sig2){ printf("sender: %d sig1\n",counter); counter = -1; exit(0); } confirmation = 0; return; } void send_kill(int num){ for (int i = 0; i < num; i++){ sigset_t new_mask; sigfillset(&new_mask); sigdelset(&new_mask,SIGUSR1); confirmation = 1; kill(catcher,sig1); sigsuspend(&new_mask); } kill(catcher,sig2); } void send_queue(int num){ union sigval number; for (int i = 0; i < num; i++){ number.sival_int = i+1; sigset_t new_mask; sigfillset(&new_mask); sigdelset(&new_mask,SIGUSR1); confirmation = 1; sigqueue(catcher,sig1,number); sigsuspend(&new_mask); } number.sival_int = -1; sigqueue(catcher,sig2,number); } int main(int argc, char** argv){ if(argc != 4) return 22; catcher = atoi(argv[1]); int num = atoi(argv[2]); if(strcmp(argv[3],"KILL") == 0){ send = send_kill; sig1 = SIGUSR1; sig2 = SIGUSR2; } else if (strcmp(argv[3],"SIGQUEUE") == 0){ send = send_queue; sig1 = SIGUSR1; sig2 = SIGUSR2; } else if (strcmp(argv[3],"SIGRT") == 0){ send = send_kill; sig1 = SIGRTMIN; sig2 = SIGRTMIN+1; } else return 22; struct sigaction new_action; new_action.sa_sigaction = handler; sigfillset(&new_action.sa_mask); new_action.sa_flags = SA_SIGINFO; if(sigaction(sig1, &new_action, NULL) < 0) printf("can't catch %d\n",sig1); if(sigaction(sig2, &new_action, NULL) < 0) printf("can't catch %d\n",sig2); if(sigaction(SIGUSR1, &new_action, NULL) < 0) printf("can't catch SIGUSR1\n"); sigset_t mask; sigfillset(&mask); sigdelset(&mask,sig1); sigdelset(&mask,sig2); sigprocmask(SIG_SETMASK,&mask,NULL); send(num); while(counter >= 0){ pause(); } return 0; }
[ "pawel.kopel2@gmail.com" ]
pawel.kopel2@gmail.com
ead92b80700b8e7be1df60ae3c6d85de32e8d348
bb45f01aa5b26d4c7640528eacbd39932bdfca13
/applications/rmsd/src/server/server.c
18417afac4b5055c54ce54736be95ac306c6ee2f
[]
no_license
BGCX067/f2f-hg-to-git
f8d17ecc95a0b72eb67505db96216a24d5d477e1
4655aa5d6983c0c8716f3ad9e8ca0b6805a67d30
refs/heads/master
2016-09-01T08:52:34.881547
2012-01-13T02:23:59
2012-01-13T02:23:59
48,871,771
0
0
null
null
null
null
UTF-8
C
false
false
4,297
c
/* server.c: Copyright (C) 2011 Martin Ramiro Gioiosa, FuDePAN This file is part of the F2F project. F2F is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. F2F is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with F2F. If not, see <http://www.gnu.org/licenses/>. NOTE: This file is in prototype stage, and is under active development. */ #include <stdio.h> #include <string.h> #include <sys/socket.h> #include <errno.h> #include <netinet/in.h> #include <unistd.h> #include <stdlib.h> /**** OWN HEADERS ****************************/ #include "arithmetic.h" #include "communication.h" #include "types.h" #include "endianTool.h" #include "socketTool.h" #include "rmsdCalc.h" /*********************************************/ static void process_packet(BufferClient* inpacket, BufferServer* outpacket) { const size_t sizeOfStructures = inpacket->numberOfCoords * 3 * sizeof(FloatType); char* pointer_first_element = inpacket->data; char* pointer_last_element = inpacket->data + sizeOfStructures * (inpacket->numberOfStructs - 1); FloatType* pointer_results = (FloatType*)outpacket->data; size_t numberOfResults = 0; char* it1; for (it1 = pointer_first_element; it1 < pointer_last_element; it1 += sizeOfStructures) { char* it2; for (it2 = it1 + sizeOfStructures; it2 <= pointer_last_element; it2 += sizeOfStructures) { *pointer_results = rmsd_to((Coord3d*)it1, (Coord3d*)it2, inpacket->numberOfCoords); ++pointer_results; ++numberOfResults; } } outpacket->numberOfResults = numberOfResults; } int main(void) { const int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sock == -1) { printf ("Error creating socket\n"); exit(EXIT_FAILURE); } struct sockaddr_in sa; sa.sin_family = AF_INET; sa.sin_addr.s_addr = INADDR_ANY; sa.sin_port = htons(PORT); socklen_t address_len = sizeof(sa); const int b = bind(sock, (struct sockaddr*)&sa, sizeof(sa)); if (b == -1) { printf("Error bind failed\n"); close(sock); exit(EXIT_FAILURE); } /* PREPARE FOR INCOMING CONNECTION */ const int list = listen(sock, 1); if (list == -1) { printf("Error list failed\n"); close(sock); exit(EXIT_FAILURE); } /***********************************/ BufferClient buffer_in; BufferServer buffer_out; while (1) { /* WAIT FOR CONNECT CLIENT */ printf ("Waiting for client...\n"); const int sock_client = accept(sock, (struct sockaddr*)&sa, &address_len); if (sock_client == -1) { printf("Error accepting client\n"); } /***************************/ /* WAIT TO RECEIVE A PACKET */ const int read = read_socket(sock_client, (char*)&buffer_in, LENGHT_BUFFER); if (read == -1) { printf("Error receiving packet\n"); } /****************************/ /* CONVERT */ endian_buffer_client(&buffer_in, networkToHost); /***********/ /* PROCESS THE PACKET */ process_packet(&buffer_in, &buffer_out); /**********************/ /* CONVERT */ endian_buffer_server(&buffer_out, hostToNetwork); /***********/ /* SEND RESULTS */ const int write = write_socket(sock_client, (char*)&buffer_out, LENGHT_BUFFER); if (write == -1) { printf("Error sending packet\n"); } /****************/ /* END OF COMMUNICATION */ const int shutdn = shutdown(sock_client, SHUT_RDWR); if (shutdn == -1) { printf("Error shutting down\n"); } /****************/ } return EXIT_SUCCESS; }
[ "giomartinr@gmail.com" ]
giomartinr@gmail.com
f75c64978f23f2c316c808a60473f85d8c575085
7e41f5263395d119d4fba880fa05022d58324ca5
/liblinear-2.1/predict.c
1b5c54715ff1f9cef62a303ce02089bd4f69c392
[ "BSD-3-Clause" ]
permissive
moulygupta23/MCM-mtp
93b95a9ed357840eb48a24577d50cf63b1d73242
1713e5a84d9269902ae8792d71e6e995c0503c83
refs/heads/master
2021-01-21T04:54:00.263144
2016-07-01T12:30:17
2016-07-01T12:30:17
54,060,125
0
0
null
null
null
null
UTF-8
C
false
false
5,337
c
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include "linear.h" int print_null(const char *s,...) {return 0;} static int (*info)(const char *fmt,...) = &printf; struct feature_node *x; int max_nr_attr = 64; struct model* model_; int flag_predict_probability=0; void exit_input_error(int line_num) { fprintf(stderr,"Wrong input format at line %d\n", line_num); exit(1); } static char *line = NULL; static int max_line_len; static char* readline(FILE *input) { int len; if(fgets(line,max_line_len,input) == NULL) return NULL; while(strrchr(line,'\n') == NULL) { max_line_len *= 2; line = (char *) realloc(line,max_line_len); len = (int) strlen(line); if(fgets(line+len,max_line_len-len,input) == NULL) break; } return line; } void do_predict(FILE *input, FILE *output) { int correct = 0; int total = 0; double error = 0; double sump = 0, sumt = 0, sumpp = 0, sumtt = 0, sumpt = 0; int nr_class=get_nr_class(model_); double *prob_estimates=NULL; int j, n; int nr_feature=get_nr_feature(model_); if(model_->bias>=0) n=nr_feature+1; else n=nr_feature; if(flag_predict_probability) { int *labels; if(!check_probability_model(model_)) { fprintf(stderr, "probability output is only supported for logistic regression\n"); exit(1); } labels=(int *) malloc(nr_class*sizeof(int)); get_labels(model_,labels); prob_estimates = (double *) malloc(nr_class*sizeof(double)); fprintf(output,"labels"); for(j=0;j<nr_class;j++) fprintf(output," %d",labels[j]); fprintf(output,"\n"); free(labels); } max_line_len = 1024; line = (char *)malloc(max_line_len*sizeof(char)); while(readline(input) != NULL) { int i = 0; double target_label, predict_label; char *idx, *val, *label, *endptr; int inst_max_index = 0; // strtol gives 0 if wrong format label = strtok(line," \t\n"); if(label == NULL) // empty line exit_input_error(total+1); target_label = strtod(label,&endptr); if(endptr == label || *endptr != '\0') exit_input_error(total+1); while(1) { if(i>=max_nr_attr-2) // need one more for index = -1 { max_nr_attr *= 2; x = (struct feature_node *) realloc(x,max_nr_attr*sizeof(struct feature_node)); } idx = strtok(NULL,":"); val = strtok(NULL," \t"); if(val == NULL) break; errno = 0; x[i].index = (int) strtol(idx,&endptr,10); if(endptr == idx || errno != 0 || *endptr != '\0' || x[i].index <= inst_max_index) exit_input_error(total+1); else inst_max_index = x[i].index; errno = 0; x[i].value = strtod(val,&endptr); if(endptr == val || errno != 0 || (*endptr != '\0' && !isspace(*endptr))) exit_input_error(total+1); // feature indices larger than those in training are not used if(x[i].index <= nr_feature) ++i; } if(model_->bias>=0) { x[i].index = n; x[i].value = model_->bias; i++; } x[i].index = -1; if(flag_predict_probability) { int j; predict_label = predict_probability(model_,x,prob_estimates); fprintf(output,"%g",predict_label); for(j=0;j<model_->nr_class;j++) fprintf(output," %g",prob_estimates[j]); fprintf(output,"\n"); } else { predict_label = predict(model_,x); fprintf(output,"%g\n",predict_label); } if(predict_label == target_label) ++correct; error += (predict_label-target_label)*(predict_label-target_label); sump += predict_label; sumt += target_label; sumpp += predict_label*predict_label; sumtt += target_label*target_label; sumpt += predict_label*target_label; ++total; } if(check_regression_model(model_)) { info("Mean squared error = %g (regression)\n",error/total); info("Squared correlation coefficient = %g (regression)\n", ((total*sumpt-sump*sumt)*(total*sumpt-sump*sumt))/ ((total*sumpp-sump*sump)*(total*sumtt-sumt*sumt)) ); } else info("Accuracy = %g%% (%d/%d)\n",(double) correct/total*100,correct,total); if(flag_predict_probability) free(prob_estimates); } void exit_with_help() { printf( "Usage: predict [options] test_file model_file output_file\n" "options:\n" "-b probability_estimates: whether to output probability estimates, 0 or 1 (default 0); currently for logistic regression only\n" "-q : quiet mode (no outputs)\n" ); exit(1); } int main(int argc, char **argv) { FILE *input, *output; int i; // parse options for(i=1;i<argc;i++) { if(argv[i][0] != '-') break; ++i; switch(argv[i-1][1]) { case 'b': flag_predict_probability = atoi(argv[i]); break; case 'q': info = &print_null; i--; break; default: fprintf(stderr,"unknown option: -%c\n", argv[i-1][1]); exit_with_help(); break; } } if(i>=argc) exit_with_help(); input = fopen(argv[i],"r"); if(input == NULL) { fprintf(stderr,"can't open input file %s\n",argv[i]); exit(1); } output = fopen(argv[i+2],"w"); if(output == NULL) { fprintf(stderr,"can't open output file %s\n",argv[i+2]); exit(1); } if((model_=load_model(argv[i+1]))==0) { fprintf(stderr,"can't open model file %s\n",argv[i+1]); exit(1); } x = (struct feature_node *) malloc(max_nr_attr*sizeof(struct feature_node)); do_predict(input, output); free_and_destroy_model(&model_); free(line); free(x); fclose(input); fclose(output); return 0; }
[ "moulygupta23@gmail.com" ]
moulygupta23@gmail.com
382cdb2c263ecef7ace773b52519020028485ccd
8d66da22764e44dd5680a5ce4bdf165f1546c25e
/Firmware_F411 V1.2/COMMUNICATE/src/radiolink.c
a02d2abcbe136ebfef46847029748e4002200d30
[]
no_license
xindong324/MiniFly
679210b8f00d7f2bac73470ffbb62d5718e9c2a9
21c0679563510728590a306e627fbeeb42a4cdd3
refs/heads/master
2020-03-26T13:19:32.942801
2018-08-16T03:42:51
2018-08-16T03:42:51
144,932,913
3
3
null
null
null
null
GB18030
C
false
false
4,515
c
#include <string.h> #include "config.h" #include "radiolink.h" #include "config_param.h" #include "led.h" #include "ledseq.h" #include "uart_syslink.h" /*FreeRtos includes*/ #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #include "queue.h" /******************************************************************************** * 本程序只供学习使用,未经作者许可,不得用于其它任何用途 * ALIENTEK MiniFly * 无线通信驱动代码 * 正点原子@ALIENTEK * 技术论坛:www.openedv.com * 创建日期:2018/6/22 * 版本:V1.2 * 版权所有,盗版必究。 * Copyright(C) 广州市星翼电子科技有限公司 2014-2024 * All rights reserved ********************************************************************************/ #define RADIOLINK_TX_QUEUE_SIZE 30 /*接收队列个数*/ static enum { waitForStartByte1, waitForStartByte2, waitForMsgID, waitForDataLength, waitForData, waitForChksum1, }rxState; static bool isInit; static atkp_t txPacket; static atkp_t rxPacket; static xQueueHandle txQueue; static void atkpPacketDispatch(atkp_t *rxPacket); //radiolink接收ATKPPacket任务 void radiolinkTask(void *param) { rxState = waitForStartByte1; u8 c; u8 dataIndex = 0; u8 cksum = 0; while(1) { if (uartslkGetDataWithTimout(&c)) { switch(rxState) { case waitForStartByte1: rxState = (c == DOWN_BYTE1) ? waitForStartByte2 : waitForStartByte1; cksum = c; break; case waitForStartByte2: rxState = (c == DOWN_BYTE2) ? waitForMsgID : waitForStartByte1; cksum += c; break; case waitForMsgID: rxPacket.msgID = c; rxState = waitForDataLength; cksum += c; break; case waitForDataLength: if (c <= ATKP_MAX_DATA_SIZE) { rxPacket.dataLen = c; dataIndex = 0; rxState = (c > 0) ? waitForData : waitForChksum1; /*c=0,数据长度为0,校验1*/ cksum += c; } else { rxState = waitForStartByte1; } break; case waitForData: rxPacket.data[dataIndex] = c; dataIndex++; cksum += c; if (dataIndex == rxPacket.dataLen) { rxState = waitForChksum1; } break; case waitForChksum1: if (cksum == c) /*所有校验正确*/ { atkpPacketDispatch(&rxPacket); } else /*校验错误*/ { rxState = waitForStartByte1; IF_DEBUG_ASSERT(1); } rxState = waitForStartByte1; break; default: ASSERT(0); break; } } else /*超时处理*/ { rxState = waitForStartByte1; } } } void radiolinkInit(void) { if (isInit) return; uartslkInit(); /*创建发送队列,CRTP_TX_QUEUE_SIZE个消息*/ txQueue = xQueueCreate(RADIOLINK_TX_QUEUE_SIZE, sizeof(atkp_t)); ASSERT(txQueue); isInit = true; } /*打包ATKPPacket数据通过串口DMA发送*/ static void uartSendPacket(atkp_t *p) { int dataSize; u8 cksum = 0; u8 sendBuffer[36]; ASSERT(p->dataLen <= ATKP_MAX_DATA_SIZE); sendBuffer[0] = UP_BYTE1; sendBuffer[1] = UP_BYTE2; sendBuffer[2] = p->msgID; sendBuffer[3] = p->dataLen; memcpy(&sendBuffer[4], p->data, p->dataLen); dataSize = p->dataLen + 5;//加上cksum /*计算校验和*/ for (int i=0; i<dataSize-1; i++) { cksum += sendBuffer[i]; } sendBuffer[dataSize-1] = cksum; /*串口DMA发送*/ uartslkSendDataDmaBlocking(dataSize, sendBuffer); } /*radiolink接收到ATKPPacket预处理*/ static void atkpPacketDispatch(atkp_t *rxPacket) { atkpReceivePacketBlocking(rxPacket); if( rxPacket->msgID == DOWN_POWER) {;}/*do noting*/ else { ledseqRun(DATA_RX_LED, seq_linkup); /*接收到一个遥控无线数据包则发送一个包*/ if(xQueueReceive(txQueue, &txPacket, 0) == pdTRUE) { ASSERT(txPacket.dataLen <= ATKP_MAX_DATA_SIZE); ledseqRun(DATA_TX_LED, seq_linkup); uartSendPacket(&txPacket); } } } bool radiolinkSendPacket(const atkp_t *p) { ASSERT(p); ASSERT(p->dataLen <= ATKP_MAX_DATA_SIZE); return xQueueSend(txQueue, p, 0); } bool radiolinkSendPacketBlocking(const atkp_t *p) { ASSERT(p); ASSERT(p->dataLen <= ATKP_MAX_DATA_SIZE); return xQueueSend(txQueue, p, portMAX_DELAY); } //获取剩余可用txQueue个数 int radiolinkGetFreeTxQueuePackets(void) { return (RADIOLINK_TX_QUEUE_SIZE - uxQueueMessagesWaiting(txQueue)); }
[ "xindong324@163.com" ]
xindong324@163.com
cdddeacb82da25ccb2e46fdfcbd46150dc6d8dfb
fe5e5f3e3da1d6199da2161fa4ee1b8516009894
/Midterm_C/Problem3_20/Problem3_20/main.c
a6bd508fdbe30ff284a36adcb13e6449fbf22eac
[]
no_license
alien-house/C
4a4d2f8ebbd2e6a86ae8e1050c2f87fd3a9f57bc
5c9c9e70580a328b761a02bbcd5c2da17c8d8a59
refs/heads/master
2021-06-12T12:10:48.901062
2017-02-03T20:09:57
2017-02-03T20:09:57
53,290,261
0
0
null
null
null
null
UTF-8
C
false
false
463
c
// // main.c // Problem3_20 // // Created by sin on 2017/01/28. // Copyright © 2017年 shinji. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p \n", a); printf("%d \n", *p); printf("%p \n", p); printf("%d \n", **r); printf("%p \n", &p); printf("%p \n", p); printf("%p \n", r); printf("%p %p", *r, a); return 0; }
[ "info@alien-house.com" ]
info@alien-house.com
f61efdf3e7d13023c1dcd7a6b0b33646224ba264
f3a5d435414b7389f0e3ac72f2ccd28d7a4911e4
/src/mx_print.c
3f3dfb9c5121474cb4b2da1354183877319564b2
[]
no_license
zeromotivat1on/ush
1a794c7abd8c7bd8ebc8ed8bc56e8f0527108110
cfae0103030163ce9fc409a6cc3f4a6f105387a2
refs/heads/master
2023-03-06T15:33:56.449353
2021-02-22T12:20:59
2021-02-22T12:20:59
329,904,735
0
0
null
null
null
null
UTF-8
C
false
false
4,471
c
#include "ush.h" void mx_print_color(char *macros, char *str) { mx_printstr(macros); mx_printstr(str); mx_printstr(RESET); } void mx_print_strarr_in_line(char **result, const char *delim) { if (!result || !delim) { return; } if (result[0] == NULL) { mx_printstr("NULL\n"); } for (int i = 0; result[i]; i++) { mx_printstr(result[i]); mx_printstr(delim); if (result[i + 1] == NULL){ mx_printstr("NULL\n"); } } } bool mx_parse_error(char *str, int k) { mx_printerr("ush: parse error near `"); write(2, str, k); mx_printerr("\'\n"); return true; } bool mx_unmached_error(char c) { if (c == '\"' || c == '\'') { mx_printerr("Odd number of quotes.\n"); return true; } else { mx_printerr("Unmatched "); write(2, &c, 1); mx_printerr(".\n"); return true; } } char *mx_syntax_error(char *str) { mx_printerr("ush: syntax error near unexpected token `"); mx_printerr(str); mx_printerr("'\n"); return NULL; } static char *get_delim_from_type(int t) { if (t == SEP) { return mx_strdup(";"); } else if (t == FON) { return mx_strdup("&"); } else if (t == R_OUTPUT) { return mx_strdup(">"); } else if (t == OR) { return mx_strdup("||"); } else if (t == AND) { return mx_strdup("&&"); } else if (t == PIPE) { return mx_strdup("|"); } else if (t == R_INPUT) { return mx_strdup("<"); } else if (t == R_OUTPUT_DBL) { return mx_strdup(">>"); } else if (t == R_INPUT_DBL) { return mx_strdup("<<"); } return NULL; } Abstract *mx_parse_error_ush(int t, Abstract *ast_res, char *str) { char *delim; if (t != SEP) { delim = get_delim_from_type(t); mx_printerr("ush: parse error near `"); write(2, delim, mx_strlen(delim)); mx_strdel(&delim); mx_printerr("\'\n"); } mx_ast_clear_list(&ast_res); mx_strdel(&str); return NULL; } static void print_all(char *command, char *error, char arg) { mx_printerr("ush: "); mx_printerr(command); mx_printerr(": -"); mx_printerr(&arg); mx_printerr(": invalid option\n"); mx_printerr(command); mx_printerr(": usage: "); mx_printerr(command); mx_printerr(error); mx_printerr(" \n"); } int mx_count_options(char **args, char *options, char *command, char *error) { int n_options = 0; for (int i = 1; args[i] != NULL; i++) { if (args[i][0] != '-' || strcmp(args[i], "-") == 0) break; if (strcmp(args[i], "--") == 0) { n_options++; break; } for (int j = 1; j < mx_strlen(args[i]); j++) { if(mx_get_char_index(options,args[i][j]) < 0) { print_all(command, error, args[i][j]); return -1; } } n_options++; } return n_options; } static void print_left(Abstract *q) { for (Abstract *tmp_left = q->left; tmp_left; tmp_left = tmp_left->next) { mx_printstr("redir == "); if (tmp_left->type == R_INPUT) mx_printstr("< "); else if (tmp_left->type == R_INPUT_DBL) mx_printstr("<< "); else if (tmp_left->type == R_OUTPUT) mx_printstr("> "); else if (tmp_left->type == R_OUTPUT_DBL) mx_printstr(">> "); if (tmp_left->args) mx_print_strarr_in_line(tmp_left->args, " "); else if (tmp_left->token) { mx_printstr(q->token); mx_printstr("\n"); } } } static void print_list(Abstract *parsed_line) { for (Abstract *q = parsed_line; q; q = q->next) { mx_printstr("proc == "); if (q->args) mx_print_strarr_in_line(q->args, " "); else if (q->token) { mx_printstr(q->token); mx_printstr("\n"); } if (q->left) print_left(q); mx_printstr("delim == "); mx_printint(q->type); mx_printstr("\n"); } } void mx_ast_print(Abstract **ast) { char *tmp = NULL; for (int i = 0; ast[i]; i++) { mx_print_color(MX_YEL, "job-"); tmp = mx_itoa(i + 1); mx_print_color(MX_YEL, tmp); mx_strdel(&tmp); mx_printstr("\n"); print_list(ast[i]); } mx_print_color(MX_YEL, "-----\n"); }
[ "lyannoy.alexander@gmail.com" ]
lyannoy.alexander@gmail.com
723e17d307a937d2a0b8fbcd4834e76b8bde5d40
91ddd17e771f99cd4eb5acec6e9127f2acb833d6
/C-algorithm/ProgrammingPearls/maxSumOfSubsequence/maxSequence_2.c
cee643333950f4be8a7377b4eb28008f864a6184
[]
no_license
jabc1/ProgramLearning
8a5a7d174e9cf6b1d0672704effa8c320380442e
90684a7f5fa76b784375b258658396c9f23f2314
refs/heads/master
2020-05-17T08:38:00.222995
2018-03-11T14:37:30
2018-03-11T14:37:30
null
0
0
null
null
null
null
UTF-8
C
false
false
1,021
c
/** 最大子序列求和 时间复杂度:O(n^2) */ int maxSequence(int *arr, int n){ int maxSum = 0; int currentSum = 0; for (int i = 0; i < n; i++){ currentSum = 0; for (int j = i; j < n; j++){ // 必须有等于号 currentSum += arr[j]; if (maxSum < currentSum){ maxSum = currentSum; } } } return maxSum; } /********************** 第二种方法 *********************/ int maxSequence(int *arr, int n){ if (arr == NULL || n < 1){ return -1; // invalid arguments } int *cumarr = (int *)malloc(n * sizeof(int)); cumarr[0] = arr[0]; for (int i = 1; i < n; i++){ cumarr[i] = cumarr[i-1] + arr[i]; } // partial_sum int maxSum = arr[0]; int currentSum = 0; for (int i = 0; i < n; i++){ for (int j = i; j < n; j++){ if (i == 0){ currentSum = cumarr[j] - 0; } else{ currentSum = cumarr[j] - cumarr[i-1]; } if (maxSum < currentSum){ maxSum = currentSum; } } } return maxSum; }
[ "ywangsh2014@sina.com" ]
ywangsh2014@sina.com
8f07dbee6914ea966e7a17f9c878dde87d7c257f
5bcbe7af06d0e47fa8c95041639e5b43f22e153a
/usr/tools/wpm/conf.h
d9183fd840d633462ff253bf681c41a7af28c061
[]
no_license
hongbochen/OS-Zero
d19a84591718fe95b622a60ba5578e70853954a5
a636f512fe31626b6aa463c0f7a635167dee951a
refs/heads/master
2020-04-05T23:30:01.475181
2014-06-24T12:32:12
2014-06-24T12:32:12
null
0
0
null
null
null
null
UTF-8
C
false
false
298
h
#ifndef __WPM_CONF_H__ #define __WPM_CONF_H__ #define WPMPREWARM 1 #define WPMVECFULL 0 #define WPMPROF 1 #define WPMVEC 0 #define PTHREAD 1 #define WPMDB 0 #define WPMDEBUG 0 #define WPMTRACE 0 #define ZASDB 0 #define WPMWORDSIZE 32 #endif /* __WPM_CONF_H__ */
[ "tuomoster@gmail.com" ]
tuomoster@gmail.com
44759bdeaa2eda0de230f4b81e3d7455c8e36d0c
a5bb874436a5238fc94e13ad900e6107dad92330
/examples/eeprom/eeprom-test.c
e543d4feaf3fe6a5c3382d763557ebe23c602a96
[]
no_license
nikhilpnarang/sprinkio-atmel-firmware
683f1865a7c192738b33db531424b17ab929c4dc
4edec2d823e12ada7248e25d364a5ea382c87b30
refs/heads/master
2021-06-14T19:37:46.523575
2017-01-12T19:50:44
2017-01-12T19:50:44
null
0
0
null
null
null
null
UTF-8
C
false
false
366
c
#include "../../sprinkio.h" uint8_t EEMEM testInteger = 30; int main() { uint8_t SRAMchar = eeprom_read_byte(&testInteger); _delay_ms(1000); // allow time for data transfer sei(); // enable global interrupts usart_init(); // enable usart connections write_rs232_s("\r\nRandom Variable: "); write_rs232_int(SRAMchar); _delay_ms(1000); return 0; }
[ "nikhilnarang@Nikhils-MacBook.local" ]
nikhilnarang@Nikhils-MacBook.local
f234d2a5cd7973325b8c1b57ee1768a11488a6c2
ff68c5e9516bba84ad4398e0094f0385ec738661
/hq_source_code/013_test_rd_wr/rd_wr.c
dad377ae0cd255d9bf5fe101a434cd65215868ee
[]
no_license
007skyfall/itop_4412_driver
28e889fb3feaa0248b976c45e3729b2c6e5e359c
8c19cfac84ea9573fdcff16b068355e8030277b0
refs/heads/master
2020-05-07T17:30:54.996804
2019-04-14T01:59:10
2019-04-14T01:59:10
180,729,593
1
2
null
null
null
null
GB18030
C
false
false
1,931
c
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/cdev.h> #include <linux/fs.h> #include <linux/errno.h> #include <asm/uaccess.h> #define NAME "rd_wr_demo" #define MAX 64 char ker_buf[MAX] = {0}; /* 1.模块三要素 2.字符框架相关 2.1 申请设备号 2.2 cdev申请 2.3 cdev初始化 2.4 cdev注册 */ ssize_t demo_read(struct file *file, char __user *user, size_t size, loff_t *loff) { if(size > MAX) size = MAX; //unsigned long copy_to_user(void *to, const void __user *from, unsigned long n) if(raw_copy_to_user(user,ker_buf,size)){ printk("copy_to_user fail...%s,%d\n",__func__,__LINE__); return -EAGAIN; } printk("%s,%d\n",__func__,__LINE__); return size; } ssize_t demo_write(struct file *file, const char __user *user ,size_t size, loff_t *loff) { if(size > MAX) size = MAX; //unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) if(raw_copy_from_user(ker_buf,user,size)){ printk("copy_from_user fail...%s,%d\n",__func__,__LINE__); return -EAGAIN; } printk("%s,%d\n",__func__,__LINE__); return size; } int demo_open (struct inode *inode, struct file *file) { printk("%s,%d\n",__func__,__LINE__); return 0; } int demo_close (struct inode *inode, struct file *file) { printk("%s,%d\n",__func__,__LINE__); return 0; } int major = 0 , minor = 0; struct file_operations f_ops = { .owner = THIS_MODULE, .open = demo_open, .release = demo_close, .read = demo_read, .write = demo_write, }; int __init demo_init(void) { major = register_chrdev(major,NAME,&f_ops); if(major < 0){ printk("register_chrdev fail ...%s,%d\n",__func__,__LINE__); return -EINVAL; } printk("major :%d \t %s,%d\n",major ,__func__,__LINE__); return 0; } void __exit demo_exit(void) { unregister_chrdev(major,NAME); printk("%s,%d\n",__func__,__LINE__); } module_init(demo_init); module_exit(demo_exit); MODULE_LICENSE("GPL");
[ "565911459@qq.com" ]
565911459@qq.com
d45f88e7cfdd51b0c9e171c4a2258fa03e959458
f7ff15d6f0eaf897d9ed9918544d68e3ed2f3c6b
/set2prgm19.c
c14bb997aad77dcd21a606c4af6bfabe1792e684
[]
no_license
SUBHAPRANAV/c
4912899a966a677677976241c9d10e702fc1fa30
91b7bbc72a331cfbfa6bf4346eb243588e25f082
refs/heads/master
2020-04-22T04:10:28.675175
2019-04-01T11:03:19
2019-04-01T11:03:19
170,113,746
1
0
null
null
null
null
UTF-8
C
false
false
129
c
#include<stdio.h> int main() { int a,i,fact=1; scanf("%d",&a); for(i=1;i<=a;i++) { fact=fact*i; } printf("%d",fact); return 0; }
[ "noreply@github.com" ]
noreply@github.com
e329a6d561f98c7ebb6243011394b7451a6e2b48
7069cb71852cf1a5995133b1858bab3e46b501f9
/source/ekernel/drivers/drv/legacy/deviceman/devices/dev.h
368d04cf99d6cf4e2bdf98d8b8d21bf15c6f04a5
[]
no_license
lindenis-org/lindenis-v833-RTOS-melis-4.0
d2646c7093851d45645679a55bcf1462b8d4d18e
71ab8faeee960e27ef83a9ff2e4ae4b7f33eda20
refs/heads/master
2023-06-24T01:40:55.111140
2021-07-23T08:01:43
2021-07-23T08:09:40
388,733,103
14
13
null
null
null
null
GB18030
C
false
false
2,971
h
/* ********************************************************************************************************* * ePOS * the Easy Portable/Player Operation System * eMOD sub-system * * (c) Copyright 2006-2007, Steven.ZGJ China * All Rights Reserved * * File : devman_private.h * Version: V1.0 * By : steven.zgj ********************************************************************************************************* */ #ifndef __DEV_H__ #define __DEV_H__ #include <typedef.h> #include <sys_device.h> #define NODETYPE_CLASS 0x00000000 #define NODETYPE_DEV 0x00000001 #define DEV_STAT_INACTIVE 0x00 #define DEV_STAT_ACTIVE 0x01 typedef struct __DEV_NODE __dev_node_t; typedef struct __DEV_CLASSNODE __dev_classnode_t; /* 设备类节点 */ struct __DEV_CLASSNODE { __dev_classnode_t *next; __dev_node_t *nodelist; int nodetype; __u8 usedcnt; char *name; }; /* 设备节点句柄,此句柄用于保存一个设备各种信息的数据结构 */ struct __DEV_NODE { __dev_node_t *next; __dev_classnode_t *classnode; /* 类节点 */ int attrib; char *name; char pletter; __u32 opentimes; /* 句柄打开的次数 */ __u32 status; /* 节点状态:0表示正常,0xff表示为死节点(驱动程序代码已经卸载)*/ __dev_devop_t DevOp; /* 保存设备操作句柄 */ void *pOpenArg; __hdle sem; __hdle hDev; /* 设备句柄 */ }; /* ****************************************************** * 设备节点操作句柄,此句柄用于用户打开一个设备节点时返 * 回的句柄,它不同于设备句柄,它是设备节点的实例,而设 * 备句柄是设备的实例。 ****************************************************** */ typedef struct __DEV_DEV { __dev_node_t *devnode; /* 指向设备节点 */ __hdle hDev; /* 设备句柄,直接从__dev_node_t里copy,以方便使用 */ __dev_devop_t DevOp; /* 设备操作入口,直接从__dev_node_t里copy,以方便使用 */ } __dev_dev_t; #endif //#ifndef __DEV_H__
[ "given@lindeni.com" ]
given@lindeni.com
eb5a3df8f01f18570018bc227655aa5b8ed3b91e
e516aa3fce5fc72bb900de01254f252187252096
/wolf3d.h
cbbe1305f4c2b991932871108261974fa51119cd
[]
no_license
Ggrybova/Wolf3D
fe604a3cf33b5936c775c8998b7e19df603dc77b
10bdfcc85d810c3cc4f27b177ec3600ebaf4dfdb
refs/heads/master
2021-05-13T13:41:50.887397
2018-01-08T18:51:20
2018-01-08T18:51:20
116,714,716
0
0
null
null
null
null
UTF-8
C
false
false
2,377
h
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* wolf3d.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ggrybova <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/07/14 19:26:51 by ggrybova #+# #+# */ /* Updated: 2017/11/14 13:04:22 by ggrybova ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef WOLF3D_H # define WOLF3D_H # define WIDTH 640 # define HEIGHT 480 # include "libft/libft.h" # include "minilibx_macos/mlx.h" # include <math.h> typedef struct s_im { int w; int h; void *im; char *addr; int b_p_p; int size_l; int end; } t_im; typedef struct s_col { int red; int green; int blue; int c; } t_col; typedef struct s_mlx { void *mlx; void *win; int map_width; int map_height; int map[24][24]; double px; double py; double dx; double dy; double plane_x; double plane_y; double move_speed; double rot_speed; t_im *wall_tex; t_im image; double camera; double ray_px; double ray_py; double ray_dx; double ray_dy; double dside_x; double dside_y; double side_x; double side_y; double wall_dist; int box_x; int box_y; int wall; int side; int step_x; int step_y; int line_height; int y0; int y1; int tex_n; int tex_x; int tex_y; double wall_x; double fl_wall_x; double fl_wall_y; int fl_tex_x; int fl_tex_y; int ray_y; int music; } t_mlx; void fill_map(t_mlx *m); void fill_data(t_mlx *m); int create_labyrinth(t_mlx *m); void get_img_color(t_im *tex, int x, int y, t_col *c); void pixel_coord_img(t_im *img, int x, int y, t_col *c); void draw_wall(t_mlx *m, int x); void draw_floor_and_ceil(t_mlx *m, int x); int hook_func(int key, t_mlx *m); void *mlx_init(); int hook_func2(t_mlx *m); #endif
[ "ggrybova@e3r5p9.unit.ua" ]
ggrybova@e3r5p9.unit.ua
1f154d18b755c958e9de32cd576abca2612694f0
76e7239d2090d861aad90fe25c5fb34860aa5d18
/src/github.com/moovweb/gokogiri/xml/helper.h
6dbde9ad5a8151470276dc2c771a18bcf3a1ade7
[ "MIT" ]
permissive
codygman/movie-availability-api
085f421820412c7adfdf00c75aecd9057a705855
e998765466bc59cb558cedcffc31a1e875a8038b
refs/heads/master
2020-04-20T03:20:19.027432
2014-01-08T19:52:29
2014-01-08T19:52:29
15,745,081
1
0
null
null
null
null
UTF-8
C
false
false
1,220
h
#ifndef __CHELPER_H__ #define __CHELPER_H__ #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/HTMLtree.h> #include <libxml/HTMLparser.h> #include <libxml/xmlsave.h> #include <libxml/xpath.h> #include <libxml/debugXML.h> xmlDoc* xmlParse(void *buffer, int buffer_len, void *url, void *encoding, int options, void *error_buffer, int errror_buffer_len); xmlNode* xmlParseFragment(void* doc, void *buffer, int buffer_len, void *url, int options, void *error_buffer, int error_buffer_len); xmlNode* xmlParseFragmentAsDoc(void *doc, void *buffer, int buffer_len, void *url, void *encoding, int options, void *error_buffer, int error_buffer_len); int xmlSaveNode(void *wbuffer, void *node, void *encoding, int options); void xmlSetContent(void* node, void *content); xmlDoc* newEmptyXmlDoc(); xmlElementType getNodeType(xmlNode *node); char *xmlDocDumpToString(xmlDoc *doc, void *encoding, int format); char *htmlDocDumpToString(xmlDoc *doc, int format); void xmlFreeChars(char *buffer); int xmlUnlinkNodeWithCheck(xmlNode *node); int xmlNodePtrCheck(void *node); typedef struct XmlBufferContext { void *obj; char *buffer; int buffer_len; int data_size; } XmlBufferContext; #endif //__CHELPER_H__
[ "codygman.consulting@gmail.com" ]
codygman.consulting@gmail.com
cd2f29d9a3d249ce259828b7c31bc2aacda1a1a9
ca739813905897c93d7b2bdb8866f93f18186060
/001HumidtyMonitor/Core/Src/DHT11.c
51cf855a45100feffbd44f7c88111445a07d4e70
[]
no_license
99003199/CortexM4_Embedded
f007b62f1ceaa6685b4bc078816a664c5a614799
8743fba4f5d3fb0596d79440c2d425ed96a5ca5e
refs/heads/main
2022-12-27T06:54:33.958097
2020-10-05T11:23:03
2020-10-05T11:23:03
null
0
0
null
null
null
null
UTF-8
C
false
false
1,570
c
#include "main.h" #include <stdint.h> void Set_Pin_Output (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) { GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = GPIO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOx, &GPIO_InitStruct); } void Set_Pin_Input (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) { GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = GPIO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOx, &GPIO_InitStruct); } void DHT11_Start (void) { Set_Pin_Output (dht11_GPIO_Port, dht11_Pin); HAL_GPIO_WritePin (dht11_GPIO_Port, dht11_Pin, DISABLE); delay(18000); HAL_GPIO_WritePin(dht11_GPIO_Port, dht11_Pin, ENABLE); delay(20); Set_Pin_Input(dht11_GPIO_Port, dht11_Pin); } uint8_t DHT11_Check_Response (void) { uint8_t Response = 0; delay (40); if (!(HAL_GPIO_ReadPin (dht11_GPIO_Port, dht11_Pin))) { delay (80); if ((HAL_GPIO_ReadPin (dht11_GPIO_Port, dht11_Pin))) Response = 1; else Response = -1; } while ((HAL_GPIO_ReadPin (dht11_GPIO_Port, dht11_Pin))); return Response; } uint8_t DHT11_Read (void) { uint8_t i,j; for (j=0;j<8;j++) { while (!(HAL_GPIO_ReadPin (dht11_GPIO_Port, dht11_Pin))); delay (40); if (!(HAL_GPIO_ReadPin (dht11_GPIO_Port, dht11_Pin))) { i&= ~(1<<(7-j)); } else { i|= (1<<(7-j)); } while ((HAL_GPIO_ReadPin (dht11_GPIO_Port, dht11_Pin))); } return i; }
[ "amit.das@ltts.com" ]
amit.das@ltts.com
d1793a3f1aac82f038110473741d9ee6b69982f2
e80e5374b8fd00379293adb35fc8cf017d5f4cc7
/qemu_mode/qemu-2.10.0/hw/ssi/omap_spi.c
22034656b8c8fde4edcdc063372ac98b36d7ee35
[ "GPL-2.0-only", "LGPL-2.1-only", "GPL-1.0-or-later", "LGPL-2.0-or-later", "LGPL-2.1-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
CAFA1/afl
dcebf3a3acae3e9783bbb79d8cff6958b496fa34
01c113b61ab70c3b02f3d7c74e6dfa20cfc7813d
refs/heads/master
2023-04-10T14:30:34.901666
2020-07-27T01:06:32
2020-07-27T01:06:32
272,596,630
0
2
Apache-2.0
2021-04-15T00:56:55
2020-06-16T03:03:26
C
UTF-8
C
false
false
10,538
c
/* * TI OMAP processor's Multichannel SPI emulation. * * Copyright (C) 2007-2009 Nokia Corporation * * Original code for OMAP2 by Andrzej Zaborowski <andrew@openedhand.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "qemu/osdep.h" #include "hw/hw.h" #include "hw/arm/omap.h" /* Multichannel SPI */ struct omap_mcspi_s { MemoryRegion iomem; qemu_irq irq; int chnum; uint32_t sysconfig; uint32_t systest; uint32_t irqst; uint32_t irqen; uint32_t wken; uint32_t control; struct omap_mcspi_ch_s { qemu_irq txdrq; qemu_irq rxdrq; uint32_t (*txrx)(void *opaque, uint32_t, int); void *opaque; uint32_t tx; uint32_t rx; uint32_t config; uint32_t status; uint32_t control; } ch[4]; }; static inline void omap_mcspi_interrupt_update(struct omap_mcspi_s *s) { qemu_set_irq(s->irq, s->irqst & s->irqen); } static inline void omap_mcspi_dmarequest_update(struct omap_mcspi_ch_s *ch) { qemu_set_irq(ch->txdrq, (ch->control & 1) && /* EN */ (ch->config & (1 << 14)) && /* DMAW */ (ch->status & (1 << 1)) && /* TXS */ ((ch->config >> 12) & 3) != 1); /* TRM */ qemu_set_irq(ch->rxdrq, (ch->control & 1) && /* EN */ (ch->config & (1 << 15)) && /* DMAW */ (ch->status & (1 << 0)) && /* RXS */ ((ch->config >> 12) & 3) != 2); /* TRM */ } static void omap_mcspi_transfer_run(struct omap_mcspi_s *s, int chnum) { struct omap_mcspi_ch_s *ch = s->ch + chnum; if (!(ch->control & 1)) /* EN */ return; if ((ch->status & (1 << 0)) && /* RXS */ ((ch->config >> 12) & 3) != 2 && /* TRM */ !(ch->config & (1 << 19))) /* TURBO */ goto intr_update; if ((ch->status & (1 << 1)) && /* TXS */ ((ch->config >> 12) & 3) != 1) /* TRM */ goto intr_update; if (!(s->control & 1) || /* SINGLE */ (ch->config & (1 << 20))) { /* FORCE */ if (ch->txrx) ch->rx = ch->txrx(ch->opaque, ch->tx, /* WL */ 1 + (0x1f & (ch->config >> 7))); } ch->tx = 0; ch->status |= 1 << 2; /* EOT */ ch->status |= 1 << 1; /* TXS */ if (((ch->config >> 12) & 3) != 2) /* TRM */ ch->status |= 1 << 0; /* RXS */ intr_update: if ((ch->status & (1 << 0)) && /* RXS */ ((ch->config >> 12) & 3) != 2 && /* TRM */ !(ch->config & (1 << 19))) /* TURBO */ s->irqst |= 1 << (2 + 4 * chnum); /* RX_FULL */ if ((ch->status & (1 << 1)) && /* TXS */ ((ch->config >> 12) & 3) != 1) /* TRM */ s->irqst |= 1 << (0 + 4 * chnum); /* TX_EMPTY */ omap_mcspi_interrupt_update(s); omap_mcspi_dmarequest_update(ch); } void omap_mcspi_reset(struct omap_mcspi_s *s) { int ch; s->sysconfig = 0; s->systest = 0; s->irqst = 0; s->irqen = 0; s->wken = 0; s->control = 4; for (ch = 0; ch < 4; ch ++) { s->ch[ch].config = 0x060000; s->ch[ch].status = 2; /* TXS */ s->ch[ch].control = 0; omap_mcspi_dmarequest_update(s->ch + ch); } omap_mcspi_interrupt_update(s); } static uint64_t omap_mcspi_read(void *opaque, hwaddr addr, unsigned size) { struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque; int ch = 0; uint32_t ret; if (size != 4) { return omap_badwidth_read32(opaque, addr); } switch (addr) { case 0x00: /* MCSPI_REVISION */ return 0x91; case 0x10: /* MCSPI_SYSCONFIG */ return s->sysconfig; case 0x14: /* MCSPI_SYSSTATUS */ return 1; /* RESETDONE */ case 0x18: /* MCSPI_IRQSTATUS */ return s->irqst; case 0x1c: /* MCSPI_IRQENABLE */ return s->irqen; case 0x20: /* MCSPI_WAKEUPENABLE */ return s->wken; case 0x24: /* MCSPI_SYST */ return s->systest; case 0x28: /* MCSPI_MODULCTRL */ return s->control; case 0x68: ch ++; /* fall through */ case 0x54: ch ++; /* fall through */ case 0x40: ch ++; /* fall through */ case 0x2c: /* MCSPI_CHCONF */ return s->ch[ch].config; case 0x6c: ch ++; /* fall through */ case 0x58: ch ++; /* fall through */ case 0x44: ch ++; /* fall through */ case 0x30: /* MCSPI_CHSTAT */ return s->ch[ch].status; case 0x70: ch ++; /* fall through */ case 0x5c: ch ++; /* fall through */ case 0x48: ch ++; /* fall through */ case 0x34: /* MCSPI_CHCTRL */ return s->ch[ch].control; case 0x74: ch ++; /* fall through */ case 0x60: ch ++; /* fall through */ case 0x4c: ch ++; /* fall through */ case 0x38: /* MCSPI_TX */ return s->ch[ch].tx; case 0x78: ch ++; /* fall through */ case 0x64: ch ++; /* fall through */ case 0x50: ch ++; /* fall through */ case 0x3c: /* MCSPI_RX */ s->ch[ch].status &= ~(1 << 0); /* RXS */ ret = s->ch[ch].rx; omap_mcspi_transfer_run(s, ch); return ret; } OMAP_BAD_REG(addr); return 0; } static void omap_mcspi_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque; int ch = 0; if (size != 4) { omap_badwidth_write32(opaque, addr, value); return; } switch (addr) { case 0x00: /* MCSPI_REVISION */ case 0x14: /* MCSPI_SYSSTATUS */ case 0x30: /* MCSPI_CHSTAT0 */ case 0x3c: /* MCSPI_RX0 */ case 0x44: /* MCSPI_CHSTAT1 */ case 0x50: /* MCSPI_RX1 */ case 0x58: /* MCSPI_CHSTAT2 */ case 0x64: /* MCSPI_RX2 */ case 0x6c: /* MCSPI_CHSTAT3 */ case 0x78: /* MCSPI_RX3 */ OMAP_RO_REG(addr); return; case 0x10: /* MCSPI_SYSCONFIG */ if (value & (1 << 1)) /* SOFTRESET */ omap_mcspi_reset(s); s->sysconfig = value & 0x31d; break; case 0x18: /* MCSPI_IRQSTATUS */ if (!((s->control & (1 << 3)) && (s->systest & (1 << 11)))) { s->irqst &= ~value; omap_mcspi_interrupt_update(s); } break; case 0x1c: /* MCSPI_IRQENABLE */ s->irqen = value & 0x1777f; omap_mcspi_interrupt_update(s); break; case 0x20: /* MCSPI_WAKEUPENABLE */ s->wken = value & 1; break; case 0x24: /* MCSPI_SYST */ if (s->control & (1 << 3)) /* SYSTEM_TEST */ if (value & (1 << 11)) { /* SSB */ s->irqst |= 0x1777f; omap_mcspi_interrupt_update(s); } s->systest = value & 0xfff; break; case 0x28: /* MCSPI_MODULCTRL */ if (value & (1 << 3)) /* SYSTEM_TEST */ if (s->systest & (1 << 11)) { /* SSB */ s->irqst |= 0x1777f; omap_mcspi_interrupt_update(s); } s->control = value & 0xf; break; case 0x68: ch ++; /* fall through */ case 0x54: ch ++; /* fall through */ case 0x40: ch ++; /* fall through */ case 0x2c: /* MCSPI_CHCONF */ if ((value ^ s->ch[ch].config) & (3 << 14)) /* DMAR | DMAW */ omap_mcspi_dmarequest_update(s->ch + ch); if (((value >> 12) & 3) == 3) /* TRM */ fprintf(stderr, "%s: invalid TRM value (3)\n", __FUNCTION__); if (((value >> 7) & 0x1f) < 3) /* WL */ fprintf(stderr, "%s: invalid WL value (%" PRIx64 ")\n", __FUNCTION__, (value >> 7) & 0x1f); s->ch[ch].config = value & 0x7fffff; break; case 0x70: ch ++; /* fall through */ case 0x5c: ch ++; /* fall through */ case 0x48: ch ++; /* fall through */ case 0x34: /* MCSPI_CHCTRL */ if (value & ~s->ch[ch].control & 1) { /* EN */ s->ch[ch].control |= 1; omap_mcspi_transfer_run(s, ch); } else s->ch[ch].control = value & 1; break; case 0x74: ch ++; /* fall through */ case 0x60: ch ++; /* fall through */ case 0x4c: ch ++; /* fall through */ case 0x38: /* MCSPI_TX */ s->ch[ch].tx = value; s->ch[ch].status &= ~(1 << 1); /* TXS */ omap_mcspi_transfer_run(s, ch); break; default: OMAP_BAD_REG(addr); return; } } static const MemoryRegionOps omap_mcspi_ops = { .read = omap_mcspi_read, .write = omap_mcspi_write, .endianness = DEVICE_NATIVE_ENDIAN, }; struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum, qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk) { struct omap_mcspi_s *s = g_new0(struct omap_mcspi_s, 1); struct omap_mcspi_ch_s *ch = s->ch; s->irq = irq; s->chnum = chnum; while (chnum --) { ch->txdrq = *drq ++; ch->rxdrq = *drq ++; ch ++; } omap_mcspi_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_mcspi_ops, s, "omap.mcspi", omap_l4_region_size(ta, 0)); omap_l4_attach(ta, 0, &s->iomem); return s; } void omap_mcspi_attach(struct omap_mcspi_s *s, uint32_t (*txrx)(void *opaque, uint32_t, int), void *opaque, int chipselect) { if (chipselect < 0 || chipselect >= s->chnum) hw_error("%s: Bad chipselect %i\n", __FUNCTION__, chipselect); s->ch[chipselect].txrx = txrx; s->ch[chipselect].opaque = opaque; }
[ "longlong_vm@dell_book.com" ]
longlong_vm@dell_book.com
1333074ef47ef099b416a615062366b52e3eb099
1744185a1e318fd0705b7c8d71635966bf2f7451
/template/lib/Projects/STM324xG_EVAL/Examples/FSMC/FSMC_SRAM_DataMemory/Src/stm32f4xx_it.c
4322586785c2bd59aeb8d68244afd9b3b24b7626
[ "BSD-2-Clause", "MIT" ]
permissive
swedishhat/stm32f4-bear-metal
99554444acc611433190b00599d5be9ebbcbac49
04c8ae72ee6ea658dc376afe64f7f3a47c67512b
refs/heads/master
2020-12-24T09:09:59.574026
2016-11-09T18:07:57
2016-11-09T18:07:57
73,302,594
0
1
MIT
2020-03-08T01:27:48
2016-11-09T16:45:24
C
UTF-8
C
false
false
5,595
c
/** ****************************************************************************** * @file FSMC/FSMC_SRAM_DataMemory/Src/stm32f4xx_it.c * @author MCD Application Team * @version V1.2.6 * @date 06-May-2016 * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics 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. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f4xx_it.h" /** @addtogroup STM32F4xx_HAL_Examples * @{ */ /** @addtogroup FSMC_SRAM_DataMemory * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M4 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F4xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f4xx.s). */ /******************************************************************************/ /** * @brief This function handles PPP interrupt request. * @param None * @retval None */ /*void PPP_IRQHandler(void) { }*/ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
[ "patrick.d.lloyd@gmail.com" ]
patrick.d.lloyd@gmail.com
e354269707a6613f4991b9bbd1834e80739f4adf
45d1881440cd736dc3624e69026d95922f9e1289
/Silicon/TigerlakePkg/Include/CpuPcieInfo.h
eb02a589cedf48494934c45f14896c7a603f4d12
[ "BSD-2-Clause-Patent", "BSD-3-Clause" ]
permissive
sagraw2/slimbootloader
cf794d9cf593f4c9ee99b958ac17480e4ccbec10
c62c995e496368a4c426da478b054120ebbc8eca
refs/heads/master
2021-06-19T18:16:08.746301
2021-01-07T21:34:59
2021-01-08T04:22:54
160,243,111
0
0
BSD-2-Clause
2018-12-03T19:31:52
2018-12-03T19:31:52
null
UTF-8
C
false
false
3,635
h
/** @file This file contains definitions of PCIe controller information Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _CPU_PCIE_INFO_H_ #define _CPU_PCIE_INFO_H_ #define PCIE_HWEQ_COEFFS_MAX 5 /** PCIe controller configuration. **/ #define CPU_PCIE_1x16 7 #define CPU_PCIE_1x8_2x4 4 #define CPU_PCIE_2x8 5 #define CPU_PCIE_1x4 0 // // Device 1 Memory Mapped IO Register Offset Equates // #define SA_PEG_BUS_NUM 0x00 #define SA_PEG_DEV_NUM 0x01 #define SA_PEG0_DEV_NUM SA_PEG_DEV_NUM #define SA_PEG0_FUN_NUM 0x00 #define SA_PEG1_DEV_NUM SA_PEG_DEV_NUM #define SA_PEG1_FUN_NUM 0x01 #define SA_PEG2_DEV_NUM SA_PEG_DEV_NUM #define SA_PEG2_FUN_NUM 0x02 #define SA_PEG3_DEV_NUM 0x06 #define SA_PEG3_FUN_NUM 0x00 #define V_SA_PEG_VID 0x8086 #define V_PH3_FS_CR_OVR 0x3E #define B_PH3_FS_CR_OVR_EN BIT8 #define V_PH3_LF_CR_OVR 0x14 #define B_PH3_LF_CR_OVR_EN BIT16 // // Temporary Device & Function Number used for Switchable Graphics DGPU // #define SA_TEMP_DGPU_DEV 0x00 #define SA_TEMP_DGPU_FUN 0x00 #define CPU_PCIE_MAX_ROOT_PORTS 4 #define CPU_PCIE_MAX_CONTROLLERS 3 #define SA_PEG_MAX_FUN 0x04 #define SA_PEG_MAX_LANE 0x14 #define SA_PEG_MAX_BUNDLE 0x0A #define SA_PEG_MAX_FUN_GEN3 0x03 #define SA_PEG_MAX_LANE_GEN3 0x10 #define SA_PEG_MAX_BUNDLE_GEN3 0x08 #define SA_PEG0_CNT_MAX_LANE 0x10 #define SA_PEG0_CNT_MAX_BUNDLE 0x08 #define SA_PEG0_CNT_FIRST_LANE 0x00 #define SA_PEG0_CNT_FIRST_BUNDLE 0x00 #define SA_PEG0_CNT_LAST_LANE 0x0F #define SA_PEG0_CNT_LAST_BUNDLE 0x07 #define SA_PEG3_CNT_MAX_LANE 0x04 #define SA_PEG3_CNT_MAX_BUNDLE 0x02 #define SA_PEG3_CNT_FIRST_LANE 0x00 #define SA_PEG3_CNT_FIRST_BUNDLE 0x00 #define SA_PEG3_CNT_LAST_LANE 0x03 #define SA_PEG3_CNT_LAST_BUNDLE 0x01 #define SA_PEG3_CNT_MAX_LANE_GEN3 0x00 #define SA_PEG3_CNT_MAX_BUNDLE_GEN3 0x00 #define SA_PEG3_CNT_FIRST_LANE_GEN3 0x00 #define SA_PEG3_CNT_FIRST_BUNDLE_GEN3 0x00 #define SA_PEG3_CNT_LAST_LANE_GEN3 0x00 #define SA_PEG3_CNT_LAST_BUNDLE_GEN3 0x00 // // Silicon and SKU- specific MAX defines // #define SA_PEG_CNL_H_MAX_FUN SA_PEG_MAX_FUN // CNL-H- SKU supports 4 controllers with 20 PEG lanes and 10 bundles #define SA_PEG_CNL_H_MAX_LANE SA_PEG_MAX_LANE #define SA_PEG_CNL_H_MAX_BUNDLE SA_PEG_MAX_BUNDLE #define SA_PEG_NON_CNL_H_MAX_FUN 0x03 // All non-CNL-H- SKU supports 3 controllers with 16 PEG lanes and 8 bundles #define SA_PEG_NON_CNL_H_MAX_LANE 0x10 #define SA_PEG_NON_CNL_H_MAX_BUNDLE 0x08 #define DMI_AUTO 0 #define DMI_GEN1 1 #define DMI_GEN2 2 #define DMI_GEN3 3 #define PH3_METHOD_AUTO 0x0 #define PH3_METHOD_HWEQ 0x1 #define PH3_METHOD_SWEQ 0x2 #define PH3_METHOD_STATIC 0x3 #define PH3_METHOD_DISABLED 0x4 #define MAX_PRESETS 9 #define BEST_PRESETS 4 // // The PEG Disable Mask BIT0 ~ BIT3 for PEG0 ~ PEG3 // #define V_PEG_DISABLE_MASK 0x0F #define B_PEG0_DISABLE_MASK BIT0 #define B_PEG1_DISABLE_MASK BIT1 #define B_PEG2_DISABLE_MASK BIT2 #define B_PEG3_DISABLE_MASK BIT3 #define CPU_PCIE_CTRL_060 0 #define CPU_PCIE_CTRL_010 1 #define CPU_PCIE_CTRL_011_012 2 // // SIP version // #define PCIE_SIP16 0 #define PCIE_SIP17 1 #endif
[ "guo.dong@intel.com" ]
guo.dong@intel.com
37d39a2e57918af3b613758d06ab5e8eb4a6a5d0
243b969733833e83002586aeeee40dc21b0d55c0
/libft/src/ft_print_byte.c
cc3c556e6d1d1ed4df4a67cb967aa9860f368353
[]
no_license
KostyaBovt/ft_ssl
bec99134c8d4a39d523c888c9d374bd7dc29b949
bc4cbb2764dbe2703e1c749dda42e8fdc881d18c
refs/heads/master
2020-04-11T03:43:34.028613
2018-12-25T13:25:44
2018-12-25T13:25:44
161,487,391
0
0
null
null
null
null
UTF-8
C
false
false
1,107
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_byte.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kbovt <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/12/15 13:34:57 by kbovt #+# #+# */ /* Updated: 2018/12/15 13:35:47 by kbovt ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/libft.h" void ft_print_byte(unsigned char c) { int i; unsigned char shift; i = 7; shift = 1; while (i >= 0) { (c & (shift << i)) ? write(1, "1", 1) : write(1, "0", 1); i--; } }
[ "kbovt@e1r1p9.unit.ua" ]
kbovt@e1r1p9.unit.ua
7e0f473475d35ae38dfa32db1440aac2da28a6e9
cd0ffa00c856e47050254e862c2c8651d9652ab9
/beginset36.c
2ee6692f2b39fad703b84e45148e9d86161d0c2c
[]
no_license
RANJITHKUMAR12345/ranjith
861d4eefcf8df715af33bade03385f30a3ecebe1
92379ac8ddd8ab6f17c38ff0a3408a24a97e8dfa
refs/heads/master
2021-04-30T13:59:51.036372
2019-03-26T10:43:16
2019-03-26T10:43:16
121,208,531
0
1
null
null
null
null
UTF-8
C
false
false
297
c
#include<stdio.h> void main() { int a[10],i,j,tp,n; printf("enter the number"); scanf("%d",&n); printf("enter the number"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[i]>a[j]) { tp=a[i]; a[i]=a[j]; a[j]=tp; } } } for(i=0;i<n;i++) { printf("%d",a[i]); } }
[ "noreply@github.com" ]
noreply@github.com
9a90ab0d4adacd276f4a6f1f675cafe6eebb8c97
206b7b2e6d7a2b55deef44d1283efdfdb9b801e1
/src/keylogger.h
8f6a0da2ee9faacaf3e4bd79e6a368dab26c07f2
[]
no_license
MatthiasJReisinger/keylogger
c9210ed47def7c37f6365cf9f857e68e76561faf
347679078810f27550e6c386c07c3ae98a1de3c3
refs/heads/master
2020-04-09T10:24:09.665444
2013-05-21T16:00:18
2013-05-21T16:00:18
10,199,563
0
1
null
null
null
null
UTF-8
C
false
false
865
h
/** * key logger component * the key logger is a singleton which is only accessible * through the methods declared here. the key logger is a thread. * there can only be one key logger at a time. * * @author d412vv1n */ #ifndef KEYLOGGER_H #define KEYLOGGER_H /** * starts the key logger in a separate thread. if the key logger * has already been started, subsequent calls of this method are * ignored. * * @return 0 if the key logger started successfully, 1 if it could * not be started */ int startKeylogger(void); /** * stops the key logger and clears all resources the key logger * has been using. after the key logger has been stopped through this * method, it can be started again through the startKeylogger() method. * * @return 0 if the key logger stopped successfully, 1 if there was an error */ int stopKeylogger(void); #endif
[ "mr@master-studios.net" ]
mr@master-studios.net
2da9f5686999c7948360488a9a01990c280f5971
805263fc4563a4074df54272d6e96ade9b4ca9da
/glues/source/glues_quad.c
7b6fc207ffbb3ba12babdb7d3a1e6aec51888e3c
[]
no_license
spygunsoft/Physic-and-Gameplay-Implementation-on-PrimeEngine
b2aa37d7781941400851e8a7551f3b789f6e5c80
f47366bd0d69691ab335924e23e915061d5ee71a
refs/heads/master
2020-04-06T12:59:28.492976
2018-11-14T02:34:37
2018-11-14T02:34:37
157,478,887
0
1
null
null
null
null
UTF-8
C
false
false
53,166
c
/* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * 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 including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * 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 * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. * * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak <mike@malva.ua>. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include "glues_quad.h" /* Make it not a power of two to avoid cache thrashing on the chip */ #define CACHE_SIZE 240 #undef PI #define PI 3.14159265358979323846f struct GLUquadric { GLint normals; GLboolean textureCoords; GLint orientation; GLint drawStyle; void (APIENTRY* errorCallback)( GLint ); }; GLAPI GLUquadric* APIENTRY gluNewQuadric(void) { GLUquadric *newstate; newstate=(GLUquadric*)malloc(sizeof(GLUquadric)); if (newstate==NULL) { /* Can't report an error at this point... */ return NULL; } newstate->normals=GLU_SMOOTH; newstate->textureCoords=GL_FALSE; newstate->orientation=GLU_OUTSIDE; newstate->drawStyle=GLU_FILL; newstate->errorCallback=NULL; return newstate; } GLAPI void APIENTRY gluDeleteQuadric(GLUquadric* state) { if (state!=NULL) { free(state); } } static void gluQuadricError(GLUquadric* qobj, GLenum which) { if (qobj->errorCallback) { qobj->errorCallback(which); } } GLAPI void APIENTRY gluQuadricCallback(GLUquadric* qobj, GLenum which, _GLUfuncptr fn) { switch (which) { case GLU_ERROR: qobj->errorCallback=(void(APIENTRY*)(GLint))fn; break; default: gluQuadricError(qobj, GLU_INVALID_ENUM); return; } } GLAPI void APIENTRY gluQuadricNormals(GLUquadric* qobj, GLenum normals) { switch (normals) { case GLU_SMOOTH: case GLU_FLAT: case GLU_NONE: break; default: gluQuadricError(qobj, GLU_INVALID_ENUM); return; } qobj->normals=normals; } GLAPI void APIENTRY gluQuadricTexture(GLUquadric* qobj, GLboolean textureCoords) { qobj->textureCoords=textureCoords; } GLAPI void APIENTRY gluQuadricOrientation(GLUquadric* qobj, GLenum orientation) { switch(orientation) { case GLU_OUTSIDE: case GLU_INSIDE: break; default: gluQuadricError(qobj, GLU_INVALID_ENUM); return; } qobj->orientation=orientation; } GLAPI void APIENTRY gluQuadricDrawStyle(GLUquadric* qobj, GLenum drawStyle) { switch(drawStyle) { case GLU_POINT: case GLU_LINE: case GLU_FILL: case GLU_SILHOUETTE: break; default: gluQuadricError(qobj, GLU_INVALID_ENUM); return; } qobj->drawStyle=drawStyle; } GLAPI void APIENTRY gluCylinder(GLUquadric* qobj, GLfloat baseRadius, GLfloat topRadius, GLfloat height, GLint slices, GLint stacks) { GLint i, j; GLfloat sinCache[CACHE_SIZE]; GLfloat cosCache[CACHE_SIZE]; GLfloat sinCache2[CACHE_SIZE]; GLfloat cosCache2[CACHE_SIZE]; GLfloat sinCache3[CACHE_SIZE]; GLfloat cosCache3[CACHE_SIZE]; GLfloat sintemp, costemp; GLfloat vertices[(CACHE_SIZE+1)*2][3]; GLfloat texcoords[(CACHE_SIZE+1)*2][2]; GLfloat normals[(CACHE_SIZE+1)*2][3]; GLfloat angle; GLfloat zLow, zHigh; GLfloat length; GLfloat deltaRadius; GLfloat zNormal; GLfloat xyNormalRatio; GLfloat radiusLow, radiusHigh; int needCache2, needCache3; GLboolean texcoord_enabled; GLboolean normal_enabled; GLboolean vertex_enabled; GLboolean color_enabled; if (slices>=CACHE_SIZE) { slices=CACHE_SIZE-1; } /* Avoid vertex array overflow */ if (stacks>=CACHE_SIZE) { stacks=CACHE_SIZE-1; } if (slices<2 || stacks<1 || baseRadius<0.0 || topRadius<0.0 || height<0.0) { gluQuadricError(qobj, GLU_INVALID_VALUE); return; } /* Compute length (needed for normal calculations) */ deltaRadius=baseRadius-topRadius; length=(GLfloat)sqrt(deltaRadius*deltaRadius+height*height); if (length==0.0) { gluQuadricError(qobj, GLU_INVALID_VALUE); return; } /* Cache is the vertex locations cache */ /* Cache2 is the various normals at the vertices themselves */ /* Cache3 is the various normals for the faces */ needCache2=needCache3=0; if (qobj->normals==GLU_SMOOTH) { needCache2=1; } if (qobj->normals==GLU_FLAT) { if (qobj->drawStyle!=GLU_POINT) { needCache3=1; } if (qobj->drawStyle==GLU_LINE) { needCache2=1; } } zNormal=deltaRadius/length; xyNormalRatio=height/length; for (i=0; i<slices; i++) { angle=2.0f*PI*i/slices; if (needCache2) { if (qobj->orientation==GLU_OUTSIDE) { sinCache2[i]=(GLfloat)(xyNormalRatio*sin(angle)); cosCache2[i]=(GLfloat)(xyNormalRatio*cos(angle)); } else { sinCache2[i]=(GLfloat)(-xyNormalRatio*sin(angle)); cosCache2[i]=(GLfloat)(-xyNormalRatio*cos(angle)); } } sinCache[i]=(GLfloat)sin(angle); cosCache[i]=(GLfloat)cos(angle); } if (needCache3) { for (i=0; i<slices; i++) { angle=2.0f*PI*(i-0.5f)/slices; if (qobj->orientation==GLU_OUTSIDE) { sinCache3[i]=(GLfloat)(xyNormalRatio*sin(angle)); cosCache3[i]=(GLfloat)(xyNormalRatio*cos(angle)); } else { sinCache3[i]=(GLfloat)(-xyNormalRatio*sin(angle)); cosCache3[i]=(GLfloat)(-xyNormalRatio*cos(angle)); } } } sinCache[slices]=sinCache[0]; cosCache[slices]=cosCache[0]; if (needCache2) { sinCache2[slices]=sinCache2[0]; cosCache2[slices]=cosCache2[0]; } if (needCache3) { sinCache3[slices]=sinCache3[0]; cosCache3[slices]=cosCache3[0]; } /* Store status of enabled arrays */ texcoord_enabled=GL_FALSE; //glIsEnabled(GL_TEXTURE_COORD_ARRAY); normal_enabled=GL_FALSE; //glIsEnabled(GL_NORMAL_ARRAY); vertex_enabled=GL_FALSE; //glIsEnabled(GL_VERTEX_ARRAY); color_enabled=GL_FALSE; //glIsEnabled(GL_COLOR_ARRAY); /* Enable or disable arrays */ glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); if (qobj->textureCoords) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, texcoords); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } if (qobj->normals!=GLU_NONE) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, normals); } else { glDisableClientState(GL_NORMAL_ARRAY); } glDisableClientState(GL_COLOR_ARRAY); switch (qobj->drawStyle) { case GLU_FILL: for (j=0; j<stacks; j++) { zLow=j*height/stacks; zHigh=(j+1)*height/stacks; radiusLow=baseRadius-deltaRadius*((GLfloat)j/stacks); radiusHigh=baseRadius-deltaRadius*((GLfloat)(j+1)/stacks); for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_FLAT: /* per vertex normals */ normals[i*2][0]=sinCache3[i]; normals[i*2][1]=cosCache3[i]; normals[i*2][2]=zNormal; normals[i*2+1][0]=sinCache3[i]; normals[i*2+1][1]=cosCache3[i]; normals[i*2+1][2]=zNormal; break; case GLU_SMOOTH: /* per vertex normals */ normals[i*2][0]=sinCache2[i]; normals[i*2][1]=cosCache2[i]; normals[i*2][2]=zNormal; normals[i*2+1][0]=sinCache2[i]; normals[i*2+1][1]=cosCache2[i]; normals[i*2+1][2]=zNormal; break; case GLU_NONE: default: break; } if (qobj->orientation==GLU_OUTSIDE) { if (qobj->textureCoords) { texcoords[i*2][0]=1-(GLfloat)i/slices; texcoords[i*2][1]=(GLfloat)j/stacks; } vertices[i*2][0]=radiusLow*sinCache[i]; vertices[i*2][1]=radiusLow*cosCache[i]; vertices[i*2][2]=zLow; if (qobj->textureCoords) { texcoords[i*2+1][0]=1-(GLfloat)i/slices; texcoords[i*2+1][1]=(GLfloat)(j+1)/stacks; } vertices[i*2+1][0]=radiusHigh*sinCache[i]; vertices[i*2+1][1]=radiusHigh*cosCache[i]; vertices[i*2+1][2]=zHigh; } else { if (qobj->textureCoords) { texcoords[i*2][0]=1-(GLfloat)i/slices; texcoords[i*2][1]=(GLfloat)(j+1)/ stacks; } vertices[i*2][0]=radiusHigh*sinCache[i]; vertices[i*2][1]=radiusHigh*cosCache[i]; vertices[i*2][2]=zHigh; if (qobj->textureCoords) { texcoords[i*2+1][0]=1-(GLfloat)i/slices; texcoords[i*2+1][1]=(GLfloat)j/stacks; } vertices[i*2+1][0]=radiusLow*sinCache[i]; vertices[i*2+1][1]=radiusLow*cosCache[i]; vertices[i*2+1][2]=zLow; } } glDrawArrays(GL_TRIANGLE_STRIP, 0, 2*(slices+1)); } break; case GLU_POINT: for (i=0; i<slices; i++) { sintemp=sinCache[i]; costemp=cosCache[i]; for (j=0; j<=stacks; j++) { switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: normals[j][0]=sinCache2[i]; normals[j][1]=cosCache2[i]; normals[j][2]=zNormal; break; case GLU_NONE: default: break; } zLow=j*height/stacks; radiusLow=baseRadius-deltaRadius*((GLfloat)j/stacks); if (qobj->textureCoords) { texcoords[j][0]=1-(GLfloat)i/slices; texcoords[j][1]=(GLfloat)j/stacks; } vertices[j][0]=radiusLow*sintemp; vertices[j][1]=radiusLow*costemp; vertices[j][2]=zLow; } glDrawArrays(GL_POINTS, 0, (stacks+1)); } break; case GLU_LINE: for (j=1; j<stacks; j++) { zLow=j*height/stacks; radiusLow=baseRadius-deltaRadius*((GLfloat)j/stacks); for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_FLAT: normals[i][0]=sinCache3[i]; normals[i][1]=cosCache3[i]; normals[i][2]=zNormal; break; case GLU_SMOOTH: normals[i][0]=sinCache2[i]; normals[i][1]=cosCache2[i]; normals[i][2]=zNormal; break; case GLU_NONE: default: break; } if (qobj->textureCoords) { texcoords[i][0]=1-(GLfloat)i/slices; texcoords[i][1]=(GLfloat)j/stacks; } vertices[i][0]=radiusLow*sinCache[i]; vertices[i][1]=radiusLow*cosCache[i]; vertices[i][2]=zLow; } glDrawArrays(GL_LINE_STRIP, 0, (slices+1)); } /* Intentionally fall through here... */ case GLU_SILHOUETTE: for (j=0; j<=stacks; j+=stacks) { zLow=j*height/stacks; radiusLow=baseRadius-deltaRadius*((GLfloat)j/stacks); for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_FLAT: normals[i][0]=sinCache3[i]; normals[i][1]=cosCache3[i]; normals[i][2]=zNormal; break; case GLU_SMOOTH: normals[i][0]=sinCache2[i]; normals[i][1]=cosCache2[i]; normals[i][2]=zNormal; break; case GLU_NONE: default: break; } if (qobj->textureCoords) { texcoords[i][0]=1-(GLfloat)i/slices; texcoords[i][1]=(GLfloat)j/stacks; } vertices[i][0]=radiusLow*sinCache[i]; vertices[i][1]=radiusLow*cosCache[i]; vertices[i][2]=zLow; } glDrawArrays(GL_LINE_STRIP, 0, (slices+1)); } for (i=0; i<slices; i++) { sintemp=sinCache[i]; costemp=cosCache[i]; for (j=0; j<=stacks; j++) { switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: normals[j][0]=sinCache2[i]; normals[j][1]=cosCache2[i]; normals[j][2]=0.0f; break; case GLU_NONE: default: break; } zLow=j*height/stacks; radiusLow=baseRadius-deltaRadius*((GLfloat)j/stacks); if (qobj->textureCoords) { texcoords[j][0]=1-(GLfloat)i/slices; texcoords[j][1]=(GLfloat)j/stacks; } vertices[j][0]=radiusLow*sintemp; vertices[j][1]=radiusLow*costemp; vertices[j][2]=zLow; } glDrawArrays(GL_LINE_STRIP, 0, (stacks+1)); } break; default: break; } /* Disable or re-enable arrays */ if (vertex_enabled) { /* Re-enable vertex array */ glEnableClientState(GL_VERTEX_ARRAY); } else { glDisableClientState(GL_VERTEX_ARRAY); } if (texcoord_enabled) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } if (normal_enabled) { glEnableClientState(GL_NORMAL_ARRAY); } else { glDisableClientState(GL_NORMAL_ARRAY); } if (color_enabled) { glEnableClientState(GL_COLOR_ARRAY); } else { glDisableClientState(GL_COLOR_ARRAY); } } GLAPI void APIENTRY gluDisk(GLUquadric* qobj, GLfloat innerRadius, GLfloat outerRadius, GLint slices, GLint loops) { gluPartialDisk(qobj, innerRadius, outerRadius, slices, loops, 0.0, 360.0); } GLAPI void APIENTRY gluPartialDisk(GLUquadric* qobj, GLfloat innerRadius, GLfloat outerRadius, GLint slices, GLint loops, GLfloat startAngle, GLfloat sweepAngle) { GLint i, j; GLfloat sinCache[CACHE_SIZE]; GLfloat cosCache[CACHE_SIZE]; GLfloat angle; GLfloat sintemp, costemp; GLfloat vertices[(CACHE_SIZE+1)*2][3]; GLfloat texcoords[(CACHE_SIZE+1)*2][2]; GLfloat deltaRadius; GLfloat radiusLow, radiusHigh; GLfloat texLow = 0.0, texHigh = 0.0; GLfloat angleOffset; GLint slices2; GLint finish; GLboolean texcoord_enabled; GLboolean normal_enabled; GLboolean vertex_enabled; GLboolean color_enabled; if (slices>=CACHE_SIZE) { slices=CACHE_SIZE-1; } if (slices<2 || loops<1 || outerRadius<=0.0 || innerRadius<0.0 ||innerRadius > outerRadius) { gluQuadricError(qobj, GLU_INVALID_VALUE); return; } if (sweepAngle<-360.0) { sweepAngle=-360.0; } if (sweepAngle>360.0) { sweepAngle=360.0; } if (sweepAngle<0) { startAngle+=sweepAngle; sweepAngle=-sweepAngle; } if (sweepAngle==360.0) { slices2=slices; } else { slices2=slices+1; } /* Compute length (needed for normal calculations) */ deltaRadius=outerRadius-innerRadius; /* Cache is the vertex locations cache */ angleOffset=startAngle/180.0f*PI; for (i=0; i<=slices; i++) { angle=angleOffset+((PI*sweepAngle)/180.0f)*i/slices; sinCache[i]=(GLfloat)sin(angle); cosCache[i]=(GLfloat)cos(angle); } if (sweepAngle==360.0) { sinCache[slices]=sinCache[0]; cosCache[slices]=cosCache[0]; } switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: if (qobj->orientation==GLU_OUTSIDE) { glNormal3f(0.0f, 0.0f, 1.0f); } else { glNormal3f(0.0f, 0.0f, -1.0f); } break; default: case GLU_NONE: break; } /* Store status of enabled arrays */ texcoord_enabled=GL_FALSE; //glIsEnabled(GL_TEXTURE_COORD_ARRAY); normal_enabled=GL_FALSE; //glIsEnabled(GL_NORMAL_ARRAY); vertex_enabled=GL_FALSE; //glIsEnabled(GL_VERTEX_ARRAY); color_enabled=GL_FALSE; //glIsEnabled(GL_COLOR_ARRAY); /* Enable arrays */ glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); if (qobj->textureCoords) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, texcoords); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); switch (qobj->drawStyle) { case GLU_FILL: if (innerRadius==0.0) { finish=loops-1; /* Triangle strip for inner polygons */ if (qobj->textureCoords) { texcoords[0][0]=0.5f; texcoords[0][1]=0.5f; } vertices[0][0]=0.0f; vertices[0][1]=0.0f; vertices[0][2]=0.0f; radiusLow=outerRadius-deltaRadius*((GLfloat)(loops-1)/loops); if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; } if (qobj->orientation==GLU_OUTSIDE) { for (i=slices; i>=0; i--) { if (qobj->textureCoords) { texcoords[slices-i+1][0]=texLow*sinCache[i]+0.5f; texcoords[slices-i+1][1]=texLow*cosCache[i]+0.5f; } vertices[slices-i+1][0]=radiusLow*sinCache[i]; vertices[slices-i+1][1]=radiusLow*cosCache[i]; vertices[slices-i+1][2]=0.0f; } } else { for (i=0; i<=slices; i++) { if (qobj->textureCoords) { texcoords[i+1][0]=texLow*sinCache[i]+0.5f; texcoords[i+1][1]=texLow*cosCache[i]+0.5f; } vertices[i+1][0]=radiusLow*sinCache[i]; vertices[i+1][1]=radiusLow*cosCache[i]; vertices[i+1][2]=0.0f; } } glDrawArrays(GL_TRIANGLE_FAN, 0, (slices+2)); } else { finish=loops; } for (j=0; j<finish; j++) { radiusLow=outerRadius-deltaRadius*((GLfloat)j/loops); radiusHigh=outerRadius-deltaRadius*((GLfloat)(j+1)/loops); if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; texHigh=radiusHigh/outerRadius/2; } for (i=0; i<=slices; i++) { if (qobj->orientation==GLU_OUTSIDE) { if (qobj->textureCoords) { texcoords[i*2][0]=texLow*sinCache[i]+0.5f; texcoords[i*2][1]=texLow*cosCache[i]+0.5f; } vertices[i*2][0]=radiusLow*sinCache[i]; vertices[i*2][1]=radiusLow*cosCache[i]; vertices[i*2][2]=0.0; if (qobj->textureCoords) { texcoords[i*2+1][0]=texHigh*sinCache[i]+0.5f; texcoords[i*2+1][1]=texHigh*cosCache[i]+0.5f; } vertices[i*2+1][0]=radiusHigh*sinCache[i]; vertices[i*2+1][1]=radiusHigh*cosCache[i]; vertices[i*2+1][2]=0.0; } else { if (qobj->textureCoords) { texcoords[i*2][0]=texHigh*sinCache[i]+0.5f; texcoords[i*2][1]=texHigh*cosCache[i]+0.5f; } vertices[i*2][0]=radiusHigh*sinCache[i]; vertices[i*2][1]=radiusHigh*cosCache[i]; vertices[i*2][2]=0.0; if (qobj->textureCoords) { texcoords[i*2+1][0]=texLow*sinCache[i]+0.5f; texcoords[i*2+1][1]=texLow*cosCache[i]+0.5f; } vertices[i*2+1][0]=radiusLow*sinCache[i]; vertices[i*2+1][1]=radiusLow*cosCache[i]; vertices[i*2+1][2]=0.0; } } glDrawArrays(GL_TRIANGLE_STRIP, 0, ((slices+1)*2)); } break; case GLU_POINT: for (j=0; j<=loops; j++) { radiusLow=outerRadius-deltaRadius*((GLfloat)j/loops); for (i=0; i<slices2; i++) { sintemp=sinCache[i]; costemp=cosCache[i]; if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; texcoords[i][0]=texLow*sinCache[i]+0.5f; texcoords[i][1]=texLow*cosCache[i]+0.5f; } vertices[i][0]=radiusLow*sintemp; vertices[i][1]=radiusLow*costemp; vertices[i][2]=0.0f; } glDrawArrays(GL_POINTS, 0, slices2); } break; case GLU_LINE: if (innerRadius==outerRadius) { for (i=0; i<=slices; i++) { if (qobj->textureCoords) { texcoords[i][0]=sinCache[i]/2+0.5f; texcoords[i][1]=cosCache[i]/2+0.5f; } vertices[i][0]=innerRadius*sinCache[i]; vertices[i][1]=innerRadius*cosCache[i]; vertices[i][2]=0.0f; } glDrawArrays(GL_LINE_STRIP, 0, slices+1); break; } for (j=0; j<=loops; j++) { radiusLow=outerRadius-deltaRadius*((GLfloat)j/loops); if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; } for (i=0; i<=slices; i++) { if (qobj->textureCoords) { texcoords[i][0]=texLow*sinCache[i]+0.5f; texcoords[i][1]=texLow*cosCache[i]+0.5f; } vertices[i][0]=radiusLow*sinCache[i]; vertices[i][1]=radiusLow*cosCache[i]; vertices[i][2]=0.0f; } glDrawArrays(GL_LINE_STRIP, 0, slices+1); } for (i=0; i<slices2; i++) { sintemp=sinCache[i]; costemp=cosCache[i]; for (j=0; j<=loops; j++) { radiusLow=outerRadius-deltaRadius*((GLfloat)j/loops); if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; } if (qobj->textureCoords) { texcoords[j][0]=texLow*sinCache[i]+0.5f; texcoords[j][1]=texLow*cosCache[i]+0.5f; } vertices[j][0]=radiusLow*sintemp; vertices[j][1]=radiusLow*costemp; vertices[j][2]=0.0f; } glDrawArrays(GL_LINE_STRIP, 0, loops+1); } break; case GLU_SILHOUETTE: if (sweepAngle<360.0) { for (i=0; i<=slices; i+=slices) { sintemp=sinCache[i]; costemp=cosCache[i]; for (j=0; j<=loops; j++) { radiusLow=outerRadius-deltaRadius*((GLfloat)j/loops); if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; texcoords[j][0]=texLow*sinCache[i]+0.5f; texcoords[j][1]=texLow*cosCache[i]+0.5f; } vertices[j][0]=radiusLow*sintemp; vertices[j][1]=radiusLow*costemp; vertices[j][2]=0.0f; } glDrawArrays(GL_LINE_STRIP, 0, loops+1); } } for (j=0; j<=loops; j+=loops) { radiusLow=outerRadius-deltaRadius*((GLfloat)j/loops); if (qobj->textureCoords) { texLow=radiusLow/outerRadius/2; } for (i=0; i<=slices; i++) { if (qobj->textureCoords) { texcoords[i][0]=texLow*sinCache[i]+0.5f; texcoords[i][1]=texLow*cosCache[i]+0.5f; } vertices[i][0]=radiusLow*sinCache[i]; vertices[i][1]=radiusLow*cosCache[i]; vertices[i][2]=0.0f; } glDrawArrays(GL_LINE_STRIP, 0, slices+1); if (innerRadius==outerRadius) { break; } } break; default: break; } /* Disable or re-enable arrays */ if (vertex_enabled) { /* Re-enable vertex array */ glEnableClientState(GL_VERTEX_ARRAY); } else { glDisableClientState(GL_VERTEX_ARRAY); } if (texcoord_enabled) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } if (normal_enabled) { glEnableClientState(GL_NORMAL_ARRAY); } else { glDisableClientState(GL_NORMAL_ARRAY); } if (color_enabled) { glEnableClientState(GL_COLOR_ARRAY); } else { glDisableClientState(GL_COLOR_ARRAY); } } GLAPI void APIENTRY gluSphere(GLUquadric* qobj, GLfloat radius, GLint slices, GLint stacks) { GLint i, j; GLfloat sinCache1a[CACHE_SIZE]; GLfloat cosCache1a[CACHE_SIZE]; GLfloat sinCache2a[CACHE_SIZE]; GLfloat cosCache2a[CACHE_SIZE]; GLfloat sinCache3a[CACHE_SIZE]; GLfloat cosCache3a[CACHE_SIZE]; GLfloat sinCache1b[CACHE_SIZE]; GLfloat cosCache1b[CACHE_SIZE]; GLfloat sinCache2b[CACHE_SIZE]; GLfloat cosCache2b[CACHE_SIZE]; GLfloat sinCache3b[CACHE_SIZE]; GLfloat cosCache3b[CACHE_SIZE]; GLfloat angle; GLfloat zLow, zHigh; GLfloat sintemp1 = 0.0, sintemp2 = 0.0, sintemp3 = 0.0, sintemp4 = 0.0; GLfloat costemp1 = 0.0, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0; GLfloat vertices[(CACHE_SIZE+1)*2][3]; GLfloat texcoords[(CACHE_SIZE+1)*2][2]; GLfloat normals[(CACHE_SIZE+1)*2][3]; GLboolean needCache2, needCache3; GLint start, finish; GLboolean texcoord_enabled; GLboolean normal_enabled; GLboolean vertex_enabled; GLboolean color_enabled; if (slices>=CACHE_SIZE) { slices=CACHE_SIZE-1; } if (stacks>=CACHE_SIZE) { stacks=CACHE_SIZE-1; } if (slices<2 || stacks<1 || radius<0.0) { gluQuadricError(qobj, GLU_INVALID_VALUE); return; } /* Cache is the vertex locations cache */ /* Cache2 is the various normals at the vertices themselves */ /* Cache3 is the various normals for the faces */ needCache2=needCache3=GL_FALSE; if (qobj->normals==GLU_SMOOTH) { needCache2=GL_TRUE; } if (qobj->normals==GLU_FLAT) { if (qobj->drawStyle!=GLU_POINT) { needCache3=GL_TRUE; } if (qobj->drawStyle==GLU_LINE) { needCache2=GL_TRUE; } } for (i=0; i<slices; i++) { angle=2.0f*PI*i/slices; sinCache1a[i]=(GLfloat)sin(angle); cosCache1a[i]=(GLfloat)cos(angle); if (needCache2) { sinCache2a[i] = sinCache1a[i]; cosCache2a[i] = cosCache1a[i]; } } for (j=0; j<=stacks; j++) { angle=PI*j/stacks; if (needCache2) { if (qobj->orientation==GLU_OUTSIDE) { sinCache2b[j]=(GLfloat)sin(angle); cosCache2b[j]=(GLfloat)cos(angle); } else { sinCache2b[j]=(GLfloat)-sin(angle); cosCache2b[j]=(GLfloat)-cos(angle); } } sinCache1b[j]=(GLfloat)(radius*sin(angle)); cosCache1b[j]=(GLfloat)(radius*cos(angle)); } /* Make sure it comes to a point */ sinCache1b[0]=0; sinCache1b[stacks]=0; if (needCache3) { for (i=0; i<slices; i++) { angle=2.0f*PI*(i-0.5f)/slices; sinCache3a[i]=(GLfloat)sin(angle); cosCache3a[i]=(GLfloat)cos(angle); } for (j=0; j<=stacks; j++) { angle=PI*(j-0.5f)/stacks; if (qobj->orientation==GLU_OUTSIDE) { sinCache3b[j]=(GLfloat)sin(angle); cosCache3b[j]=(GLfloat)cos(angle); } else { sinCache3b[j]=(GLfloat)-sin(angle); cosCache3b[j]=(GLfloat)-cos(angle); } } } sinCache1a[slices]=sinCache1a[0]; cosCache1a[slices]=cosCache1a[0]; if (needCache2) { sinCache2a[slices]=sinCache2a[0]; cosCache2a[slices]=cosCache2a[0]; } if (needCache3) { sinCache3a[slices]=sinCache3a[0]; cosCache3a[slices]=cosCache3a[0]; } /* Store status of enabled arrays */ texcoord_enabled=GL_FALSE; //glIsEnabled(GL_TEXTURE_COORD_ARRAY); normal_enabled=GL_FALSE; //glIsEnabled(GL_NORMAL_ARRAY); vertex_enabled=GL_FALSE; //glIsEnabled(GL_VERTEX_ARRAY); color_enabled=GL_FALSE; //glIsEnabled(GL_COLOR_ARRAY); /* Enable arrays */ glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); if (qobj->textureCoords) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, texcoords); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } if (qobj->normals!=GLU_NONE) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, normals); } else { glDisableClientState(GL_NORMAL_ARRAY); } glDisableClientState(GL_COLOR_ARRAY); switch (qobj->drawStyle) { case GLU_FILL: if (!(qobj->textureCoords)) { start=1; finish=stacks-1; /* Low end first (j == 0 iteration) */ sintemp2=sinCache1b[1]; zHigh=cosCache1b[1]; switch(qobj->normals) { case GLU_FLAT: sintemp3=sinCache3b[1]; costemp3=cosCache3b[1]; normals[0][0]=sinCache3a[0]*sinCache3b[0]; normals[0][1]=cosCache3a[0]*sinCache3b[0]; normals[0][2]=cosCache3b[0]; break; case GLU_SMOOTH: sintemp3=sinCache2b[1]; costemp3=cosCache2b[1]; normals[0][0]=sinCache2a[0]*sinCache2b[0]; normals[0][1]=cosCache2a[0]*sinCache2b[0]; normals[0][2]=cosCache2b[0]; break; default: break; } vertices[0][0]=0.0f; vertices[0][1]=0.0f; vertices[0][2]=radius; if (qobj->orientation==GLU_OUTSIDE) { for (i=slices; i>=0; i--) { switch(qobj->normals) { case GLU_SMOOTH: normals[slices-i+1][0]=sinCache2a[i]*sintemp3; normals[slices-i+1][1]=cosCache2a[i]*sintemp3; normals[slices-i+1][2]=costemp3; break; case GLU_FLAT: if (i!=slices) { normals[slices-i+1][0]=sinCache3a[i+1]*sintemp3; normals[slices-i+1][1]=cosCache3a[i+1]*sintemp3; normals[slices-i+1][2]=costemp3; } else { /* We must add any normal here */ normals[slices-i+1][0]=sinCache3a[i]*sintemp3; normals[slices-i+1][1]=cosCache3a[i]*sintemp3; normals[slices-i+1][2]=costemp3; } break; case GLU_NONE: default: break; } vertices[slices-i+1][0]=sintemp2*sinCache1a[i]; vertices[slices-i+1][1]=sintemp2*cosCache1a[i]; vertices[slices-i+1][2]=zHigh; } } else { for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_SMOOTH: normals[i+1][0]=sinCache2a[i]*sintemp3; normals[i+1][1]=cosCache2a[i]*sintemp3; normals[i+1][2]=costemp3; break; case GLU_FLAT: normals[i+1][0]=sinCache3a[i]*sintemp3; normals[i+1][1]=cosCache3a[i]*sintemp3; normals[i+1][2]=costemp3; break; case GLU_NONE: default: break; } vertices[i+1][0]=sintemp2*sinCache1a[i]; vertices[i+1][1]=sintemp2*cosCache1a[i]; vertices[i+1][2]=zHigh; } } glDrawArrays(GL_TRIANGLE_FAN, 0, (slices+2)); /* High end next (j==stacks-1 iteration) */ sintemp2=sinCache1b[stacks-1]; zHigh=cosCache1b[stacks-1]; switch(qobj->normals) { case GLU_FLAT: sintemp3=sinCache3b[stacks]; costemp3=cosCache3b[stacks]; normals[0][0]=sinCache3a[stacks]*sinCache3b[stacks]; normals[0][1]=cosCache3a[stacks]*sinCache3b[stacks]; normals[0][2]=cosCache3b[stacks]; break; case GLU_SMOOTH: sintemp3=sinCache2b[stacks-1]; costemp3=cosCache2b[stacks-1]; normals[0][0]=sinCache2a[stacks]*sinCache2b[stacks]; normals[0][1]=cosCache2a[stacks]*sinCache2b[stacks]; normals[0][2]=cosCache2b[stacks]; break; default: break; } vertices[0][0]=0.0f; vertices[0][1]=0.0f; vertices[0][2]=-radius; if (qobj->orientation==GLU_OUTSIDE) { for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_SMOOTH: normals[i+1][0]=sinCache2a[i]*sintemp3; normals[i+1][1]=cosCache2a[i]*sintemp3; normals[i+1][2]=costemp3; break; case GLU_FLAT: normals[i+1][0]=sinCache3a[i]*sintemp3; normals[i+1][1]=cosCache3a[i]*sintemp3; normals[i+1][2]=costemp3; break; case GLU_NONE: default: break; } vertices[i+1][0]=sintemp2*sinCache1a[i]; vertices[i+1][1]=sintemp2*cosCache1a[i]; vertices[i+1][2]=zHigh; } } else { for (i=slices; i>=0; i--) { switch(qobj->normals) { case GLU_SMOOTH: normals[slices-i+1][0]=sinCache2a[i]*sintemp3; normals[slices-i+1][1]=cosCache2a[i]*sintemp3; normals[slices-i+1][2]=costemp3; break; case GLU_FLAT: if (i!=slices) { normals[slices-i+1][0]=sinCache3a[i+1]*sintemp3; normals[slices-i+1][1]=cosCache3a[i+1]*sintemp3; normals[slices-i+1][2]=costemp3; } else { normals[slices-i+1][0]=sinCache3a[i]*sintemp3; normals[slices-i+1][1]=cosCache3a[i]*sintemp3; normals[slices-i+1][2]=costemp3; } break; case GLU_NONE: default: break; } vertices[slices-i+1][0]=sintemp2*sinCache1a[i]; vertices[slices-i+1][1]=sintemp2*cosCache1a[i]; vertices[slices-i+1][2]=zHigh; } } glDrawArrays(GL_TRIANGLE_FAN, 0, (slices+2)); } else { start=0; finish=stacks; } for (j=start; j<finish; j++) { zLow=cosCache1b[j]; zHigh=cosCache1b[j+1]; sintemp1=sinCache1b[j]; sintemp2=sinCache1b[j+1]; switch(qobj->normals) { case GLU_FLAT: sintemp4=sinCache3b[j+1]; costemp4=cosCache3b[j+1]; break; case GLU_SMOOTH: if (qobj->orientation==GLU_OUTSIDE) { sintemp3=sinCache2b[j+1]; costemp3=cosCache2b[j+1]; sintemp4=sinCache2b[j]; costemp4=cosCache2b[j]; } else { sintemp3=sinCache2b[j]; costemp3=cosCache2b[j]; sintemp4=sinCache2b[j+1]; costemp4=cosCache2b[j+1]; } break; default: break; } for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_SMOOTH: normals[i*2][0]=sinCache2a[i]*sintemp3; normals[i*2][1]=cosCache2a[i]*sintemp3; normals[i*2][2]=costemp3; break; case GLU_FLAT: normals[i*2][0]=sinCache3a[i]*sintemp4; normals[i*2][1]=cosCache3a[i]*sintemp4; normals[i*2][2]=costemp4; break; case GLU_NONE: default: break; } if (qobj->orientation==GLU_OUTSIDE) { if (qobj->textureCoords) { texcoords[i*2][0]=1-(GLfloat)i/slices; texcoords[i*2][1]=1-(GLfloat)(j+1)/stacks; } vertices[i*2][0]=sintemp2*sinCache1a[i]; vertices[i*2][1]=sintemp2*cosCache1a[i]; vertices[i*2][2]=zHigh; } else { if (qobj->textureCoords) { texcoords[i*2][0]=1-(GLfloat)i/slices; texcoords[i*2][1]=1-(GLfloat)j/stacks; } vertices[i*2][0]=sintemp1*sinCache1a[i]; vertices[i*2][1]=sintemp1*cosCache1a[i]; vertices[i*2][2]=zLow; } switch(qobj->normals) { case GLU_SMOOTH: normals[i*2+1][0]=sinCache2a[i]*sintemp4; normals[i*2+1][1]=cosCache2a[i]*sintemp4; normals[i*2+1][2]=costemp4; break; case GLU_FLAT: normals[i*2+1][0]=sinCache3a[i]*sintemp4; normals[i*2+1][1]=cosCache3a[i]*sintemp4; normals[i*2+1][2]=costemp4; break; case GLU_NONE: default: break; } if (qobj->orientation==GLU_OUTSIDE) { if (qobj->textureCoords) { texcoords[i*2+1][0]=1-(GLfloat)i/slices; texcoords[i*2+1][1]=1-(GLfloat)j/stacks; } vertices[i*2+1][0]=sintemp1*sinCache1a[i]; vertices[i*2+1][1]=sintemp1*cosCache1a[i]; vertices[i*2+1][2]=zLow; } else { if (qobj->textureCoords) { texcoords[i*2+1][0]=1-(GLfloat)i/slices; texcoords[i*2+1][1]=1-(GLfloat)(j+1)/stacks; } vertices[i*2+1][0]=sintemp2*sinCache1a[i]; vertices[i*2+1][1]=sintemp2*cosCache1a[i]; vertices[i*2+1][2]=zHigh; } } glDrawArrays(GL_TRIANGLE_STRIP, 0, (slices+1)*2); } break; case GLU_POINT: for (j=0; j<=stacks; j++) { sintemp1=sinCache1b[j]; costemp1=cosCache1b[j]; switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: sintemp2=sinCache2b[j]; costemp2=cosCache2b[j]; break; default: break; } for (i=0; i<slices; i++) { switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: normals[i][0]=sinCache2a[i]*sintemp2; normals[i][1]=cosCache2a[i]*sintemp2; normals[i][2]=costemp2; break; case GLU_NONE: default: break; } zLow=j*radius/stacks; if (qobj->textureCoords) { texcoords[i][0]=1-(GLfloat)i/slices; texcoords[i][1]=1-(GLfloat)j/stacks; } vertices[i][0]=sintemp1*sinCache1a[i]; vertices[i][1]=sintemp1*cosCache1a[i]; vertices[i][2]=costemp1; } glDrawArrays(GL_POINTS, 0, slices); } break; case GLU_LINE: case GLU_SILHOUETTE: for (j=1; j<stacks; j++) { sintemp1=sinCache1b[j]; costemp1=cosCache1b[j]; switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: sintemp2=sinCache2b[j]; costemp2=cosCache2b[j]; break; default: break; } for (i=0; i<=slices; i++) { switch(qobj->normals) { case GLU_FLAT: normals[i][0]=sinCache3a[i]*sintemp2; normals[i][1]=cosCache3a[i]*sintemp2; normals[i][2]=costemp2; break; case GLU_SMOOTH: normals[i][0]=sinCache2a[i]*sintemp2; normals[i][1]=cosCache2a[i]*sintemp2; normals[i][2]=costemp2; break; case GLU_NONE: default: break; } if (qobj->textureCoords) { texcoords[i][0]=1-(GLfloat)i/slices; texcoords[i][1]=1-(GLfloat)j/stacks; } vertices[i][0]=sintemp1*sinCache1a[i]; vertices[i][1]=sintemp1*cosCache1a[i]; vertices[i][2]=costemp1; } glDrawArrays(GL_LINE_STRIP, 0, slices+1); } for (i=0; i<slices; i++) { sintemp1=sinCache1a[i]; costemp1=cosCache1a[i]; switch(qobj->normals) { case GLU_FLAT: case GLU_SMOOTH: sintemp2=sinCache2a[i]; costemp2=cosCache2a[i]; break; default: break; } for (j=0; j<=stacks; j++) { switch(qobj->normals) { case GLU_FLAT: normals[j][0]=sintemp2*sinCache3b[j]; normals[j][1]=costemp2*sinCache3b[j]; normals[j][2]=cosCache3b[j]; break; case GLU_SMOOTH: normals[j][0]=sintemp2*sinCache2b[j]; normals[j][1]=costemp2*sinCache2b[j]; normals[j][2]=cosCache2b[j]; break; case GLU_NONE: default: break; } if (qobj->textureCoords) { texcoords[j][0]=1-(GLfloat)i/slices; texcoords[j][1]=1-(GLfloat)j/stacks; } vertices[j][0]=sintemp1*sinCache1b[j]; vertices[j][1]=costemp1*sinCache1b[j]; vertices[j][2]=cosCache1b[j]; } glDrawArrays(GL_LINE_STRIP, 0, stacks+1); } break; default: break; } /* Disable or re-enable arrays */ if (vertex_enabled) { /* Re-enable vertex array */ glEnableClientState(GL_VERTEX_ARRAY); } else { glDisableClientState(GL_VERTEX_ARRAY); } if (texcoord_enabled) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } if (normal_enabled) { glEnableClientState(GL_NORMAL_ARRAY); } else { glDisableClientState(GL_NORMAL_ARRAY); } if (color_enabled) { glEnableClientState(GL_COLOR_ARRAY); } else { glDisableClientState(GL_COLOR_ARRAY); } }
[ "devel.spygunsoft@gmail.com" ]
devel.spygunsoft@gmail.com
d97fd8400d58fe7c7c2e3d4cdc56be9c1c672c63
e381bee2348bb2af111c726e86866a1759312563
/srcs/lst/ft_lstiter.c
a01f0fb4c1e0a119370d22e617a6e07cac39c660
[]
no_license
AnthonyLedru/libft
852f3ccffb5ebe4a3ed17ec648ae8de54ed4ac0a
ac807dc2d59de2fea77278eae1f474fd0ff1ecf8
refs/heads/master
2021-03-24T10:18:53.851026
2020-10-07T19:59:33
2020-10-07T19:59:33
113,672,950
7
0
null
null
null
null
UTF-8
C
false
false
1,018
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstiter.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aledru <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/11/10 01:52:56 by aledru #+# #+# */ /* Updated: 2017/11/10 02:24:57 by aledru ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { while (lst) { f(lst); lst = lst->next; } }
[ "aledru@e1r10p7.42.fr" ]
aledru@e1r10p7.42.fr
be5e0fd30545eef4145079ab6832219510e984f0
7774f5fa84edbe372df5bbb536e8b07b51306681
/Temp/StagingArea/Data/il2cppOutput/t1295.h
a44fa6b78fca3271b53f369182495cb1f49677c2
[]
no_license
1jeffcohen/Mr-Turtle-Breaks-Free
677f4792b30ac3041e1454e6027a64478ec18a05
360506196b46e3b8234cf732230b266e655975e1
refs/heads/master
2016-09-01T16:24:29.294516
2015-10-08T21:46:23
2015-10-08T21:46:23
43,917,971
0
0
null
null
null
null
UTF-8
C
false
false
215
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> struct t322; #include "t14.h" struct t1295 : public t14 { t322* f0; };
[ "1jeffcohen@gmail.com" ]
1jeffcohen@gmail.com
4ceddd972c5c748c17bb9f57e841a370ef477ea6
fb75dcfff838efddd2148080f910608b36ee0e40
/bin/MACROS/src/CMSStyle.C
54831975de4c3d1999c57916bb3fd40e04ad4dea
[]
no_license
iraklic/myZgamma
14231930d63c749458e85dd052cd3c3976039699
9b4ced4b134fbb4f557138fe4e6c5f6b833a1635
refs/heads/master
2020-12-24T17:17:22.019058
2015-09-14T23:47:35
2015-09-14T23:47:35
42,483,524
0
0
null
null
null
null
UTF-8
C
false
false
2,637
c
//########################################################################## // Initialization code executed at the start of a ROOT session. // // File: $Id: CMSStyle.C,v 1.1 2005/11/10 15:46:14 ganzhur Exp $ //########################################################################## //#include <iostream> //using namespace std; void CMSstyle(){ // use the 'plain' style for plots (white backgrounds, etc) // cout << "...using style 'Plain'" << endl; gROOT->SetStyle("Plain"); // Create the 'CMS' style for approved plots. Note that this style may need // some fine tuning in your macro depending on what you are plotting, e.g. // // gStyle->SetMarkerSize(0.75); // use smaller markers in a histogram with many bins // gStyle->SetTitleOffset(0.65,"y"); // bring y axis label closer to narrow values TStyle *cmsStyle= new TStyle("CMS","CMS approved plots style"); // use plain black on white colors cmsStyle->SetFrameBorderMode(0); cmsStyle->SetCanvasBorderMode(0); cmsStyle->SetPadBorderMode(0); cmsStyle->SetPadColor(0); cmsStyle->SetCanvasColor(0); cmsStyle->SetTitleColor(1); cmsStyle->SetStatColor(0); cmsStyle->SetFrameFillColor(0); cmsStyle->SetLegendBorderSize(0); // set the paper & margin sizes cmsStyle->SetPaperSize(20,26); cmsStyle->SetPadTopMargin(0.05); cmsStyle->SetPadRightMargin(0.05); cmsStyle->SetPadBottomMargin(0.17); cmsStyle->SetPadLeftMargin(0.17); // use large Times-Roman fonts cmsStyle->SetTextFont(132); cmsStyle->SetTextSize(0.08); cmsStyle->SetLabelFont(132,"x"); cmsStyle->SetLabelFont(132,"y"); cmsStyle->SetLabelFont(132,"z"); cmsStyle->SetTitleFont(132,"x"); cmsStyle->SetTitleFont(132,"y"); cmsStyle->SetTitleFont(132,"z"); cmsStyle->SetLabelSize(0.05,"x"); cmsStyle->SetTitleSize(0.06,"x"); cmsStyle->SetLabelSize(0.05,"y"); cmsStyle->SetTitleSize(0.06,"y"); cmsStyle->SetLabelSize(0.05,"z"); cmsStyle->SetTitleSize(0.06,"z"); // use bold lines and markers cmsStyle->SetMarkerStyle(8); cmsStyle->SetHistLineWidth(1.85); cmsStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes // do not display any of the standard histogram decorations cmsStyle->SetOptTitle(1); cmsStyle->SetOptStat(1); cmsStyle->SetOptFit(1); // put tick marks on top and RHS of plots cmsStyle->SetPadTickX(1); cmsStyle->SetPadTickY(1); // cout << endl << " For approved plots use: gROOT->SetStyle(\"CMS\");" // << endl << " To add a CMS label use: CMSLabel();" // << endl << endl; // restore the plain style gROOT->SetStyle("Plain"); gROOT->SetStyle("CMS"); return ; }
[ "iraklic@gmail.com" ]
iraklic@gmail.com
955a4350db196e2dfccbde697d8e1be98beea1a8
67d65e4ba2381b7a8ca36afb3189085512fa8197
/HttpRequest/pheader.h
ea0122c8936c4bf488c1cb0fe940583c0e1a39a3
[]
no_license
Ryan--Yang/winpcap
6a06a8317e98b6957c3a38b7be3a22077963a1f7
f844dd097887d45da6b81fd26e6a914d6ce08b56
refs/heads/master
2020-02-26T13:23:18.383554
2013-04-07T11:53:51
2013-04-07T11:53:51
null
0
0
null
null
null
null
UTF-8
C
false
false
1,983
h
#ifndef PHEADER_H_INCLUDED #define PHEADER_H_INCLUDED /* * */ #define ETHER_ADDR_LEN 6 /* ethernet address */ #define ETHERTYPE_IP 0x0800 /* ip protocol */ #define TCP_PROTOCAL 0x0600 /* tcp protocol */ #define BUFFER_MAX_LENGTH 65536 /* buffer max length */ #define true 1 /* define true */ #define false 0 /* define false */ /* * define struct of ethernet header , ip address , ip header and tcp header */ /* ethernet header */ typedef struct ether_header { u_char ether_shost[ETHER_ADDR_LEN]; /* source ethernet address, 8 bytes */ u_char ether_dhost[ETHER_ADDR_LEN]; /* destination ethernet addresss, 8 bytes */ u_short ether_type; /* ethernet type, 16 bytes */ }ether_header; /* four bytes ip address */ typedef struct ip_address { u_char byte1; u_char byte2; u_char byte3; u_char byte4; }ip_address; /* ipv4 header */ typedef struct ip_header { u_char ver_ihl; /* version and ip header length */ u_char tos; /* type of service */ u_short tlen; /* total length */ u_short identification; /* identification */ u_short flags_fo; // flags and fragment offset u_char ttl; /* time to live */ u_char proto; /* protocol */ u_short crc; /* header checksum */ ip_address saddr; /* source address */ ip_address daddr; /* destination address */ u_int op_pad; /* option and padding */ }ip_header; /* tcp header */ typedef struct tcp_header { u_short th_sport; /* source port */ u_short th_dport; /* destination port */ u_int th_seq; /* sequence number */ u_int th_ack; /* acknowledgement number */ u_short th_len_resv_code; /* datagram length and reserved code */ u_short th_window; /* window */ u_short th_sum; /* checksum */ u_short th_urp; /* urgent pointer */ }tcp_header; #endif // PHEADER_H_INCLUDED
[ "yfnick2010@gmail.com" ]
yfnick2010@gmail.com
34bfe63f15c2d0a942627f591bc3308707cd0dfd
a3421ecebedf3ba47a5480776078132be98ee61c
/lib/cmds/players/money.c
4df874fda26619362b1604a0b595da7ebf03eb67
[]
no_license
Muderru/NighmareMUD
7851738d08b0d3d6a46fc7fe32cf25b3cdaffdb0
c8f91447afaa4ff70460e300dd0a6c64e369bfd5
refs/heads/master
2020-03-27T13:45:03.384061
2018-08-29T15:57:52
2018-08-29T15:57:52
146,626,384
1
0
null
null
null
null
UTF-8
C
false
false
1,495
c
// /bin/user/_money.c // from the Nightmare mudlib // a comand to allow players to search their pockets // created by Descartes of Borg 25 april 1993 #include <lib.h> inherit LIB_DAEMON; mixed cmd(string str) { string *currs; string borg; int i, tmp; if(str) return 0; /* to allow the wiz command to work */ if( creatorp(this_player()) ) return "Sorry, coders don't get salaries here!"; currs = (string *)this_player()->GetCurrencies(); currs = filter(currs, (: this_player()->GetCurrency($1) > 0 :)); if( !currs || !sizeof(currs) ) { write("You are broke."); say(this_player()->GetName()+" comes up with empty pockets."); return 1; } say(this_player()->GetName()+" fishes through "+ possessive(this_player())+" pockets examining some money."); message("my_action", "In your pockets you find "+ ((sizeof(currs) > 1) ? "these currencies: " : "only: "), this_player()); for(borg = "", i=0, tmp = sizeof(currs); i<tmp; i++) { borg += ((this_player()->GetCurrency(currs[i]))+" "+currs[i]); if(i == tmp-1) borg +=(".\n"); else if(tmp > 2 && i == tmp-2) borg += (", and "); else if(tmp == 2) borg +=(" and "); else borg +=(", "); } message("my_action", borg, this_player()); return 1; } void help() { write("Syntax: <money>\n\n" "Allows you to search your pockets for all your money\n" "of all currency types.\n" ); }
[ "overmind2017@yandex.ru" ]
overmind2017@yandex.ru
e29206271b16aafaa8e71c6f225e0baf2ed27bd6
f8fe633947f3db3aff35f0af688937469aa60066
/server/server.h
a72d3f102a4e7e96398bd8c41230027943ee4692
[]
no_license
mcordischi/photosynthesis
5a25c5d5bc5d6e52e23fa53539bb899f03ba89d8
6e08001764aaf5e015e470a3ae1b74326ee087d7
refs/heads/master
2020-07-21T14:28:24.103792
2014-06-07T19:48:01
2014-06-07T19:48:01
10,872,925
0
1
null
null
null
null
UTF-8
C
false
false
85
h
#ifndef __SERVER_H_ #define __SERVER_H_ void listen(char* (*proc)(char*)); #endif
[ "nico@dazeo.com.ar" ]
nico@dazeo.com.ar
8e40eeb74b69fcae2a3ec6744835ac2c616cabc7
a171838fff520661daf6f7cccb2a273a4124edc9
/NOIP2010/20100924/all/program/A王俊涛/concert.c
20e786fbc695f88625d06c284def5fb92d9a85d8
[]
no_license
strawberryfg/pascal
5077e70900492e13d9857ab4fffd868e970a01ba
257194db62aacd2fa8024aac095df601b09f417b
refs/heads/master
2021-01-10T03:26:54.704729
2016-03-12T03:33:35
2016-03-12T03:33:35
53,711,195
1
0
null
null
null
null
UTF-8
C
false
false
1,399
c
#include <stdio.h> #include <stdlib.h> FILE *fin,*fout; int i,j,k,l,p1,p2,s1,s2; int sum1,sum2,cha; int girl[301],boy[301]; int main(int argc, char *argv[]) { fin=fopen("concert.in","r"); fout=fopen("concert.out","w"); fscanf(fin,"%d",&l); for(i=1;i<=l;i++) fscanf(fin,"%d",&girl[i]); for(i=1;i<=l;i++) fscanf(fin,"%d",&boy[i]); p1=1; p2=1; s1=1; s2=1; sum1=0; sum2=0; cha=0; while((p1<l)&&(p2<l)) {while(boy[p2]==1) p2++; while(girl[p1]==1) p1++; sum1=boy[p2]*girl[p1]; s1=p1+1; s2=p2+1; if((p2!=l)&&(p1!=l)) { for(j=1;j<p1;j++) cha=cha+girl[p1]; sum1=sum1-cha*cha; cha=0; for(j=1;j<p2;j++) cha=cha+boy[p2]; sum1=sum1-cha*cha; } else if(p1==l) {for(j=p2+1;j<=l;j++) cha=cha+boy[p2]; sum1=sum1-cha*cha; cha=0; for(j=s1;j<p1;j++) cha=cha+girl[p1]; sum1=sum1-cha*cha; } else if(p2==l) { for(j=p1+1;j<=l;j++) cha=cha+girl[p1]; sum1=sum1-cha*cha; cha=0; for(j=s2;j<p2;j++) cha=cha+boy[p2]; sum1=sum1-cha*cha; } } for(j=1;j<=l;j++) sum2=sum2+boy[j]*girl[j]; if(sum2>sum1) fprintf(fout,"%d\n",sum2); else fprintf(fout,"%d\n",sum1); return 0; }
[ "wanqingfu@sina.com" ]
wanqingfu@sina.com
56b300ff87268a31a62843dc4f6b607b18532df6
afc8d5a9b1c2dd476ea59a7211b455732806fdfd
/Configurations/VBF/Full2016BDT/mymacros/hww_VBF_mvaBDT14.C
05f3a8592e7615fe79e28e06efd226fbe8cf6bec
[]
no_license
latinos/PlotsConfigurations
6d88a5ad828dde4a7f45c68765081ed182fcda21
02417839021e2112e740607b0fb78e09b58c930f
refs/heads/master
2023-08-18T20:39:31.954943
2023-08-18T09:23:34
2023-08-18T09:23:34
39,819,875
10
63
null
2023-08-10T14:08:04
2015-07-28T07:36:50
Python
UTF-8
C
false
false
2,101
c
#include <TMVA/Reader.h> using namespace std; TMVA::Reader* myreaderBDT14 = new TMVA::Reader(); // float lepton_pt1; // float lepton_pt2; float mll_52; float mjj_52; float jetpt1_52; float jetpt2_52; float detajj_52; // float ptll_52; float jeteta1_52; float jeteta2_52; float met_52; float mth_52; void initmyreaderBDT14(){ // myreaderBDT14->AddVariable( "std_vector_lepton_pt[0]", &lepton_pt1 ); // myreaderBDT14->AddVariable( "std_vector_lepton_pt[1]", &lepton_pt2 ); myreaderBDT14->AddVariable( "mll", &mll_52 ); myreaderBDT14->AddVariable( "mjj", &mjj_52 ); myreaderBDT14->AddVariable( "jetpt1", &jetpt1_52 ); myreaderBDT14->AddVariable( "jetpt2", &jetpt2_52 ); myreaderBDT14->AddVariable( "detajj",&detajj_52); // myreaderBDT14->AddVariable( "ptll", &ptll_52 ); myreaderBDT14->AddVariable( "jeteta1", &jeteta1_52); myreaderBDT14->AddVariable( "jeteta2", &jeteta2_52); myreaderBDT14->AddVariable( "metPfType1",&met_52); myreaderBDT14->AddVariable( "mth",&mth_52); TString direction = ""; direction = "/afs/cern.ch/work/a/arun/Latinos/HWW_Full2016/CMSSW_8_0_26_patch1/src/MUCCA/Optimization/weights/VBF_INCL_TMVAClassification_VBF_new_BDT14.weights.xml"; cout<<direction<<endl; myreaderBDT14->BookMVA("BDT14",direction); } float hww_VBF_mvaBDT14( //float leppt1, // float leppt2, float mll_53, float mjj_53, float jetpt1_53, float jetpt2_53, float detajj_53, // float ptllf, float jeteta1_53, float jeteta2_53, float met_53, float mth_53 ){ // lepton_pt1 = leppt1; // lepton_pt2 = leppt2; mll_52 = mll_53; mjj_52 = mjj_53; jetpt1_52 = jetpt1_53; jetpt2_52 = jetpt2_53; detajj_52 = detajj_53; // ptll_52 = ptllf; jeteta1_52 = jeteta1_53; jeteta2_52 = jeteta2_53; met_52 = met_53; mth_52 = mth_53; //cout<<"BEFORE READING!!!!!!-------"<<endl; return myreaderBDT14->EvaluateMVA("BDT14"); }
[ "arun.kumar@cern.ch" ]
arun.kumar@cern.ch
08113360ad500737a7a5484c45b9eafc178d9774
c4afbfe1885e8d0c7a1c8b928563f7bb8ab6a683
/openETCS_Releases/v0.3-D3.6.3/KCG_GreenField/CAST_int_to_DMI_TEXT_DATA_Varia.c
cc1403d9726ddbafe4826b0732e7b218f84714c1
[]
no_license
VladislavLasmann/srcAndBinary
cd48ebaa2f1f7f697ba5df9f38abb9ed50658e10
13aa76e545b9596f6dac84fb20480dffae7584d8
refs/heads/master
2021-05-08T15:04:05.709079
2016-01-22T12:40:10
2016-01-22T12:40:10
null
0
0
null
null
null
null
UTF-8
C
false
false
1,086
c
/* $**************** KCG Version 6.4 (build i21) **************** ** Command: kcg64.exe -config D:/Github/modeling/model/Scade/System/OBU_PreIntegrations/openETCS_EVC/KCG_GreenField/config.txt ** Generation date: 2015-11-05T08:54:04 *************************************************************$ */ #include "kcg_consts.h" #include "kcg_sensors.h" #include "CAST_int_to_DMI_TEXT_DATA_Varia.h" /* DATA::Variables::CAST_int_to_DMI_TEXT */ void CAST_int_to_DMI_TEXT_DATA_Varia( /* DATA::Variables::CAST_int_to_DMI_TEXT::dmi_text_int_array_in */ DMI_TEXT_INT_Array_T_DATA *dmi_text_int_array_in, /* DATA::Variables::CAST_int_to_DMI_TEXT::dmi_text_string_out */ DMI_TEXT_DMI_Types_Pkg *dmi_text_string_out) { static kcg_int i; /* 1 */ for (i = 0; i < 255; i++) { (*dmi_text_string_out)[i] = /* 1 */ Int_to_Char_Utilities((*dmi_text_int_array_in)[i]); } } /* $**************** KCG Version 6.4 (build i21) **************** ** CAST_int_to_DMI_TEXT_DATA_Varia.c ** Generation date: 2015-11-05T08:54:04 *************************************************************$ */
[ "bernd.hekele@deutschebahn.com" ]
bernd.hekele@deutschebahn.com
ecdf48a5e99c03e80d3d0804d4749b5ff8d67d07
5fe634e7327f5f62bcafa356e76d46f07b794b36
/APUE/src/8/8-9_1.c
ef96ceb6650db9d35842bb2a1bc6f18626ff4e23
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
MarsonShine/Books
8433bc1a5757e6d85e9cd649347926cfac59af08
7265c8a6226408ae687c796f604b35320926ed79
refs/heads/master
2023-08-31T05:32:35.202491
2023-08-30T10:29:26
2023-08-30T10:29:26
131,323,678
29
3
Apache-2.0
2022-12-07T13:01:31
2018-04-27T17:00:17
C#
UTF-8
C
false
false
627
c
#include "apue.h" static void charatatime(char *); int main(void) { pid_t pid; if ((pid == fork()) < 0) { err_sys("fork error"); } else if (pid == 0) { // 子进程 charatatime("output from child\n"); } else {// 父进程 charatatime("output from parent\n"); } exit(0); } static void charatatime(char *str) { char *ptr; int c; setbuf(stdout, NULL); // 设置无缓冲 for (ptr = str; (c = *ptr++) != 0;) putc(c, stdout); } // 可能的输出结果: // 1. // ooutput form child // utput from parent // 2. // oooutput from child // utput from parent
[ "ms27946@outlook.com" ]
ms27946@outlook.com
d590cc92c070f3e44fad3ed8985e80174f21d20b
b2d48aac47dc3a3050f9cb562808f0e6f19a36e4
/mohansai/zetair/src/bucket.c
fe2a221cbe62c8cca6760d793fd2823b8ab59b25
[]
no_license
bhagavansprasad/students
7f7df2f4c2350025d58406794a7d94d9c8a9d7be
2822fb81cfb6714d48dea1e4957d6011ffa6198b
refs/heads/master
2023-08-04T04:44:11.346963
2023-07-24T06:09:00
2023-07-24T06:09:00
193,177,404
0
0
null
2022-11-30T23:33:00
2019-06-22T01:21:59
C
UTF-8
C
false
false
76,306
c
/* bucket.c implements a structure that manages short inverted lists by * keeping them in fixed size buckets. * * actually, since i need to do some experimentation to find the best bucket * design, it will probably implement a number of structures. There are a * number of good reasons for having different bucket structures around, * including specialising to match the current architecture endianness and * reducing costs for fixed-length entries and keys. * * The first bucket design that we will use is as follows: * * +-------------------------------+ * |num|t1p|t1l|t2p|t2l| | * +-------------------------------+ * | |xxxxx,term2|xxxxxxxxx,term1| * +-------------------------------+ * * term vectors are stored in lexographic order with the corresponding term * immediately afterward. (shown as xxxx,term1 etc). * The term length is stored in the directory as t1l, t2l etc. * The term pointers (t1p, t2p etc) point to the start of the entry for that * term, where entries are kept packed to the back of the bucket (to allow * easy appending of new entries). All entries in the directory (shown on top * row) are fixed length numbers of size 16 bits (stored in big-endian format), * which allows quick lookup given the index of the term. * The term pointers combined with knowledge of the size of the bucket * and the term lengths can be used to deduce the length of each vector. * * Bucket design 2 is the same as one, except that all entries have uniform * length and are stored (once) at the start of the bucket. * * +-------------------------------+ * |num|size|t1p|t2p| | * +-------------------------------+ * | |xxxxx,term2|xxxxxxxxx,term1| * +-------------------------------+ * * written nml 2003-10-06 * */ #include "firstinclude.h" #include "bucket.h" #include "_mem.h" #include "bit.h" #include "mem.h" #include "str.h" /* for str_ncmp use in assert */ #include "vec.h" #include "zstdint.h" #include <assert.h> #include <errno.h> #include <limits.h> #include <stdlib.h> #include <string.h> /* return address of entries (it's at the start of memory) for bucket designs * 1 and 2 */ #define B1_ENTRIES_ADDR(base) (base) #define B2_ENTRIES_ADDR(base) (base) /* return address of the pointer for entries for bucket designs 1 and 2 */ #define B1_PTR(entry) (sizeof(uint16_t) * (2 * (entry) + 1)) #define B1_PTR_ADDR(base, entry) (((char *) base) + B1_PTR(entry)) #define B2_PTR(entry) (sizeof(uint16_t) * ((entry) + 2)) #define B2_PTR_ADDR(base, entry) (((char *) base) + B2_PTR(entry)) /* return address of the size for an entry for bucket designs 1 and 2 */ #define B1_SIZE(entry) (sizeof(uint16_t) * (2 * (entry) + 2)) #define B1_SIZE_ADDR(base, entry) (((char *) base) + B1_SIZE(entry)) #define B2_SIZE(entry) (sizeof(uint16_t)) #define B2_SIZE_ADDR(base, entry) (((char *) base) + B1_SIZE(entry)) /* macro to read a vbyte number from cmem (which is incremented over the number) * into n. Note that cmem must be a uchar * */ #define GETVBYTE(cmem, n) \ if (1) { \ unsigned int GETVBYTE_count = 0; \ \ *(n) = 0; \ while ((STR_FROM_CHAR(*(cmem)) >= 128)) { \ *(n) |= (*(cmem) & 0x7f) << GETVBYTE_count; \ GETVBYTE_count += 7; \ (cmem)++; \ } \ *(n) |= STR_FROM_CHAR(*(cmem)) << GETVBYTE_count; \ (cmem)++; \ } else /* macro to put a vbyte number to cmem (which is incremented over the number) * from n (which is destroyed by the operation). Note that cmem must be * a uchar * */ #define PUTVBYTE(cmem, n) \ if (1) { \ while ((n) >= 128) { \ *(cmem) = ((n) & 0x7f) | 0x80; \ (n) >>= 7; \ (cmem)++; \ } \ *(cmem) = ((unsigned char) n); \ (cmem)++; \ } else int bucket_new(void *mem, unsigned int bucketsize, int strategy) { if (bucketsize >= UINT16_MAX) { return 0; } /* this isn't strictly necessary, but means that everything is guaranteed * to be initialised (even the space we don't use) */ memset(mem, 0, bucketsize); switch (strategy) { case 1: case 2: return 1; default: return 0; }; } int bucket_sorted(int strategy) { switch (strategy) { case 1: case 2: return 1; default: return 0; } } unsigned int bucket_entries(void *mem, unsigned int bucketsize, int strategy) { uint16_t entries; switch (strategy) { case 1: case 2: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); return entries; break; default: assert(0); return 0; break; } } unsigned int bucket_utilised(void *mem, unsigned int bucketsize, int strategy) { unsigned int i; uint16_t entries, length, utilised = 0; switch (strategy) { case 1: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); /* read each entry */ for (i = 0; i < entries; i++) { MEM_NTOH(&length, B1_SIZE_ADDR(mem, i), sizeof(length)); utilised += length; } return utilised; break; case 2: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); /* read each entry */ for (i = 0; i < entries; i++) { MEM_NTOH(&length, B2_SIZE_ADDR(mem, i), sizeof(length)); utilised += length; } return utilised; break; default: assert(0); return 0; break; } } unsigned int bucket_string(void *mem, unsigned int bucketsize, int strategy) { unsigned int i; uint16_t entries, prevptr = bucketsize, ptr, length, string = 0; switch (strategy) { case 1: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); /* read each entry */ for (i = 0; i < entries; i++) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, i), sizeof(ptr)); MEM_NTOH(&length, B1_SIZE_ADDR(mem, i), sizeof(length)); string += (prevptr - ptr) - length; prevptr = ptr; } return string; break; case 2: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); /* read each entry */ for (i = 0; i < entries; i++) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem, i), sizeof(ptr)); MEM_NTOH(&length, B2_SIZE_ADDR(mem, i), sizeof(length)); string += (prevptr - ptr) - length; prevptr = ptr; } return string; break; default: assert(0); return 0; break; } } unsigned int bucket_overhead(void *mem, unsigned int bucketsize, int strategy) { uint16_t entries; switch (strategy) { case 1: case 2: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); return entries * 2 * sizeof(uint16_t) + sizeof(entries); break; default: assert(0); return 0; break; } } unsigned int bucket_unused(void *mem, unsigned int bucketsize, int strategy) { uint16_t entries, lastptr; switch (strategy) { case 1: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); /* read last entry */ if (entries) { MEM_NTOH(&lastptr, B1_PTR_ADDR(mem, entries - 1), sizeof(lastptr)); return lastptr - B1_PTR(entries); } else { return bucketsize - sizeof(entries); } break; case 2: /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); /* read last entry */ if (entries) { MEM_NTOH(&lastptr, B2_PTR_ADDR(mem, entries - 1), sizeof(lastptr)); return lastptr - B2_PTR(entries); } else { return bucketsize - sizeof(entries); } break; default: assert(0); return 0; break; } } /* functions for strategy 1 */ /* binary searches a bucket for a term, returning the largest thing that is less * than or equal to the given term (this property, which the usual binary search * must be modified to provide, is important because we can then use it for * insertion sorting as well as searching) */ static unsigned int bucket1_binsearch(void *mem, unsigned int bucketsize, unsigned int entries, const char *term, unsigned int termlen) { unsigned int l, r, m, i, len, tlen; uint16_t ptr, prevptr, size; assert(entries); l = 0; r = entries - 1; while (l < r) { m = BIT_DIV2((r + l + 1), 1); /* decode m ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, m), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, m), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (m) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, m - 1), sizeof(prevptr)); tlen = prevptr - ptr - size; len = (tlen > termlen) ? termlen : tlen; for (i = 0; i < len; i++) { if (term[i] < ((char *) mem)[i + ptr + size]) { r = m - 1; break; } else if (term[i] > ((char *) mem)[i + ptr + size]) { l = m; break; } } /* exact match of prefixes */ if (i == len) { if (termlen == tlen) { return m; } else if (termlen < tlen) { r = m - 1; } else { l = m; } } } else { /* m is first entry */ prevptr = bucketsize; tlen = prevptr - ptr - size; len = (tlen > termlen) ? termlen : tlen; for (i = 0; i < len; i++) { if (term[i] < ((char *) mem)[i + ptr + size]) { /* no exact match, act now to prevent underflow */ return 0; break; } else if (term[i] > ((char *) mem)[i + ptr + size]) { l = m; break; } } /* exact match of prefixes */ if (i == len) { if (termlen <= tlen) { /* no match, act now to prevent underflow */ return 0; } else { l = m; } } } } /* no exact match */ return l; } void *bucket1_find(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int *veclen, unsigned int *idx) { unsigned int index, i; uint16_t entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries) { return NULL; } index = bucket1_binsearch(mem, bucketsize, entries, term, termlen); /* decode ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); if (((unsigned int) prevptr - ptr) - size == termlen) { for (i = 0; i < termlen; i++) { if (term[i] != ((char *) mem)[i + ptr + size]) { return NULL; } } *veclen = size; if (idx) { *idx = index; } return ((char *) mem) + ptr; } return NULL; } void *bucket1_search(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int *veclen, unsigned int *idx) { unsigned int index; uint16_t entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries) { return NULL; } index = bucket1_binsearch(mem, bucketsize, entries, term, termlen); /* decode ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } if (idx) { *idx = index; } *veclen = size; return ((char *) mem) + ptr; } void *bucket1_realloc_at(void *mem, unsigned int bucketsize, unsigned int index, unsigned int newsize, int *toobig) { unsigned int termlen; uint16_t size, lastaddr, entries, new_bucket_size, ptr, prevptr, movesize; new_bucket_size = bucketsize - sizeof(uint16_t); /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries || (index >= entries)) { *toobig = 0; return NULL; } /* decode ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); /* read the last entry */ MEM_NTOH(&lastaddr, B1_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); /* infer term length */ termlen = prevptr - ptr - size; if (newsize > size) { /* allocation is growing */ if ((newsize - size) > lastaddr - B1_PTR(entries)) { /* not enough space to grow the entry */ if (termlen + newsize + sizeof(uint16_t) * 2 > new_bucket_size) { /* ... even if the bucket was empty */ *toobig = 1; } return NULL; } /* only need to move the bytes from the old entry */ movesize = size; } else { /* shrinking realloc, move only the bytes that will be preserved */ movesize = newsize; } /* move strings and vectors (careful, this line is tricky) */ memmove(((char *) mem) + lastaddr - (newsize - size), ((char *) mem) + lastaddr, ptr + movesize - lastaddr); /* adjust pointers */ assert(((newsize > size) && ptr > (newsize - size)) || ((newsize < size) && ptr > (size - newsize)) || (newsize == size)); ptr -= (newsize - size); MEM_HTON(B1_PTR_ADDR(mem, index), &ptr, sizeof(ptr)); MEM_HTON(B1_SIZE_ADDR(mem, index), &newsize, sizeof(ptr)); prevptr = ptr; for (index++; index < entries; index++) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); ptr -= (newsize - size); MEM_HTON(B1_PTR_ADDR(mem, index), &ptr, sizeof(ptr)); } /* done */ return ((char *) mem) + prevptr; } void *bucket1_realloc(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int newsize, int *toobig) { unsigned int i, index; uint16_t entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries) { *toobig = 0; return NULL; } index = bucket1_binsearch(mem, bucketsize, entries, term, termlen); /* verify that index points to requested term */ /* decode ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); if (((unsigned int) prevptr - ptr - size) == termlen) { for (i = 0; i < termlen; i++) { if (term[i] != ((char *) mem)[ptr + size + i]) { return NULL; } } return bucket1_realloc_at(mem, bucketsize, index, newsize, toobig); } else { return NULL; } } void *bucket1_alloc(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int newsize, int *toobig, unsigned int *idx) { unsigned int index, i, len; uint16_t size, lastaddr, entries, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); size = newsize; if (entries) { /* read the last entry */ MEM_NTOH(&lastaddr, B1_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); /* check that we have enough space to allocate entry */ if ((size + termlen + 2 * (sizeof(uint16_t))) > (lastaddr - B1_PTR(entries))) { /* test whether theres enough space to allocate the entry if the * bucket was empty */ *toobig = (termlen + newsize + sizeof(uint16_t) * 2 > bucketsize - sizeof(entries)); return NULL; } index = bucket1_binsearch(mem, bucketsize, entries, term, termlen); /* need to do a last comparison to figure out whether we want to insert * here or in the next position */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } /* the way we do our binary search, the item may need to be inserted * at the *next* location (assuming that there is no exact match) */ assert(prevptr >= ptr); len = (unsigned int) (((unsigned int) prevptr - ptr - size) > termlen) ? termlen : prevptr - ptr - size; for (i = 0; i < len; i++) { if (term[i] < ((char *) mem)[i + ptr + size]) { break; } else if (term[i] > ((char *) mem)[i + ptr + size]) { index++; prevptr = ptr; MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); break; } } /* exact match of prefixes */ /* XXX: should check for exact match */ if (i == len) { if (termlen > len) { index++; prevptr = ptr; MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); } } /* new allocation needs to be inserted at index */ if (index < entries) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } /* move strings and data down */ memmove(((char *) mem) + lastaddr - termlen - newsize, ((char *) mem) + lastaddr, ptr - lastaddr + (prevptr - ptr)); /* shift pointers up */ for (i = entries; (i > index); i--) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, i - 1), sizeof(ptr)); ptr -= termlen + newsize; MEM_HTON(B1_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); memcpy(B1_SIZE_ADDR(mem, i), B1_SIZE_ADDR(mem, i - 1), sizeof(size)); } ptr = prevptr - termlen - newsize; } else { ptr = lastaddr - termlen - newsize; } } else { /* check that we have enough space to allocate entry */ if (termlen + newsize + sizeof(uint16_t) * 2 > bucketsize - sizeof(entries)) { *toobig = 1; return NULL; } ptr = bucketsize - termlen - newsize; index = 0; } /* encode new pointer */ size = newsize; MEM_HTON(B1_PTR_ADDR(mem, index), &ptr, sizeof(ptr)); MEM_HTON(B1_SIZE_ADDR(mem, index), &size, sizeof(size)); /* copy new string in */ memcpy(((char *) mem) + ptr + size, term, termlen); /* encode new entries record */ entries++; MEM_HTON(B1_ENTRIES_ADDR(mem), &entries, sizeof(entries)); if (idx) { *idx = index; } return ((char *) mem) + ptr; } int bucket1_remove_at(void *mem, unsigned int bucketsize, unsigned int index) { unsigned int i; uint16_t lastaddr, entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); if (!entries || (index >= entries)) { return 0; } /* decode ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); /* read the last entry */ MEM_NTOH(&lastaddr, B1_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); /* move strings/data up */ memmove(((char *) mem) + lastaddr + (prevptr - ptr), ((char *) mem) + lastaddr, ptr - lastaddr); size = prevptr - ptr; /* update pointers */ for (i = index; i + 1 < entries; i++) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, i + 1), sizeof(ptr)); ptr += size; MEM_HTON(B1_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); memcpy(B1_SIZE_ADDR(mem, i), B1_SIZE_ADDR(mem, i + 1), sizeof(size)); } /* encode new entries record */ entries--; MEM_HTON(B1_ENTRIES_ADDR(mem), &entries, sizeof(entries)); return 1; } int bucket1_remove(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen) { unsigned int i, index; uint16_t entries, ptr, size, prevptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); if (!entries) { return 0; } index = bucket1_binsearch(mem, bucketsize, entries, term, termlen); /* verify that index points to requested term */ /* decode ptr */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); if (((unsigned int) prevptr - ptr - size) == termlen) { for (i = 0; i < termlen; i++) { if (term[i] != ((char *) mem)[ptr + size + i]) { return 0; } } return bucket1_remove_at(mem, bucketsize, index); } else { return 0; } } const char *bucket1_term_at(void *mem, unsigned int bucketsize, unsigned int index, unsigned int *len, void **data, unsigned int *veclen) { uint16_t addr, prevaddr, /* logically previous (physically next) address */ size, entries; /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); if (index < entries) { /* read the entry */ MEM_NTOH(&addr, B1_PTR_ADDR(mem, index), sizeof(addr)); MEM_NTOH(&size, B1_SIZE_ADDR(mem, index), sizeof(size)); assert(((sizeof(addr) * entries) <= addr) && (bucketsize > addr)); if (index) { /* its not the first entry, read the previous entry's address */ MEM_NTOH(&prevaddr, B1_PTR_ADDR(mem, index - 1), sizeof(prevaddr)); } else { /* its the first entry, boundary is the end of the bucket */ prevaddr = bucketsize; } *len = prevaddr - addr - size; *veclen = size; *data = ((char *) mem) + addr; return ((char *) mem) + addr + size; } else { /* its past the last entry */ return NULL; } } int bucket1_split(void *mem1, unsigned int bucketsize1, void *mem2, unsigned int bucketsize2, unsigned int terms) { unsigned int i, j; uint16_t lastaddr, entries, size, ptr, prevptr; memset(mem2, 0, bucketsize2); /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem1), sizeof(entries)); if (terms >= entries) { return (terms == entries); } if (terms) { /* read split entry */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem1, terms - 1), sizeof(ptr)); } else { ptr = bucketsize1; } /* read last entry */ MEM_NTOH(&lastaddr, B1_PTR_ADDR(mem1, entries - 1), sizeof(lastaddr)); /* copy strings and data from bucket 1 to bucket 2 */ memcpy((char *) mem2 + bucketsize2 - (ptr - lastaddr), (char *) mem1 + lastaddr, ptr - lastaddr); /* copy pointers to new bucket */ prevptr = ptr; for (j = 0, i = terms; i < entries; i++, j++) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem1, i), sizeof(ptr)); ptr += bucketsize1 - prevptr; MEM_HTON(B1_PTR_ADDR(mem2, j), &ptr, sizeof(size)); memcpy(B1_SIZE_ADDR(mem2, j), B1_SIZE_ADDR(mem1, i), sizeof(size)); } /* adjust entries record in both buckets */ size = terms; mem_hton(B1_ENTRIES_ADDR(mem1), &size, sizeof(size)); entries -= size; mem_hton(B1_ENTRIES_ADDR(mem2), &entries, sizeof(entries)); return 1; } int bucket1_set_term(void *mem, unsigned int bucketsize, unsigned int termno, const char *newterm, unsigned int newtermlen, int *toobig) { unsigned int i, termlen; uint16_t size, ptr, prevptr, lastptr, entries; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); if (termno >= entries) { return 0; } /* read entry, previous and last pointers */ MEM_NTOH(&ptr, B1_PTR_ADDR(mem, termno), sizeof(ptr)); if (termno + 1 < entries) { MEM_NTOH(&prevptr, B1_PTR_ADDR(mem, termno + 1), sizeof(prevptr)); /* read the last entry */ MEM_NTOH(&lastptr, B1_PTR_ADDR(mem, (entries - 1)), sizeof(lastptr)); } else { prevptr = bucketsize; lastptr = ptr; } MEM_NTOH(&size, B1_SIZE_ADDR(mem, size), sizeof(size)); termlen = prevptr - ptr - size; if (newtermlen > termlen) { /* string is growing */ /* check that we have enough space to allocate entry */ if (((newtermlen - termlen) > (lastptr - B1_PTR(entries)))) { /* not enough space to allocate the entry */ if ((newtermlen + 2 * sizeof(uint16_t) + size) > bucketsize - sizeof(entries)) { /* ... even if the bucket was empty */ *toobig = 1; } return 0; } /* move strings and data prior to the entry */ memmove(((char *) mem) + lastptr - (newtermlen - termlen), ((char *) mem) + lastptr, ptr - lastptr + size); /* update pointers prior to the entry */ for (i = termno; i < entries; i++) { MEM_NTOH(&lastptr, B1_PTR_ADDR(mem, i), sizeof(lastptr)); lastptr -= (newtermlen - termlen); MEM_HTON(B1_PTR_ADDR(mem, i), &lastptr, sizeof(lastptr)); } } else if (newtermlen < termlen) { /* string is shrinking */ /* move strings and data prior to the entry */ memmove(((char *) mem) + lastptr + (termlen - newtermlen), ((char *) mem) + lastptr, ptr - lastptr + size); /* update pointers prior to the entry */ for (i = termno; i < entries; i++) { MEM_NTOH(&lastptr, B1_PTR_ADDR(mem, i), sizeof(lastptr)); lastptr += (termlen - newtermlen); MEM_HTON(B1_PTR_ADDR(mem, i), &lastptr, sizeof(lastptr)); } } /* copy new string in */ memcpy(((char *) mem) + ptr + size, newterm, newtermlen); return 1; } int bucket1_resize(void *mem, unsigned int oldsize, unsigned int newsize) { unsigned int i; uint16_t ptr, lastptr, entries; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); if (!entries) { return 1; } /* read last entry */ MEM_NTOH(&lastptr, B1_PTR_ADDR(mem, (entries - 1)), sizeof(lastptr)); if (newsize < oldsize) { /* shrinking */ if ((oldsize - newsize) > (lastptr - B1_PTR(entries))) { return 0; } /* move data and strings */ memmove(((char *) mem) + lastptr - (oldsize - newsize), ((char *) mem) + lastptr, oldsize - lastptr); /* update pointer entries */ for (i = 0; i < entries; i++) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, i), sizeof(ptr)); ptr -= (oldsize - newsize); MEM_HTON(B1_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); } } else if (newsize > oldsize) { /* growing */ /* move data and strings */ memmove(((char *) mem) + lastptr + (newsize - oldsize), ((char *) mem) + lastptr, oldsize - lastptr); /* update pointer entries */ for (i = 0; i < entries; i++) { MEM_NTOH(&ptr, B1_PTR_ADDR(mem, i), sizeof(ptr)); ptr += (newsize - oldsize); MEM_HTON(B1_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); } } return 1; } void *bucket1_append(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int size, int *toobig) { uint16_t entries, lastaddr, ptr; /* read number of entries */ MEM_NTOH(&entries, B1_ENTRIES_ADDR(mem), sizeof(entries)); if (entries) { /* read the last entry */ MEM_NTOH(&lastaddr, B1_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); } else { lastaddr = bucketsize; } /* check that we have enough free space */ if ((size + termlen + 2 * (sizeof(uint16_t))) > (lastaddr - B1_PTR(entries))) { /* test whether theres enough space to allocate the entry if the * bucket was empty */ *toobig = (termlen + size + sizeof(uint16_t) * 2 > bucketsize - sizeof(entries)); return NULL; } /* copy term in */ memcpy(((char *) mem) + lastaddr - termlen, term, termlen); /* update entries record and pointer */ ptr = lastaddr - termlen - size; mem_hton(B1_PTR_ADDR(mem, entries), &ptr, sizeof(ptr)); ptr = size; mem_hton(B1_SIZE_ADDR(mem, entries), &ptr, sizeof(ptr)); entries++; mem_hton(B1_ENTRIES_ADDR(mem), &entries, sizeof(entries)); return ((char *) mem) + lastaddr - termlen - size; } /* functions for strategy 2 */ /* binary searches a bucket for a term, returning the largest thing that is less * than or equal to the given term (this property, which the usual binary search * must be modified to provide, is important because we can then use it for * insertion sorting as well as searching) */ static unsigned int bucket2_binsearch(void *mem, unsigned int bucketsize, unsigned int entries, const char *term, unsigned int termlen) { unsigned int l, r, m, i, len, tlen; uint16_t ptr, prevptr, size; assert(entries); l = 0; r = entries - 1; while (l < r) { m = BIT_DIV2((r + l + 1), 1); /* decode m ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, m), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, m), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (m) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, m - 1), sizeof(prevptr)); tlen = prevptr - ptr - size; len = (tlen > termlen) ? termlen : tlen; for (i = 0; i < len; i++) { if (term[i] < ((char *) mem)[i + ptr + size]) { r = m - 1; break; } else if (term[i] > ((char *) mem)[i + ptr + size]) { l = m; break; } } /* exact match of prefixes */ if (i == len) { if (termlen == tlen) { return m; } else if (termlen < tlen) { r = m - 1; } else { l = m; } } } else { /* m is first entry */ prevptr = bucketsize; tlen = prevptr - ptr - size; len = (tlen > termlen) ? termlen : tlen; for (i = 0; i < len; i++) { if (term[i] < ((char *) mem)[i + ptr + size]) { /* no exact match, act now to prevent underflow */ return 0; break; } else if (term[i] > ((char *) mem)[i + ptr + size]) { l = m; break; } } /* exact match of prefixes */ if (i == len) { if (termlen <= tlen) { /* no match, act now to prevent underflow */ return 0; } else { l = m; } } } } /* no exact match */ return l; } void *bucket2_find(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int *veclen, unsigned int *idx) { unsigned int index, i; uint16_t entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries) { return NULL; } index = bucket2_binsearch(mem, bucketsize, entries, term, termlen); /* decode ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); if (((unsigned int) prevptr - ptr) - size == termlen) { for (i = 0; i < termlen; i++) { if (term[i] != ((char *) mem)[i + ptr + size]) { return NULL; } } *veclen = size; if (idx) { *idx = index; } return ((char *) mem) + ptr; } return NULL; } void *bucket2_search(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int *veclen, unsigned int *idx) { unsigned int index; uint16_t entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries) { return NULL; } index = bucket2_binsearch(mem, bucketsize, entries, term, termlen); /* decode ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } if (idx) { *idx = index; } *veclen = size; return ((char *) mem) + ptr; } void *bucket2_realloc_at(void *mem, unsigned int bucketsize, unsigned int index, unsigned int newsize, int *toobig) { uint16_t size, entries, new_bucket_size, ptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries || (index >= entries)) { *toobig = 0; return NULL; } new_bucket_size = bucketsize - sizeof(uint16_t); /* decode ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); if (size == newsize) { return ((char *) mem) + ptr; } else { return NULL; } } void *bucket2_realloc(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int newsize, int *toobig) { unsigned int i, index; uint16_t entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); /* handle 0 entries case */ if (!entries) { *toobig = 0; return NULL; } index = bucket2_binsearch(mem, bucketsize, entries, term, termlen); /* verify that index points to requested term */ /* decode ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); if (size != newsize) { return NULL; } /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); if (((unsigned int) prevptr - ptr - size) == termlen) { for (i = 0; i < termlen; i++) { if (term[i] != ((char *) mem)[ptr + size + i]) { return NULL; } } return bucket2_realloc_at(mem, bucketsize, index, newsize, toobig); } else { return NULL; } } void *bucket2_alloc(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int newsize, int *toobig, unsigned int *idx) { unsigned int index, i, len; uint16_t size, lastaddr, entries, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, 0), sizeof(size)); if (entries && (size != newsize)) { return NULL; } if (entries) { /* read the last entry */ MEM_NTOH(&lastaddr, B2_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); /* check that we have enough space to allocate entry */ if ((size + termlen + 2 * (sizeof(uint16_t))) > (lastaddr - B2_PTR(entries))) { /* test whether theres enough space to allocate the entry if the * bucket was empty */ *toobig = (termlen + newsize + sizeof(uint16_t) * 2 > bucketsize - sizeof(entries)); return NULL; } index = bucket2_binsearch(mem, bucketsize, entries, term, termlen); /* need to do a last comparison to figure out whether we want to insert * here or in the next position */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } /* the way we do our binary search, the item may need to be inserted * at the *next* location (assuming that there is no exact match) */ assert(prevptr >= ptr); len = (unsigned int) (((unsigned int) prevptr - ptr - size) > termlen) ? termlen : prevptr - ptr - size; for (i = 0; i < len; i++) { if (term[i] < ((char *) mem)[i + ptr + size]) { break; } else if (term[i] > ((char *) mem)[i + ptr + size]) { index++; prevptr = ptr; MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); break; } } /* exact match of prefixes */ /* XXX: should check for exact match */ if (i == len) { if (termlen > len) { index++; prevptr = ptr; MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); } } /* new allocation needs to be inserted at index */ if (index < entries) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } /* move strings and data down */ memmove(((char *) mem) + lastaddr - termlen - newsize, ((char *) mem) + lastaddr, ptr - lastaddr + (prevptr - ptr)); /* shift pointers up */ for (i = entries; (i > index); i--) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem, i - 1), sizeof(ptr)); ptr -= termlen + newsize; MEM_HTON(B2_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); memcpy(B2_SIZE_ADDR(mem, i), B2_SIZE_ADDR(mem, i - 1), sizeof(size)); } ptr = prevptr - termlen - newsize; } else { ptr = lastaddr - termlen - newsize; } } else { /* check that we have enough space to allocate entry */ if (termlen + newsize + sizeof(uint16_t) * 2 > bucketsize - sizeof(entries)) { *toobig = 1; return NULL; } ptr = bucketsize - termlen - newsize; index = 0; } /* encode new pointer */ size = newsize; MEM_HTON(B2_PTR_ADDR(mem, index), &ptr, sizeof(ptr)); MEM_HTON(B2_SIZE_ADDR(mem, index), &size, sizeof(size)); /* copy new string in */ memcpy(((char *) mem) + ptr + size, term, termlen); /* encode new entries record */ entries++; MEM_HTON(B2_ENTRIES_ADDR(mem), &entries, sizeof(entries)); if (idx) { *idx = index; } return ((char *) mem) + ptr; } int bucket2_remove_at(void *mem, unsigned int bucketsize, unsigned int index) { unsigned int i; uint16_t lastaddr, entries, size, ptr, prevptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); if (!entries || (index >= entries)) { return 0; } /* decode ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); /* read the last entry */ MEM_NTOH(&lastaddr, B2_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); /* move strings/data up */ memmove(((char *) mem) + lastaddr + (prevptr - ptr), ((char *) mem) + lastaddr, ptr - lastaddr); size = prevptr - ptr; /* update pointers */ for (i = index; i + 1 < entries; i++) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem, i + 1), sizeof(ptr)); ptr += size; MEM_HTON(B2_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); } /* encode new entries record */ entries--; MEM_HTON(B2_ENTRIES_ADDR(mem), &entries, sizeof(entries)); return 1; } int bucket2_remove(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen) { unsigned int i, index; uint16_t entries, ptr, size, prevptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); if (!entries) { return 0; } index = bucket2_binsearch(mem, bucketsize, entries, term, termlen); /* verify that index points to requested term */ /* decode ptr */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, index), sizeof(ptr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(ptr)); /* decode next pointer, so we know where this one ends */ if (index) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, index - 1), sizeof(prevptr)); } else { prevptr = bucketsize; } assert(prevptr >= ptr); if (((unsigned int) prevptr - ptr - size) == termlen) { for (i = 0; i < termlen; i++) { if (term[i] != ((char *) mem)[ptr + size + i]) { return 0; } } return bucket2_remove_at(mem, bucketsize, index); } else { return 0; } } const char *bucket2_term_at(void *mem, unsigned int bucketsize, unsigned int index, unsigned int *len, void **data, unsigned int *veclen) { uint16_t addr, prevaddr, /* logically previous (physically next) address */ size, entries; /* read number of entries */ MEM_NTOH(&entries, mem, sizeof(entries)); if (index < entries) { /* read the entry */ MEM_NTOH(&addr, B2_PTR_ADDR(mem, index), sizeof(addr)); MEM_NTOH(&size, B2_SIZE_ADDR(mem, index), sizeof(size)); assert(((sizeof(addr) * entries) <= addr) && (bucketsize > addr)); if (index) { /* its not the first entry, read the previous entry's address */ MEM_NTOH(&prevaddr, B2_PTR_ADDR(mem, index - 1), sizeof(prevaddr)); } else { /* its the first entry, boundary is the end of the bucket */ prevaddr = bucketsize; } *len = prevaddr - addr - size; *veclen = size; *data = ((char *) mem) + addr; return ((char *) mem) + addr + size; } else { /* its past the last entry */ return NULL; } } int bucket2_split(void *mem1, unsigned int bucketsize1, void *mem2, unsigned int bucketsize2, unsigned int terms) { unsigned int i, j; uint16_t lastaddr, entries, size, ptr, prevptr; memset(mem2, 0, bucketsize2); /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem1), sizeof(entries)); if (terms >= entries) { return (terms == entries); } if (terms) { /* read split entry */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem1, terms - 1), sizeof(ptr)); } else { ptr = bucketsize1; } /* read last entry */ MEM_NTOH(&lastaddr, B2_PTR_ADDR(mem1, entries - 1), sizeof(lastaddr)); /* copy strings and data from bucket 1 to bucket 2 */ memcpy((char *) mem2 + bucketsize2 - (ptr - lastaddr), (char *) mem1 + lastaddr, ptr - lastaddr); /* copy pointers to new bucket */ prevptr = ptr; for (j = 0, i = terms; i < entries; i++, j++) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem1, i), sizeof(ptr)); ptr += bucketsize1 - prevptr; MEM_HTON(B2_PTR_ADDR(mem2, j), &ptr, sizeof(size)); } memcpy(B2_SIZE_ADDR(mem2, j), B2_SIZE_ADDR(mem1, i), sizeof(size)); /* adjust entries record in both buckets */ size = terms; mem_hton(B2_ENTRIES_ADDR(mem1), &size, sizeof(size)); entries -= size; mem_hton(B2_ENTRIES_ADDR(mem2), &entries, sizeof(entries)); return 1; } int bucket2_set_term(void *mem, unsigned int bucketsize, unsigned int termno, const char *newterm, unsigned int newtermlen, int *toobig) { unsigned int i, termlen; uint16_t size, ptr, prevptr, lastptr, entries; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); if (termno >= entries) { return 0; } /* read entry, previous and last pointers */ MEM_NTOH(&ptr, B2_PTR_ADDR(mem, termno), sizeof(ptr)); if (termno + 1 < entries) { MEM_NTOH(&prevptr, B2_PTR_ADDR(mem, termno + 1), sizeof(prevptr)); /* read the last entry */ MEM_NTOH(&lastptr, B2_PTR_ADDR(mem, (entries - 1)), sizeof(lastptr)); } else { prevptr = bucketsize; lastptr = ptr; } MEM_NTOH(&size, B2_SIZE_ADDR(mem, size), sizeof(size)); termlen = prevptr - ptr - size; if (newtermlen > termlen) { /* string is growing */ /* check that we have enough space to allocate entry */ if (((newtermlen - termlen) > (lastptr - B2_PTR(entries)))) { /* not enough space to allocate the entry */ if ((newtermlen + 2 * sizeof(uint16_t) + size) > bucketsize - sizeof(entries)) { /* ... even if the bucket was empty */ *toobig = 1; } return 0; } /* move strings and data prior to the entry */ memmove(((char *) mem) + lastptr - (newtermlen - termlen), ((char *) mem) + lastptr, ptr - lastptr + size); /* update pointers prior to the entry */ for (i = termno; i < entries; i++) { MEM_NTOH(&lastptr, B2_PTR_ADDR(mem, i), sizeof(lastptr)); lastptr -= (newtermlen - termlen); MEM_HTON(B2_PTR_ADDR(mem, i), &lastptr, sizeof(lastptr)); } } else if (newtermlen < termlen) { /* string is shrinking */ /* move strings and data prior to the entry */ memmove(((char *) mem) + lastptr + (termlen - newtermlen), ((char *) mem) + lastptr, ptr - lastptr + size); /* update pointers prior to the entry */ for (i = termno; i < entries; i++) { MEM_NTOH(&lastptr, B2_PTR_ADDR(mem, i), sizeof(lastptr)); lastptr += (termlen - newtermlen); MEM_HTON(B2_PTR_ADDR(mem, i), &lastptr, sizeof(lastptr)); } } /* copy new string in */ memcpy(((char *) mem) + ptr + size, newterm, newtermlen); return 1; } int bucket2_resize(void *mem, unsigned int oldsize, unsigned int newsize) { unsigned int i; uint16_t ptr, lastptr, entries; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); if (!entries) { return 1; } /* read last entry */ MEM_NTOH(&lastptr, B2_PTR_ADDR(mem, (entries - 1)), sizeof(lastptr)); if (newsize < oldsize) { /* shrinking */ if ((oldsize - newsize) > (lastptr - B2_PTR(entries))) { return 0; } /* move data and strings */ memmove(((char *) mem) + lastptr - (oldsize - newsize), ((char *) mem) + lastptr, oldsize - lastptr); /* update pointer entries */ for (i = 0; i < entries; i++) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem, i), sizeof(ptr)); ptr -= (oldsize - newsize); MEM_HTON(B2_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); } } else if (newsize > oldsize) { /* growing */ /* move data and strings */ memmove(((char *) mem) + lastptr + (newsize - oldsize), ((char *) mem) + lastptr, oldsize - lastptr); /* update pointer entries */ for (i = 0; i < entries; i++) { MEM_NTOH(&ptr, B2_PTR_ADDR(mem, i), sizeof(ptr)); ptr += (newsize - oldsize); MEM_HTON(B2_PTR_ADDR(mem, i), &ptr, sizeof(ptr)); } } return 1; } void *bucket2_append(void *mem, unsigned int bucketsize, const char *term, unsigned int termlen, unsigned int size, int *toobig) { uint16_t entries, lastaddr, ptr; /* read number of entries */ MEM_NTOH(&entries, B2_ENTRIES_ADDR(mem), sizeof(entries)); if (entries) { /* read the last entry */ MEM_NTOH(&lastaddr, B2_PTR_ADDR(mem, (entries - 1)), sizeof(lastaddr)); } else { lastaddr = bucketsize; } /* check that we have enough free space */ if ((size + termlen + 2 * (sizeof(uint16_t))) > (lastaddr - B2_PTR(entries))) { /* test whether theres enough space to allocate the entry if the * bucket was empty */ *toobig = (termlen + size + sizeof(uint16_t) * 2 > bucketsize - sizeof(entries)); return NULL; } /* copy term in */ memcpy(((char *) mem) + lastaddr - termlen, term, termlen); /* update entries record and pointer */ ptr = lastaddr - termlen - size; mem_hton(B2_PTR_ADDR(mem, entries), &ptr, sizeof(ptr)); ptr = size; mem_hton(B2_SIZE_ADDR(mem, entries), &ptr, sizeof(ptr)); entries++; mem_hton(B2_ENTRIES_ADDR(mem), &entries, sizeof(entries)); return ((char *) mem) + lastaddr - termlen - size; } #include <stdio.h> int bucket_print(void *mem, unsigned int bucketsize, int strategy) { void *data; const char *term; unsigned int i, tlen, vlen; unsigned int state = 0; printf("%u entries\n", bucket_entries(mem, bucketsize, strategy)); while ((term = bucket_next_term(mem, bucketsize, strategy, &state, &tlen, &data, &vlen))) { putc('\'', stdout); for (i = 0; i < tlen; i++) { putc(term[i], stdout); } putc('\'', stdout); putc(' ', stdout); printf("%u %u (off %u)\n", tlen, vlen, (unsigned int) (((char *) data) - (char *) mem)); } putc('\n', stdout); return 1; } /* switching functions */ void *bucket_alloc(void *bucketmem, unsigned int bucketsize, int strategy, const char *term, unsigned int termlen, unsigned int newsize, int *toobig, unsigned int *idx) { switch (strategy) { case 1: return bucket1_alloc(bucketmem, bucketsize, term, termlen, newsize, toobig, idx); case 2: return bucket2_alloc(bucketmem, bucketsize, term, termlen, newsize, toobig, idx); default: *toobig = 0; return NULL; }; } void *bucket_find(void *bucketmem, unsigned int bucketsize, int strategy, const char *term, unsigned int termlen, unsigned int *veclen, unsigned int *idx) { switch (strategy) { case 1: return bucket1_find(bucketmem, bucketsize, term, termlen, veclen, idx); case 2: return bucket2_find(bucketmem, bucketsize, term, termlen, veclen, idx); default: return NULL; }; } void *bucket_search(void *bucketmem, unsigned int bucketsize, int strategy, const char *term, unsigned int termlen, unsigned int *veclen, unsigned int *idx) { switch (strategy) { case 1: return bucket1_search(bucketmem, bucketsize, term, termlen, veclen, idx); case 2: return bucket2_search(bucketmem, bucketsize, term, termlen, veclen, idx); default: return NULL; }; } int bucket_remove(void *bucketmem, unsigned int bucketsize, int strategy, const char *term, unsigned int termlen) { switch (strategy) { case 1: return bucket1_remove(bucketmem, bucketsize, term, termlen); case 2: return bucket2_remove(bucketmem, bucketsize, term, termlen); default: return 0; }; } int bucket_remove_at(void *bucketmem, unsigned int bucketsize, int strategy, unsigned int index) { switch (strategy) { case 1: return bucket1_remove_at(bucketmem, bucketsize, index); case 2: return bucket2_remove_at(bucketmem, bucketsize, index); default: return 0; }; } void *bucket_realloc(void *bucketmem, unsigned int bucketsize, int strategy, const char *term, unsigned int termlen, unsigned int newlen, int *toobig) { switch (strategy) { case 1: return bucket1_realloc(bucketmem, bucketsize, term, termlen, newlen, toobig); case 2: return bucket2_realloc(bucketmem, bucketsize, term, termlen, newlen, toobig); default: *toobig = 0; return NULL; }; } void *bucket_realloc_at(void *bucketmem, unsigned int bucketsize, int strategy, unsigned int index, unsigned int newlen, int *toobig) { switch (strategy) { case 1: return bucket1_realloc_at(bucketmem, bucketsize, index, newlen, toobig); case 2: return bucket2_realloc_at(bucketmem, bucketsize, index, newlen, toobig); default: *toobig = 0; return NULL; }; } const char *bucket_next_term(void *bucketmem, unsigned int bucketsize, int strategy, unsigned int *state, unsigned int *len, void **data, unsigned int *veclen) { assert(bucketsize); switch (strategy) { case 1: return bucket1_term_at(bucketmem, bucketsize, (*state)++, len, data, veclen); case 2: return bucket2_term_at(bucketmem, bucketsize, (*state)++, len, data, veclen); default: return NULL; }; } const char *bucket_term_at(void *bucketmem, unsigned int bucketsize, int strategy, unsigned int index, unsigned int *len, void **data, unsigned int *veclen) { assert(bucketsize); switch (strategy) { case 1: return bucket1_term_at(bucketmem, bucketsize, index, len, data, veclen); case 2: return bucket2_term_at(bucketmem, bucketsize, index, len, data, veclen); default: return NULL; }; } int bucket_split(void *bucketmem1, unsigned int bucketsize1, void *bucketmem2, unsigned int bucketsize2, int strategy, unsigned int split_terms) { switch (strategy) { case 1: return bucket1_split(bucketmem1, bucketsize1, bucketmem2, bucketsize2, split_terms); case 2: return bucket2_split(bucketmem1, bucketsize1, bucketmem2, bucketsize2, split_terms); default: return 0; } } int bucket_resize(void *bucketmem, unsigned int old_bucketsize, int strategy, unsigned int new_bucketsize) { switch (strategy) { case 1: return bucket1_resize(bucketmem, old_bucketsize, new_bucketsize); case 2: return bucket2_resize(bucketmem, old_bucketsize, new_bucketsize); default: return 0; }; } void *bucket_append(void *bucketmem, unsigned int bucketsize, int strategy, const char *term, unsigned int termlen, unsigned int size, int *toobig) { switch (strategy) { case 1: return bucket1_append(bucketmem, bucketsize, term, termlen, size, toobig); case 2: return bucket2_append(bucketmem, bucketsize, term, termlen, size, toobig); default: *toobig = 0; return NULL; }; } void bucket_print_split(void *bucketmem, unsigned int bucketsize, int strategy, unsigned int terms, const char *term, unsigned int termlen, unsigned int additional, int smaller) { const char *currterm; unsigned int state = 0; void *vec; unsigned int i, j, len, veclen, sum = 0; for (i = 0; i < terms; i++) { currterm = bucket_next_term(bucketmem, bucketsize, strategy, &state, &len, &vec, &veclen); assert(currterm); for (j = 0; j < len; j++) { putc(currterm[j], stdout); } printf(" (%u) ", veclen + len); sum += len + veclen; } if (smaller) { printf("(additional) "); for (j = 0; j < termlen; j++) { putc(term[j], stdout); } printf(" (%u) ", additional); sum += additional; } printf("[%u] | ", sum); sum = 0; if (!smaller) { printf("(additional) "); for (j = 0; j < termlen; j++) { putc(term[j], stdout); } printf(" (%u) ", additional); sum += additional; } while ((currterm = bucket_next_term(bucketmem, bucketsize, strategy, &state, &len, &vec, &veclen))) { for (j = 0; j < len; j++) { putc(currterm[j], stdout); } printf(" (%u) ", veclen + len); sum += len + veclen; } printf(" [%u]\n", sum); } unsigned int bucket_find_split_entry(void *bucketmem, unsigned int bucketsize, int strategy, unsigned int range, const char *term, unsigned int termlen, unsigned int additional, int *smaller) { const void *ret; /* return value from bucket functions */ void *dataptr; /* data location of vector in bucket */ int tmpsmaller = 0, /* value to be copied into smaller */ consumed = 0, /* whether the additional term has been * consumed */ cmp; /* result of string comparison */ unsigned int shortest, /* size of the shortest entry we've seen */ index, /* split bucket term index */ disp, /* displacement of shortest entry from a * perfectly balanced split */ terms = 0, /* number of terms seen thus far */ sum = 0, /* sum of data thus far */ len, /* length of string entry */ veclen, /* length of data in entry */ data, /* amount of data in bucket */ iter_state = 0; /* state of iteration */ /* determine where to split the leaf node * * prefix b-tree magic is performed here, by selecting shortest string to * push up within given range. If two strings are equally short, the * distribution of data between the buckets is considered, with more even * distribution favoured. */ assert(bucket_sorted(strategy)); /* XXX: should handle unsorted buckets * (by sorting) */ data = bucket_utilised(bucketmem, bucketsize, strategy) + bucket_string(bucketmem, bucketsize, strategy) + additional; data /= 2; /* our interval of interest is now data +/- range */ ret = bucket_next_term(bucketmem, bucketsize, strategy, &iter_state, &len, &dataptr, &veclen); assert(ret); /* iterate until we come up to term that enters range */ while (ret /* need to do comparison to additional term now so that we can stop on * term that crosses boundary into acceptable range */ && ((cmp = str_nncmp(term, termlen, ret, len)), 1) /* if additional term is less than bucket term ... */ && (((!consumed && (cmp < 0)) /* ... check that its not going to cross into range ... */ && (sum + additional < data - range) /* ... and consume it */ && ((sum += additional), (consumed = 1))) /* else if additional term is greater than bucket term or already * consumed ... */ || ((consumed || (cmp > 0)) /* ... check that bucket term isn't going to cross into range ... */ && (sum + len + veclen < data - range) && ((sum += len + veclen), ++terms) && (ret = bucket_next_term(bucketmem, bucketsize, strategy, &iter_state, &len, &dataptr, &veclen))) /* else if they're equal ... */ || ((!consumed && !cmp) /* ... check that the sum isn't going to cross into range ... */ && (sum + len + veclen + additional < data - range) /* ... and consume them */ && ((sum += len + veclen + additional), ++terms, (consumed = 1)) && (ret = bucket_next_term(bucketmem, bucketsize, strategy, &iter_state, &len, &dataptr, &veclen))))) { /* do nothing */ } /* we're now up to term that may enter range, its the answer if it crosses * the entire range. Either way we have to consume the next term here. */ /* if additional term hasn't been consumed, and is less than bucket * term ... */ if (ret && ((cmp = str_nncmp(term, termlen, ret, len)) < 0) && !consumed) { /* ... and its going to cross entire range ... */ if (sum + additional >= data + range) { /* its the splitting point, determine whether it balances better on * left or right of split and return */ *smaller = (sum + additional - data < data - sum); return terms; } else { /* its not the splitting point, or even a candidate, just consume * it */ sum += additional; consumed = 1; tmpsmaller = 1; } /* else if additional term is greater than bucket term or already * consumed ... */ } else if (ret && (consumed || (cmp > 0))) { /* ... and bucket term is going to cross entire range */ if (sum + len + veclen >= data + range) { /* its the splitting point, determine whether it balances better on * left or right of split and return */ *smaller = consumed; return terms + (sum + len + veclen - data < data - sum); } else { /* its not the splitting point, or even a candidate, consume it */ sum += len + veclen; tmpsmaller = consumed; terms++; ret = bucket_next_term(bucketmem, bucketsize, strategy, &iter_state, &len, &dataptr, &veclen); } /* else if they're equal ... */ } else if (ret && !consumed && !cmp) { /* ... check if they will cross entire range ... */ if (sum + len + veclen + additional >= data + range) { /* combination is the splitting point, determine whether it * balances better on left or right of split and return */ *smaller = (sum + len + veclen + additional - data < data - sum); return terms + *smaller; } else { /* they aren't the splitting point, or even a candidate, consume * them */ sum += len + veclen + additional; consumed = 1; tmpsmaller = 1; terms++; ret = bucket_next_term(bucketmem, bucketsize, strategy, &iter_state, &len, &dataptr, &veclen); } } /* haven't found a splitting point thus far, but everything until we exit * the range is now a candidate */ index = -1; disp = shortest = UINT_MAX; /* XXX: note that code below here hasn't really been debugged, since * ranges haven't been enabled yet */ /* iterate until we exit range */ assert(sum >= data - range); while (ret && (sum < data + range)) { cmp = str_nncmp(term, termlen, ret, len); if (!consumed && (cmp < 0)) { /* consume additional term */ /* if its the shortest entry, or equal shortest with smaller * displacement from a perfectly balanced bucket, then its our * current best candidate for splitting point */ if ((len < shortest) || ((len == shortest) && (((sum < data) && (data - sum < disp) && (((sum + additional < data) && (data - sum - additional < disp)) || ((sum + additional > data) && (sum + additional - data < disp)))) || ((sum > data) && (sum + additional - data < disp))))) { /* calculate maximum displacement of term from midpoint */ if (sum < data) { disp = data - sum; if (sum + additional > data) { if (sum + additional - data > disp) { disp = sum + additional - data; } } } else { disp = sum + additional - data; } index = terms; shortest = len; tmpsmaller = 0; } sum += additional; consumed = 1; } else { if (!consumed && !cmp) { /* consume both terms */ if ((len < shortest) || ((len == shortest) && (((sum < data) && (data - sum < disp) && (((sum + len + veclen + additional < data) && (data - sum - len - veclen - additional < disp)) || ((sum + len + veclen + additional > data) && (sum + len + veclen + additional - data < disp)))) || ((sum > data) && (sum + len + veclen + additional - data < disp))))) { /* calculate maximum displacement of term from midpoint */ if (sum < data) { disp = data - sum; if (sum + len + veclen + additional > data) { if (sum + len + veclen + additional - data > disp) { disp = sum + len + veclen + additional - data; } } } else { disp = sum + len + veclen + additional - data; } index = terms + 1; shortest = len; tmpsmaller = 0; } sum += additional + len + veclen; consumed = 1; } else { /* consume term from bucket */ if ((len < shortest) || ((len == shortest) && (((sum < data) && (data - sum < disp) && (((sum + len + veclen < data) && (data - sum - len - veclen < disp)) || ((sum + len + veclen > data) && (sum + len + veclen - data < disp)))) || ((sum > data) && (sum + len + veclen - data < disp))))) { /* calculate maximum displacement of term from midpoint */ if (sum < data) { disp = data - sum; if (sum + len + veclen > data) { if (sum + len + veclen - data > disp) { disp = sum + len + veclen - data; } } } else { disp = sum + len + veclen - data; } index = terms + 1; shortest = len; tmpsmaller = consumed; } sum += len + veclen; } /* get next term from bucket */ terms++; ret = bucket_next_term(bucketmem, bucketsize, strategy, &iter_state, &len, &dataptr, &veclen); } } assert((index != -1) && (disp != UINT_MAX) && (shortest != UINT_MAX)); *smaller = tmpsmaller; return index; }
[ "bhagavan.prasad@blackpeppertech.com" ]
bhagavan.prasad@blackpeppertech.com
569854ba4bcf306821fc8938cfd0e90e233272ea
7eab8a9d4e3d04842b319305e826215ca9bb5cbe
/Examples/Linux/Testbenches/ftp_test/Sources/ardrone_testing_tool.c
be67111096346633cc3a4a2efd6142545e437c72
[]
no_license
islanderz/ARDRoneSDK
65ef37320ee439eadfd70a09ba2cb220a25e59f5
7c56c8bfb36b81c01879295cff093b1eb1a51329
refs/heads/master
2021-01-10T10:19:35.649098
2016-02-24T14:38:59
2016-02-24T14:38:59
48,492,531
2
1
null
null
null
null
UTF-8
C
false
false
30,614
c
/** * @file main.c * @author sylvain.gaeremynck@parrot.com * @date 2009/07/01 */ #include <ardrone_testing_tool.h> //ARDroneLib #include <utils/ardrone_time.h> #include <ardrone_tool/Navdata/ardrone_navdata_client.h> #include <ardrone_tool/Control/ardrone_control.h> #include <ardrone_tool/UI/ardrone_input.h> #include <ardrone_tool/ardrone_tool_configuration.h> //Common #include <config.h> #include <ardrone_api.h> //VP_SDK #include <ATcodec/ATcodec_api.h> #include <VP_Os/vp_os_print.h> #include <VP_Os/vp_os_thread.h> #include <VP_Api/vp_api_thread_helper.h> #include <VP_Os/vp_os_signal.h> #include <VP_Os/vp_os_types.h> #include <VP_Os/vp_os_delay.h> //Local project #include <Video/video_stage.h> #include <utils/ardrone_ftp.h> #include <semaphore.h> static int32_t exit_ihm_program = 1; /* Implementing Custom methods for the main function of an ARDrone application */ int main(int argc, char** argv) { return ardrone_tool_main(argc, argv); } /* The delegate object calls this method during initialization of an ARDrone application */ C_RESULT ardrone_tool_init_custom(void) { /* Start all threads of your application */ START_THREAD( main_application_thread , NULL ); return C_OK; } /* The delegate object calls this method when the event loop exit */ C_RESULT ardrone_tool_shutdown_custom() { /* Relinquish all threads of your application */ JOIN_THREAD( main_application_thread ); return C_OK; } /* The event loop calls this method for the exit condition */ bool_t ardrone_tool_exit() { return exit_ihm_program == 0; } C_RESULT signal_exit() { exit_ihm_program = 0; return C_OK; } PROTO_THREAD_ROUTINE(main_application_thread, data); /* Implementing thread table in which you add routines of your application and those provided by the SDK */ BEGIN_THREAD_TABLE THREAD_TABLE_ENTRY( main_application_thread, 20 ) END_THREAD_TABLE sem_t synchroSem; #define BLUE { printf("%s","\033[34;01m"); } #define RED { printf("%s","\033[31;01m"); } #define GREEN { printf("%s","\033[32;01m"); } #define RAZ { printf("%s","\033[0m"); } #define TEST_RESULT(result, formatFAIL, formatOK, ...) \ do \ { \ _ftp_status locResult = (result); \ totalOp++; \ if (FTP_FAILED (locResult)) \ { \ RED; \ printf ("[%i : KO] : ", __LINE__); \ printf (formatFAIL, __VA_ARGS__); \ printf ("\n"); \ RAZ; \ } \ else \ { \ GREEN; \ printf ("[%i : OK] : ", __LINE__); \ printf (formatOK, __VA_ARGS__); \ printf ("\n"); \ RAZ; \ opOk++; \ } \ if ((FTP_TIMEOUT == locResult) || \ (FTP_BUSY == locResult)) \ { \ runOperation = 1; \ } \ else \ { \ runOperation = 0; \ } \ } \ while (0) #define COMPUTE_PERCENT_OK \ do \ { \ if (totalOp> 0) \ { \ float percentOk = (100.0 * opOk) / (1.0 * totalOp); \ if (90.0 < percentOk) \ { \ GREEN; \ } \ else \ { \ RED; \ } \ printf ("Success of %llu operations on %llu (%6.2f %%)\n", opOk, totalOp, percentOk); \ RAZ; \ } \ } while (0) #define TEST_ABORTION(abortFunc) \ do \ { \ _ftp_status locStat = (abortFunc); \ totalOp++; \ switch (locStat) \ { \ case FTP_SUCCESS: \ GREEN; \ printf ("[%i : OK] : ", __LINE__); \ printf ("Abortion successfull\n"); \ RAZ; \ opOk++; \ break; \ case FTP_SAMESIZE: \ RED; \ printf ("[%i : KO] : ", __LINE__); \ printf ("Abortion failed, op was not running\n"); \ RAZ; \ break; \ case FTP_FAIL: \ default: \ RED; \ printf ("[%i : KO] : ", __LINE__); \ printf ("Unknown result\n"); \ RAZ; \ break; \ } \ } while (0) \ #define WAIT_COND(result) \ do \ { \ sem_wait (&synchroSem); \ } while (0) #define SEND_COND \ do \ { \ sem_post (&synchroSem); \ } \ while (0) _ftp_status globalStatus; int runOperation = 1; char *listBuffer = NULL; void ftpCallback (_ftp_status status, void *arg, _ftp_t *callingFtp) { float percent = (NULL != arg) ? *(float *)arg : -1.0; if (NULL != arg && FTP_SUCCESS == status) { listBuffer = arg; } globalStatus = status; static int calls = 0; #define CALLBACK_FORMAT "Callback called with status %s\n" #ifdef DEBUG #define PRINT_CALLBACK_FORMAT(statusString) { printf (CALLBACK_FORMAT, statusString); calls++; } #else #define PRINT_CALLBACK_FORMAT(statusString) { calls++; } #endif switch (status) { case FTP_BUSY: PRINT_CALLBACK_FORMAT ("FTP_BUSY"); SEND_COND; break; case FTP_ABORT: PRINT_CALLBACK_FORMAT ("FTP_ABORT"); SEND_COND; break; case FTP_FAIL: PRINT_CALLBACK_FORMAT ("FTP_FAIL"); SEND_COND; break; case FTP_SUCCESS: PRINT_CALLBACK_FORMAT ("FTP_SUCCESS"); SEND_COND; break; case FTP_TIMEOUT: PRINT_CALLBACK_FORMAT ("FTP_TIMEOUT"); SEND_COND; break; case FTP_BADSIZE: PRINT_CALLBACK_FORMAT ("FTP_BADSIZE"); SEND_COND; break; case FTP_SAMESIZE: PRINT_CALLBACK_FORMAT ("FTP_SAMESIZE"); SEND_COND; break; case FTP_PROGRESS: printf ("\rProgress : %5.2f", percent); fflush (stdout); if (100.0 <= percent) { printf ("\n"); } break; default: // Should not happen ... kill the program in this case ! printf ("Callback called with unknown status : %d\n", status); exit (-1); break; } #undef CALLBACK_FORMAT } #define title(x) { BLUE; printf("[%i] %s",__LINE__,x); RAZ; } #define ARDRONE_IP "192.168.1.1" #define ARDRONE_PORT (21) #define ARDRONE_USER "anonymous" #define ARDRONE_PASSWORD "" #define _1MB_ORIGIN_FILE "origin.txt" #define _512K_FAILED_FILE "half_file.txt" #define _256K_FAILED_FILE "quarter_file.txt" #define _1MB_MERGED_FILE "merged.txt" #define LOCAL_RESULT_FILE "result.txt" #define NOCB_NORESUME_RESULT "result_nocb_noresume.txt" #define CB_NORESUME_RESULT "result_cb_noresume.txt" #define NOCB_RESUME_RESULT "result_nocb_resume.txt" #define CB_RESUME_RESULT "result_cb_resume.txt" #define ARDRONE_FILE_BEFORE_RENAME "origin.txt" #define ARDRONE_FILE_AFTER_RENAME "result.txt" DEFINE_THREAD_ROUTINE(main_application_thread, data) { /* Semaphore for synchronisation */ sem_init (&synchroSem, 0, 0); vp_os_delay(1000); char buffer [512] = {0}; int systemRet = 0; _ftp_t *droneFtp = NULL; _ftp_status ftp_result = FTP_FAIL; int runOperation = 1; uint64_t totalOp = 0; uint64_t opOk = 0; title ("\n\n------ CLEANING ------\n\n"); title ("--- Connecting to AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { droneFtp = ftpConnect (ARDRONE_IP, ARDRONE_PORT, ARDRONE_USER, ARDRONE_PASSWORD, &ftp_result); TEST_RESULT (ftp_result, "Unable to connect to %s@%s:%d (PASS : %s)", "Connected to %s@%s:%d (PASS : %s)", ARDRONE_USER, ARDRONE_IP, ARDRONE_PORT, ARDRONE_PASSWORD); } title ("--- Getting PWD ---\n"); char pwd [256] = {0}; ftp_result = ftpPwd (droneFtp, pwd, 256); TEST_RESULT (ftp_result, "Unable to get PWD [%1s]", "Got PWD : %s", pwd); title ("--- Removing previous file on AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_BEFORE_RENAME); TEST_RESULT (ftp_result, " (STILL OK !) file %s does not exist", "Deleted file %s", ARDRONE_FILE_BEFORE_RENAME); } for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, " (STILL OK !) file %s does not exist", "Deleted file %s", ARDRONE_FILE_AFTER_RENAME); } title ("--- Removing local result file ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "rm -f %s", LOCAL_RESULT_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Disconnecting from AR.Drone FTP ---\n"); TEST_RESULT (ftpClose (&droneFtp), "AR.Drone FTP (%s:%d) was not opened", "Closed AR.Drone FTP (%s:%d)", ARDRONE_IP, ARDRONE_PORT); while (1) { title ("\n\n------ TESTS WITHOUT RESUME NOR CALLBACK ------\n\n"); title ("--- Connecting to AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { droneFtp = ftpConnect (ARDRONE_IP, ARDRONE_PORT, ARDRONE_USER, ARDRONE_PASSWORD, &ftp_result); TEST_RESULT (ftp_result, "Unable to connect to %s@%s:%d (PASS : %s)", "Connected to %s@%s:%d (PASS : %s)", ARDRONE_USER, ARDRONE_IP, ARDRONE_PORT, ARDRONE_PASSWORD); } title ("--- Sending origin file to the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME, 0, NULL); TEST_RESULT (ftp_result, "Unable to send file %s->%s", "Sent file %s->%s", _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Renaming file on the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRename (droneFtp, ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Impossible to rename %s->%s", "Renamed %s->%s", ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); } title ("--- Getting AR.Drone FTP Listing ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpList (droneFtp, &listBuffer, NULL); TEST_RESULT (ftp_result, "Unable to list FTP [%1s]", "Listed FTP :\n%s", listBuffer); if (NULL != listBuffer) { vp_os_free (listBuffer); listBuffer = NULL; } } title ("--- Getting back result file ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpGet (droneFtp, ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE, 0, NULL); TEST_RESULT (ftp_result, "Unable to get file %s->%s", "Got back file %s->%s", ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE); } title ("--- Checking file ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "diff %s %s > /dev/null", LOCAL_RESULT_FILE, _1MB_ORIGIN_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); totalOp++; if (0 != systemRet) { RED; printf ("[%d : KO] : Files are different !\n", __LINE__); RAZ; } else { opOk++; GREEN; printf ("[%d : OK] : Files are the same\n", __LINE__); RAZ; } title ("--- Removing file on AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Unable to delete file %s", "Deleted file %s", ARDRONE_FILE_AFTER_RENAME); } title ("--- Local file backup ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "mv %s %s", LOCAL_RESULT_FILE, NOCB_NORESUME_RESULT); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Closing AR.Drone FTP ---\n"); TEST_RESULT (ftpClose (&droneFtp), "AR.Drone FTP (%s:%d) was not opened", "Closed AR.Drone FTP (%s:%d)", ARDRONE_IP, ARDRONE_PORT); title ("\n\n------ TESTS WITHOUT RESUME / WITH CALLBACK ------\n\n"); title ("--- Connecting to AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { droneFtp = ftpConnect (ARDRONE_IP, ARDRONE_PORT, ARDRONE_USER, ARDRONE_PASSWORD, &ftp_result); TEST_RESULT (ftp_result, "Unable to connect to %s@%s:%d (PASS : %s)", "Connected to %s@%s:%d (PASS : %s)", ARDRONE_USER, ARDRONE_IP, ARDRONE_PORT, ARDRONE_PASSWORD); } title ("--- Sending origin file to the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME, 0, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to send file %s->%s", "Sent file %s->%s", _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Renaming file on the AR.Drone ---\n"); ftp_result = ftpRename (droneFtp, ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Impossible to rename %s->%s", "Renamed %s->%s", ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); title ("--- Getting AR.Drone FTP Listing ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpList (droneFtp, NULL, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to list FTP [%1s]", "Listed FTP :\n%s", listBuffer); if (NULL != listBuffer) { vp_os_free (listBuffer); listBuffer = NULL; } } title ("--- Getting back result file ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpGet (droneFtp, ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE, 0, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to get file %s->%s", "Got back file %s->%s", ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE); } title ("--- Checking file ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "diff %s %s > /dev/null", LOCAL_RESULT_FILE, _1MB_ORIGIN_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); totalOp++; if (0 != systemRet) { RED; printf ("[%d : KO] : Files are different !\n", __LINE__); RAZ; } else { opOk++; GREEN; printf ("[%d : OK] : Files are the same\n", __LINE__); RAZ; } title ("--- Removing file on AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Unable to delete file %s", "Deleted file %s", ARDRONE_FILE_AFTER_RENAME); } title ("--- Local file backup ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "mv %s %s", LOCAL_RESULT_FILE, CB_NORESUME_RESULT); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Closing AR.Drone FTP ---\n"); TEST_RESULT (ftpClose (&droneFtp), "AR.Drone FTP (%s:%d) was not opened", "Closed AR.Drone FTP (%s:%d)", ARDRONE_IP, ARDRONE_PORT); title ("\n\n------ TESTS WITH RESUME / NO CALLBACK ------\n\n"); title ("--- Preparing bad file (256K) locally ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "cp %s %s", _256K_FAILED_FILE, LOCAL_RESULT_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Connecting to AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { droneFtp = ftpConnect (ARDRONE_IP, ARDRONE_PORT, ARDRONE_USER, ARDRONE_PASSWORD, &ftp_result); TEST_RESULT (ftp_result, "Unable to connect to %s@%s:%d (PASS : %s)", "Connected to %s@%s:%d (PASS : %s)", ARDRONE_USER, ARDRONE_IP, ARDRONE_PORT, ARDRONE_PASSWORD); } title ("--- Preparing bad file (512K) on AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _512K_FAILED_FILE, ARDRONE_FILE_BEFORE_RENAME, 1, NULL); TEST_RESULT (ftp_result, "Unable to send partial file %s->%s", "Sent partial file %s->%s", _512K_FAILED_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Sending origin file to the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME, 1, NULL); TEST_RESULT (ftp_result, "Unable to send file %s->%s", "Sent file %s->%s", _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Renaming file on the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRename (droneFtp, ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Impossible to rename %s->%s", "Renamed %s->%s", ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); } title ("--- Getting AR.Drone FTP Listing ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpList (droneFtp, &listBuffer, NULL); TEST_RESULT (ftp_result, "Unable to list FTP [%1s]", "Listed FTP :\n%s", listBuffer); if (NULL != listBuffer) { vp_os_free (listBuffer); listBuffer = NULL; } } title ("--- Getting back result file ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpGet (droneFtp, ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE, 1, NULL); TEST_RESULT (ftp_result, "Unable to get file %s->%s", "Got back file %s->%s", ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE); } title ("--- Checking file ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "diff %s %s > /dev/null", LOCAL_RESULT_FILE, _1MB_MERGED_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); totalOp++; if (0 != systemRet) { RED; printf ("[%d : KO] : Files are different !\n", __LINE__); RAZ; } else { opOk++; GREEN; printf ("[%d : OK] : Files are the same\n", __LINE__); RAZ; } title ("--- Removing file on AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Unable to delete file %s", "Deleted file %s", ARDRONE_FILE_AFTER_RENAME); } title ("--- Local file backup ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "mv %s %s", LOCAL_RESULT_FILE, NOCB_RESUME_RESULT); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Closing AR.Drone FTP ---\n"); TEST_RESULT (ftpClose (&droneFtp), "AR.Drone FTP (%s:%d) was not opened", "Closed AR.Drone FTP (%s:%d)", ARDRONE_IP, ARDRONE_PORT); title ("\n\n------ TESTS WITH RESUME AND CALLBACK ------\n\n"); title ("--- Preparing bad file (256K) locally ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "cp %s %s", _256K_FAILED_FILE, LOCAL_RESULT_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Connecting to AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { droneFtp = ftpConnect (ARDRONE_IP, ARDRONE_PORT, ARDRONE_USER, ARDRONE_PASSWORD, &ftp_result); TEST_RESULT (ftp_result, "Unable to connect to %s@%s:%d (PASS : %s)", "Connected to %s@%s:%d (PASS : %s)", ARDRONE_USER, ARDRONE_IP, ARDRONE_PORT, ARDRONE_PASSWORD); } title ("--- Preparing bad file (512K) on AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _512K_FAILED_FILE, ARDRONE_FILE_BEFORE_RENAME, 1, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to send partial file %s->%s", "Sent partial file %s->%s", _512K_FAILED_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Sending origin file to the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME, 1, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to send file %s->%s", "Sent file %s->%s", _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Renaming file on the AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRename (droneFtp, ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Impossible to rename %s->%s", "Renamed %s->%s", ARDRONE_FILE_BEFORE_RENAME, ARDRONE_FILE_AFTER_RENAME); } title ("--- Getting AR.Drone FTP Listing ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpList (droneFtp, NULL, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to list FTP [%1s]", "Listed FTP :\n%s", listBuffer); if (NULL != listBuffer) { vp_os_free (listBuffer); listBuffer = NULL; } } title ("--- Getting back result file ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpGet (droneFtp, ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE, 1, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to get file %s->%s", "Got back file %s->%s", ARDRONE_FILE_AFTER_RENAME, LOCAL_RESULT_FILE); } title ("--- Checking file ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "diff %s %s > /dev/null", LOCAL_RESULT_FILE, _1MB_MERGED_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); totalOp++; if (0 != systemRet) { RED; printf ("[%d : KO] : Files are different !\n", __LINE__); RAZ; } else { opOk++; GREEN; printf ("[%d : OK] : Files are the same\n", __LINE__); RAZ; } title ("--- Removing file on AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_AFTER_RENAME); TEST_RESULT (ftp_result, "Unable to delete file %s", "Deleted file %s", ARDRONE_FILE_AFTER_RENAME); } title ("--- Local file backup ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "mv %s %s", LOCAL_RESULT_FILE, CB_RESUME_RESULT); systemRet = system (buffer); printf ("System : %s\n", buffer); title ("--- Closing AR.Drone FTP ---\n"); TEST_RESULT (ftpClose (&droneFtp), "AR.Drone FTP (%s:%d) was not opened", "Closed AR.Drone FTP (%s:%d)", ARDRONE_IP, ARDRONE_PORT); title ("\n\n------ ABORTION TESTS ------\n\n"); title ("--- Connecting to AR.Drone FTP ---\n"); for (runOperation = 1; runOperation;) { droneFtp = ftpConnect (ARDRONE_IP, ARDRONE_PORT, ARDRONE_USER, ARDRONE_PASSWORD, &ftp_result); TEST_RESULT (ftp_result, "Unable to connect to %s@%s:%d (PASS : %s)", "Connected to %s@%s:%d (PASS : %s)", ARDRONE_USER, ARDRONE_IP, ARDRONE_PORT, ARDRONE_PASSWORD); } title ("--- Sending origin file to the AR.Drone ... aborted ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME, 1, ftpCallback); usleep (500000); TEST_ABORTION (ftpAbort (droneFtp)); WAIT_COND (ftp_result); TEST_RESULT ((FTP_ABORT == globalStatus) ? FTP_SUCCESS : FTP_FAIL, "Impossible to abort %s->%s transfert", "Aborted %s->%s transfert", _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Sending origin file to the AR.Drone ... complete previous operation ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpPut (droneFtp, _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME, 1, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to send file %s->%s", "Sent file %s->%s", _1MB_ORIGIN_FILE, ARDRONE_FILE_BEFORE_RENAME); } title ("--- Getting AR.Drone FTP Listing ... aborted ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpList (droneFtp, NULL, ftpCallback); usleep (1000); TEST_ABORTION (ftpAbort (droneFtp)); WAIT_COND (ftp_result); TEST_RESULT ((FTP_ABORT == globalStatus) ? FTP_SUCCESS : FTP_FAIL, "Impossible to abort %s", "Aborted %s", "listing"); if (NULL != listBuffer) { vp_os_free (listBuffer); listBuffer = NULL; } } title ("--- Getting AR.Drone FTP Listing ... ok ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpList (droneFtp, NULL, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to list FTP [%1s]", "Listed FTP :\n%s", listBuffer); if (NULL != listBuffer) { vp_os_free (listBuffer); listBuffer = NULL; } } title ("--- Getting back origin file as result ... aborted ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpGet (droneFtp, ARDRONE_FILE_BEFORE_RENAME, LOCAL_RESULT_FILE, 1, ftpCallback); usleep (500000); TEST_ABORTION (ftpAbort (droneFtp)); WAIT_COND (ftp_result); TEST_RESULT ((FTP_ABORT == globalStatus) ? FTP_SUCCESS : FTP_FAIL, "Impossible to abort %s->%s transfert", "Aborted %s->%s transfert", ARDRONE_FILE_BEFORE_RENAME, LOCAL_RESULT_FILE); } title ("--- Getting back origin file as result ... complete previous operation ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpGet (droneFtp, ARDRONE_FILE_BEFORE_RENAME, LOCAL_RESULT_FILE, 1, ftpCallback); WAIT_COND (ftp_result); TEST_RESULT (globalStatus, "Unable to get file %s->%s", "Got back file %s->%s", ARDRONE_FILE_BEFORE_RENAME, LOCAL_RESULT_FILE); } title ("--- Checking file ---\n"); vp_os_memset (buffer, 0x0, 512); snprintf (buffer, 512, "diff %s %s > /dev/null", LOCAL_RESULT_FILE, _1MB_ORIGIN_FILE); systemRet = system (buffer); printf ("System : %s\n", buffer); totalOp++; if (0 != systemRet) { RED; printf ("[%d : KO] : Files are different !\n", __LINE__); RAZ; } else { opOk++; GREEN; printf ("[%d : OK] : Files are the same\n", __LINE__); RAZ; } title ("--- Removing file on AR.Drone ---\n"); for (runOperation = 1; runOperation;) { ftp_result = ftpRemove (droneFtp, ARDRONE_FILE_BEFORE_RENAME); TEST_RESULT (ftp_result, "Unable to delete file %s", "Deleted file %s", ARDRONE_FILE_BEFORE_RENAME); } title ("--- Closing AR.Drone FTP ---\n"); TEST_RESULT (ftpClose (&droneFtp), "AR.Drone FTP (%s:%d) was not opened", "Closed AR.Drone FTP (%s:%d)", ARDRONE_IP, ARDRONE_PORT); title ("\n\n------ RESULT ------\n\n"); COMPUTE_PERCENT_OK; } sem_destroy (&synchroSem); exit (0); return 0; }
[ "kamilns@hotmail.com" ]
kamilns@hotmail.com
08aecb4a9536aebf4aaf37b98cc367687a0c8365
eb7a1fb1c70fc82be0dfc0245255d5506433d156
/Microchip/SAMG_DFP/3.2.35/samg53/include/samg53n19.h
6fe2860ec312ae40a34b60f4ebcb58b456db212b
[ "Apache-2.0" ]
permissive
muthukrishnankarthik/dev_packs
c03f66ce3f32d34340c8053363121657a0a37474
60d97ca66b10c00b3c42430b0cf0b4ae7542f217
refs/heads/master
2021-01-06T13:26:53.637757
2020-02-10T23:49:35
2020-02-10T23:49:35
null
0
0
null
null
null
null
UTF-8
C
false
false
30,365
h
/** * \brief Header file for ATSAMG53N19 * * Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries. * * Subject to your compliance with these terms, you may use Microchip software and any derivatives * exclusively with Microchip products. It is your responsibility to comply with third party license * terms applicable to your use of third party software (including open source software) that may * accompany Microchip software. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, * APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND * FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF * MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT * EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. * */ /* file generated from device description version 2019-12-16T02:52:00Z */ #ifndef _SAMG53N19_H_ #define _SAMG53N19_H_ // Header version uses Semantic Versioning 2.0.0 (https://semver.org/) #define HEADER_FORMAT_VERSION "2.0.0" #define HEADER_FORMAT_VERSION_MAJOR (2) #define HEADER_FORMAT_VERSION_MINOR (0) /** \addtogroup SAMG53N19_definitions SAMG53N19 definitions This file defines all structures and symbols for SAMG53N19: - registers and bitfields - peripheral base address - peripheral ID - PIO definitions * @{ */ #ifdef __cplusplus extern "C" { #endif #if !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) # include <stdint.h> #endif /* !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) */ #if !defined(SKIP_INTEGER_LITERALS) # if defined(_U_) || defined(_L_) || defined(_UL_) # error "Integer Literals macros already defined elsewhere" # endif #if !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) /* Macros that deal with adding suffixes to integer literal constants for C/C++ */ # define _U_(x) (x ## U) /**< C code: Unsigned integer literal constant value */ # define _L_(x) (x ## L) /**< C code: Long integer literal constant value */ # define _UL_(x) (x ## UL) /**< C code: Unsigned Long integer literal constant value */ #else /* Assembler */ # define _U_(x) x /**< Assembler: Unsigned integer literal constant value */ # define _L_(x) x /**< Assembler: Long integer literal constant value */ # define _UL_(x) x /**< Assembler: Unsigned Long integer literal constant value */ #endif /* !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) */ #endif /* SKIP_INTEGER_LITERALS */ /** @} end of Atmel Global Defines */ /* ************************************************************************** */ /* CMSIS DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #if !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) /** Interrupt Number Definition */ typedef enum IRQn { /****** CORTEX-M4 Processor Exceptions Numbers ******************************/ Reset_IRQn = -15, /**< -15 Reset Vector, invoked on Power up and warm reset */ NonMaskableInt_IRQn = -14, /**< -14 Non maskable Interrupt, cannot be stopped or preempted */ HardFault_IRQn = -13, /**< -13 Hard Fault, all classes of Fault */ MemoryManagement_IRQn = -12, /**< -12 Memory Management, MPU mismatch, including Access Violation and No Match */ BusFault_IRQn = -11, /**< -11 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory related Fault */ UsageFault_IRQn = -10, /**< -10 Usage Fault, i.e. Undef Instruction, Illegal State Transition */ SVCall_IRQn = -5, /**< -5 System Service Call via SVC instruction */ DebugMonitor_IRQn = -4, /**< -4 Debug Monitor */ PendSV_IRQn = -2, /**< -2 Pendable request for system service */ SysTick_IRQn = -1, /**< -1 System Tick Timer */ /****** SAMG53N19 specific Interrupt Numbers ***********************************/ SUPC_IRQn = 0, /**< 0 Supply Controller (SUPC) */ RSTC_IRQn = 1, /**< 1 Reset Controller (RSTC) */ RTC_IRQn = 2, /**< 2 Real-time Clock (RTC) */ RTT_IRQn = 3, /**< 3 Real-time Timer (RTT) */ WDT_IRQn = 4, /**< 4 Watchdog Timer (WDT) */ PMC_IRQn = 5, /**< 5 Power Management Controller (PMC) */ EFC_IRQn = 6, /**< 6 Embedded Flash Controller (EFC) */ UART0_IRQn = 8, /**< 8 Universal Asynchronous Receiver Transmitter (UART0) */ UART1_IRQn = 9, /**< 9 Universal Asynchronous Receiver Transmitter (UART1) */ PIOA_IRQn = 11, /**< 11 Parallel Input/Output Controller (PIOA) */ PIOB_IRQn = 12, /**< 12 Parallel Input/Output Controller (PIOB) */ PDMIC0_IRQn = 13, /**< 13 Pulse Density Modulation Interface Controller (PDMIC0) */ USART_IRQn = 14, /**< 14 Universal Synchronous Asynchronous Receiver Transmitter (USART) */ MEM2MEM_IRQn = 15, /**< 15 Memory to Memory (MEM2MEM) */ I2SC0_IRQn = 16, /**< 16 Inter-IC Sound Controller (I2SC0) */ I2SC1_IRQn = 17, /**< 17 Inter-IC Sound Controller (I2SC1) */ PDMIC1_IRQn = 18, /**< 18 Pulse Density Modulation Interface Controller (PDMIC1) */ TWI0_IRQn = 19, /**< 19 Two-wire Interface High Speed (TWI0) */ TWI1_IRQn = 20, /**< 20 Two-wire Interface (TWI1) */ SPI_IRQn = 21, /**< 21 Serial Peripheral Interface (SPI) */ TWI2_IRQn = 22, /**< 22 Two-wire Interface (TWI2) */ TC0_CH0_IRQn = 23, /**< 23 Timer/Counter 0 Channel 0 (TC0) */ TC0_CH1_IRQn = 24, /**< 24 Timer/Counter 0 Channel 1 (TC0) */ TC0_CH2_IRQn = 25, /**< 25 Timer/Counter 0 Channel 2 (TC0) */ TC1_CH0_IRQn = 26, /**< 26 Timer/Counter 1 Channel 0 (TC1) */ TC1_CH1_IRQn = 27, /**< 27 Timer/Counter 1 Channel 1 (TC1) */ TC1_CH2_IRQn = 28, /**< 28 Timer/Counter 1 Channel 2 (TC1) */ ADC_IRQn = 29, /**< 29 Analog-to-Digital Converter (ADC) */ PERIPH_MAX_IRQn = 29 /**< Max peripheral ID */ } IRQn_Type; #endif /* !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) */ #if !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) typedef struct _DeviceVectors { /* Stack pointer */ void* pvStack; /* Cortex-M handlers */ void* pfnReset_Handler; /* -15 Reset Vector, invoked on Power up and warm reset */ void* pfnNonMaskableInt_Handler; /* -14 Non maskable Interrupt, cannot be stopped or preempted */ void* pfnHardFault_Handler; /* -13 Hard Fault, all classes of Fault */ void* pfnMemoryManagement_Handler; /* -12 Memory Management, MPU mismatch, including Access Violation and No Match */ void* pfnBusFault_Handler; /* -11 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory related Fault */ void* pfnUsageFault_Handler; /* -10 Usage Fault, i.e. Undef Instruction, Illegal State Transition */ void* pvReservedC9; void* pvReservedC8; void* pvReservedC7; void* pvReservedC6; void* pfnSVCall_Handler; /* -5 System Service Call via SVC instruction */ void* pfnDebugMonitor_Handler; /* -4 Debug Monitor */ void* pvReservedC3; void* pfnPendSV_Handler; /* -2 Pendable request for system service */ void* pfnSysTick_Handler; /* -1 System Tick Timer */ /* Peripheral handlers */ void* pfnSUPC_Handler; /* 0 Supply Controller (SUPC) */ void* pfnRSTC_Handler; /* 1 Reset Controller (RSTC) */ void* pfnRTC_Handler; /* 2 Real-time Clock (RTC) */ void* pfnRTT_Handler; /* 3 Real-time Timer (RTT) */ void* pfnWDT_Handler; /* 4 Watchdog Timer (WDT) */ void* pfnPMC_Handler; /* 5 Power Management Controller (PMC) */ void* pfnEFC_Handler; /* 6 Embedded Flash Controller (EFC) */ void* pvReserved7; void* pfnUART0_Handler; /* 8 Universal Asynchronous Receiver Transmitter (UART0) */ void* pfnUART1_Handler; /* 9 Universal Asynchronous Receiver Transmitter (UART1) */ void* pvReserved10; void* pfnPIOA_Handler; /* 11 Parallel Input/Output Controller (PIOA) */ void* pfnPIOB_Handler; /* 12 Parallel Input/Output Controller (PIOB) */ void* pfnPDMIC0_Handler; /* 13 Pulse Density Modulation Interface Controller (PDMIC0) */ void* pfnUSART_Handler; /* 14 Universal Synchronous Asynchronous Receiver Transmitter (USART) */ void* pfnMEM2MEM_Handler; /* 15 Memory to Memory (MEM2MEM) */ void* pfnI2SC0_Handler; /* 16 Inter-IC Sound Controller (I2SC0) */ void* pfnI2SC1_Handler; /* 17 Inter-IC Sound Controller (I2SC1) */ void* pfnPDMIC1_Handler; /* 18 Pulse Density Modulation Interface Controller (PDMIC1) */ void* pfnTWI0_Handler; /* 19 Two-wire Interface High Speed (TWI0) */ void* pfnTWI1_Handler; /* 20 Two-wire Interface (TWI1) */ void* pfnSPI_Handler; /* 21 Serial Peripheral Interface (SPI) */ void* pfnTWI2_Handler; /* 22 Two-wire Interface (TWI2) */ void* pfnTC0_CH0_Handler; /* 23 Timer/Counter 0 Channel 0 (TC0) */ void* pfnTC0_CH1_Handler; /* 24 Timer/Counter 0 Channel 1 (TC0) */ void* pfnTC0_CH2_Handler; /* 25 Timer/Counter 0 Channel 2 (TC0) */ void* pfnTC1_CH0_Handler; /* 26 Timer/Counter 1 Channel 0 (TC1) */ void* pfnTC1_CH1_Handler; /* 27 Timer/Counter 1 Channel 1 (TC1) */ void* pfnTC1_CH2_Handler; /* 28 Timer/Counter 1 Channel 2 (TC1) */ void* pfnADC_Handler; /* 29 Analog-to-Digital Converter (ADC) */ } DeviceVectors; /* Defines for Deprecated Interrupt and Exceptions handler names */ #define pfnMemManage_Handler pfnMemoryManagement_Handler /**< \deprecated Backward compatibility for ASF*/ #define pfnDebugMon_Handler pfnDebugMonitor_Handler /**< \deprecated Backward compatibility for ASF*/ #define pfnNMI_Handler pfnNonMaskableInt_Handler /**< \deprecated Backward compatibility for ASF*/ #define pfnSVC_Handler pfnSVCall_Handler /**< \deprecated Backward compatibility for ASF*/ #endif /* !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) */ #if !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) #if !defined DONT_USE_PREDEFINED_CORE_HANDLERS /* CORTEX-M4 exception handlers */ void Reset_Handler ( void ); void NonMaskableInt_Handler ( void ); void HardFault_Handler ( void ); void MemoryManagement_Handler ( void ); void BusFault_Handler ( void ); void UsageFault_Handler ( void ); void SVCall_Handler ( void ); void DebugMonitor_Handler ( void ); void PendSV_Handler ( void ); void SysTick_Handler ( void ); #endif /* DONT_USE_PREDEFINED_CORE_HANDLERS */ #if !defined DONT_USE_PREDEFINED_PERIPHERALS_HANDLERS /* Peripherals interrupt handlers */ void SUPC_Handler ( void ); void RSTC_Handler ( void ); void RTC_Handler ( void ); void RTT_Handler ( void ); void WDT_Handler ( void ); void PMC_Handler ( void ); void EFC_Handler ( void ); void UART0_Handler ( void ); void UART1_Handler ( void ); void PIOA_Handler ( void ); void PIOB_Handler ( void ); void PDMIC0_Handler ( void ); void USART_Handler ( void ); void MEM2MEM_Handler ( void ); void I2SC0_Handler ( void ); void I2SC1_Handler ( void ); void PDMIC1_Handler ( void ); void TWI0_Handler ( void ); void TWI1_Handler ( void ); void SPI_Handler ( void ); void TWI2_Handler ( void ); void TC0_CH0_Handler ( void ); void TC0_CH1_Handler ( void ); void TC0_CH2_Handler ( void ); void TC1_CH0_Handler ( void ); void TC1_CH1_Handler ( void ); void TC1_CH2_Handler ( void ); void ADC_Handler ( void ); #endif /* DONT_USE_PREDEFINED_PERIPHERALS_HANDLERS */ /* Defines for Deprecated Interrupt and Exceptions handler names */ #define MemManage_Handler MemoryManagement_Handler /**< \deprecated Backward compatibility*/ #define DebugMon_Handler DebugMonitor_Handler /**< \deprecated Backward compatibility*/ #define NMI_Handler NonMaskableInt_Handler /**< \deprecated Backward compatibility*/ #define SVC_Handler SVCall_Handler /**< \deprecated Backward compatibility*/ #endif /* !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) */ /* * \brief Configuration of the CORTEX-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001 /**< CM4 Core Revision */ #define __NVIC_PRIO_BITS 4 /**< Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0 /**< Set to 1 if different SysTick Config is used */ #define __MPU_PRESENT 1 /**< MPU present or not */ #define __VTOR_PRESENT 1 /**< Vector Table Offset Register present or not */ #define __FPU_PRESENT 1 /**< FPU present or not */ #define __ARCH_ARM 1 #define __ARCH_ARM_CORTEX_M 1 #define __DEVICE_IS_SAM 1 /* * \brief CMSIS includes */ #include "core_cm4.h" #if defined USE_CMSIS_INIT #include "system_samg53.h" #endif /* USE_CMSIS_INIT */ /** \defgroup SAMG53N19_api Peripheral Software API * @{ */ /* ************************************************************************** */ /** SOFTWARE PERIPHERAL API DEFINITION FOR SAMG53N19 */ /* ************************************************************************** */ #include "component/adc.h" #include "component/chipid.h" #include "component/efc.h" #include "component/gpbr.h" #include "component/i2sc.h" #include "component/matrix.h" #include "component/mem2mem.h" #include "component/pdc.h" #include "component/pdmic.h" #include "component/pio.h" #include "component/pmc.h" #include "component/rstc.h" #include "component/rtc.h" #include "component/rtt.h" #include "component/spi.h" #include "component/supc.h" #include "component/tc.h" #include "component/twi.h" #include "component/twihs.h" #include "component/uart.h" #include "component/usart.h" #include "component/wdt.h" /** @} end of Peripheral Software API */ /** \addtogroup SAMG53N19_id Peripheral Ids Definitions * @{ */ /* ************************************************************************** */ /* PERIPHERAL ID DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #define ID_SUPC ( 0) /**< \brief Supply Controller (SUPC) */ #define ID_RSTC ( 1) /**< \brief Reset Controller (RSTC) */ #define ID_RTC ( 2) /**< \brief Real-time Clock (RTC) */ #define ID_RTT ( 3) /**< \brief Real-time Timer (RTT) */ #define ID_WDT ( 4) /**< \brief Watchdog Timer (WDT) */ #define ID_PMC ( 5) /**< \brief Power Management Controller (PMC) */ #define ID_EFC ( 6) /**< \brief Embedded Flash Controller (EFC) */ #define ID_UART0 ( 8) /**< \brief Universal Asynchronous Receiver Transmitter (UART0) */ #define ID_UART1 ( 9) /**< \brief Universal Asynchronous Receiver Transmitter (UART1) */ #define ID_PIOA ( 11) /**< \brief Parallel Input/Output Controller (PIOA) */ #define ID_PIOB ( 12) /**< \brief Parallel Input/Output Controller (PIOB) */ #define ID_PDMIC0 ( 13) /**< \brief Pulse Density Modulation Interface Controller (PDMIC0) */ #define ID_USART ( 14) /**< \brief Universal Synchronous Asynchronous Receiver Transmitter (USART) */ #define ID_MEM2MEM ( 15) /**< \brief Memory to Memory (MEM2MEM) */ #define ID_I2SC0 ( 16) /**< \brief Inter-IC Sound Controller (I2SC0) */ #define ID_I2SC1 ( 17) /**< \brief Inter-IC Sound Controller (I2SC1) */ #define ID_PDMIC1 ( 18) /**< \brief Pulse Density Modulation Interface Controller (PDMIC1) */ #define ID_TWI0 ( 19) /**< \brief Two-wire Interface High Speed (TWI0) */ #define ID_TWI1 ( 20) /**< \brief Two-wire Interface (TWI1) */ #define ID_SPI ( 21) /**< \brief Serial Peripheral Interface (SPI) */ #define ID_TWI2 ( 22) /**< \brief Two-wire Interface (TWI2) */ #define ID_TC0_CHANNEL0 ( 23) /**< \brief Timer Counter (TC0_CHANNEL0) */ #define ID_TC0_CHANNEL1 ( 24) /**< \brief Timer Counter (TC0_CHANNEL1) */ #define ID_TC0_CHANNEL2 ( 25) /**< \brief Timer Counter (TC0_CHANNEL2) */ #define ID_TC1_CHANNEL0 ( 26) /**< \brief Timer Counter (TC1_CHANNEL0) */ #define ID_TC1_CHANNEL1 ( 27) /**< \brief Timer Counter (TC1_CHANNEL1) */ #define ID_TC1_CHANNEL2 ( 28) /**< \brief Timer Counter (TC1_CHANNEL2) */ #define ID_ADC ( 29) /**< \brief Analog-to-Digital Converter (ADC) */ #define ID_PERIPH_MAX ( 29) /**< \brief Number of peripheral IDs */ /** @} end of Peripheral Ids Definitions */ /** \addtogroup SAMG53N19_base Peripheral Base Address Definitions * @{ */ /* ************************************************************************** */ /* REGISTER STRUCTURE ADDRESS DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #if !(defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) #define ADC_REGS ((adc_registers_t*)0x40038000) /**< \brief ADC Registers Address */ #define CHIPID_REGS ((chipid_registers_t*)0x400e0740) /**< \brief CHIPID Registers Address */ #define EFC_REGS ((efc_registers_t*)0x400e0a00) /**< \brief EFC Registers Address */ #define GPBR_REGS ((gpbr_registers_t*)0x400e1490) /**< \brief GPBR Registers Address */ #define I2SC0_REGS ((i2sc_registers_t*)0x40000000) /**< \brief I2SC0 Registers Address */ #define I2SC1_REGS ((i2sc_registers_t*)0x40004000) /**< \brief I2SC1 Registers Address */ #define MATRIX_REGS ((matrix_registers_t*)0x400e0200) /**< \brief MATRIX Registers Address */ #define MEM2MEM_REGS ((mem2mem_registers_t*)0x40028000) /**< \brief MEM2MEM Registers Address */ #define PDMIC0_REGS ((pdmic_registers_t*)0x4002c000) /**< \brief PDMIC0 Registers Address */ #define PDMIC1_REGS ((pdmic_registers_t*)0x40030000) /**< \brief PDMIC1 Registers Address */ #define PIOA_REGS ((pio_registers_t*)0x400e0e00) /**< \brief PIOA Registers Address */ #define PIOB_REGS ((pio_registers_t*)0x400e1000) /**< \brief PIOB Registers Address */ #define PMC_REGS ((pmc_registers_t*)0x400e0400) /**< \brief PMC Registers Address */ #define RSTC_REGS ((rstc_registers_t*)0x400e1400) /**< \brief RSTC Registers Address */ #define RTC_REGS ((rtc_registers_t*)0x400e1460) /**< \brief RTC Registers Address */ #define RTT_REGS ((rtt_registers_t*)0x400e1430) /**< \brief RTT Registers Address */ #define SPI_REGS ((spi_registers_t*)0x40008000) /**< \brief SPI Registers Address */ #define SUPC_REGS ((supc_registers_t*)0x400e1410) /**< \brief SUPC Registers Address */ #define TC0_REGS ((tc_registers_t*)0x40010000) /**< \brief TC0 Registers Address */ #define TC1_REGS ((tc_registers_t*)0x40014000) /**< \brief TC1 Registers Address */ #define TWI1_REGS ((twi_registers_t*)0x4001c000) /**< \brief TWI1 Registers Address */ #define TWI2_REGS ((twi_registers_t*)0x40040000) /**< \brief TWI2 Registers Address */ #define TWI0_REGS ((twihs_registers_t*)0x40018000) /**< \brief TWI0 Registers Address */ #define UART0_REGS ((uart_registers_t*)0x400e0600) /**< \brief UART0 Registers Address */ #define UART1_REGS ((uart_registers_t*)0x400e0800) /**< \brief UART1 Registers Address */ #define USART_REGS ((usart_registers_t*)0x40024000) /**< \brief USART Registers Address */ #define WDT_REGS ((wdt_registers_t*)0x400e1450) /**< \brief WDT Registers Address */ #endif /* (defined(__ASSEMBLER__) || defined(__IAR_SYSTEMS_ASM__)) */ /** @} end of Peripheral Base Address Definitions */ /** \addtogroup SAMG53N19_base Peripheral Base Address Definitions * @{ */ /* ************************************************************************** */ /* BASE ADDRESS DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #define ADC_BASE_ADDRESS _UL_(0x40038000) /**< \brief ADC Base Address */ #define CHIPID_BASE_ADDRESS _UL_(0x400e0740) /**< \brief CHIPID Base Address */ #define EFC_BASE_ADDRESS _UL_(0x400e0a00) /**< \brief EFC Base Address */ #define GPBR_BASE_ADDRESS _UL_(0x400e1490) /**< \brief GPBR Base Address */ #define I2SC0_BASE_ADDRESS _UL_(0x40000000) /**< \brief I2SC0 Base Address */ #define I2SC1_BASE_ADDRESS _UL_(0x40004000) /**< \brief I2SC1 Base Address */ #define MATRIX_BASE_ADDRESS _UL_(0x400e0200) /**< \brief MATRIX Base Address */ #define MEM2MEM_BASE_ADDRESS _UL_(0x40028000) /**< \brief MEM2MEM Base Address */ #define PDMIC0_BASE_ADDRESS _UL_(0x4002c000) /**< \brief PDMIC0 Base Address */ #define PDMIC1_BASE_ADDRESS _UL_(0x40030000) /**< \brief PDMIC1 Base Address */ #define PIOA_BASE_ADDRESS _UL_(0x400e0e00) /**< \brief PIOA Base Address */ #define PIOB_BASE_ADDRESS _UL_(0x400e1000) /**< \brief PIOB Base Address */ #define PMC_BASE_ADDRESS _UL_(0x400e0400) /**< \brief PMC Base Address */ #define RSTC_BASE_ADDRESS _UL_(0x400e1400) /**< \brief RSTC Base Address */ #define RTC_BASE_ADDRESS _UL_(0x400e1460) /**< \brief RTC Base Address */ #define RTT_BASE_ADDRESS _UL_(0x400e1430) /**< \brief RTT Base Address */ #define SPI_BASE_ADDRESS _UL_(0x40008000) /**< \brief SPI Base Address */ #define SUPC_BASE_ADDRESS _UL_(0x400e1410) /**< \brief SUPC Base Address */ #define TC0_BASE_ADDRESS _UL_(0x40010000) /**< \brief TC0 Base Address */ #define TC1_BASE_ADDRESS _UL_(0x40014000) /**< \brief TC1 Base Address */ #define TWI1_BASE_ADDRESS _UL_(0x4001c000) /**< \brief TWI1 Base Address */ #define TWI2_BASE_ADDRESS _UL_(0x40040000) /**< \brief TWI2 Base Address */ #define TWI0_BASE_ADDRESS _UL_(0x40018000) /**< \brief TWI0 Base Address */ #define UART0_BASE_ADDRESS _UL_(0x400e0600) /**< \brief UART0 Base Address */ #define UART1_BASE_ADDRESS _UL_(0x400e0800) /**< \brief UART1 Base Address */ #define USART_BASE_ADDRESS _UL_(0x40024000) /**< \brief USART Base Address */ #define WDT_BASE_ADDRESS _UL_(0x400e1450) /**< \brief WDT Base Address */ /** @} end of Peripheral Base Address Definitions */ /** \addtogroup SAMG53N19_pio Peripheral Pio Definitions * @{ */ /* ************************************************************************** */ /* PIO DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #include "pio/samg53n19.h" /** @} end of Peripheral Pio Definitions */ /* ************************************************************************** */ /* MEMORY MAPPING DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #define PERIPHERALS_SIZE _UL_(0x20000000) /* 524288kB Memory segment type: io */ #define SYSTEM_SIZE _UL_(0x10000000) /* 262144kB Memory segment type: io */ #define IFLASH_SIZE _UL_(0x00080000) /* 512kB Memory segment type: flash */ #define IFLASH_PAGE_SIZE _UL_( 512) #define IFLASH_NB_OF_PAGES _UL_( 1024) #define IROM_SIZE _UL_(0x00400000) /* 4096kB Memory segment type: rom */ #define IRAM_SIZE _UL_(0x00018000) /* 96kB Memory segment type: ram */ #define PERIPHERALS_ADDR _UL_(0x40000000) /**< PERIPHERALS base address (type: io)*/ #define SYSTEM_ADDR _UL_(0xe0000000) /**< SYSTEM base address (type: io)*/ #define IFLASH_ADDR _UL_(0x00400000) /**< IFLASH base address (type: flash)*/ #define IROM_ADDR _UL_(0x00800000) /**< IROM base address (type: rom)*/ #define IRAM_ADDR _UL_(0x20000000) /**< IRAM base address (type: ram)*/ /* ************************************************************************** */ /** DEVICE SIGNATURES FOR SAMG53N19 */ /* ************************************************************************** */ #define CHIP_JTAGID _UL_(0X05B3C03F) #define CHIP_CIDR _UL_(0X247E0AE8) #define CHIP_EXID _UL_(0X00000000) /* ************************************************************************** */ /** ELECTRICAL DEFINITIONS FOR SAMG53N19 */ /* ************************************************************************** */ #define CHIP_FREQ_SLCK_RC_MIN _UL_(20000) #define CHIP_FREQ_SLCK_RC _UL_(32000) /**< \brief Typical Slow Clock Internal RC frequency */ #define CHIP_FREQ_SLCK_RC_MAX _UL_(44000) #define CHIP_FREQ_MAINCK_RC_8MHZ _UL_(8000000) #define CHIP_FREQ_MAINCK_RC_16MHZ _UL_(16000000) #define CHIP_FREQ_MAINCK_RC_24MHZ _UL_(24000000) #define CHIP_FREQ_CPU_MAX _UL_(48000000) #define CHIP_FREQ_XTAL_32K _UL_(32768) #define CHIP_FLASH_WRITE_WAIT_STATE _UL_(6) /**< \brief Embedded Flash Write Wait State */ #define CHIP_FREQ_FWS_0 _UL_(12000000) /**< \brief Maximum operating frequency when FWS is 0 */ #define CHIP_FREQ_FWS_1 _UL_(25000000) /**< \brief Maximum operating frequency when FWS is 1 */ #define CHIP_FREQ_FWS_2 _UL_(38000000) /**< \brief Maximum operating frequency when FWS is 2 */ #define CHIP_FREQ_FWS_3 _UL_(48000000) /**< \brief Maximum operating frequency when FWS is 3 */ #define CHIP_FREQ_FWS_NUMBER _UL_(4) /**< \brief Number of FWS ranges */ #ifdef __cplusplus } #endif /** @} end of SAMG53N19 definitions */ #endif /* _SAMG53N19_H_ */
[ "thibaut.viard@microchip.com" ]
thibaut.viard@microchip.com
6ac15295a92c8a12a0c975af81dbd9a355096001
4c518f3a393e8a436dd75ceede72cc8eacd3e797
/abc.c
03c4af0f798ffdd70177dc44501711b3bfd60c1f
[]
no_license
aartigodase1998/AssignmentDemo
dc852189fdcd39b8462ce6ca156243f91d4d943a
d63d7fdf7584d5e32cbe982187e50e6f36f9f19b
refs/heads/master
2023-05-14T22:42:44.443112
2021-05-28T13:59:43
2021-05-28T13:59:43
371,621,422
0
0
null
null
null
null
UTF-8
C
false
false
158
c
#include<stdio.h> void main() { int i; int n=5; for(i=0;i<10;i++) { printf("i value is %d",i); } for(i=1;i<=10;i++) { printf("\n %d",i*n); } }
[ "arati.godase@ibm.com" ]
arati.godase@ibm.com
c410186aaa272cd6625a38f8e698df7b7265309d
09f63e43bb01fb1803584cd4774f07bddbb21d25
/Windows/stdafx.h
a427989b1d5faf40799d03d8192c87f3bd7d0d02
[]
no_license
KatekovAnton/wwiseIntegrationDemo
74ab0d5302e9d09c689db0f6798798c0af6fe01e
70caeb323919076e5ca66dde1bdbfb2063da9551
refs/heads/master
2020-06-20T23:20:09.395626
2020-03-19T13:33:11
2020-03-19T13:33:11
197,285,062
0
0
null
null
null
null
UTF-8
C
false
false
1,313
h
/******************************************************************************* The content of this file includes portions of the AUDIOKINETIC Wwise Technology released in source code form as part of the SDK installer package. Commercial License Usage Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology may use this file in accordance with the end user license agreement provided with the software or, alternatively, in accordance with the terms contained in a written agreement between you and Audiokinetic Inc. Version: v2019.1.1 Build: 6977 Copyright (c) 2006-2019 Audiokinetic Inc. *******************************************************************************/ // stdafx.h /// \file /// Precompiled Header File for the Integration Demo application. #pragma once //////////////////////////////////////////// // Helper Includes //////////////////////////////////////////// #include <AK/SoundEngine/Common/AkTypes.h> #include <AK/Tools/Common/AkPlatformFuncs.h> #define WIN32_LEAN_AND_MEAN #define DIRECTINPUT_VERSION 0x0800 #if defined(_MSC_VER) && (_MSC_VER < 1900) #define snprintf _snprintf #endif #include <windows.h> #include <dinput.h> #include <xinput.h> #include <d3d9.h> #include <D3dx9core.h> #include <wchar.h>
[ "void0main@gmail.com" ]
void0main@gmail.com
b6e8634221cb4319c3532a60dc30f6d8f8b006a1
accbe82b976125427a864937a3b5d57e2c90ddcf
/09/ex10/main.c
3b9461b37ab9379d1fdcf9ef9a1ba7225019b754
[]
no_license
simdax/42correc
861882cf9efebfad6266f819ed5a585832984e2b
6e9af8980f74e48a945f61c7e51679b86e9a7f65
refs/heads/master
2021-01-15T22:39:30.229327
2017-08-24T12:23:24
2017-08-24T12:23:24
99,907,453
0
0
null
null
null
null
UTF-8
C
false
false
670
c
#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void ft_scrambler(int ***a, int *b, int *******c, int ****d); int main() { int nb = 1; int nb1 = 2; int nb2 = 3; int nb3 = 4; int *pnb0 = &nb; int **pnb01 = &pnb0; int ***pnb02 = &pnb01; int *pnb1 = &nb2; int **pnb11 = &pnb1; int ***pnb12 = &pnb11; int ****pnb13 = &pnb12; int *****pnb14 = &pnb13; int ******pnb15 = &pnb14; int *******pnb16 = &pnb15; int *pnb2 = &nb3; int **pnb21 = &pnb2; int ***pnb22 = &pnb21; int ****pnb23 = &pnb22; int *pnb3 = &nb1; ft_scrambler(pnb02, pnb3, pnb16, pnb23); printf("%d et %d et %d et %d", nb, nb1, nb2, nb3); return (0); }
[ "scornaz@e2r5p7.42.fr" ]
scornaz@e2r5p7.42.fr
4c458e2fec5c9fcf895977fb1c22fc4accdef9a2
6f3e0000993816afa03d64c5a02b94fca2931200
/sys/arch/amiga/dev/viewioctl.h
f1c075c8281de3e8628c8a572886e40a90191061
[]
no_license
fallen/NetBSD6
b6dc7a2593846816b8cb6f47cf26054ca2811667
44e0ac4ada812ace1f9ca8ce4792e287d83bd951
refs/heads/master
2022-04-09T14:50:47.274147
2020-03-08T14:01:38
2020-03-08T14:01:38
8,187,676
2
2
null
2020-03-08T14:01:39
2013-02-13T20:57:45
null
UTF-8
C
false
false
2,588
h
/* $NetBSD: viewioctl.h,v 1.9 2002/09/06 13:19:18 gehenna Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Christian E. Hopps. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * The view major device is a placeholder device. It serves * simply to map the semantics of a graphics dipslay to * the semantics of a character block device. In other * words the graphics system as currently built does not like to be * refered to by open/close/ioctl. This device serves as * a interface to graphics. */ struct view_size { int x; int y; u_int width; u_int height; u_int depth; }; #define VIOCREMOVE _IO('V', 0x0) /* if displaying remove. */ #define VIOCDISPLAY _IO('V', 0x1) /* if not displaying, display */ #define VIOCSSIZE _IOW('V', 0x2, struct view_size) #define VIOCGSIZE _IOR('V', 0x3, struct view_size) #define VIOCGBMAP _IOR('V', 0x4, bmap_t) #define VIOCSCMAP _IOW('V', 0x5, colormap_t) #define VIOCGCMAP _IOWR('V', 0x6, colormap_t) #ifdef _KERNEL void viewprobe(void); #endif
[ "yann.sionneau@gmail.com" ]
yann.sionneau@gmail.com
f2ddd405c80a7469f4b5a0b544f63369a81d3848
c461a81314c3ae909c734a1736f90894344ff006
/temp/util69.c
a2a0952d8ab4e62627e1cfdb17d610e9a58f115d
[]
no_license
flarss/many
3e85ea139fc702ba4561942ac8bee6a520839f57
a671f2fec22cde015f3bccf0bbd9eef345225de7
refs/heads/master
2021-01-10T11:42:52.047674
2015-10-08T18:46:40
2015-10-08T18:46:40
43,835,809
0
0
null
null
null
null
UTF-8
C
false
false
256
c
#include "inc6.h" #include <stdio.h> #include "inc61.h" #include "inc62.h" #include "inc63.h" #include "inc64.h" #include "inc65.h" #include "inc66.h" #include "inc67.h" #include "inc68.h" #include "inc69.h" void util69() { printf("util69 was here\n"); }
[ "fredrikgit@gmail.com" ]
fredrikgit@gmail.com
885767f5ed2f17df19164d9915b241118b43e746
ea09f69660a8982a94c15adf66bdc99531b4b8aa
/0x0D-preprocessor/3-function_like_macro.h
d1f7f2ae20be34fd19be81d0c13622ce7b90d75d
[]
no_license
gorgyboy/holbertonschool-low_level_programming
96ff91a00c4373ca77b513a6ba81fa78b6a4374f
ac3660f83e207417ff2a01f0992f14f2bd998515
refs/heads/master
2020-12-29T08:33:48.049008
2020-12-01T08:18:05
2020-12-01T08:18:05
238,536,274
0
1
null
null
null
null
UTF-8
C
false
false
95
h
#ifndef FLM_H #define FLM_H #define ABS(x) (((x) < 0) ? ((x) * -1) : (x)) #endif /* FLM_H */
[ "jlrogb@gmail.com" ]
jlrogb@gmail.com
fc2f2fc3f3ab5920563455ebe43d334e723b728c
af7c753cfbc9309e1276d12e2e29fbbd6d7602ce
/Firmware/ESP8266/Clay_ESP8266EX_Firmware/user/Message.c
22acdc922d747c3a6b001c8467ec576401269790
[ "MIT" ]
permissive
zzrgenius/Clay
b179c64f2348449f6766ba356af5daecf90639e5
31a84237d09eb93affb9b2587ff1d5b9a2b8c6a6
refs/heads/master
2021-05-31T08:29:51.309212
2016-06-05T04:52:12
2016-06-05T04:52:12
null
0
0
null
null
null
null
UTF-8
C
false
false
4,414
c
#include "stdlib.h" #include "stdint.h" #include "stdio.h" #include "string.h" #include "Message.h" #include "CRC16.h" #define DEFAULT_UUID_LENGTH 37 char messageUuidBuffer[DEFAULT_UUID_LENGTH] = { 0 }; char grammarSymbolBuffer[MAXIMUM_GRAMMAR_SYMBOL_LENGTH] = { 0 }; Message* Create_Message() { // Allocate memory for message structure. Message *message = (Message *) malloc(sizeof(Message)); (*message).message_type = NULL; (*message).source = NULL; (*message).destination = NULL; (*message).content_length = 0; (*message).content_checksum = 0; (*message).content_type = NULL; (*message).content = NULL; // Set up links for queue (*message).previous = NULL; (*message).next = NULL; return message; } int8_t Delete_Message(Message *message) { if (message != NULL) { // TODO: Remove references to the message in the queue. if ((*message).message_type != NULL) { free((*message).message_type); (*message).message_type = NULL; } if ((*message).source != NULL) { free((*message).source); (*message).source = NULL; } if ((*message).destination != NULL) { free((*message).destination); (*message).destination = NULL; } if ((*message).content_type != NULL) { free((*message).content_type); (*message).content_type = NULL; } if ((*message).content != NULL) { free((*message).content); (*message).content = NULL; } free(message); message = NULL; return true; } return false; } void Set_Message_Type(Message *message, const char *type) { // Free the message's destination stored type from memory if ((*message).message_type != NULL) { free((*message).message_type); (*message).message_type = NULL; } // Copy the type into the structure (*message).message_type = (char *) zalloc(strlen(type) + 1); memset((*message).message_type, '\0', strlen(type) + 1); strcpy((*message).message_type, type); } void Set_Message_Source(Message *message, const char *address) { // Free the message's destination address from memory if ((*message).source != NULL) { free((*message).source); (*message).source = NULL; } // Copy the message destination address (*message).source = (char *) zalloc(strlen(address) + 1); memset((*message).source, '\0', strlen(address) + 1); strcpy((*message).source, address); } void Set_Message_Destination(Message *message, const char *address) { // Free the message's destination address from memory if ((*message).destination != NULL) { free((*message).destination); (*message).destination = NULL; } // Copy the message destination address (*message).destination = (char *) zalloc(strlen(address) + 1); memset((*message).destination, '\0', strlen(address) + 1); strcpy((*message).destination, address); } void Set_Message_Content(Message * message, const char *content, uint32_t content_length) { if ((*message).content != NULL) { free((*message).content); (*message).content = NULL; (*message).content_length = 0; (*message).content_checksum = 0; } (*message).content_length = content_length; // Allocate memory for the message's content. (*message).content = (char *) malloc((*message).content_length + 1); (*message).content_checksum = Calculate_Checksum_On_Bytes(content, content_length); memset((*message).content, 0, (*message).content_length + 1); // Copy message content memcpy((*message).content, content, (*message).content_length); } extern void Set_Message_Content_Type(Message *message, const char *content_type) { // Free the message's destination address from memory if ((*message).content_type != NULL) { free((*message).content_type); (*message).content_type = NULL; } // Copy the message content_type address (*message).content_type = (char *) malloc(strlen(content_type) + 1); memset((*message).content_type, '\0', strlen(content_type) + 1); strcpy((*message).content_type, content_type); } char * Get_Message_Type(Message *message) { return (*message).message_type; } char * Get_Message_Source(Message *message) { return (*message).source; } char * Get_Message_Destination(Message *message) { return (*message).destination; } char * Get_Message_Content(Message *message) { return (*message).content; } uint32_t Get_Message_Content_Length(Message *message) { return (*message).content_length; } char * Get_Message_Content_Type(Message *message) { return (*message).message_type; }
[ "thebhef@gmail.com" ]
thebhef@gmail.com
a56523d691f882861f8034e7160307fc7fd860c8
409e10d2e57f7a3ee7c5a8c03320df0cef990d39
/移动距离/src/移动距离.c
d04b23b232c8dd43f24087e8327bc68b233dff6c
[]
no_license
asdlei99/SomeOjCode-CXX
7f437ed041ee984d5abd7b10b0d433f4b759b99c
bc7253f8534184fac748f28f9c93ecbb09e0906f
refs/heads/master
2021-06-13T17:24:07.097452
2017-04-03T11:48:17
2017-04-03T11:48:17
null
0
0
null
null
null
null
UTF-8
C
false
false
870
c
/* ============================================================================ Name : 移动距离.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio.h> #include <stdlib.h> #define N 100 int main(void) { int n, a, b; scanf("%d%d%d", &n, &a, &b); int arr[N / n][n]; for (int i = 0; i < N / n; i++) { for (int j = 0; j < n; j++) { if (i % 2 == 0) arr[i][j] = i * n + j + 1; else arr[i][j] = (i + 1) * n - j; } } int x1, y1, x2, y2; for (int i = 0; i < N / n; i++) { for (int j = 0; j < n; j++) { if (a == arr[i][j]) { x1 = i; y1 = j; } if (b == arr[i][j]) { x2 = i; y2 = j; } } } printf("%d",abs(x2-x1)+abs(y2-y1)); return EXIT_SUCCESS; }
[ "imqqyangfan@gmail.com" ]
imqqyangfan@gmail.com
a0e3a07a3dae566c5a995ecd3772ef4caf72a311
440fe9bc55a3d9fc44410d1748f47fbc74e30506
/anycloud39ev300/SDK/component/UVC_check_sensor/component/drvlib/include/randomizer.h
7f768eb96d869a227d1c1a8c4e627985959e8a51
[]
no_license
haihoang1219931/qiwen
5def7764f48e70a8c4fbb9692f5fd0714dcb5a20
6c86facd09a5c2efe5314a669f653fa90acbc999
refs/heads/main
2023-07-10T17:37:18.512888
2021-08-22T07:01:43
2021-08-22T07:01:43
null
0
0
null
null
null
null
UTF-8
C
false
false
1,232
h
/** * @filename randomizer.h * @brief the arithmetic to randomize or derandomize the data * Copyright (C) 2006 Anyka (Guangzhou) Software Technology Co., LTD * @author yangyiming * @date 2012-05-15 * @version 1.0 */ #ifndef __RANDOMIZER_H_ #define __RANDOMIZER_H_ #define MALLOC drv_malloc /** *@brief initial the randomizer * *@author yangyiming *@date 2012-05-15 *@param PageSize[in] the pagesize of the nand *@return bool true for success, false for failure */ bool randomizer_init(unsigned long PageSize); /** *@brief randomize the data or derandomize the randomized data * *@author yangyiming *@date 2012-05-15 *@param pageIndex[in] the offset of the page where the data got from /will be stored in the nand *@param EccFrameIndex[in] which ecc frame in a page *@param destBuff[out] the buffer to store the data to be converted *@param srcBuff[in] the buffer stored the data to be converted *@param datalen[in] the data length ,unit byte *@return void */ void randomize(unsigned long pageIndex, unsigned long EccFrameIndex, unsigned char *destBuff,unsigned char *srcBuff, unsigned long datalen); #endif
[ "1397610152@qq.com" ]
1397610152@qq.com
59756cdc7478a47f4c2393d8d2fc18e6c812af5b
d0c4232f57b408e9d4de4813a28e0b4396772d05
/gems/gems/libxml-ruby-0.9.4/ext/libxml/ruby_xml_document.c
467b3a069fd8e594e2bec5592a4c5555d7585916
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
larssg/group-shelf
8a154feb39a820b66411d54a25f4d066cd87b894
fa1a0156c62b9ea3694180ba415bacc77a3cabb9
refs/heads/master
2020-04-13T13:42:48.417264
2008-12-07T16:38:00
2008-12-07T16:38:00
81,270
1
1
null
null
null
null
UTF-8
C
false
false
24,922
c
/* $Id: ruby_xml_document.c 626 2008-11-22 20:47:07Z cfis $ */ /* * Document-class: LibXML::XML::Document * * The XML::Document class provides a tree based API for working * with xml documents. You may directly create a document and * manipulate it, or create a document from a data source by * using an XML::Parser object. * * To create a document from scratch: * * doc = XML::Document.new() * doc.root = XML::Node.new('root_node') * doc.root << XML::Node.new('elem1') * doc.save('output.xml', format) * * To read a document from a file: * * doc = XML::Document.file('my_file') * * To use a parser to read a document: * * parser = XML::Parser.new * parser.file = 'my_file' * doc = parser.parse * * To write a file: * * * doc = XML::Document.new() * doc.root = XML::Node.new('root_node') * root = doc.root * * root << elem1 = XML::Node.new('elem1') * elem1['attr1'] = 'val1' * elem1['attr2'] = 'val2' * * root << elem2 = XML::Node.new('elem2') * elem2['attr1'] = 'val1' * elem2['attr2'] = 'val2' * * root << elem3 = XML::Node.new('elem3') * elem3 << elem4 = XML::Node.new('elem4') * elem3 << elem5 = XML::Node.new('elem5') * * elem5 << elem6 = XML::Node.new('elem6') * elem6 << 'Content for element 6' * * elem3['attr'] = 'baz' * * format = true * doc.save('output.xml', format) */ #include <stdarg.h> #include <st.h> #include "ruby_libxml.h" #include "ruby_xml_document.h" VALUE cXMLDocument; void rxml_document_free(xmlDocPtr xdoc) { xdoc->_private = NULL; xmlFreeDoc(xdoc); } void rxml_document_mark(xmlDocPtr xdoc) { rb_gc_mark(LIBXML_STATE); } VALUE rxml_document_wrap(xmlDocPtr xdoc) { VALUE result; // This node is already wrapped if (xdoc->_private != NULL) { result = (VALUE)xdoc->_private; } else { result = Data_Wrap_Struct(cXMLDocument, rxml_document_mark, rxml_document_free, xdoc); xdoc->_private = (void*)result; } return result; } /* * call-seq: * XML::Document.alloc(xml_version = 1.0) -> document * * Alocates a new XML::Document, optionally specifying the * XML version. */ static VALUE rxml_document_alloc(VALUE klass) { return Data_Wrap_Struct(klass, rxml_document_mark, rxml_document_free, NULL); } /* * call-seq: * XML::Document.initialize(xml_version = 1.0) -> document * * Initializes a new XML::Document, optionally specifying the * XML version. */ static VALUE rxml_document_initialize(int argc, VALUE *argv, VALUE self) { xmlDocPtr xdoc; VALUE xmlver; switch (argc) { case 0: xmlver = rb_str_new2("1.0"); break; case 1: rb_scan_args(argc, argv, "01", &xmlver); break; default: rb_raise(rb_eArgError, "wrong number of arguments (need 0 or 1)"); } Check_Type(xmlver, T_STRING); xdoc = xmlNewDoc((xmlChar*)StringValuePtr(xmlver)); xdoc->_private = (void*)self; DATA_PTR(self) = xdoc; return self; } /* * call-seq: * document.compression -> num * * Obtain this document's compression mode identifier. */ static VALUE rxml_document_compression_get(VALUE self) { #ifdef HAVE_ZLIB_H xmlDocPtr xdoc; int compmode; Data_Get_Struct(self, xmlDoc, xdoc); compmode = xmlGetDocCompressMode(xdoc); if (compmode == -1) return(Qnil); else return(INT2NUM(compmode)); #else rb_warn("libxml not compiled with zlib support"); return(Qfalse); #endif } /* * call-seq: * document.compression = num * * Set this document's compression mode. */ static VALUE rxml_document_compression_set(VALUE self, VALUE num) { #ifdef HAVE_ZLIB_H xmlDocPtr xdoc; int compmode; Check_Type(num, T_FIXNUM); Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc == NULL) { return(Qnil); } else { xmlSetDocCompressMode(xdoc, NUM2INT(num)); compmode = xmlGetDocCompressMode(xdoc); if (compmode == -1) return(Qnil); else return(INT2NUM(compmode)); } #else rb_warn("libxml compiled without zlib support"); return(Qfalse); #endif } /* * call-seq: * document.compression? -> (true|false) * * Determine whether this document is compressed. */ static VALUE rxml_document_compression_q(VALUE self) { #ifdef HAVE_ZLIB_H xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->compression != -1) return(Qtrue); else return(Qfalse); #else rb_warn("libxml compiled without zlib support"); return(Qfalse); #endif } /* * call-seq: * document.child -> node * * Get this document's child node. */ static VALUE rxml_document_child_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->children == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, xdoc->children); } /* * call-seq: * document.child? -> (true|false) * * Determine whether this document has a child node. */ static VALUE rxml_document_child_q(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->children == NULL) return(Qfalse); else return(Qtrue); } /* * call-seq: * document.dump([stream]) -> true * * Dump this document's XML to the specified IO stream. * If no stream is specified, stdout is used. */ static VALUE rxml_document_dump(int argc, VALUE *argv, VALUE self) { OpenFile *fptr; VALUE io; FILE *out; xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc == NULL) return(Qnil); switch (argc) { case 0: io = rb_stdout; break; case 1: io = argv[0]; if (!rb_obj_is_kind_of(io, rb_cIO)) rb_raise(rb_eTypeError, "need an IO object"); break; default: rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)"); } GetOpenFile(io, fptr); rb_io_check_writable(fptr); out = GetWriteFile(fptr); xmlDocDump(out, xdoc); return(Qtrue); } /* * call-seq: * document.debug_dump([stream]) -> true * * Debug version of dump. */ static VALUE rxml_document_debug_dump(int argc, VALUE *argv, VALUE self) { #ifdef LIBXML_DEBUG_ENABLED OpenFile *fptr; VALUE io; FILE *out; xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc == NULL) return(Qnil); switch (argc) { case 0: io = rb_stderr; break; case 1: io = argv[0]; if (!rb_obj_is_kind_of(io, rb_cIO)) rb_raise(rb_eTypeError, "need an IO object"); break; default: rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)"); } GetOpenFile(io, fptr); rb_io_check_writable(fptr); out = GetWriteFile(fptr); xmlDebugDumpDocument(out, xdoc); return(Qtrue); #else rb_warn("libxml was compiled without debugging support. Please recompile libxml and ruby-libxml"); return(Qfalse); #endif } /* * call-seq: * document.debug_dump_head([stream]) -> true * * Debug-dump this document's header to the specified IO stream. * If no stream is specified, stdout is used. */ static VALUE rxml_document_debug_dump_head(int argc, VALUE *argv, VALUE self) { #ifdef LIBXML_DEBUG_ENABLED OpenFile *fptr; VALUE io; FILE *out; xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc == NULL) return(Qnil); switch (argc) { case 0: io = rb_stdout; break; case 1: io = argv[0]; if (!rb_obj_is_kind_of(io, rb_cIO)) rb_raise(rb_eTypeError, "need an IO object"); break; default: rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)"); } GetOpenFile(io, fptr); rb_io_check_writable(fptr); out = GetWriteFile(fptr); xmlDebugDumpDocumentHead(out, xdoc); return(Qtrue); #else rb_warn("libxml was compiled without debugging support. Please recompile libxml and ruby-libxml"); return(Qfalse); #endif } /* * call-seq: * document.format_dump([stream], [spacing]) -> true * * Dump this document's formatted XML to the specified IO stream. * If no stream is specified, stdout is used. If spacing is * specified, it must be a boolean that determines whether * spacing is used. */ static VALUE rxml_document_format_dump(int argc, VALUE *argv, VALUE self) { OpenFile *fptr; VALUE bool, io; FILE *out; xmlDocPtr xdoc; int size, spacing; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc == NULL) return(Qnil); switch (argc) { case 0: io = rb_stdout; spacing = 1; break; case 1: io = argv[0]; if (!rb_obj_is_kind_of(io, rb_cIO)) rb_raise(rb_eTypeError, "need an IO object"); spacing = 1; break; case 2: io = argv[0]; if (!rb_obj_is_kind_of(io, rb_cIO)) rb_raise(rb_eTypeError, "need an IO object"); bool = argv[1]; if (TYPE(bool) == T_TRUE) spacing = 1; else if (TYPE(bool) == T_FALSE) spacing = 0; else rb_raise(rb_eTypeError, "incorect argument type, second argument must be bool"); break; default: rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)"); } GetOpenFile(io, fptr); rb_io_check_writable(fptr); out = GetWriteFile(fptr); size = xmlDocFormatDump(out, xdoc, spacing); return(INT2NUM(size)); } /* * call-seq: * document.debug_format_dump([stream]) -> true * * *Deprecated* in favour of format_dump. */ static VALUE rxml_document_debug_format_dump(int argc, VALUE *argv, VALUE self) { rb_warn("debug_format_dump has been deprecaited, use format_dump instead"); return(rxml_document_format_dump(argc, argv, self)); } /* * call-seq: * document.encoding -> "encoding" * * Obtain the encoding specified by this document. */ static VALUE rxml_document_encoding_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->encoding == NULL) return(Qnil); else return(rb_str_new2((const char*)xdoc->encoding)); } /* * call-seq: * document.encoding = "encoding" * * Set the encoding for this document. */ static VALUE rxml_document_encoding_set(VALUE self, VALUE encoding) { xmlDocPtr xdoc; Check_Type(encoding, T_STRING); Data_Get_Struct(self, xmlDoc, xdoc); xdoc->encoding = xmlStrdup(StringValuePtr(encoding)); return(rxml_document_encoding_get(self)); } /* * call-seq: * document.last -> node * * Obtain the last node. */ static VALUE rxml_document_last_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->last == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, xdoc->last); } /* * call-seq: * document.last? -> (true|false) * * Determine whether there is a last node. */ static VALUE rxml_document_last_q(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->last == NULL) return(Qfalse); else return(Qtrue); } /* * call-seq: * document.next -> node * * Obtain the next node. */ static VALUE rxml_document_next_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->next == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, xdoc->next); } /* * call-seq: * document.next? -> (true|false) * * Determine whether there is a next node. */ static VALUE rxml_document_next_q(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->next == NULL) return(Qfalse); else return(Qtrue); } /* * call-seq: * document.parent -> node * * Obtain the parent node. */ static VALUE rxml_document_parent_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->parent == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, xdoc->parent); } /* * call-seq: * document.parent? -> (true|false) * * Determine whether there is a parent node. */ static VALUE rxml_document_parent_q(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->parent == NULL) return(Qfalse); else return(Qtrue); } /* * call-seq: * document.prev -> node * * Obtain the previous node. */ static VALUE rxml_document_prev_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->prev == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, xdoc->prev); } /* * call-seq: * document.prev? -> (true|false) * * Determine whether there is a previous node. */ static VALUE rxml_document_prev_q(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->prev == NULL) return(Qfalse); else return(Qtrue); } /* * call-seq: * document.root -> node * * Obtain the root node. */ static VALUE rxml_document_root_get(VALUE self) { xmlDocPtr xdoc; xmlNodePtr root; Data_Get_Struct(self, xmlDoc, xdoc); root = xmlDocGetRootElement(xdoc); if (root == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, root); } /* * call-seq: * document.root = node * * Set the root node. */ static VALUE rxml_document_root_set(VALUE self, VALUE node) { xmlDocPtr xdoc; xmlNodePtr xroot, xnode; if (rb_obj_is_kind_of(node, cXMLNode) == Qfalse) rb_raise(rb_eTypeError, "must pass an XML::Node type object"); Data_Get_Struct(self, xmlDoc, xdoc); Data_Get_Struct(node, xmlNode, xnode); xroot = xmlDocSetRootElement(xdoc, xnode); if (xroot == NULL) return(Qnil); return rxml_node2_wrap(cXMLNode, xroot); } /* * call-seq: * document.save(filename, format = false) -> int * * Save this document to the file given by filename, * optionally formatting the output. * Parameters: * filename: The filename or URL of the new document * format: Specifies whether formatting spaces should be added. * returns: The number of bytes written or -1 in case of error. */ static VALUE rxml_document_save(int argc, VALUE *argv, VALUE self) { xmlDocPtr xdoc; const char *filename; int format = 0; int len; if (argc <1 || argc > 2) rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)"); Check_Type(argv[0], T_STRING); filename = StringValuePtr(argv[0]); if (argc == 2) { switch (TYPE(argv[1])) { case T_TRUE: format = 1; break; case T_FALSE: format = 0; break; default: rb_raise(rb_eArgError, "The second parameter (format) must be true or false"); } } Data_Get_Struct(self, xmlDoc, xdoc); len = xmlSaveFormatFileEnc(filename, xdoc, (const char*)xdoc->encoding, format); if (len == -1) rb_raise(rb_eIOError, "Could not write document"); else return(INT2NUM(len)); } /* * call-seq: * document.standalone? -> (true|false) * * Determine whether this is a standalone document. */ static VALUE rxml_document_standalone_q(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->standalone) return(Qtrue); else return(Qfalse); } /* * call-seq: * document.to_s({format=true,encoding) -> "xml" * * Coerce this document to a string representation * of it's XML. The default is to pretty format, but this * depends Parser#indent_tree_output==true or * Parser#default_keep_blanks==false. * * The encoding is not applied to the document, but is * encoding target of the resulting string. */ static VALUE rxml_document_to_s(int argc, VALUE *argv, VALUE self) { xmlDocPtr xdoc; xmlChar *result, *encoding=NULL; int format, len; VALUE rresult; switch (argc) { case 0: format = 1; break; case 2: if (TYPE(argv[1]) == T_STRING) encoding=(xmlChar *)StringValuePtr(argv[1]); case 1: if (TYPE(argv[0]) == T_TRUE) format = 1; else if (TYPE(argv[0]) == T_FALSE) format = 0; else rb_raise(rb_eTypeError, "wrong type of argument, must be bool"); break; default: rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)"); } Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc == NULL) { return(Qnil); } else if (encoding != NULL) { if (format) { xmlDocDumpFormatMemoryEnc(xdoc, &result, &len, (const char*)encoding, format); } else { xmlDocDumpMemoryEnc(xdoc, &result, &len, (const char *)encoding); } } else { if (format) xmlDocDumpFormatMemory(xdoc, &result, &len, format); else xmlDocDumpMemory(xdoc, &result, &len); } rresult=rb_str_new((const char*)result,len); xmlFree(result); return rresult; } /* * call-seq: * document.url -> "url" * * Obtain this document's source URL, if any. */ static VALUE rxml_document_url_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->URL == NULL) return(Qnil); else return(rb_str_new2((const char*)xdoc->URL)); } /* * call-seq: * document.version -> "version" * * Obtain the XML version specified by this document. */ static VALUE rxml_document_version_get(VALUE self) { xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); if (xdoc->version == NULL) return(Qnil); else return(rb_str_new2((const char*)xdoc->version)); } /* * call-seq: * document.xinclude -> num * * Process xinclude directives in this document. */ static VALUE rxml_document_xinclude(VALUE self) { #ifdef LIBXML_XINCLUDE_ENABLED xmlDocPtr xdoc; int ret; Data_Get_Struct(self, xmlDoc, xdoc); ret = xmlXIncludeProcess(xdoc); if (ret >= 0) { return(INT2NUM(ret)); } else { rxml_raise(&xmlLastError); return Qnil; } #else rb_warn("libxml was compiled without XInclude support. Please recompile libxml and ruby-libxml"); return(Qfalse); #endif } void LibXML_validity_error(void * ctxt, const char * msg, va_list ap) { if (rb_block_given_p()) { char buff[1024]; snprintf(buff, 1024, msg, ap); rb_yield(rb_ary_new3(2, rb_str_new2(buff), Qtrue)); } else { fprintf(stderr, "error -- found validity error: "); fprintf(stderr, msg, ap); } } void LibXML_validity_warning(void * ctxt, const char * msg, va_list ap) { if (rb_block_given_p()) { char buff[1024]; snprintf(buff, 1024, msg, ap); rb_yield(rb_ary_new3(2, rb_str_new2(buff), Qfalse)); } else { fprintf(stderr, "warning -- found validity error: "); fprintf(stderr, msg, ap); } } /* * call-seq: * document.validate_schema(schema) -> (true|false) * * Validate this document against the specified XML::Schema. * * If a block is provided it is used as an error handler for validaten errors. * The block is called with two argument, the message and a flag indication * if the message is an error (true) or a warning (false). */ static VALUE rxml_document_validate_schema(VALUE self, VALUE schema) { xmlSchemaValidCtxtPtr vptr; xmlDocPtr xdoc; xmlSchemaPtr xschema; int is_invalid; Data_Get_Struct(self, xmlDoc, xdoc); Data_Get_Struct(schema, xmlSchema, xschema); vptr = xmlSchemaNewValidCtxt(xschema); xmlSchemaSetValidErrors(vptr, (xmlSchemaValidityErrorFunc)LibXML_validity_error, (xmlSchemaValidityWarningFunc)LibXML_validity_warning, NULL); is_invalid = xmlSchemaValidateDoc(vptr, xdoc); xmlSchemaFreeValidCtxt(vptr); if (is_invalid) { rxml_raise(&xmlLastError); return Qfalse; } else { return Qtrue; } } /* * call-seq: * document.validate_schema(relaxng) -> (true|false) * * Validate this document against the specified XML::RelaxNG. * * If a block is provided it is used as an error handler for validaten errors. * The block is called with two argument, the message and a flag indication * if the message is an error (true) or a warning (false). */ static VALUE rxml_document_validate_relaxng(VALUE self, VALUE relaxng) { xmlRelaxNGValidCtxtPtr vptr; xmlDocPtr xdoc; xmlRelaxNGPtr xrelaxng; int is_invalid; Data_Get_Struct(self, xmlDoc, xdoc); Data_Get_Struct(relaxng, xmlRelaxNG, xrelaxng); vptr = xmlRelaxNGNewValidCtxt(xrelaxng); xmlRelaxNGSetValidErrors(vptr, (xmlRelaxNGValidityErrorFunc)LibXML_validity_error, (xmlRelaxNGValidityWarningFunc)LibXML_validity_warning, NULL); is_invalid = xmlRelaxNGValidateDoc(vptr, xdoc); xmlRelaxNGFreeValidCtxt(vptr); if (is_invalid) { rxml_raise(&xmlLastError); return Qfalse; } else { return Qtrue; } } /* * call-seq: * document.validate(dtd) -> (true|false) * * Validate this document against the specified XML::DTD. */ static VALUE rxml_document_validate_dtd(VALUE self, VALUE dtd) { VALUE error = Qnil; xmlValidCtxt ctxt; xmlDocPtr xdoc; xmlDtdPtr xdtd; Data_Get_Struct(self, xmlDoc, xdoc); Data_Get_Struct(dtd, xmlDtd, xdtd); ctxt.userData = &error; ctxt.error = (xmlValidityErrorFunc)LibXML_validity_error; ctxt.warning = (xmlValidityWarningFunc)LibXML_validity_warning; ctxt.nodeNr = 0; ctxt.nodeTab = NULL; ctxt.vstateNr = 0; ctxt.vstateTab = NULL; if (xmlValidateDtd(&ctxt, xdoc, xdtd)) { return(Qtrue); } else { rxml_raise(&xmlLastError); return Qfalse; } } /* * call-seq: * document.reader -> reader * * Create a XML::Reader from the document. This is a shortcut to * XML::Reader.walker(). */ static VALUE rxml_document_reader(VALUE self) { return rxml_reader_new_walker(cXMLReader, self); } // Rdoc needs to know #ifdef RDOC_NEVER_DEFINED mLibXML = rb_define_module("LibXML"); mXML = rb_define_module_under(mLibXML, "XML"); #endif void ruby_init_xml_document(void) { cXMLDocument = rb_define_class_under(mXML, "Document", rb_cObject); rb_define_alloc_func(cXMLDocument, rxml_document_alloc); rb_define_method(cXMLDocument, "initialize", rxml_document_initialize, -1); rb_define_method(cXMLDocument, "child", rxml_document_child_get, 0); rb_define_method(cXMLDocument, "child?", rxml_document_child_q, 0); rb_define_method(cXMLDocument, "compression", rxml_document_compression_get, 0); rb_define_method(cXMLDocument, "compression=", rxml_document_compression_set, 1); rb_define_method(cXMLDocument, "compression?", rxml_document_compression_q, 0); rb_define_method(cXMLDocument, "dump", rxml_document_dump, -1); rb_define_method(cXMLDocument, "debug_dump", rxml_document_debug_dump, -1); rb_define_method(cXMLDocument, "debug_dump_head", rxml_document_debug_dump_head, -1); rb_define_method(cXMLDocument, "debug_format_dump", rxml_document_debug_format_dump, -1); rb_define_method(cXMLDocument, "encoding", rxml_document_encoding_get, 0); rb_define_method(cXMLDocument, "encoding=", rxml_document_encoding_set, 1); rb_define_method(cXMLDocument, "format_dump", rxml_document_format_dump, -1); rb_define_method(cXMLDocument, "last", rxml_document_last_get, 0); rb_define_method(cXMLDocument, "last?", rxml_document_last_q, 0); rb_define_method(cXMLDocument, "next", rxml_document_next_get, 0); rb_define_method(cXMLDocument, "next?", rxml_document_next_q, 0); rb_define_method(cXMLDocument, "parent", rxml_document_parent_get, 0); rb_define_method(cXMLDocument, "parent?", rxml_document_parent_q, 0); rb_define_method(cXMLDocument, "prev", rxml_document_prev_get, 0); rb_define_method(cXMLDocument, "prev?", rxml_document_prev_q, 0); rb_define_method(cXMLDocument, "root", rxml_document_root_get, 0); rb_define_method(cXMLDocument, "root=", rxml_document_root_set, 1); rb_define_method(cXMLDocument, "save", rxml_document_save, -1); rb_define_method(cXMLDocument, "standalone?", rxml_document_standalone_q, 0); rb_define_method(cXMLDocument, "to_s", rxml_document_to_s, -1); rb_define_method(cXMLDocument, "url", rxml_document_url_get, 0); rb_define_method(cXMLDocument, "version", rxml_document_version_get, 0); rb_define_method(cXMLDocument, "xinclude", rxml_document_xinclude, 0); rb_define_method(cXMLDocument, "validate", rxml_document_validate_dtd, 1); rb_define_method(cXMLDocument, "validate_schema", rxml_document_validate_schema, 1); rb_define_method(cXMLDocument, "validate_relaxng", rxml_document_validate_relaxng, 1); rb_define_method(cXMLDocument, "reader", rxml_document_reader, 0); }
[ "lgs@lenio.dk" ]
lgs@lenio.dk
db2a78e09b1a1fcb258316b2a2245c63fc704a22
91d42e36516668992e7df8b63823392601f07cb8
/CommonTools/test/plotSyst_ch6.C
0e6eefe3e4f19198f517de495b06aaf5b99fc4c3
[]
no_license
senka/CombinedEWKAnalysis_shapeVSlnN_debug
9e0a04876792c236782cfd1769d0719ff8d7694c
35925317281eb2c7d841dd2c7fb1415037644e3e
refs/heads/master
2016-09-05T20:49:52.142062
2014-04-29T11:26:17
2014-04-29T11:26:17
null
0
0
null
null
null
null
UTF-8
C
false
false
8,458
c
void plotSyst_ch6(){ TFile * file_in=new TFile("../data/WV_semileptonic/ch6_boosted.root","read"); file_in->cd(); zz2l2nu ->SetFillColor(0); zz2l2nu_CMS_eff_bUp ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_QCD_ACC_JVetoUp ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_lesUp ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_puUp ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_stat_ll_zz2l2nu_8TeVUp ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_umetUp ->SetFillColor(0); zz2l2nu_CMS_res_jUp ->SetFillColor(0); zz2l2nu_CMS_scale_jUp ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_sherpaUp ->SetFillColor(0); zz2l2nu_CMS_eff_bDown ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_QCD_ACC_JVetoDown ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_lesDown ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_puDown ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_stat_ll_zz2l2nu_8TeVDown ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_umetDown ->SetFillColor(0); zz2l2nu_CMS_res_jDown ->SetFillColor(0); zz2l2nu_CMS_scale_jDown ->SetFillColor(0); zz2l2nu_CMS_hzz2l2v_sherpaDown ->SetFillColor(0); wz3lnu ->SetFillColor(0); wz3lnu_CMS_eff_bUp ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_lesUp ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_puUp ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_stat_ll_wz3lnu_8TeVUp ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_umetUp ->SetFillColor(0); wz3lnu_CMS_res_jUp ->SetFillColor(0); wz3lnu_CMS_scale_jUp ->SetFillColor(0); wz3lnu_CMS_eff_bDown ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_lesDown ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_puDown ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_stat_ll_wz3lnu_8TeVDown ->SetFillColor(0); wz3lnu_CMS_hzz2l2v_umetDown ->SetFillColor(0); wz3lnu_CMS_res_jDown ->SetFillColor(0); wz3lnu_CMS_scale_jDown ->SetFillColor(0); zll ->SetFillColor(0); zll_CMS_hzz2l2v_stat_ll_zll_8TeVUp ->SetFillColor(0); zll_CMS_hzz2l2v_stat_ll_zll_8TeVDown ->SetFillColor(0); topwwwjetsdata ->SetFillColor(0); topwwwjetsdata_CMS_hzz2l2v_stat_ll_topwwwjetsdata_8TeVUp ->SetFillColor(0); topwwwjetsdata_CMS_hzz2l2v_stat_ll_topwwwjetsdata_8TeVDown ->SetFillColor(0); data_obs ->SetFillColor(0); zz2l2nu_CMS_eff_bUp ->SetLineColor(2); zz2l2nu_CMS_hzz2l2v_QCD_ACC_JVetoUp ->SetLineColor(2); zz2l2nu_CMS_hzz2l2v_lesUp ->SetLineColor(2); zz2l2nu_CMS_hzz2l2v_puUp ->SetLineColor(2); zz2l2nu_CMS_hzz2l2v_stat_ll_zz2l2nu_8TeVUp ->SetLineColor(2); zz2l2nu_CMS_hzz2l2v_umetUp ->SetLineColor(2); zz2l2nu_CMS_res_jUp ->SetLineColor(2); zz2l2nu_CMS_scale_jUp ->SetLineColor(2); zz2l2nu_CMS_hzz2l2v_sherpaUp ->SetLineColor(2); wz3lnu_CMS_eff_bUp ->SetLineColor(2); wz3lnu_CMS_hzz2l2v_lesUp ->SetLineColor(2); wz3lnu_CMS_hzz2l2v_puUp ->SetLineColor(2); wz3lnu_CMS_hzz2l2v_stat_ll_wz3lnu_8TeVUp ->SetLineColor(2); wz3lnu_CMS_hzz2l2v_umetUp ->SetLineColor(2); wz3lnu_CMS_res_jUp ->SetLineColor(2); wz3lnu_CMS_scale_jUp ->SetLineColor(2); zll_CMS_hzz2l2v_stat_ll_zll_8TeVUp ->SetLineColor(2); topwwwjetsdata_CMS_hzz2l2v_stat_ll_topwwwjetsdata_8TeVUp ->SetLineColor(2); zz2l2nu_CMS_eff_bDown ->SetLineColor(3); zz2l2nu_CMS_hzz2l2v_QCD_ACC_JVetoDown ->SetLineColor(3); zz2l2nu_CMS_hzz2l2v_lesDown ->SetLineColor(3); zz2l2nu_CMS_hzz2l2v_puDown ->SetLineColor(3); zz2l2nu_CMS_hzz2l2v_stat_ll_zz2l2nu_8TeVDown ->SetLineColor(3); zz2l2nu_CMS_hzz2l2v_umetDown ->SetLineColor(3); zz2l2nu_CMS_res_jDown ->SetLineColor(3); zz2l2nu_CMS_scale_jDown ->SetLineColor(3); zz2l2nu_CMS_hzz2l2v_sherpaDown ->SetLineColor(3); wz3lnu_CMS_eff_bDown ->SetLineColor(3); wz3lnu_CMS_hzz2l2v_lesDown ->SetLineColor(3); wz3lnu_CMS_hzz2l2v_puDown ->SetLineColor(3); wz3lnu_CMS_hzz2l2v_stat_ll_wz3lnu_8TeVDown ->SetLineColor(3); wz3lnu_CMS_hzz2l2v_umetDown ->SetLineColor(3); wz3lnu_CMS_res_jDown ->SetLineColor(3); wz3lnu_CMS_scale_jDown ->SetLineColor(3); zll_CMS_hzz2l2v_stat_ll_zll_8TeVDown ->SetLineColor(3); topwwwjetsdata_CMS_hzz2l2v_stat_ll_topwwwjetsdata_8TeVDown ->SetLineColor(3); TCanvas * c1_eff_b=new TCanvas("c1_eff_b","c1_eff_b",600,600); zz2l2nu_CMS_eff_bUp->Draw("histo"); zz2l2nu_CMS_eff_bDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_hzz2l2v_QCD_ACC_JVeto=new TCanvas("c1_hzz2l2v_QCD_ACC_JVeto","c1_hzz2l2v_QCD_ACC_JVeto",600,600); zz2l2nu_CMS_hzz2l2v_QCD_ACC_JVetoUp->Draw("histo"); zz2l2nu_CMS_hzz2l2v_QCD_ACC_JVetoDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_hzz2l2v_les=new TCanvas("c1_hzz2l2v_les","c1_hzz2l2v_les",600,600); zz2l2nu_CMS_hzz2l2v_lesUp->Draw("histo"); zz2l2nu_CMS_hzz2l2v_lesDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_hzz2l2v_pu=new TCanvas("c1_hzz2l2v_pu","c1_hzz2l2v_pu",600,600); zz2l2nu_CMS_hzz2l2v_puUp->Draw("histo"); zz2l2nu_CMS_hzz2l2v_puDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_hzz2l2v_stat_ll_zz2l2nu_8TeV=new TCanvas("c1_hzz2l2v_stat_ll_zz2l2nu_8TeV","c1_hzz2l2v_stat_ll_zz2l2nu_8TeV",600,600); zz2l2nu_CMS_hzz2l2v_stat_ll_zz2l2nu_8TeVUp->Draw("histo"); zz2l2nu_CMS_hzz2l2v_stat_ll_zz2l2nu_8TeVDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_hzz2l2v_umet=new TCanvas("c1_hzz2l2v_umet","c1_hzz2l2v_umet",600,600); zz2l2nu_CMS_hzz2l2v_umetUp->Draw("histo"); zz2l2nu_CMS_hzz2l2v_umetDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_res_j=new TCanvas("c1_res_j","c1_res_j",600,600); zz2l2nu_CMS_res_jUp->Draw("histo"); zz2l2nu_CMS_res_jDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_scale_j=new TCanvas("c1_scale_j","c1_scale_j",600,600); zz2l2nu_CMS_scale_jDown->Draw("histo"); zz2l2nu_CMS_scale_jUp->Draw("samehisto"); // zz2l2nu_CMS_scale_jDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_hzz2l2v_sherpa=new TCanvas("c1_hzz2l2v_sherpa","c1_hzz2l2v_sherpa",600,600); zz2l2nu_CMS_hzz2l2v_sherpaUp->Draw("histo"); zz2l2nu_CMS_hzz2l2v_sherpaDown->Draw("samehisto"); zz2l2nu->Draw("histosame"); TCanvas * c1_wz3lnu_eff_b=new TCanvas("c1_wz3lnu_eff_b","c1_wz3lnu_eff_b",600,600); wz3lnu_CMS_eff_bUp->Draw("histo"); wz3lnu_CMS_eff_bDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_wz3lnu_hzz2l2v_les=new TCanvas("c1_wz3lnu_hzz2l2v_les","c1_wz3lnu_hzz2l2v_les",600,600); wz3lnu_CMS_hzz2l2v_lesUp->Draw("histo"); wz3lnu_CMS_hzz2l2v_lesDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_wz3lnu_hzz2l2v_pu=new TCanvas("c1_wz3lnu_hzz2l2v_pu","c1_wz3lnu_hzz2l2v_pu",600,600); wz3lnu_CMS_hzz2l2v_puUp->Draw("histo"); wz3lnu_CMS_hzz2l2v_puDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_wz3lnu_hzz2l2v_stat_ll_wz3lnu_8TeV=new TCanvas("c1_wz3lnu_hzz2l2v_stat_ll_wz3lnu_8TeV","c1_wz3lnu_hzz2l2v_stat_ll_wz3lnu_8TeV",600,600); wz3lnu_CMS_hzz2l2v_stat_ll_wz3lnu_8TeVUp->Draw("histo"); wz3lnu_CMS_hzz2l2v_stat_ll_wz3lnu_8TeVDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_wz3lnu_hzz2l2v_umet=new TCanvas("c1_wz3lnu_hzz2l2v_umet","c1_wz3lnu_hzz2l2v_umet",600,600); wz3lnu_CMS_hzz2l2v_umetUp->Draw("histo"); wz3lnu_CMS_hzz2l2v_umetDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_wz3lnu_res_j=new TCanvas("c1_wz3lnu_res_j","c1_wz3lnu_res_j",600,600); wz3lnu_CMS_res_jUp->Draw("histo"); wz3lnu_CMS_res_jDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_wz3lnu_scale_j=new TCanvas("c1_wz3lnu_scale_j","c1_wz3lnu_scale_j",600,600); wz3lnu_CMS_scale_jDown->Draw("histo"); wz3lnu_CMS_scale_jUp->Draw("samehisto"); // wz3lnu_CMS_scale_jDown->Draw("samehisto"); wz3lnu->Draw("histosame"); TCanvas * c1_zll_hzz2l2v_stat_ll_zll_8TeV=new TCanvas("c1_zll_hzz2l2v_stat_ll_zll_8TeV","c1_zll_hzz2l2v_stat_ll_zll_8TeV",600,600); zll_CMS_hzz2l2v_stat_ll_zll_8TeVUp->Draw("histo"); zll_CMS_hzz2l2v_stat_ll_zll_8TeVDown->Draw("samehisto"); zll->Draw("histosame"); TCanvas * c1_top_hzz2l2v_stat_ll_topwwwjetsdata_8TeV=new TCanvas("c1_top_hzz2l2v_stat_ll_topwwwjetsdata_8TeV","c1_top_hzz2l2v_stat_ll_topwwwjetsdata_8TeV",600,600); topwwwjetsdata_CMS_hzz2l2v_stat_ll_topwwwjetsdata_8TeVUp->Draw("histo"); topwwwjetsdata_CMS_hzz2l2v_stat_ll_topwwwjetsdata_8TeVDown->Draw("samehisto"); topwwwjetsdata->Draw("histosame"); }
[ "senka.duric@cern.ch" ]
senka.duric@cern.ch
14ebb3be62e42e60047eccb260e7219aef395c97
fd90d577d6c848607ef56bf24ce5fe108bf13da8
/devices/MIMXRT1062/drivers/fsl_elcdif.h
063a1b777f2ac43caacb0d986b90537a498ea099
[ "Apache-2.0" ]
permissive
JayHeng/imxrt-tool-flash-algo
210e7adb904c8d95761e2914e69b8cc15e349326
0af70dfeea9dea669916bf404769144ed403a5e1
refs/heads/master
2022-11-26T20:56:24.771562
2022-03-26T14:18:45
2022-03-26T14:18:45
232,016,920
40
17
Apache-2.0
2022-10-31T18:21:32
2020-01-06T03:29:02
C
UTF-8
C
false
false
24,052
h
/* * Copyright 2017-2019 NXP * All rights reserved. * * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _FSL_ELCDIF_H_ #define _FSL_ELCDIF_H_ #include "fsl_common.h" /*! * @addtogroup elcdif * @{ */ /******************************************************************************* * Definitions ******************************************************************************/ /*! @name Driver version */ /*@{*/ /*! @brief eLCDIF driver version */ #define FSL_ELCDIF_DRIVER_VERSION (MAKE_VERSION(2, 0, 2)) /*@}*/ /* All IRQ flags in CTRL1 register. */ #define ELCDIF_CTRL1_IRQ_MASK \ (LCDIF_CTRL1_BM_ERROR_IRQ_MASK | LCDIF_CTRL1_OVERFLOW_IRQ_MASK | LCDIF_CTRL1_UNDERFLOW_IRQ_MASK | \ LCDIF_CTRL1_CUR_FRAME_DONE_IRQ_MASK | LCDIF_CTRL1_VSYNC_EDGE_IRQ_MASK) /* All IRQ enable control bits in CTRL1 register. */ #define ELCDIF_CTRL1_IRQ_EN_MASK \ (LCDIF_CTRL1_BM_ERROR_IRQ_EN_MASK | LCDIF_CTRL1_OVERFLOW_IRQ_EN_MASK | LCDIF_CTRL1_UNDERFLOW_IRQ_EN_MASK | \ LCDIF_CTRL1_CUR_FRAME_DONE_IRQ_EN_MASK | LCDIF_CTRL1_VSYNC_EDGE_IRQ_EN_MASK) /* All IRQ flags in AS_CTRL register. */ #if defined(LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_MASK) #define ELCDIF_AS_CTRL_IRQ_MASK (LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_MASK) #else #define ELCDIF_AS_CTRL_IRQ_MASK 0U #endif /* All IRQ enable control bits in AS_CTRL register. */ #if defined(LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_EN_MASK) #define ELCDIF_AS_CTRL_IRQ_EN_MASK (LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_EN_MASK) #else #define ELCDIF_AS_CTRL_IRQ_EN_MASK 0U #endif #if ((ELCDIF_CTRL1_IRQ_MASK & ELCDIF_AS_CTRL_IRQ_MASK) || (ELCDIF_AS_CTRL_IRQ_MASK & ELCDIF_AS_CTRL_IRQ_EN_MASK)) #error Interrupt bits overlap, need to update the interrupt functions. #endif /* LUT memory entery number. */ #define ELCDIF_LUT_ENTRY_NUM 256U /*! * @brief eLCDIF signal polarity flags */ enum _elcdif_polarity_flags { kELCDIF_VsyncActiveLow = 0U, /*!< VSYNC active low. */ kELCDIF_VsyncActiveHigh = LCDIF_VDCTRL0_VSYNC_POL_MASK, /*!< VSYNC active high. */ kELCDIF_HsyncActiveLow = 0U, /*!< HSYNC active low. */ kELCDIF_HsyncActiveHigh = LCDIF_VDCTRL0_HSYNC_POL_MASK, /*!< HSYNC active high. */ kELCDIF_DataEnableActiveLow = 0U, /*!< Data enable line active low. */ kELCDIF_DataEnableActiveHigh = LCDIF_VDCTRL0_ENABLE_POL_MASK, /*!< Data enable line active high. */ kELCDIF_DriveDataOnFallingClkEdge = 0U, /*!< Drive data on falling clock edge, capture data on rising clock edge. */ kELCDIF_DriveDataOnRisingClkEdge = LCDIF_VDCTRL0_DOTCLK_POL_MASK, /*!< Drive data on falling clock edge, capture data on rising clock edge. */ }; /*! * @brief The eLCDIF interrupts to enable. */ enum _elcdif_interrupt_enable { kELCDIF_BusMasterErrorInterruptEnable = LCDIF_CTRL1_BM_ERROR_IRQ_EN_MASK, /*!< Bus master error interrupt. */ kELCDIF_TxFifoOverflowInterruptEnable = LCDIF_CTRL1_OVERFLOW_IRQ_EN_MASK, /*!< TXFIFO overflow interrupt. */ kELCDIF_TxFifoUnderflowInterruptEnable = LCDIF_CTRL1_UNDERFLOW_IRQ_EN_MASK, /*!< TXFIFO underflow interrupt. */ kELCDIF_CurFrameDoneInterruptEnable = LCDIF_CTRL1_CUR_FRAME_DONE_IRQ_EN_MASK, /*!< Interrupt when hardware enters vertical blanking state. */ kELCDIF_VsyncEdgeInterruptEnable = LCDIF_CTRL1_VSYNC_EDGE_IRQ_EN_MASK, /*!< Interrupt when hardware encounters VSYNC edge. */ #if defined(LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_EN_MASK) kELCDIF_SciSyncOnInterruptEnable = LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_EN_MASK, /*!< Interrupt when eLCDIF lock with CSI input. */ #endif }; /*! * @brief The eLCDIF interrupt status flags. */ enum _elcdif_interrupt_flags { kELCDIF_BusMasterError = LCDIF_CTRL1_BM_ERROR_IRQ_MASK, /*!< Bus master error interrupt. */ kELCDIF_TxFifoOverflow = LCDIF_CTRL1_OVERFLOW_IRQ_MASK, /*!< TXFIFO overflow interrupt. */ kELCDIF_TxFifoUnderflow = LCDIF_CTRL1_UNDERFLOW_IRQ_MASK, /*!< TXFIFO underflow interrupt. */ kELCDIF_CurFrameDone = LCDIF_CTRL1_CUR_FRAME_DONE_IRQ_MASK, /*!< Interrupt when hardware enters vertical blanking state. */ kELCDIF_VsyncEdge = LCDIF_CTRL1_VSYNC_EDGE_IRQ_MASK, /*!< Interrupt when hardware encounters VSYNC edge. */ #if defined(LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_MASK) kELCDIF_SciSyncOn = LCDIF_AS_CTRL_CSI_SYNC_ON_IRQ_MASK, /*!< Interrupt when eLCDIF lock with CSI input. */ #endif }; /*! * @brief eLCDIF status flags */ enum _elcdif_status_flags { kELCDIF_LFifoFull = LCDIF_STAT_LFIFO_FULL_MASK, /*!< LFIFO full. */ kELCDIF_LFifoEmpty = LCDIF_STAT_LFIFO_EMPTY_MASK, /*!< LFIFO empty. */ kELCDIF_TxFifoFull = LCDIF_STAT_TXFIFO_FULL_MASK, /*!< TXFIFO full. */ kELCDIF_TxFifoEmpty = LCDIF_STAT_TXFIFO_EMPTY_MASK, /*!< TXFIFO empty. */ #if defined(LCDIF_STAT_BUSY_MASK) kELCDIF_LcdControllerBusy = LCDIF_STAT_BUSY_MASK, /*!< The external LCD controller busy signal. */ #endif #if defined(LCDIF_STAT_DVI_CURRENT_FIELD_MASK) kELCDIF_CurDviField2 = LCDIF_STAT_DVI_CURRENT_FIELD_MASK, /*!< Current DVI filed, if set, then current filed is 2, otherwise current filed is 1. */ #endif }; /*! * @brief The pixel format. * * This enumerator should be defined together with the array s_pixelFormatReg. * To support new pixel format, enhance this enumerator and s_pixelFormatReg. */ typedef enum _elcdif_pixel_format { kELCDIF_PixelFormatRAW8 = 0, /*!< RAW 8 bit, four data use 32 bits. */ kELCDIF_PixelFormatRGB565 = 1, /*!< RGB565, two pixel use 32 bits. */ kELCDIF_PixelFormatRGB666 = 2, /*!< RGB666 unpacked, one pixel uses 32 bits, high byte unused, upper 2 bits of other bytes unused. */ kELCDIF_PixelFormatXRGB8888 = 3, /*!< XRGB8888 unpacked, one pixel uses 32 bits, high byte unused. */ kELCDIF_PixelFormatRGB888 = 4, /*!< RGB888 packed, one pixel uses 24 bits. */ } elcdif_pixel_format_t; /*! @brief The LCD data bus type. */ typedef enum _elcdif_lcd_data_bus { kELCDIF_DataBus8Bit = LCDIF_CTRL_LCD_DATABUS_WIDTH(1), /*!< 8-bit data bus. */ kELCDIF_DataBus16Bit = LCDIF_CTRL_LCD_DATABUS_WIDTH(0), /*!< 16-bit data bus, support RGB565. */ kELCDIF_DataBus18Bit = LCDIF_CTRL_LCD_DATABUS_WIDTH(2), /*!< 18-bit data bus, support RGB666. */ kELCDIF_DataBus24Bit = LCDIF_CTRL_LCD_DATABUS_WIDTH(3), /*!< 24-bit data bus, support RGB888. */ } elcdif_lcd_data_bus_t; /*! * @brief The register value when using different pixel format. * * These register bits control the pixel format: * - CTRL[DATA_FORMAT_24_BIT] * - CTRL[DATA_FORMAT_18_BIT] * - CTRL[DATA_FORMAT_16_BIT] * - CTRL[WORD_LENGTH] * - CTRL1[BYTE_PACKING_FORMAT] */ typedef struct _elcdif_pixel_format_reg { uint32_t regCtrl; /*!< Value of register CTRL. */ uint32_t regCtrl1; /*!< Value of register CTRL1. */ } elcdif_pixel_format_reg_t; /*! * @brief eLCDIF configure structure for RGB mode (DOTCLK mode). */ typedef struct _elcdif_rgb_mode_config { uint16_t panelWidth; /*!< Display panel width, pixels per line. */ uint16_t panelHeight; /*!< Display panel height, how many lines per panel. */ uint8_t hsw; /*!< HSYNC pulse width. */ uint8_t hfp; /*!< Horizontal front porch. */ uint8_t hbp; /*!< Horizontal back porch. */ uint8_t vsw; /*!< VSYNC pulse width. */ uint8_t vfp; /*!< Vrtical front porch. */ uint8_t vbp; /*!< Vertical back porch. */ uint32_t polarityFlags; /*!< OR'ed value of @ref _elcdif_polarity_flags, used to contol the signal polarity. */ uint32_t bufferAddr; /*!< Frame buffer address. */ elcdif_pixel_format_t pixelFormat; /*!< Pixel format. */ elcdif_lcd_data_bus_t dataBus; /*!< LCD data bus. */ } elcdif_rgb_mode_config_t; /*! * @brief eLCDIF alpha surface pixel format. */ typedef enum _elcdif_as_pixel_format { kELCDIF_AsPixelFormatARGB8888 = 0x0, /*!< 32-bit pixels with alpha. */ kELCDIF_AsPixelFormatRGB888 = 0x4, /*!< 32-bit pixels without alpha (unpacked 24-bit format) */ kELCDIF_AsPixelFormatARGB1555 = 0x8, /*!< 16-bit pixels with alpha. */ kELCDIF_AsPixelFormatARGB4444 = 0x9, /*!< 16-bit pixels with alpha. */ kELCDIF_AsPixelFormatRGB555 = 0xC, /*!< 16-bit pixels without alpha. */ kELCDIF_AsPixelFormatRGB444 = 0xD, /*!< 16-bit pixels without alpha. */ kELCDIF_AsPixelFormatRGB565 = 0xE, /*!< 16-bit pixels without alpha. */ } elcdif_as_pixel_format_t; /*! * @brief eLCDIF alpha surface buffer configuration. */ typedef struct _elcdif_as_buffer_config { uint32_t bufferAddr; /*!< Buffer address. */ elcdif_as_pixel_format_t pixelFormat; /*!< Pixel format. */ } elcdif_as_buffer_config_t; /*! * @brief eLCDIF alpha mode during blending. */ typedef enum _elcdif_alpha_mode { kELCDIF_AlphaEmbedded, /*!< The alpha surface pixel alpha value will be used for blend. */ kELCDIF_AlphaOverride, /*!< The user defined alpha value will be used for blend directly. */ kELCDIF_AlphaMultiply, /*!< The alpha surface pixel alpha value scaled the user defined alpha value will be used for blend, for example, pixel alpha set set to 200, user defined alpha set to 100, then the reault alpha is 200 * 100 / 255. */ kELCDIF_AlphaRop /*!< Raster operation. */ } elcdif_alpha_mode_t; /*! * @brief eLCDIF ROP mode during blending. * * Explanation: * - AS: Alpha surface * - PS: Process surface * - nAS: Alpha surface NOT value * - nPS: Process surface NOT value */ typedef enum _elcdif_rop_mode { kELCDIF_RopMaskAs = 0x0, /*!< AS AND PS. */ kELCDIF_RopMaskNotAs = 0x1, /*!< nAS AND PS. */ kELCDIF_RopMaskAsNot = 0x2, /*!< AS AND nPS. */ kELCDIF_RopMergeAs = 0x3, /*!< AS OR PS. */ kELCDIF_RopMergeNotAs = 0x4, /*!< nAS OR PS. */ kELCDIF_RopMergeAsNot = 0x5, /*!< AS OR nPS. */ kELCDIF_RopNotCopyAs = 0x6, /*!< nAS. */ kELCDIF_RopNot = 0x7, /*!< nPS. */ kELCDIF_RopNotMaskAs = 0x8, /*!< AS NAND PS. */ kELCDIF_RopNotMergeAs = 0x9, /*!< AS NOR PS. */ kELCDIF_RopXorAs = 0xA, /*!< AS XOR PS. */ kELCDIF_RopNotXorAs = 0xB /*!< AS XNOR PS. */ } elcdif_rop_mode_t; /*! * @brief eLCDIF alpha surface blending configuration. */ typedef struct _elcdif_as_blend_config { uint8_t alpha; /*!< User defined alpha value, only used when @ref alphaMode is @ref kELCDIF_AlphaOverride or @ref kELCDIF_AlphaRop. */ bool invertAlpha; /*!< Set true to invert the alpha. */ elcdif_alpha_mode_t alphaMode; /*!< Alpha mode. */ elcdif_rop_mode_t ropMode; /*!< ROP mode, only valid when @ref alphaMode is @ref kELCDIF_AlphaRop. */ } elcdif_as_blend_config_t; /*! * @brief eLCDIF LUT * * The Lookup Table (LUT) is used to expand the 8 bits pixel to 24 bits pixel * before output to external displayer. * * There are two 256x24 bits LUT memory in LCDIF, the LSB of frame buffer address * determins which memory to use. */ typedef enum _elcdif_lut { kELCDIF_Lut0 = 0, /*!< LUT 0. */ kELCDIF_Lut1, /*!< LUT 1. */ } elcdif_lut_t; /******************************************************************************* * APIs ******************************************************************************/ #if defined(__cplusplus) extern "C" { #endif /* __cplusplus */ /*! * @name eLCDIF initialization and de-initialization * @{ */ /*! * @brief Initializes the eLCDIF to work in RGB mode (DOTCLK mode). * * This function ungates the eLCDIF clock and configures the eLCDIF peripheral according * to the configuration structure. * * @param base eLCDIF peripheral base address. * @param config Pointer to the configuration structure. */ void ELCDIF_RgbModeInit(LCDIF_Type *base, const elcdif_rgb_mode_config_t *config); /*! * @brief Gets the eLCDIF default configuration structure for RGB (DOTCLK) mode. * * This function sets the configuration structure to default values. * The default configuration is set to the following values. * @code config->panelWidth = 480U; config->panelHeight = 272U; config->hsw = 41; config->hfp = 4; config->hbp = 8; config->vsw = 10; config->vfp = 4; config->vbp = 2; config->polarityFlags = kELCDIF_VsyncActiveLow | kELCDIF_HsyncActiveLow | kELCDIF_DataEnableActiveLow | kELCDIF_DriveDataOnFallingClkEdge; config->bufferAddr = 0U; config->pixelFormat = kELCDIF_PixelFormatRGB888; config->dataBus = kELCDIF_DataBus24Bit; @code * * @param config Pointer to the eLCDIF configuration structure. */ void ELCDIF_RgbModeGetDefaultConfig(elcdif_rgb_mode_config_t *config); /*! * @brief Deinitializes the eLCDIF peripheral. * * @param base eLCDIF peripheral base address. */ void ELCDIF_Deinit(LCDIF_Type *base); /* @} */ /*! * @name Module operation * @{ */ /*! * @brief Set the pixel format in RGB (DOTCLK) mode. * * @param base eLCDIF peripheral base address. * @param pixelFormat The pixel format. */ void ELCDIF_RgbModeSetPixelFormat(LCDIF_Type *base, elcdif_pixel_format_t pixelFormat); /*! * @brief Start to display in RGB (DOTCLK) mode. * * @param base eLCDIF peripheral base address. */ static inline void ELCDIF_RgbModeStart(LCDIF_Type *base) { base->CTRL_SET = LCDIF_CTRL_RUN_MASK | LCDIF_CTRL_DOTCLK_MODE_MASK; } /*! * @brief Stop display in RGB (DOTCLK) mode and wait until finished. * * @param base eLCDIF peripheral base address. */ void ELCDIF_RgbModeStop(LCDIF_Type *base); /*! * @brief Set the next frame buffer address to display. * * @param base eLCDIF peripheral base address. * @param bufferAddr The frame buffer address to set. */ static inline void ELCDIF_SetNextBufferAddr(LCDIF_Type *base, uint32_t bufferAddr) { base->NEXT_BUF = bufferAddr; } /*! * @brief Reset the eLCDIF peripheral. * * @param base eLCDIF peripheral base address. */ void ELCDIF_Reset(LCDIF_Type *base); #if !(defined(FSL_FEATURE_LCDIF_HAS_NO_RESET_PIN) && FSL_FEATURE_LCDIF_HAS_NO_RESET_PIN) /*! * @brief Pull up or down the reset pin for the externel LCD controller. * * @param base eLCDIF peripheral base address. * @param pullUp True to pull up reset pin, false to pull down. */ static inline void ELCDIF_PullUpResetPin(LCDIF_Type *base, bool pullUp) { if (pullUp) { base->CTRL1_SET = LCDIF_CTRL1_RESET_MASK; } else { base->CTRL1_CLR = LCDIF_CTRL1_RESET_MASK; } } #endif /*! * @brief Enable or disable the hand shake with PXP. * * @param base eLCDIF peripheral base address. * @param enable True to enable, false to disable. */ static inline void ELCDIF_EnablePxpHandShake(LCDIF_Type *base, bool enable) { if (enable) { base->CTRL_SET = LCDIF_CTRL_ENABLE_PXP_HANDSHAKE_MASK; } else { base->CTRL_CLR = LCDIF_CTRL_ENABLE_PXP_HANDSHAKE_MASK; } } /* @} */ /*! * @name Status * @{ */ /*! * @brief Get the CRC value of the frame sent out. * * When a frame is sent complete (the interrupt @ref kELCDIF_CurFrameDone assert), this function * can be used to get the CRC value of the frame sent. * * @param base eLCDIF peripheral base address. * @return The CRC value. * * @note The CRC value is dependent on the LCD_DATABUS_WIDTH. */ static inline uint32_t ELCDIF_GetCrcValue(LCDIF_Type *base) { return base->CRC_STAT; } /*! * @brief Get the bus master error virtual address. * * When bus master error occurs (the interrupt kELCDIF_BusMasterError assert), this function * can get the virtual address at which the AXI master received an error * response from the slave. * * @param base eLCDIF peripheral base address. * @return The error virtual address. */ static inline uint32_t ELCDIF_GetBusMasterErrorAddr(LCDIF_Type *base) { return base->BM_ERROR_STAT; } /*! * @brief Get the eLCDIF status. * * The status flags are returned as a mask value, application could check the * corresponding bit. Example: * * @code uint32_t statusFlags; statusFlags = ELCDIF_GetStatus(LCDIF); if (kELCDIF_LFifoFull & statusFlags) { } if (kELCDIF_TxFifoEmpty & statusFlags) { } @endcode * * @param base eLCDIF peripheral base address. * @return The mask value of status flags, it is OR'ed value of @ref _elcdif_status_flags. */ static inline uint32_t ELCDIF_GetStatus(LCDIF_Type *base) { return base->STAT & (LCDIF_STAT_LFIFO_FULL_MASK | LCDIF_STAT_LFIFO_EMPTY_MASK | LCDIF_STAT_TXFIFO_FULL_MASK | LCDIF_STAT_TXFIFO_EMPTY_MASK #if defined(LCDIF_STAT_BUSY_MASK) | LCDIF_STAT_BUSY_MASK #endif #if defined(LCDIF_STAT_DVI_CURRENT_FIELD_MASK) | LCDIF_STAT_DVI_CURRENT_FIELD_MASK #endif ); } /*! * @brief Get current count in Latency buffer (LFIFO). * * @param base eLCDIF peripheral base address. * @return The LFIFO current count */ static inline uint32_t ELCDIF_GetLFifoCount(LCDIF_Type *base) { return (base->STAT & LCDIF_STAT_LFIFO_COUNT_MASK) >> LCDIF_STAT_LFIFO_COUNT_SHIFT; } /* @} */ /*! * @name Interrupts * @{ */ /*! * @brief Enables eLCDIF interrupt requests. * * @param base eLCDIF peripheral base address. * @param mask interrupt source, OR'ed value of _elcdif_interrupt_enable. */ static inline void ELCDIF_EnableInterrupts(LCDIF_Type *base, uint32_t mask) { base->CTRL1_SET = (mask & ELCDIF_CTRL1_IRQ_EN_MASK); #if !(defined(FSL_FEATURE_LCDIF_HAS_NO_AS) && FSL_FEATURE_LCDIF_HAS_NO_AS) base->AS_CTRL |= (mask & ELCDIF_AS_CTRL_IRQ_EN_MASK); #endif } /*! * @brief Disables eLCDIF interrupt requests. * * @param base eLCDIF peripheral base address. * @param mask interrupt source, OR'ed value of _elcdif_interrupt_enable. */ static inline void ELCDIF_DisableInterrupts(LCDIF_Type *base, uint32_t mask) { base->CTRL1_CLR = (mask & ELCDIF_CTRL1_IRQ_EN_MASK); #if !(defined(FSL_FEATURE_LCDIF_HAS_NO_AS) && FSL_FEATURE_LCDIF_HAS_NO_AS) base->AS_CTRL &= ~(mask & ELCDIF_AS_CTRL_IRQ_EN_MASK); #endif } /*! * @brief Get eLCDIF interrupt peding status. * * @param base eLCDIF peripheral base address. * @return Interrupt pending status, OR'ed value of _elcdif_interrupt_flags. */ static inline uint32_t ELCDIF_GetInterruptStatus(LCDIF_Type *base) { uint32_t flags; flags = (base->CTRL1 & ELCDIF_CTRL1_IRQ_MASK); #if !(defined(FSL_FEATURE_LCDIF_HAS_NO_AS) && FSL_FEATURE_LCDIF_HAS_NO_AS) flags |= (base->AS_CTRL & ELCDIF_AS_CTRL_IRQ_MASK); #endif return flags; } /*! * @brief Clear eLCDIF interrupt peding status. * * @param base eLCDIF peripheral base address. * @param mask of the flags to clear, OR'ed value of _elcdif_interrupt_flags. */ static inline void ELCDIF_ClearInterruptStatus(LCDIF_Type *base, uint32_t mask) { base->CTRL1_CLR = (mask & ELCDIF_CTRL1_IRQ_MASK); #if !(defined(FSL_FEATURE_LCDIF_HAS_NO_AS) && FSL_FEATURE_LCDIF_HAS_NO_AS) base->AS_CTRL &= ~(mask & ELCDIF_AS_CTRL_IRQ_MASK); #endif } /* @} */ #if !(defined(FSL_FEATURE_LCDIF_HAS_NO_AS) && FSL_FEATURE_LCDIF_HAS_NO_AS) /*! * @name Alpha surface * @{ */ /*! * @brief Set the configuration for alpha surface buffer. * * @param base eLCDIF peripheral base address. * @param config Pointer to the configuration structure. */ void ELCDIF_SetAlphaSurfaceBufferConfig(LCDIF_Type *base, const elcdif_as_buffer_config_t *config); /*! * @brief Set the alpha surface blending configuration. * * @param base eLCDIF peripheral base address. * @param config Pointer to the configuration structure. */ void ELCDIF_SetAlphaSurfaceBlendConfig(LCDIF_Type *base, const elcdif_as_blend_config_t *config); /*! * @brief Set the next alpha surface buffer address. * * @param base eLCDIF peripheral base address. * @param bufferAddr Alpha surface buffer address. */ static inline void ELCDIF_SetNextAlphaSurfaceBufferAddr(LCDIF_Type *base, uint32_t bufferAddr) { base->AS_NEXT_BUF = bufferAddr; } /*! * @brief Set the overlay color key. * * If a pixel in the current overlay image with a color that falls in the range * from the @p colorKeyLow to @p colorKeyHigh range, it will use the process surface * pixel value for that location. * * @param base eLCDIF peripheral base address. * @param colorKeyLow Color key low range. * @param colorKeyHigh Color key high range. * * @note Colorkey operations are higher priority than alpha or ROP operations */ static inline void ELCDIF_SetOverlayColorKey(LCDIF_Type *base, uint32_t colorKeyLow, uint32_t colorKeyHigh) { base->AS_CLRKEYLOW = colorKeyLow; base->AS_CLRKEYHIGH = colorKeyHigh; } /*! * @brief Enable or disable the color key. * * @param base eLCDIF peripheral base address. * @param enable True to enable, false to disable. */ static inline void ELCDIF_EnableOverlayColorKey(LCDIF_Type *base, bool enable) { if (enable) { base->AS_CTRL |= LCDIF_AS_CTRL_ENABLE_COLORKEY_MASK; } else { base->AS_CTRL &= ~LCDIF_AS_CTRL_ENABLE_COLORKEY_MASK; } } /*! * @brief Enable or disable the alpha surface. * * @param base eLCDIF peripheral base address. * @param enable True to enable, false to disable. */ static inline void ELCDIF_EnableAlphaSurface(LCDIF_Type *base, bool enable) { if (enable) { base->AS_CTRL |= LCDIF_AS_CTRL_AS_ENABLE_MASK; } else { base->AS_CTRL &= ~LCDIF_AS_CTRL_AS_ENABLE_MASK; } } /*! * @brief Enable or disable the process surface. * * Process surface is the normal frame buffer. The process surface content * is controlled by @ref ELCDIF_SetNextBufferAddr. * * @param base eLCDIF peripheral base address. * @param enable True to enable, false to disable. */ static inline void ELCDIF_EnableProcessSurface(LCDIF_Type *base, bool enable) { if (enable) { base->AS_CTRL &= ~LCDIF_AS_CTRL_PS_DISABLE_MASK; } else { base->AS_CTRL |= LCDIF_AS_CTRL_PS_DISABLE_MASK; } } /* @} */ #endif /* FSL_FEATURE_LCDIF_HAS_NO_AS */ #if (defined(FSL_FEATURE_LCDIF_HAS_LUT) && FSL_FEATURE_LCDIF_HAS_LUT) /*! * @name LUT * * The Lookup Table (LUT) is used to expand the 8 bits pixel to 24 bits pixel * before output to external displayer. * * There are two 256x24 bits LUT memory in LCDIF, the LSB of frame buffer address * determins which memory to use. * * @{ */ /*! * @brief Enable or disable the LUT. * * @param base eLCDIF peripheral base address. * @param enable True to enable, false to disable. */ static inline void ELCDIF_EnableLut(LCDIF_Type *base, bool enable) { if (enable) { base->LUT_CTRL &= ~LCDIF_LUT_CTRL_LUT_BYPASS_MASK; } else { base->LUT_CTRL |= LCDIF_LUT_CTRL_LUT_BYPASS_MASK; } } /*! * @brief Load the LUT value. * * This function loads the LUT value to the specific LUT memory, user can * specify the start entry index. * * @param base eLCDIF peripheral base address. * @param lut Which LUT to load. * @param startIndex The start index of the LUT entry to update. * @param lutData The LUT data to load. * @param count Count of @p lutData. * @retval kStatus_Success Initialization success. * @retval kStatus_InvalidArgument Wrong argument. */ status_t ELCDIF_UpdateLut( LCDIF_Type *base, elcdif_lut_t lut, uint16_t startIndex, const uint32_t *lutData, uint16_t count); /* @} */ #endif /* FSL_FEATURE_LCDIF_HAS_LUT */ #if defined(__cplusplus) } #endif /* __cplusplus */ /* @} */ #endif /*_FSL_ELCDIF_H_*/
[ "jie.heng@nxp.com" ]
jie.heng@nxp.com
9e778b020a7b122b424fc4a64f489a0fd59c25c5
77cf4be91eb945cacf96e8cc56bec03c97e144d0
/evenint.c
232a3918e7243568191620bd566d7bed14f716e8
[]
no_license
THARANYATHANGAVEL/hai-dear
a3aa72c8b36315206321ff98f04ebbedde5fed79
3642319093c3da442c86e016b5c39d7fb4e71274
refs/heads/master
2021-01-16T18:07:15.441115
2018-04-11T14:14:56
2018-04-11T14:14:56
100,038,034
1
7
null
null
null
null
UTF-8
C
false
false
225
c
#include<stdio.h> #include<conio.h> void main() { int f,l,i; printf("enter the value first number"); scanf("%d",&f); printf("enter last value"); scanf("%d",&l); for(i=f;i<=l;i++) { if(i%2==0) { printf("%d",i); } } getch(); }
[ "noreply@github.com" ]
noreply@github.com
5db7b7772830f1476bd1d8df4109aad3f0f5a622
863f370574674bfcdc79961a4b1589778d6c2624
/charData.c
aa2272ccfbfdd60b293bca18134168435a8e11ae
[]
no_license
NoMan2000/c-prog
df94aec681a41567093f1b24bbdae5359516cea7
6e20d0d98e772d0f37f32078ff6aecdbb1c8b4d2
refs/heads/master
2021-01-16T19:20:25.993495
2013-10-02T20:13:38
2013-10-02T20:13:38
null
0
0
null
null
null
null
UTF-8
C
false
false
188
c
#include <stdio.h> #include <cstring> int main() { char firstName[20]; strcpy(firstName, "Michael"); printf("Your first name is %s", firstName); return(0); }
[ "msoileau@itt-tech.edu" ]
msoileau@itt-tech.edu
3bcfe912e2c48183513153ec1e084967483f23ef
4d09e33424a0cee1605701fc905e4c5585044000
/C_Projects/ft_printf/src/help_functions2.c
0748ba72435d1c2714fb933b78909bede1e3a2cf
[]
no_license
BenjaminLaine/projects
c0e01adfa827aba51b1b3373215b667cfa2f7752
c324881a7a644c7dbe342969efce37eb0a189b92
refs/heads/main
2023-02-24T03:52:13.782997
2021-02-04T08:55:55
2021-02-04T08:55:55
328,151,926
0
0
null
null
null
null
UTF-8
C
false
false
2,432
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* help_functions2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: blaine <blaine@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/29 15:36:38 by blaine #+# #+# */ /* Updated: 2020/01/29 18:31:22 by blaine ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf.h" void ft_des(int *len, int *prec, long double *nb, long double num) { if ((*len - 1) < *prec) { if (num > (long double)-1 && num < (long double)1) *len = *prec + 2; else *len += *prec - 1; } if (*nb > (long double)18446744073709551615.0) { num = (num < 0) ? -num : num; *len = *prec + 1 + ft_f_count((unsigned long long)num); } (*nb == 0.500000) ? *len = *prec + 2 : 1; ((*len - 1) == *prec) ? *len += 1 : 1; (*prec == 0) ? *len -= 1 : 1; } char *ft_ftoa(long double num, int prec) { long double nb; char *str; int len; int neg; neg = (num < 0) ? 1 : 0; nb = (num < 0) ? -num : num; prec = (prec == -1) ? 6 : prec; nb = ft_change_prec(prec, nb); nb += 0.5000000; len = ft_f_count((unsigned long long)nb) + 1; ft_des(&len, &prec, &nb, num); if (!(str = (char *)ft_strnew(len + neg))) return (NULL); while ((len-- + neg > 0)) { str[len + neg] = (((unsigned long long)nb % 10) + 48); (--prec == 0 && len > neg) ? str[--len + neg] = '.' : 1; nb /= 10; } neg == 1 ? str[0] = '-' : 1; return (str); } void ft_putnstr(t_stf *stf, int i, int n) { stf->printed += n; write(1, stf->str + i, n); } void ft_putunbr(unsigned long long n) { char str[20]; int z; unsigned long long num; z = n < 0 ? 2 : 1; num = n < 0 ? -n : n; str[0] = z == 2 ? '-' : 1; while (((n > 0) || (n < 0)) && (n = n < 0 ? ((n * -1) / 10) : (n / 10))) z++; str[z] = '\0'; while ((str[0] == '-' ? z > 1 : z > 0) && (str[--z] = ((num % 10) + 48))) num /= 10; ft_putstr(str); }
[ "benjaminlaine@hotmail.com" ]
benjaminlaine@hotmail.com
f87e6ea06fb1bd1da03641948cd311c077adaef4
b9c44d43f69fd3e6eea09cff9d33ccb77d00b001
/UVA10341.c
dcc345281cdf54e71b9718747337af0d31883296
[]
no_license
harryramsey/UVA-Online
e04b924aec2079d0b4a918267276cda03b9b58f4
32062582ec0c5e110c1a7fd7ddbd750091e0bd6c
refs/heads/master
2021-01-21T12:35:50.591520
2015-09-18T04:08:21
2015-09-18T04:08:21
23,942,293
0
0
null
null
null
null
UTF-8
C
false
false
1,017
c
#include <stdio.h> #include <stdlib.h> #include <math.h> double fun(double p, double q, double r, double s, double t, double u, double x) { return p*exp(-x) + q*sin(x) + r*cos(x) + s*tan(x) + t*x*x + u; } void secant(double pcoeff, double q, double r, double s, double t, double u){ double tol = 0.00000001; double p = 0, q0 = 0, q1 = 0, p0 = 0, p1 = 1; if (fun(pcoeff,q,r,s,t,u,0) * fun(pcoeff,q,r,s,t,u,1) > 0){ printf("No solution\n"); } else if (pcoeff == 0.0 && q == 0.0 && r == 0.0 && s == 0.0 && s == 0.0 && t == 0.0 && u == 0.0){ printf("0.0000\n"); } else { while (1){ q0 = fun(pcoeff,q,r,s,t,u,p0); q1 = fun(pcoeff,q,r,s,t,u,p1); p = p1-q1*(p1-p0)/(q1-q0); if (fabs(p-p1) < tol){ printf("%.4lf\n",p); break; } p0 = p1; q0 = q1; p1 = p; q1 = fun(pcoeff,q,r,s,t,u,p1); } } } int main() { double p,q,r,s,t,u; while(scanf("%lf %lf %lf %lf %lf %lf", &p, &q, &r, &s, &t, &u) == 6){ secant(p,q,r,s,t,u); } return 0; }
[ "hbramsey@live.unc.edu" ]
hbramsey@live.unc.edu
7c4fd607ae87f32065be8efdbc63793683534436
13b21706e7ed4dc1291c88c9ad62c88de4320b9b
/Projects/Shark/Reload.h
51ed1406b59d46a6f31602d9c24af0e43f1a3f91
[ "MIT" ]
permissive
fadinglr/Shark
dcbf1139433ecd8bb62d70e48b93a510215597a4
0a62f87eb5ea6f8b963775e8be2481f3b5a8a31a
refs/heads/master
2023-04-27T01:40:14.289676
2021-04-27T02:06:10
2021-04-27T02:06:10
319,513,746
0
0
MIT
2021-04-27T02:06:11
2020-12-08T03:23:56
null
UTF-8
C
false
false
10,178
h
/* * * Copyright (c) 2015 - 2021 by blindtiger. All rights reserved. * * The contents of this file are subject to the Mozilla Public 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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. SEe the License * for the specific language governing rights and limitations under the * License. * * The Initial Developer of the Original e is blindtiger. * */ #ifndef _RELOAD_H_ #define _RELOAD_H_ #include <guarddefs.h> #include <devicedefs.h> #include <dump.h> #include "Space.h" #ifdef __cplusplus /* Assume byte packing throughout */ extern "C" { #endif /* __cplusplus */ typedef LONG EX_SPIN_LOCK, *PEX_SPIN_LOCK; typedef enum _OB_PREOP_CALLBACK_STATUS OB_PREOP_CALLBACK_STATUS; typedef struct _OB_PRE_OPERATION_INFORMATION *POB_PRE_OPERATION_INFORMATION; typedef struct _OB_POST_OPERATION_INFORMATION *POB_POST_OPERATION_INFORMATION; typedef struct _GPBLOCK { PLIST_ENTRY PsLoadedModuleList; PEPROCESS PsInitialSystemProcess; PERESOURCE PsLoadedModuleResource; struct _FUNCTION_TABLE * PsInvertedFunctionTable; KSERVICE_TABLE_DESCRIPTOR * KeServiceDescriptorTable; KSERVICE_TABLE_DESCRIPTOR * KeServiceDescriptorTableShadow; PKLDR_DATA_TABLE_ENTRY KernelDataTableEntry; // ntoskrnl.exe PKLDR_DATA_TABLE_ENTRY CoreDataTableEntry; // self ptr CpuControlBlock; // hypervisor ptr NativeObject; #ifdef _WIN64 ptr Wx86NativeObject; #endif // _WIN64 LIST_ENTRY LoadedPrivateImageList; LIST_ENTRY ObjectList; KSPIN_LOCK ObjectLock; s8 NumberProcessors; s8 Linkage[3];// { 0x33, 0xc0, 0xc3 }; s32 BuildNumber; u32 Flags; u64 * PerfGlobalGroupMask; s8 KiSystemServiceCopyEnd[6]; cptr PerfInfoLogSysCallEntry; ptr KeUserExceptionDispatcher; #ifdef _WIN64 PMMPTE PxeBase; PMMPTE PxeTop; PMMPTE PpeBase; PMMPTE PpeTop; #endif // _WIN64 PMMPTE PdeBase; PMMPTE PdeTop; PMMPTE PteBase; PMMPTE PteTop; void (NTAPI * KiDispatchException)( __in PEXCEPTION_RECORD ExceptionRecord, __in PKEXCEPTION_FRAME ExceptionFrame, __in PKTRAP_FRAME TrapFrame, __in KPROCESSOR_MODE PreviousMode, __in b FirstChance ); void (NTAPI * KeContextFromKframes)( __in PKTRAP_FRAME TrapFrame, #if defined(_X86_) __in_opt PKEXCEPTION_FRAME ExceptionFrame, #else __in PKEXCEPTION_FRAME ExceptionFrame, #endif __inout PCONTEXT ContextFrame ); void (NTAPI * KeContextToKframes)( __inout PKTRAP_FRAME TrapFrame, #if defined(_X86_) __inout_opt PKEXCEPTION_FRAME ExceptionFrame, #else __inout PKEXCEPTION_FRAME ExceptionFrame, #endif __in PCONTEXT ContextFrame, __in u32 ContextFlags, __in KPROCESSOR_MODE PreviousMode ); #ifndef _WIN64 status (NTAPI * DbgkpSendApiMessageLpc)( __inout ptr ApiMsg, __in ptr Port, __in b SuspendProcess ); status (FASTCALL * FastDbgkpSendApiMessageLpc)( __inout ptr ApiMsg, __in ptr Port, __in b SuspendProcess ); #else status (FASTCALL * DbgkpSendApiMessageLpc)( __inout ptr ApiMsg, __in ptr Port, __in b SuspendProcess ); #endif // !_WIN64 OB_PREOP_CALLBACK_STATUS (NTAPI * GlobalObjectPreCallback)( __in ptr RegistrationContext, __in POB_PRE_OPERATION_INFORMATION OperationInformation ); void (NTAPI * GlobalObjectPostCallback)( __in ptr RegistrationContext, __in POB_POST_OPERATION_INFORMATION OperationInformation ); void (NTAPI * GlobalProcessNotify)( __in ptr ParentId, __in ptr ProcessId, __in b Create ); void (NTAPI * GlobalThreadNotify)( __in ptr ProcessId, __in ptr ThreadId, __in b Create ); void (NTAPI * GlobalImageNotify)( __in PUNICODE_STRING FullImageName, __in ptr ProcessId, __in PIMAGE_INFO ImageInfo ); void (NTAPI * KeEnterCriticalRegion)( void ); void (NTAPI * KeLeaveCriticalRegion)( void ); status (NTAPI * PspCreateThread)( __out ptr * ThreadHandle, __in ACCESS_MASK DesiredAccess, __in_opt POBJECT_ATTRIBUTES ObjectAttributes, __in ptr ProcessHandle, __in PEPROCESS ProcessPointer, __in_opt ptr Reserved, __in_opt PLARGE_INTEGER Cookie, __out_opt PCLIENT_ID ClientId, __in_opt PCONTEXT ThreadContext, __in_opt PINITIAL_TEB InitialTeb, __in b CreateSuspended, __in_opt PKSTART_ROUTINE StartRoutine, __in ptr StartContext ); void (NTAPI * PspInitializeThunkContext)( void ); b (FASTCALL * ExAcquireRundownProtection)( __inout PEX_RUNDOWN_REF RunRef ); void (FASTCALL * ExReleaseRundownProtection)( __inout PEX_RUNDOWN_REF RunRef ); void (FASTCALL * ExWaitForRundownProtectionRelease)( __inout PEX_RUNDOWN_REF RunRef ); KIRQL (NTAPI * ExAcquireSpinLockShared)( __inout PEX_SPIN_LOCK SpinLock ); void (NTAPI * ExReleaseSpinLockShared)( __inout PEX_SPIN_LOCK SpinLock, __in KIRQL OldIrql ); u32 (NTAPI * DbgPrint)( __in PCH Format, ... ); u (NTAPI * RtlCompareMemory)( const void * Destination, const void * Source, u Length ); void (NTAPI * RtlRestoreContext)( __in PCONTEXT ContextRecord, __in_opt struct _EXCEPTION_RECORD *ExceptionRecord ); void (NTAPI * ExQueueWorkItem)( __inout PWORK_QUEUE_ITEM WorkItem, __in WORK_QUEUE_TYPE QueueType ); void (NTAPI * ExFreePoolWithTag)( __in ptr P, __in u32 Tag ); PSAFEGUARD_OBJECT BugCheckHandle; void (NTAPI * KeBugCheckEx)( __in u32 BugCheckCode, __in u P1, __in u P2, __in u P3, __in u P4 ); PLIST_ENTRY (FASTCALL * ExInterlockedRemoveHeadList)( __inout PLIST_ENTRY ListHead, __inout PKSPIN_LOCK Lock ); ptr ObjectCallback; KDDEBUGGER_DATA64 DebuggerDataBlock; KDDEBUGGER_DATA_ADDITION64 DebuggerDataAdditionBlock; u16 OffsetKProcessThreadListHead; u16 OffsetKThreadThreadListEntry; u16 OffsetKThreadWin32StartAddress; u32 OffsetKThreadProcessId; struct _PGBLOCK * PgBlock; } GPBLOCK, *PGPBLOCK; NTKERNELAPI status NTAPI PsAcquireProcessExitSynchronization( __in PEPROCESS Process ); NTKERNELAPI void NTAPI PsReleaseProcessExitSynchronization( __in PEPROCESS Process ); #define FastAcquireRundownProtection(ref) \ GpBlock.ExAcquireRundownProtection((ref)) #define FastReleaseRundownProtection(ref) \ GpBlock.ExReleaseRundownProtection((ref)) #define FastWaitForRundownProtectionRelease(ref) \ GpBlock.ExWaitForRundownProtectionRelease((ref)) #define FastAcquireObjectLock(irql) \ *(irql) = GpBlock.ExAcquireSpinLockShared(&GpBlock.ObjectLock) #define FastReleaseObjectLock(irql) \ GpBlock.ExReleaseSpinLockShared(&GpBlock.ObjectLock, (irql)) VOID NTAPI InitializeGpBlock( __in PGPBLOCK Block ); ULONG NTAPI GetPlatform( __in PVOID ImageBase ); ULONG NTAPI GetTimeStamp( __in PVOID ImageBase ); USHORT NTAPI GetSubsystem( __in PVOID ImageBase ); ULONG NTAPI GetSizeOfImage( __in PVOID ImageBase ); PVOID NTAPI GetAddressOfEntryPoint( __in PVOID ImageBase ); PIMAGE_SECTION_HEADER NTAPI SectionTableFromVirtualAddress( __in PVOID ImageBase, __in PVOID Address ); PIMAGE_SECTION_HEADER NTAPI FindSection( __in PVOID ImageBase, __in PCSTR SectionName ); NTSTATUS NTAPI FindEntryForKernelImage( __in PUNICODE_STRING ImageFileName, __out PKLDR_DATA_TABLE_ENTRY * DataTableEntry ); NTSTATUS NTAPI FindEntryForKernelImageAddress( __in PVOID Address, __out PKLDR_DATA_TABLE_ENTRY * DataTableEntry ); extern PGPBLOCK GpBlock; #ifdef __cplusplus } #endif /* __cplusplus */ #endif // !_RELOAD_H_
[ "blindtiger@foxmail.com" ]
blindtiger@foxmail.com
96da62af45a6379c5b8c44c233ce6528905d61d7
48a400042c41feb1b305da0aff3b8a2ad535bdc1
/clang/test/RC99/CodeGen/irf-sub-02.c
ef52b4a29131feab34bcf99426fa245f027828b7
[ "Apache-2.0", "LLVM-exception", "NCSA" ]
permissive
Daasin/tpc_llvm
d9942f0a031213ba5f23e2053d04c3649aa67b03
ece488f96ae81dd9790f07438a949407dc87ef66
refs/heads/main
2023-07-29T16:10:36.488513
2021-08-23T10:38:48
2021-09-10T05:48:53
null
0
0
null
null
null
null
UTF-8
C
false
false
407
c
// RUN: %codegen -S -O1 -triple tpc-none-none -std=rc99 %s -o - | FileCheck %s void main(int src, int src1, int src2) { int64 val = src; int cnt = 0; int5 ndx1 = { src, src, src, src, src }; while (cnt > src2) { i32_st_tnsr_i_v_b(ndx1, 1, val, 1, 0); ndx1[3] -= 10; } } // CHECK: st_tnsr 0x1, [[NDX:%I[0-9]+]], %V{{[0-9]+}}, %SP{{[0-9]+}} // CHECK: add.i32 b01000 %I2, -0xa, %I2, %SP0
[ "ogabbay@kernel.org" ]
ogabbay@kernel.org
9599475ac5875a9c5fa0a0f563aee79bb4b2d68d
65e8e9886d6a6ac18e76809b3153d62aaff1a4ad
/socket_test/net_test/client.c
a630e02b185cba6e6e53f1f79c9323d00086fa0c
[]
no_license
Greatjackson/test
e7c0cacd968628fc3ab516d0bd5ddbefc9c5bbdb
e9ffb5aecfe96f042a2f7102df41fdea52fbb77b
refs/heads/master
2023-01-14T05:24:21.310828
2020-11-24T08:45:27
2020-11-24T08:45:27
50,358,034
0
0
null
null
null
null
UTF-8
C
false
false
1,103
c
/************************************************************************* > File Name: client.c > Author: liugang > Mail: 308584349@163.com > Created Time: Sat 26 Sep 2020 10:07:32 PM CST ************************************************************************/ #include <stdio.h> #include <string.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include "wrap.h" #define MAXLINE 80 #define SERV_PORT 8000 int main(int argc, char *argv[]) { struct sockaddr_in servaddr; char buf[MAXLINE]; int sockfd, n; sockfd = Socket(AF_INET, SOCK_STREAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_pton(AF_INET, "192.168.93.128", &servaddr.sin_addr); servaddr.sin_port = htons(SERV_PORT); Connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); while (fgets(buf, MAXLINE, stdin)!= NULL) { Write (sockfd, buf, strlen(buf)); n = Read(sockfd, buf, MAXLINE); if (n == 0) printf("the other side has been closed.\n"); else Write(STDOUT_FILENO, buf, n); } Close(sockfd); return 0; }
[ "308584349@163.com" ]
308584349@163.com
1d13319c0abacec7a7884e288d607b1f790a4d41
7e07ea939d0717c416b1306258e519b94fb53efb
/main_strncmp.c
d5d4fd111930eaae249ca77458a0bd993fb41c92
[]
no_license
mduma123/Main-Programs_libft
08fd73903a743c24cf5899b9a404f3a9d308832f
c96cc621b6a024ea932e5a107c94989ff55e78f8
refs/heads/master
2020-06-06T10:52:52.541570
2019-06-24T11:06:19
2019-06-24T11:06:19
192,720,340
4
0
null
null
null
null
UTF-8
C
false
false
1,378
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main_strncmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mduma <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/06/12 16:17:20 by mduma #+# #+# */ /* Updated: 2019/06/12 16:23:00 by mduma ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include "libft.h" //Compare two strings, up to a given length //Returns < 0 s1 is less than s2 .0 s1 is equal to s2 .> 0s1 is greater than s2. int main( void ) { printf( "%d\n", ft_strncmp( "abcdef", "abcDEF", 10 ) ); printf( "%d\n", ft_strncmp( "abcdef", "abcDEF", 6 ) ); printf( "%d\n", ft_strncmp( "abcdef", "abcDEF", 3 ) ); printf( "%d\n", ft_strncmp( "abcdef", "abcDEF", 0 ) ); return (0); }
[ "mduma@c5r10s8.wethinkcode.co.za" ]
mduma@c5r10s8.wethinkcode.co.za
99ac395fe9f250c485f763d5cc1a616351eb417c
3d5d50bf1e4ea7c67b86f3de44b03e6a0ce0a0be
/Robot/Velho/SENSOR.C
ad6f001984b41e81d3790256bd4fa3d04d2883a6
[]
no_license
mzani/main
1df9ff4640a5167732052d18f757bbc07aa7571d
e1a1e024888435d28c2b4766a24931c61b85c087
refs/heads/master
2020-03-31T15:27:54.115404
2018-12-05T01:02:47
2018-12-05T01:02:47
152,338,053
0
0
null
null
null
null
ISO-8859-1
C
false
false
11,929
c
/*****************************************************************/ /* Programa........: Robot */ /*----------------------------------------------------------------*/ /* Módulo..........: robot.c */ /*----------------------------------------------------------------*/ /* Início..........: 01/03/2007 */ /* Autor...........: Marcelo Tadeu Marchesoni Zani */ /*----------------------------------------------------------------*/ /* Última alteração: 13/03/2007 */ /* Responsável.....: Marcelo Tadeu Marchesoni Zani */ /*----------------------------------------------------------------*/ /* 01/03/2007, mtmz : Codificação inicial. */ /*----------------------------------------------------------------*/ /* 13/03/2007, mtmz : Mudança na estrutura do programa. */ /*----------------------------------------------------------------*/ /* 22/03/2007, mtmz : Primeiro teste do programa e função */ /* que verifica e mostra sensores */ /* funcionando. */ /******************************************************************/ /*################################################################*/ /* Includes */ /*################################################################*/ #include "8085io.h" #include "8085int.h" #include "C:\USERS\MZani\defines.h" /*################################################################*/ /* Variaveis Globais */ /*################################################################*/ int ValorSensor1; int ValorSensor2; int ValorSensor3; int ValorSensor4; int MostraSensor1; int MostraSensor2; int MostraSensor3; int MostraSensor4; int TeclaPressionada; int FinalizaRobo; /*################################################################*/ /* Rotinas de display */ /*################################################################*/ /******************************************************************/ /* Função: getStatusLCD */ /******************************************************************/ /* Verifica se o visor está livre*/ int getStatusLCD () { // Retorna o flag de busy. return (in(END_DSPL_BUSY) & END_FLG_BUSY) != 0; } /******************************************************************/ /* Função: setCursorLCD */ /******************************************************************/ /* Posiciona o cursor na posicao c da linha l */ int setCursorLCD (int l, int c) { int posicao; if (l == 1) posicao = END_DSPL_PRIM_POS_L_1; else if(l == 2) posicao = END_DSPL_PRIM_POS_L_2; else return FALSE; // Se passar linha errada ignora. if(c > 40 || c < 1) return FALSE; // Se passar uma posicao invalida, ignora. out(END_DSPL, posicao + c - 1); return TRUE; } /******************************************************************/ /* Função: putChrLCD */ /******************************************************************/ /* Escreve um char no display na posicao atual do cursor */ putChrLCD (char c) { while(getStatusLCD()); // Aguarda o display desocupar. out(END_DSPL_WRITE, c); } /******************************************************************/ /* Função: putStrLCD */ /******************************************************************/ /* Escreve uma string no display a partir da posicao atual */ putStrLCD (char *s) { int i; for(i=0; s[i] != '\0'; i++) putChrLCD (s[i]); } /******************************************************************/ /* Função: MostraSensorLed */ /******************************************************************/ /* Escreve os leds no display */ MostraSensorLed(int ValorMedido) { int ValorLed; ValorLed = ValorMedido/VALOR_ESCALA; // Acende os leds correspondentes switch (ValorLed) { case 0: out(END_LEDS, END_1_LED_LIGADO); break; case 1: out(END_LEDS, END_2_LEDS_LIGADOS); break; case 2: out(END_LEDS, END_3_LEDS_LIGADOS); break; case 3: out(END_LEDS, END_4_LEDS_LIGADOS); break; case 4: out(END_LEDS, END_5_LEDS_LIGADOS); break; case 5: out(END_LEDS, END_6_LEDS_LIGADOS); break; case 6: out(END_LEDS, END_7_LEDS_LIGADOS); break; case 7: out(END_LEDS, END_8_LEDS_LIGADOS); break; }// Switch leds. } /*################################################################*/ /* Rotinas de Interrupção */ /*################################################################*/ /******************************************************************/ /* Função: IniciaSensorLed */ /******************************************************************/ /* Função de interrupção que atualiza os sensores.*/ INTERRUPT (32820) IniciaSensorLed () { /* Para quando o robo estiver funcionando.*/ // Le e guarda o valor lido do sensor 1. if (MostraSensor1 == TRUE) { out(END_ROBOT, END_RD_GP2D_1); ValorSensor1 = in(END_ROBOT); } // Le e guarda o valor lido do sensor 2. if (MostraSensor2 == TRUE) { out(END_ROBOT, END_RD_GP2D_2); ValorSensor2 = in(END_ROBOT); } // Le e guarda o valor lido do sensor 3. if (MostraSensor3 == TRUE) { out(END_ROBOT, END_RD_GP2D_3); ValorSensor3 = in(END_ROBOT); } // Le e guarda o valor lido do sensor 4. if (MostraSensor4 == TRUE) { out(END_ROBOT, END_RD_GP2D_4); ValorSensor4 = in(END_ROBOT); } } /*################################################################*/ /* Main */ /*################################################################*/ main () { int tecla, i, ValorSensor; char Sensor; char s[TAM_MSG_TEXTO]; /****************************************************************** Inicializa as Variaveis Globais. ******************************************************************/ ValorSensor1 = 0; ValorSensor2 = 0; ValorSensor3 = 0; ValorSensor4 = 0; MostraSensor1 = FALSE; MostraSensor2 = FALSE; MostraSensor3 = FALSE; MostraSensor4 = FALSE; TeclaPressionada = 0; FinalizaRobo = FALSE; /*****************************************************************/ /****************************************************************** Inicializa as Variaveis Locais. ******************************************************************/ ValorSensor = 0; /*****************************************************************/ /****************************************************************** Inicializa o visor LCD. ******************************************************************/ // 8 bits, 2 linhas, matrix 5x10. out (END_DSPL, END_DSPL_CONFIG); for (i=0 ; i<TEMPO_ESP_INIC; i++); // Desliga o display. out (END_DSPL, END_DSPL_DESLIGA); for (i=0 ; i<TEMPO_ESP_INIC; i++); // Limpa memoria e contador. out (END_DSPL, END_DSPL_LIMPA); for (i=0 ; i<TEMPO_ESP_INIC; i++); // Incrementa contador. out (END_DSPL, END_DSPL_INC); for (i=0 ; i<TEMPO_ESP_INIC; i++); // Liga display com cursor piscando. out (END_DSPL, END_DSPL_LIGA); for (i=0 ; i<TEMPO_ESP_INIC; i++); // Aponta para o endereco 80h - primeira posicao da linha 1. out (END_DSPL, END_DSPL_PRIM_POS_L_1); /*****************************************************************/ printf ("Inicializa Inter \n\n"); /****************************************************************** Inicializa as interupções. ******************************************************************/ // Marca o tempo das interrupções. out(END_ROBOT, END_TMR_MS); out(END_ROBOT, TEMPO_INTERRUPCAO); //Inicializa o timer. out (END_ROBOT, END_TMR_ON); printf ("Inicializa Inter \n\n"); //desmascara asm { mvi A,$1D sim } printf ("Inicializa Inter \n\n"); //Habilita enable(); printf ("Inicializa Inter \n\n"); /*****************************************************************/ printf ("Inicia Loop\n\n"); /****************************************************************** Loop Principal. ******************************************************************/ while (TRUE) { /***************************************************************** Verifica se há alguma tecla pressionada. *****************************************************************/ // Pega ultima tecla pressionada. tecla = in(END_TECLAS); /****************************************************************/ /******************************************************************* Sinaliza os flags de teclas. *******************************************************************/ switch (TeclaPressionada) { case VALOR_TECLA_1: // Tecla verifica o sensor 1 MostraSensor1 = TRUE; break; case VALOR_TECLA_2: MostraSensor2 = TRUE; break; case VALOR_TECLA_3: MostraSensor3 = TRUE; break; case VALOR_TECLA_4: MostraSensor4 = TRUE; break; case VALOR_TECLA_5: break; case VALOR_TECLA_6: break; case VALOR_TECLA_7: break; case VALOR_TECLA_8:// Tecla de Saida. FinalizaRobo = TRUE; break; }// Switch. /******************************************************************/ /***************************************************************** Posiciona e escreve o sensor no display e nos leds. *****************************************************************/ if (MostraSensor1) { Sensor = '1'; ValorSensor = ValorSensor1; } if (MostraSensor2) { Sensor = '2'; ValorSensor = ValorSensor2; } if (MostraSensor3) { Sensor = '3'; ValorSensor = ValorSensor3; } if (MostraSensor4) { Sensor = '4'; ValorSensor = ValorSensor4; } //Verifico se devo escrever Sensor 1 no display if ((MostraSensor1 == TRUE) || (MostraSensor2 == TRUE) || (MostraSensor3 == TRUE) || (MostraSensor4 == TRUE) ) { setCursorLCD(1,8); if (in(END_DSPL_READ) != Sensor) { setCursorLCD(1,1); sprintf(s, "Sensor %c", Sensor); putStrLCD(s); } } if (ValorSensor != 0) { MostraSensorLed (ValorSensor); } printf("%d %d %d %d\n", ValorSensor1, ValorSensor2, ValorSensor3, ValorSensor4); /****************************************************************/ /***************************************************************** Finalizo o robo, a interrupção, os leds e o display. *****************************************************************/ if (FinalizaRobo == TRUE) { // Para o Robo. out(END_ROBOT, STOP); // Desabilita Interrupções. disable(); out (0xf0, 0x51); // Apaga os Leds. out (END_LEDS, END_0_LEDS_LIGADOS); while (getStatusLCD()); // Aguarda o display ser liberado. // Desliga o display. out (END_DSPL, END_DSPL_DESLIGA); break; } /****************************************************************/ /***************************************************************** Confirma tecla pressionada e reinicia os flags. *****************************************************************/ if(tecla) { if( (tecla == in(END_TECLAS)) ) { TeclaPressionada = tecla; // Reseta os flags de Controle de sensor MostraSensor1 = FALSE; MostraSensor2 = FALSE; MostraSensor3 = FALSE; MostraSensor4 = FALSE; } } /******************************************************************/ }// While Principal. /******************************************************************/ }
[ "zani.marcelo@gmail.com" ]
zani.marcelo@gmail.com
56d59f7a24c21bfa9482c5381203f92b49776ffa
aced0b0b4b73ecb9837500a9b65eb039033e94d3
/Win10_1511_TS2/x64/System32/hal.dll/ALL_SORTED.h
e7faf7a4bbc814dd7a71ba6d568333f4373508a0
[]
no_license
Qazwar/headers
a16193b7343f8497c4dde1f0eb6fee52a0ed91e1
049e8a564a1f82a8316f187f8a8bbcdb29be5e01
refs/heads/master
2020-04-05T15:36:20.462296
2018-11-08T18:53:40
2018-11-08T20:37:03
null
0
0
null
null
null
null
UTF-8
C
false
false
164,009
h
enum BUS_QUERY_ID_TYPE; enum DEVICE_TEXT_TYPE; struct LIST_ENTRY32; struct LIST_ENTRY64; struct POHANDLE__; enum POWER_ACTION; struct _ACCESS_STATE; struct _ACPI_CACHED_TABLE; struct _CM_FULL_RESOURCE_DESCRIPTOR; struct _CM_PARTIAL_RESOURCE_DESCRIPTOR; struct _CM_PARTIAL_RESOURCE_LIST; struct _CM_RESOURCE_LIST; struct _COMPRESSED_DATA_INFO; struct _CONTEXT; struct _CONTROLLER_OBJECT; struct _DESCRIPTION_HEADER; struct _DEVICE_CAPABILITIES; struct _DEVICE_OBJECT; struct _DEVICE_OBJECT_POWER_EXTENSION; enum _DEVICE_POWER_STATE; enum _DEVICE_RELATION_TYPE; enum _DEVICE_USAGE_NOTIFICATION_TYPE; enum _DEVICE_WAKE_DEPTH; struct _DEVOBJ_EXTENSION; struct _DISPATCHER_HEADER; struct _DRIVER_EXTENSION; struct _DRIVER_OBJECT; struct _ECP_LIST; struct _EPROCESS; struct _ERESOURCE; struct _ESILO; struct _ETHREAD; struct _EVENT_DATA_DESCRIPTOR; struct _EVENT_DESCRIPTOR; enum _EVENT_TYPE; enum _EXCEPTION_DISPOSITION; struct _EXCEPTION_RECORD; struct _EXCEPTION_REGISTRATION_RECORD; struct _EXT_DELETE_PARAMETERS; struct _EXT_SET_PARAMETERS_V0; struct _FACS; struct _FADT; struct _FAST_IO_DISPATCH; struct _FAST_MUTEX; struct _FILE_BASIC_INFORMATION; struct _FILE_GET_QUOTA_INFORMATION; enum _FILE_INFORMATION_CLASS; struct _FILE_NETWORK_OPEN_INFORMATION; struct _FILE_OBJECT; struct _FILE_STANDARD_INFORMATION; enum _FSINFOCLASS; struct _GENERAL_LOOKASIDE; struct _GENERAL_LOOKASIDE_POOL; struct _GEN_ADDR; struct _GROUP_AFFINITY; struct _GUID; struct _HALP_ALLOC_CONTEXT; enum _HALP_DMA_MAP_BUFFER_TYPE; enum _HAL_DMA_CRASH_DUMP_REGISTER_TYPE; struct _HAL_HV_SVM_DEVICE_CAPABILITIES; struct _HAL_HV_SVM_SYSTEM_CAPABILITIES; enum _HAL_INIT_PHASE; struct _HAL_INTEL_ENLIGHTENMENT_INFORMATION; struct _HARDWARE_PTE; struct _INITIAL_PRIVILEGE_SET; struct _INTERFACE; enum _INTERFACE_TYPE; enum _INTERLOCKED_RESULT; struct _INTERRUPT_FUNCTION_TABLE; struct _INTERRUPT_LINE; struct _INTERRUPT_LINE_STATE; enum _INTERRUPT_PROBLEM; enum _INTERRUPT_RESULT; struct _INTERRUPT_TARGET; enum _INTERRUPT_TARGET_TYPE; struct _IOAPIC; struct _IOSAPIC; enum _IO_ALLOCATION_ACTION; struct _IO_APIC_DATA; struct _IO_APIC_REGISTERS; struct _IO_COMPLETION_CONTEXT; struct _IO_DRIVER_CREATE_CONTEXT; struct _IO_NMISOURCE; struct _IO_RESOURCE_DESCRIPTOR; struct _IO_RESOURCE_LIST; struct _IO_RESOURCE_REQUIREMENTS_LIST; struct _IO_SECURITY_CONTEXT; struct _IO_STACK_LOCATION; struct _IO_STATUS_BLOCK; struct _IO_TIMER; struct _IRP; enum _IRQ_PRIORITY; struct _ISA_VECTOR; struct _KAFFINITY_EX; struct _KAPC; struct _KDESCRIPTOR; struct _KDEVICE_QUEUE; struct _KDEVICE_QUEUE_ENTRY; struct _KDPC; struct _KEVENT; struct _KFLOATING_SAVE; union _KGDTENTRY64; union _KIDTENTRY64; enum _KINTERRUPT_MODE; enum _KINTERRUPT_POLARITY; struct _KNODE; enum _KNOWN_CONTROLLER_TYPE; struct _KPCR; struct _KPRCB; struct _KPROCESS; struct _KPROCESSOR_STATE; struct _KSPECIAL_REGISTERS; struct _KSPIN_LOCK_QUEUE; struct _KTB_FLUSH_VA; struct _KTHREAD; struct _KTSS64; struct _KWAIT_CHAIN; union _LARGE_INTEGER; struct _LIST_ENTRY; struct _LOCAL_NMISOURCE; struct _LOOKASIDE_LIST_EX; struct _LUID; struct _LUID_AND_ATTRIBUTES; struct _M128A; struct _MAILSLOT_CREATE_PARAMETERS; struct _MAPIC; union _MCG_STATUS; union _MCI_STATUS; struct _MDL; enum _MEMORY_CACHING_TYPE; enum _MEMORY_CACHING_TYPE_ORIG; enum _MODE; struct _NAMED_PIPE_CREATE_PARAMETERS; struct _NPAGED_LOOKASIDE_LIST; struct _NT_TIB; struct _OWNER_ENTRY; struct _PAGED_LOOKASIDE_LIST; struct _PLATFORM_INTERRUPT; enum _POOL_TYPE; struct _POWER_SEQUENCE; union _POWER_STATE; enum _POWER_STATE_TYPE; struct _PRIVILEGE_SET; struct _PROCLOCALAPIC; struct _PROCLOCALSAPIC; struct _REGISTERED_INTERRUPT_CONTROLLER; enum _REG_NOTIFY_CLASS; struct _RSDP; struct _RSDT_32; struct _RTL_AVL_TREE; struct _RTL_BALANCED_NODE; struct _RTL_BITMAP; struct _RTL_DYNAMIC_HASH_TABLE; struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT; struct _RTL_DYNAMIC_HASH_TABLE_ENTRY; struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR; struct _RTL_QUERY_REGISTRY_TABLE; struct _RTL_RB_TREE; struct _RTL_SPLAY_LINKS; struct _SCSI_REQUEST_BLOCK; struct _SECONDARY_IC_LIST_ENTRY; struct _SECONDARY_INTERRUPT_LINE_STATE; struct _SECONDARY_INTERRUPT_PROVIDER_INTERFACE; struct _SECTION_OBJECT_POINTERS; enum _SECURITY_IMPERSONATION_LEVEL; struct _SECURITY_QUALITY_OF_SERVICE; struct _SECURITY_SUBJECT_CONTEXT; struct _SINGLE_LIST_ENTRY; struct _SLIST_ENTRY; union _SLIST_HEADER; struct _STRING; enum _SYSTEM_POWER_STATE; struct _SYSTEM_POWER_STATE_CONTEXT; struct _TXN_PARAMETER_BLOCK; union _ULARGE_INTEGER; struct _UNICODE_STRING; enum _USER_ACTIVITY_PRESENCE; struct _VPB; struct _WAIT_CONTEXT_BLOCK; enum _WHEA_CPU_VENDOR; enum _WHEA_ERROR_PACKET_DATA_FORMAT; union _WHEA_ERROR_PACKET_FLAGS; struct _WHEA_ERROR_PACKET_V2; struct _WHEA_ERROR_RECORD; struct _WHEA_ERROR_RECORD_HEADER; union _WHEA_ERROR_RECORD_HEADER_FLAGS; union _WHEA_ERROR_RECORD_HEADER_VALIDBITS; struct _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR; union _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS; union _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS; enum _WHEA_ERROR_SEVERITY; enum _WHEA_ERROR_SOURCE_TYPE; enum _WHEA_ERROR_TYPE; union _WHEA_PERSISTENCE_INFO; struct _WHEA_PROCESSOR_GENERIC_ERROR_SECTION; union _WHEA_PROCESSOR_GENERIC_ERROR_SECTION_VALIDBITS; struct _WHEA_RECOVERY_CONTEXT; union _WHEA_REVISION; union _WHEA_TIMESTAMP; struct _WHEA_XPF_MCA_SECTION; struct _WHEA_XPF_PROCESSOR_ERROR_SECTION; union _WHEA_XPF_PROCESSOR_ERROR_SECTION_VALIDBITS; struct _WORK_QUEUE_ITEM; struct _XSAVE_FORMAT; struct _XSDT; enum BUS_QUERY_ID_TYPE { BusQueryDeviceID = 0, BusQueryHardwareIDs = 1, BusQueryCompatibleIDs = 2, BusQueryInstanceID = 3, BusQueryDeviceSerialNumber = 4, BusQueryContainerID = 5, }; enum DEVICE_TEXT_TYPE { DeviceTextDescription = 0, DeviceTextLocationInformation = 1, }; struct LIST_ENTRY32 { /* 0x0000 */ unsigned long Flink; /* 0x0004 */ unsigned long Blink; }; /* size: 0x0008 */ struct LIST_ENTRY64 { /* 0x0000 */ unsigned __int64 Flink; /* 0x0008 */ unsigned __int64 Blink; }; /* size: 0x0010 */ struct POHANDLE__ { /* 0x0000 */ int unused; }; /* size: 0x0004 */ enum POWER_ACTION { PowerActionNone = 0, PowerActionReserved = 1, PowerActionSleep = 2, PowerActionHibernate = 3, PowerActionShutdown = 4, PowerActionShutdownReset = 5, PowerActionShutdownOff = 6, PowerActionWarmEject = 7, PowerActionDisplayOff = 8, }; typedef struct _ACCESS_STATE { /* 0x0000 */ struct _LUID OperationID; /* 0x0008 */ unsigned char SecurityEvaluated; /* 0x0009 */ unsigned char GenerateAudit; /* 0x000a */ unsigned char GenerateOnClose; /* 0x000b */ unsigned char PrivilegesAllocated; /* 0x000c */ unsigned long Flags; /* 0x0010 */ unsigned long RemainingDesiredAccess; /* 0x0014 */ unsigned long PreviouslyGrantedAccess; /* 0x0018 */ unsigned long OriginalDesiredAccess; /* 0x0020 */ struct _SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; /* 0x0040 */ void* SecurityDescriptor; /* 0x0048 */ void* AuxData; union // _TAG_UNNAMED_1 { union { /* 0x0050 */ struct _INITIAL_PRIVILEGE_SET InitialPrivilegeSet; /* 0x0050 */ struct _PRIVILEGE_SET PrivilegeSet; }; /* size: 0x002c */ } /* size: 0x002c */ Privileges; /* 0x007c */ unsigned char AuditPrivileges; /* 0x0080 */ struct _UNICODE_STRING ObjectName; /* 0x0090 */ struct _UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; /* size: 0x00a0 */ typedef struct _ACPI_CACHED_TABLE { /* 0x0000 */ struct _LIST_ENTRY Links; /* 0x0010 */ union _LARGE_INTEGER PhysicalAddress; /* 0x0018 */ struct _DESCRIPTION_HEADER Header; /* 0x003c */ long __PADDING__[1]; } ACPI_CACHED_TABLE, *PACPI_CACHED_TABLE; /* size: 0x0040 */ typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { /* 0x0000 */ enum _INTERFACE_TYPE InterfaceType; /* 0x0004 */ unsigned long BusNumber; /* 0x0008 */ struct _CM_PARTIAL_RESOURCE_LIST PartialResourceList; } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; /* size: 0x0024 */ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char ShareDisposition; /* 0x0002 */ unsigned short Flags; union // _TAG_UNNAMED_2 { union { struct // _TAG_UNNAMED_3 { /* 0x0004 */ union _LARGE_INTEGER Start; /* 0x000c */ unsigned long Length; } /* size: 0x000c */ Generic; struct // _TAG_UNNAMED_3 { /* 0x0004 */ union _LARGE_INTEGER Start; /* 0x000c */ unsigned long Length; } /* size: 0x000c */ Port; struct // _TAG_UNNAMED_4 { /* 0x0004 */ unsigned short Level; /* 0x0006 */ unsigned short Group; /* 0x0008 */ unsigned long Vector; /* 0x000c */ unsigned __int64 Affinity; } /* size: 0x0010 */ Interrupt; struct // _TAG_UNNAMED_5 { union { struct // _TAG_UNNAMED_6 { /* 0x0004 */ unsigned short Group; /* 0x0006 */ unsigned short MessageCount; /* 0x0008 */ unsigned long Vector; /* 0x000c */ unsigned __int64 Affinity; } /* size: 0x0010 */ Raw; struct // _TAG_UNNAMED_4 { /* 0x0004 */ unsigned short Level; /* 0x0006 */ unsigned short Group; /* 0x0008 */ unsigned long Vector; /* 0x000c */ unsigned __int64 Affinity; } /* size: 0x0010 */ Translated; }; /* size: 0x0010 */ } /* size: 0x0010 */ MessageInterrupt; struct // _TAG_UNNAMED_3 { /* 0x0004 */ union _LARGE_INTEGER Start; /* 0x000c */ unsigned long Length; } /* size: 0x000c */ Memory; struct // _TAG_UNNAMED_7 { /* 0x0004 */ unsigned long Channel; /* 0x0008 */ unsigned long Port; /* 0x000c */ unsigned long Reserved1; } /* size: 0x000c */ Dma; struct // _TAG_UNNAMED_8 { /* 0x0004 */ unsigned long Channel; /* 0x0008 */ unsigned long RequestLine; /* 0x000c */ unsigned char TransferWidth; /* 0x000d */ unsigned char Reserved1; /* 0x000e */ unsigned char Reserved2; /* 0x000f */ unsigned char Reserved3; } /* size: 0x000c */ DmaV3; struct // _TAG_UNNAMED_9 { /* 0x0004 */ unsigned long Data[3]; } /* size: 0x000c */ DevicePrivate; struct // _TAG_UNNAMED_10 { /* 0x0004 */ unsigned long Start; /* 0x0008 */ unsigned long Length; /* 0x000c */ unsigned long Reserved; } /* size: 0x000c */ BusNumber; struct // _TAG_UNNAMED_11 { /* 0x0004 */ unsigned long DataSize; /* 0x0008 */ unsigned long Reserved1; /* 0x000c */ unsigned long Reserved2; } /* size: 0x000c */ DeviceSpecificData; struct // _TAG_UNNAMED_12 { /* 0x0004 */ union _LARGE_INTEGER Start; /* 0x000c */ unsigned long Length40; } /* size: 0x000c */ Memory40; struct // _TAG_UNNAMED_13 { /* 0x0004 */ union _LARGE_INTEGER Start; /* 0x000c */ unsigned long Length48; } /* size: 0x000c */ Memory48; struct // _TAG_UNNAMED_14 { /* 0x0004 */ union _LARGE_INTEGER Start; /* 0x000c */ unsigned long Length64; } /* size: 0x000c */ Memory64; struct // _TAG_UNNAMED_15 { /* 0x0004 */ unsigned char Class; /* 0x0005 */ unsigned char Type; /* 0x0006 */ unsigned char Reserved1; /* 0x0007 */ unsigned char Reserved2; /* 0x0008 */ unsigned long IdLowPart; /* 0x000c */ unsigned long IdHighPart; } /* size: 0x000c */ Connection; }; /* size: 0x0010 */ } /* size: 0x0010 */ u; } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR; /* size: 0x0014 */ typedef struct _CM_PARTIAL_RESOURCE_LIST { /* 0x0000 */ unsigned short Version; /* 0x0002 */ unsigned short Revision; /* 0x0004 */ unsigned long Count; /* 0x0008 */ struct _CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; /* size: 0x001c */ typedef struct _CM_RESOURCE_LIST { /* 0x0000 */ unsigned long Count; /* 0x0004 */ struct _CM_FULL_RESOURCE_DESCRIPTOR List[1]; } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; /* size: 0x0028 */ struct _COMPRESSED_DATA_INFO; typedef struct _CONTEXT { /* 0x0000 */ unsigned __int64 P1Home; /* 0x0008 */ unsigned __int64 P2Home; /* 0x0010 */ unsigned __int64 P3Home; /* 0x0018 */ unsigned __int64 P4Home; /* 0x0020 */ unsigned __int64 P5Home; /* 0x0028 */ unsigned __int64 P6Home; /* 0x0030 */ unsigned long ContextFlags; /* 0x0034 */ unsigned long MxCsr; /* 0x0038 */ unsigned short SegCs; /* 0x003a */ unsigned short SegDs; /* 0x003c */ unsigned short SegEs; /* 0x003e */ unsigned short SegFs; /* 0x0040 */ unsigned short SegGs; /* 0x0042 */ unsigned short SegSs; /* 0x0044 */ unsigned long EFlags; /* 0x0048 */ unsigned __int64 Dr0; /* 0x0050 */ unsigned __int64 Dr1; /* 0x0058 */ unsigned __int64 Dr2; /* 0x0060 */ unsigned __int64 Dr3; /* 0x0068 */ unsigned __int64 Dr6; /* 0x0070 */ unsigned __int64 Dr7; /* 0x0078 */ unsigned __int64 Rax; /* 0x0080 */ unsigned __int64 Rcx; /* 0x0088 */ unsigned __int64 Rdx; /* 0x0090 */ unsigned __int64 Rbx; /* 0x0098 */ unsigned __int64 Rsp; /* 0x00a0 */ unsigned __int64 Rbp; /* 0x00a8 */ unsigned __int64 Rsi; /* 0x00b0 */ unsigned __int64 Rdi; /* 0x00b8 */ unsigned __int64 R8; /* 0x00c0 */ unsigned __int64 R9; /* 0x00c8 */ unsigned __int64 R10; /* 0x00d0 */ unsigned __int64 R11; /* 0x00d8 */ unsigned __int64 R12; /* 0x00e0 */ unsigned __int64 R13; /* 0x00e8 */ unsigned __int64 R14; /* 0x00f0 */ unsigned __int64 R15; /* 0x00f8 */ unsigned __int64 Rip; union { /* 0x0100 */ struct _XSAVE_FORMAT FltSave; struct { /* 0x0100 */ struct _M128A Header[2]; /* 0x0120 */ struct _M128A Legacy[8]; /* 0x01a0 */ struct _M128A Xmm0; /* 0x01b0 */ struct _M128A Xmm1; /* 0x01c0 */ struct _M128A Xmm2; /* 0x01d0 */ struct _M128A Xmm3; /* 0x01e0 */ struct _M128A Xmm4; /* 0x01f0 */ struct _M128A Xmm5; /* 0x0200 */ struct _M128A Xmm6; /* 0x0210 */ struct _M128A Xmm7; /* 0x0220 */ struct _M128A Xmm8; /* 0x0230 */ struct _M128A Xmm9; /* 0x0240 */ struct _M128A Xmm10; /* 0x0250 */ struct _M128A Xmm11; /* 0x0260 */ struct _M128A Xmm12; /* 0x0270 */ struct _M128A Xmm13; /* 0x0280 */ struct _M128A Xmm14; /* 0x0290 */ struct _M128A Xmm15; }; /* size: 0x01a0 */ }; /* size: 0x0200 */ /* 0x0300 */ struct _M128A VectorRegister[26]; /* 0x04a0 */ unsigned __int64 VectorControl; /* 0x04a8 */ unsigned __int64 DebugControl; /* 0x04b0 */ unsigned __int64 LastBranchToRip; /* 0x04b8 */ unsigned __int64 LastBranchFromRip; /* 0x04c0 */ unsigned __int64 LastExceptionToRip; /* 0x04c8 */ unsigned __int64 LastExceptionFromRip; } CONTEXT, *PCONTEXT; /* size: 0x04d0 */ typedef struct _CONTROLLER_OBJECT { /* 0x0000 */ short Type; /* 0x0002 */ short Size; /* 0x0008 */ void* ControllerExtension; /* 0x0010 */ struct _KDEVICE_QUEUE DeviceWaitQueue; /* 0x0038 */ unsigned long Spare1; /* 0x0040 */ union _LARGE_INTEGER Spare2; } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; /* size: 0x0048 */ typedef struct _DESCRIPTION_HEADER { /* 0x0000 */ unsigned long Signature; /* 0x0004 */ unsigned long Length; /* 0x0008 */ unsigned char Revision; /* 0x0009 */ unsigned char Checksum; /* 0x000a */ char OEMID[6]; /* 0x0010 */ char OEMTableID[8]; /* 0x0018 */ unsigned long OEMRevision; /* 0x001c */ char CreatorID[4]; /* 0x0020 */ unsigned long CreatorRev; } DESCRIPTION_HEADER, *PDESCRIPTION_HEADER; /* size: 0x0024 */ typedef struct _DEVICE_CAPABILITIES { /* 0x0000 */ unsigned short Size; /* 0x0002 */ unsigned short Version; struct /* bitfield */ { /* 0x0004 */ unsigned long DeviceD1 : 1; /* bit position: 0 */ /* 0x0004 */ unsigned long DeviceD2 : 1; /* bit position: 1 */ /* 0x0004 */ unsigned long LockSupported : 1; /* bit position: 2 */ /* 0x0004 */ unsigned long EjectSupported : 1; /* bit position: 3 */ /* 0x0004 */ unsigned long Removable : 1; /* bit position: 4 */ /* 0x0004 */ unsigned long DockDevice : 1; /* bit position: 5 */ /* 0x0004 */ unsigned long UniqueID : 1; /* bit position: 6 */ /* 0x0004 */ unsigned long SilentInstall : 1; /* bit position: 7 */ /* 0x0004 */ unsigned long RawDeviceOK : 1; /* bit position: 8 */ /* 0x0004 */ unsigned long SurpriseRemovalOK : 1; /* bit position: 9 */ /* 0x0004 */ unsigned long WakeFromD0 : 1; /* bit position: 10 */ /* 0x0004 */ unsigned long WakeFromD1 : 1; /* bit position: 11 */ /* 0x0004 */ unsigned long WakeFromD2 : 1; /* bit position: 12 */ /* 0x0004 */ unsigned long WakeFromD3 : 1; /* bit position: 13 */ /* 0x0004 */ unsigned long HardwareDisabled : 1; /* bit position: 14 */ /* 0x0004 */ unsigned long NonDynamic : 1; /* bit position: 15 */ /* 0x0004 */ unsigned long WarmEjectSupported : 1; /* bit position: 16 */ /* 0x0004 */ unsigned long NoDisplayInUI : 1; /* bit position: 17 */ /* 0x0004 */ unsigned long Reserved1 : 1; /* bit position: 18 */ /* 0x0004 */ unsigned long WakeFromInterrupt : 1; /* bit position: 19 */ /* 0x0004 */ unsigned long Reserved : 12; /* bit position: 20 */ }; /* bitfield */ /* 0x0008 */ unsigned long Address; /* 0x000c */ unsigned long UINumber; /* 0x0010 */ enum _DEVICE_POWER_STATE DeviceState[7]; /* 0x002c */ enum _SYSTEM_POWER_STATE SystemWake; /* 0x0030 */ enum _DEVICE_POWER_STATE DeviceWake; /* 0x0034 */ unsigned long D1Latency; /* 0x0038 */ unsigned long D2Latency; /* 0x003c */ unsigned long D3Latency; } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; /* size: 0x0040 */ typedef struct _DEVICE_OBJECT { /* 0x0000 */ short Type; /* 0x0002 */ unsigned short Size; /* 0x0004 */ long ReferenceCount; /* 0x0008 */ struct _DRIVER_OBJECT* DriverObject; /* 0x0010 */ struct _DEVICE_OBJECT* NextDevice; /* 0x0018 */ struct _DEVICE_OBJECT* AttachedDevice; /* 0x0020 */ struct _IRP* CurrentIrp; /* 0x0028 */ struct _IO_TIMER* Timer; /* 0x0030 */ unsigned long Flags; /* 0x0034 */ unsigned long Characteristics; /* 0x0038 */ struct _VPB* Vpb; /* 0x0040 */ void* DeviceExtension; /* 0x0048 */ unsigned long DeviceType; /* 0x004c */ char StackSize; union // _TAG_UNNAMED_16 { union { /* 0x0050 */ struct _LIST_ENTRY ListEntry; /* 0x0050 */ struct _WAIT_CONTEXT_BLOCK Wcb; }; /* size: 0x0048 */ } /* size: 0x0048 */ Queue; /* 0x0098 */ unsigned long AlignmentRequirement; /* 0x00a0 */ struct _KDEVICE_QUEUE DeviceQueue; /* 0x00c8 */ struct _KDPC Dpc; /* 0x0108 */ unsigned long ActiveThreadCount; /* 0x0110 */ void* SecurityDescriptor; /* 0x0118 */ struct _KEVENT DeviceLock; /* 0x0130 */ unsigned short SectorSize; /* 0x0132 */ unsigned short Spare1; /* 0x0138 */ struct _DEVOBJ_EXTENSION* DeviceObjectExtension; /* 0x0140 */ void* Reserved; /* 0x0148 */ long __PADDING__[2]; } DEVICE_OBJECT, *PDEVICE_OBJECT; /* size: 0x0150 */ struct _DEVICE_OBJECT_POWER_EXTENSION; typedef enum _DEVICE_POWER_STATE { PowerDeviceUnspecified = 0, PowerDeviceD0 = 1, PowerDeviceD1 = 2, PowerDeviceD2 = 3, PowerDeviceD3 = 4, PowerDeviceMaximum = 5, } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; typedef enum _DEVICE_RELATION_TYPE { BusRelations = 0, EjectionRelations = 1, PowerRelations = 2, RemovalRelations = 3, TargetDeviceRelation = 4, SingleBusRelations = 5, TransportRelations = 6, } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE; typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { DeviceUsageTypeUndefined = 0, DeviceUsageTypePaging = 1, DeviceUsageTypeHibernation = 2, DeviceUsageTypeDumpFile = 3, DeviceUsageTypeBoot = 4, DeviceUsageTypePostDisplay = 5, } DEVICE_USAGE_NOTIFICATION_TYPE, *PDEVICE_USAGE_NOTIFICATION_TYPE; typedef enum _DEVICE_WAKE_DEPTH { DeviceWakeDepthNotWakeable = 0, DeviceWakeDepthD0 = 1, DeviceWakeDepthD1 = 2, DeviceWakeDepthD2 = 3, DeviceWakeDepthD3hot = 4, DeviceWakeDepthD3cold = 5, DeviceWakeDepthMaximum = 6, } DEVICE_WAKE_DEPTH, *PDEVICE_WAKE_DEPTH; typedef struct _DEVOBJ_EXTENSION { /* 0x0000 */ short Type; /* 0x0002 */ unsigned short Size; /* 0x0008 */ struct _DEVICE_OBJECT* DeviceObject; /* 0x0010 */ unsigned long PowerFlags; /* 0x0018 */ struct _DEVICE_OBJECT_POWER_EXTENSION* Dope; /* 0x0020 */ unsigned long ExtensionFlags; /* 0x0028 */ void* DeviceNode; /* 0x0030 */ struct _DEVICE_OBJECT* AttachedTo; /* 0x0038 */ long StartIoCount; /* 0x003c */ long StartIoKey; /* 0x0040 */ unsigned long StartIoFlags; /* 0x0048 */ struct _VPB* Vpb; /* 0x0050 */ void* DependencyNode; /* 0x0058 */ void* InterruptContext; /* 0x0060 */ void* VerifierContext; } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; /* size: 0x0068 */ typedef struct _DISPATCHER_HEADER { union { /* 0x0000 */ volatile long Lock; /* 0x0000 */ long LockNV; struct { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Signalling; /* 0x0002 */ unsigned char Size; /* 0x0003 */ unsigned char Reserved1; }; /* size: 0x0004 */ struct { /* 0x0000 */ unsigned char TimerType; union { /* 0x0001 */ unsigned char TimerControlFlags; struct { struct /* bitfield */ { /* 0x0001 */ unsigned char Absolute : 1; /* bit position: 0 */ /* 0x0001 */ unsigned char Wake : 1; /* bit position: 1 */ /* 0x0001 */ unsigned char EncodedTolerableDelay : 6; /* bit position: 2 */ }; /* bitfield */ /* 0x0002 */ unsigned char Hand; union { /* 0x0003 */ unsigned char TimerMiscFlags; struct /* bitfield */ { /* 0x0003 */ unsigned char Index : 6; /* bit position: 0 */ /* 0x0003 */ unsigned char Inserted : 1; /* bit position: 6 */ /* 0x0003 */ volatile unsigned char Expired : 1; /* bit position: 7 */ }; /* bitfield */ }; /* size: 0x0001 */ }; /* size: 0x0003 */ }; /* size: 0x0003 */ }; /* size: 0x0004 */ struct { /* 0x0000 */ unsigned char Timer2Type; union { /* 0x0001 */ unsigned char Timer2Flags; struct { struct /* bitfield */ { /* 0x0001 */ unsigned char Timer2Inserted : 1; /* bit position: 0 */ /* 0x0001 */ unsigned char Timer2Expiring : 1; /* bit position: 1 */ /* 0x0001 */ unsigned char Timer2CancelPending : 1; /* bit position: 2 */ /* 0x0001 */ unsigned char Timer2SetPending : 1; /* bit position: 3 */ /* 0x0001 */ unsigned char Timer2Running : 1; /* bit position: 4 */ /* 0x0001 */ unsigned char Timer2Disabled : 1; /* bit position: 5 */ /* 0x0001 */ unsigned char Timer2ReservedFlags : 2; /* bit position: 6 */ }; /* bitfield */ /* 0x0002 */ unsigned char Timer2Reserved1; /* 0x0003 */ unsigned char Timer2Reserved2; }; /* size: 0x0003 */ }; /* size: 0x0003 */ }; /* size: 0x0004 */ struct { /* 0x0000 */ unsigned char QueueType; union { /* 0x0001 */ unsigned char QueueControlFlags; struct { struct /* bitfield */ { /* 0x0001 */ unsigned char Abandoned : 1; /* bit position: 0 */ /* 0x0001 */ unsigned char DisableIncrement : 1; /* bit position: 1 */ /* 0x0001 */ unsigned char QueueReservedControlFlags : 6; /* bit position: 2 */ }; /* bitfield */ /* 0x0002 */ unsigned char QueueSize; /* 0x0003 */ unsigned char QueueReserved; }; /* size: 0x0003 */ }; /* size: 0x0003 */ }; /* size: 0x0004 */ struct { /* 0x0000 */ unsigned char ThreadType; /* 0x0001 */ unsigned char ThreadReserved; union { /* 0x0002 */ unsigned char ThreadControlFlags; struct { struct /* bitfield */ { /* 0x0002 */ unsigned char CycleProfiling : 1; /* bit position: 0 */ /* 0x0002 */ unsigned char CounterProfiling : 1; /* bit position: 1 */ /* 0x0002 */ unsigned char GroupScheduling : 1; /* bit position: 2 */ /* 0x0002 */ unsigned char AffinitySet : 1; /* bit position: 3 */ /* 0x0002 */ unsigned char Tagged : 1; /* bit position: 4 */ /* 0x0002 */ unsigned char EnergyProfiling : 1; /* bit position: 5 */ /* 0x0002 */ unsigned char ThreadReservedControlFlags : 2; /* bit position: 6 */ }; /* bitfield */ union { /* 0x0003 */ unsigned char DebugActive; struct /* bitfield */ { /* 0x0003 */ unsigned char ActiveDR7 : 1; /* bit position: 0 */ /* 0x0003 */ unsigned char Instrumented : 1; /* bit position: 1 */ /* 0x0003 */ unsigned char Minimal : 1; /* bit position: 2 */ /* 0x0003 */ unsigned char Reserved4 : 3; /* bit position: 3 */ /* 0x0003 */ unsigned char UmsScheduled : 1; /* bit position: 6 */ /* 0x0003 */ unsigned char UmsPrimary : 1; /* bit position: 7 */ }; /* bitfield */ }; /* size: 0x0001 */ }; /* size: 0x0002 */ }; /* size: 0x0002 */ }; /* size: 0x0004 */ struct { /* 0x0000 */ unsigned char MutantType; /* 0x0001 */ unsigned char MutantSize; /* 0x0002 */ unsigned char DpcActive; /* 0x0003 */ unsigned char MutantReserved; }; /* size: 0x0004 */ }; /* size: 0x0004 */ /* 0x0004 */ long SignalState; /* 0x0008 */ struct _LIST_ENTRY WaitListHead; } DISPATCHER_HEADER, *PDISPATCHER_HEADER; /* size: 0x0018 */ typedef struct _DRIVER_EXTENSION { /* 0x0000 */ struct _DRIVER_OBJECT* DriverObject; /* 0x0008 */ void* AddDevice /* function */; /* 0x0010 */ unsigned long Count; /* 0x0018 */ struct _UNICODE_STRING ServiceKeyName; } DRIVER_EXTENSION, *PDRIVER_EXTENSION; /* size: 0x0028 */ typedef struct _DRIVER_OBJECT { /* 0x0000 */ short Type; /* 0x0002 */ short Size; /* 0x0008 */ struct _DEVICE_OBJECT* DeviceObject; /* 0x0010 */ unsigned long Flags; /* 0x0018 */ void* DriverStart; /* 0x0020 */ unsigned long DriverSize; /* 0x0028 */ void* DriverSection; /* 0x0030 */ struct _DRIVER_EXTENSION* DriverExtension; /* 0x0038 */ struct _UNICODE_STRING DriverName; /* 0x0048 */ struct _UNICODE_STRING* HardwareDatabase; /* 0x0050 */ struct _FAST_IO_DISPATCH* FastIoDispatch; /* 0x0058 */ void* DriverInit /* function */; /* 0x0060 */ void* DriverStartIo /* function */; /* 0x0068 */ void* DriverUnload /* function */; /* 0x0070 */ void* MajorFunction[28] /* function */; } DRIVER_OBJECT, *PDRIVER_OBJECT; /* size: 0x0150 */ struct _ECP_LIST; struct _EPROCESS; typedef struct _ERESOURCE { /* 0x0000 */ struct _LIST_ENTRY SystemResourcesList; /* 0x0010 */ struct _OWNER_ENTRY* OwnerTable; /* 0x0018 */ short ActiveCount; union { /* 0x001a */ unsigned short Flag; struct { /* 0x001a */ unsigned char ReservedLowFlags; /* 0x001b */ unsigned char WaiterPriority; }; /* size: 0x0002 */ }; /* size: 0x0002 */ /* 0x0020 */ struct _KWAIT_CHAIN SharedWaiters; /* 0x0028 */ struct _KEVENT* ExclusiveWaiters; /* 0x0030 */ struct _OWNER_ENTRY OwnerEntry; /* 0x0040 */ unsigned long ActiveEntries; /* 0x0044 */ unsigned long ContentionCount; /* 0x0048 */ unsigned long NumberOfSharedWaiters; /* 0x004c */ unsigned long NumberOfExclusiveWaiters; /* 0x0050 */ void* Reserved2; union { /* 0x0058 */ void* Address; /* 0x0058 */ unsigned __int64 CreatorBackTraceIndex; }; /* size: 0x0008 */ /* 0x0060 */ unsigned __int64 SpinLock; } ERESOURCE, *PERESOURCE; /* size: 0x0068 */ struct _ESILO; struct _ETHREAD; typedef struct _EVENT_DATA_DESCRIPTOR { /* 0x0000 */ unsigned __int64 Ptr; /* 0x0008 */ unsigned long Size; union { /* 0x000c */ unsigned long Reserved; struct { /* 0x000c */ unsigned char Type; /* 0x000d */ unsigned char Reserved1; /* 0x000e */ unsigned short Reserved2; }; /* size: 0x0004 */ }; /* size: 0x0004 */ } EVENT_DATA_DESCRIPTOR, *PEVENT_DATA_DESCRIPTOR; /* size: 0x0010 */ typedef struct _EVENT_DESCRIPTOR { /* 0x0000 */ unsigned short Id; /* 0x0002 */ unsigned char Version; /* 0x0003 */ unsigned char Channel; /* 0x0004 */ unsigned char Level; /* 0x0005 */ unsigned char Opcode; /* 0x0006 */ unsigned short Task; /* 0x0008 */ unsigned __int64 Keyword; } EVENT_DESCRIPTOR, *PEVENT_DESCRIPTOR; /* size: 0x0010 */ typedef enum _EVENT_TYPE { NotificationEvent = 0, SynchronizationEvent = 1, } EVENT_TYPE, *PEVENT_TYPE; typedef enum _EXCEPTION_DISPOSITION { ExceptionContinueExecution = 0, ExceptionContinueSearch = 1, ExceptionNestedException = 2, ExceptionCollidedUnwind = 3, } EXCEPTION_DISPOSITION, *PEXCEPTION_DISPOSITION; typedef struct _EXCEPTION_RECORD { /* 0x0000 */ long ExceptionCode; /* 0x0004 */ unsigned long ExceptionFlags; /* 0x0008 */ struct _EXCEPTION_RECORD* ExceptionRecord; /* 0x0010 */ void* ExceptionAddress; /* 0x0018 */ unsigned long NumberParameters; /* 0x0020 */ unsigned __int64 ExceptionInformation[15]; } EXCEPTION_RECORD, *PEXCEPTION_RECORD; /* size: 0x0098 */ typedef struct _EXCEPTION_REGISTRATION_RECORD { /* 0x0000 */ struct _EXCEPTION_REGISTRATION_RECORD* Next; /* 0x0008 */ void* Handler /* function */; } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD; /* size: 0x0010 */ typedef struct _EXT_DELETE_PARAMETERS { /* 0x0000 */ unsigned long Version; /* 0x0004 */ unsigned long Reserved; /* 0x0008 */ void* DeleteCallback /* function */; /* 0x0010 */ void* DeleteContext; } EXT_DELETE_PARAMETERS, *PEXT_DELETE_PARAMETERS; /* size: 0x0018 */ typedef struct _EXT_SET_PARAMETERS_V0 { /* 0x0000 */ unsigned long Version; /* 0x0004 */ unsigned long Reserved; /* 0x0008 */ __int64 NoWakeTolerance; } EXT_SET_PARAMETERS_V0, *PEXT_SET_PARAMETERS_V0; /* size: 0x0010 */ typedef struct _FACS { /* 0x0000 */ unsigned long Signature; /* 0x0004 */ unsigned long Length; /* 0x0008 */ unsigned long HardwareSignature; /* 0x000c */ unsigned long pFirmwareWakingVector; /* 0x0010 */ unsigned long GlobalLock; /* 0x0014 */ unsigned long Flags; /* 0x0018 */ union _LARGE_INTEGER x_FirmwareWakingVector; /* 0x0020 */ unsigned char version; /* 0x0021 */ unsigned char Reserved[31]; } FACS, *PFACS; /* size: 0x0040 */ typedef struct _FADT { /* 0x0000 */ struct _DESCRIPTION_HEADER Header; /* 0x0024 */ unsigned long facs; /* 0x0028 */ unsigned long dsdt; /* 0x002c */ unsigned char int_model; /* 0x002d */ unsigned char pm_profile; /* 0x002e */ unsigned short sci_int_vector; /* 0x0030 */ unsigned long smi_cmd_io_port; /* 0x0034 */ unsigned char acpi_on_value; /* 0x0035 */ unsigned char acpi_off_value; /* 0x0036 */ unsigned char s4bios_req; /* 0x0037 */ unsigned char pstate_control; /* 0x0038 */ unsigned long pm1a_evt_blk_io_port; /* 0x003c */ unsigned long pm1b_evt_blk_io_port; /* 0x0040 */ unsigned long pm1a_ctrl_blk_io_port; /* 0x0044 */ unsigned long pm1b_ctrl_blk_io_port; /* 0x0048 */ unsigned long pm2_ctrl_blk_io_port; /* 0x004c */ unsigned long pm_tmr_blk_io_port; /* 0x0050 */ unsigned long gp0_blk_io_port; /* 0x0054 */ unsigned long gp1_blk_io_port; /* 0x0058 */ unsigned char pm1_evt_len; /* 0x0059 */ unsigned char pm1_ctrl_len; /* 0x005a */ unsigned char pm2_ctrl_len; /* 0x005b */ unsigned char pm_tmr_len; /* 0x005c */ unsigned char gp0_blk_len; /* 0x005d */ unsigned char gp1_blk_len; /* 0x005e */ unsigned char gp1_base; /* 0x005f */ unsigned char cstate_control; /* 0x0060 */ unsigned short lvl2_latency; /* 0x0062 */ unsigned short lvl3_latency; /* 0x0064 */ unsigned short flush_size; /* 0x0066 */ unsigned short flush_stride; /* 0x0068 */ unsigned char duty_offset; /* 0x0069 */ unsigned char duty_width; /* 0x006a */ unsigned char day_alarm_index; /* 0x006b */ unsigned char month_alarm_index; /* 0x006c */ unsigned char century_alarm_index; /* 0x006d */ unsigned short boot_arch; /* 0x006f */ unsigned char reserved3[1]; /* 0x0070 */ unsigned long flags; /* 0x0074 */ struct _GEN_ADDR reset_reg; /* 0x0080 */ unsigned char reset_val; /* 0x0081 */ unsigned short arm_boot_arch; /* 0x0083 */ unsigned char reserved4; /* 0x0084 */ union _LARGE_INTEGER x_firmware_ctrl; /* 0x008c */ union _LARGE_INTEGER x_dsdt; /* 0x0094 */ struct _GEN_ADDR x_pm1a_evt_blk; /* 0x00a0 */ struct _GEN_ADDR x_pm1b_evt_blk; /* 0x00ac */ struct _GEN_ADDR x_pm1a_ctrl_blk; /* 0x00b8 */ struct _GEN_ADDR x_pm1b_ctrl_blk; /* 0x00c4 */ struct _GEN_ADDR x_pm2_ctrl_blk; /* 0x00d0 */ struct _GEN_ADDR x_pm_tmr_blk; /* 0x00dc */ struct _GEN_ADDR x_gp0_blk; /* 0x00e8 */ struct _GEN_ADDR x_gp1_blk; /* 0x00f4 */ struct _GEN_ADDR sleep_control_reg; /* 0x0100 */ struct _GEN_ADDR sleep_status_reg; } FADT, *PFADT; /* size: 0x010c */ typedef struct _FAST_IO_DISPATCH { /* 0x0000 */ unsigned long SizeOfFastIoDispatch; /* 0x0008 */ void* FastIoCheckIfPossible /* function */; /* 0x0010 */ void* FastIoRead /* function */; /* 0x0018 */ void* FastIoWrite /* function */; /* 0x0020 */ void* FastIoQueryBasicInfo /* function */; /* 0x0028 */ void* FastIoQueryStandardInfo /* function */; /* 0x0030 */ void* FastIoLock /* function */; /* 0x0038 */ void* FastIoUnlockSingle /* function */; /* 0x0040 */ void* FastIoUnlockAll /* function */; /* 0x0048 */ void* FastIoUnlockAllByKey /* function */; /* 0x0050 */ void* FastIoDeviceControl /* function */; /* 0x0058 */ void* AcquireFileForNtCreateSection /* function */; /* 0x0060 */ void* ReleaseFileForNtCreateSection /* function */; /* 0x0068 */ void* FastIoDetachDevice /* function */; /* 0x0070 */ void* FastIoQueryNetworkOpenInfo /* function */; /* 0x0078 */ void* AcquireForModWrite /* function */; /* 0x0080 */ void* MdlRead /* function */; /* 0x0088 */ void* MdlReadComplete /* function */; /* 0x0090 */ void* PrepareMdlWrite /* function */; /* 0x0098 */ void* MdlWriteComplete /* function */; /* 0x00a0 */ void* FastIoReadCompressed /* function */; /* 0x00a8 */ void* FastIoWriteCompressed /* function */; /* 0x00b0 */ void* MdlReadCompleteCompressed /* function */; /* 0x00b8 */ void* MdlWriteCompleteCompressed /* function */; /* 0x00c0 */ void* FastIoQueryOpen /* function */; /* 0x00c8 */ void* ReleaseForModWrite /* function */; /* 0x00d0 */ void* AcquireForCcFlush /* function */; /* 0x00d8 */ void* ReleaseForCcFlush /* function */; } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH; /* size: 0x00e0 */ typedef struct _FAST_MUTEX { /* 0x0000 */ long Count; /* 0x0008 */ void* Owner; /* 0x0010 */ unsigned long Contention; /* 0x0018 */ struct _KEVENT Event; /* 0x0030 */ unsigned long OldIrql; /* 0x0034 */ long __PADDING__[1]; } FAST_MUTEX, *PFAST_MUTEX; /* size: 0x0038 */ typedef struct _FILE_BASIC_INFORMATION { /* 0x0000 */ union _LARGE_INTEGER CreationTime; /* 0x0008 */ union _LARGE_INTEGER LastAccessTime; /* 0x0010 */ union _LARGE_INTEGER LastWriteTime; /* 0x0018 */ union _LARGE_INTEGER ChangeTime; /* 0x0020 */ unsigned long FileAttributes; /* 0x0024 */ long __PADDING__[1]; } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; /* size: 0x0028 */ struct _FILE_GET_QUOTA_INFORMATION; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, FileFullDirectoryInformation = 2, FileBothDirectoryInformation = 3, FileBasicInformation = 4, FileStandardInformation = 5, FileInternalInformation = 6, FileEaInformation = 7, FileAccessInformation = 8, FileNameInformation = 9, FileRenameInformation = 10, FileLinkInformation = 11, FileNamesInformation = 12, FileDispositionInformation = 13, FilePositionInformation = 14, FileFullEaInformation = 15, FileModeInformation = 16, FileAlignmentInformation = 17, FileAllInformation = 18, FileAllocationInformation = 19, FileEndOfFileInformation = 20, FileAlternateNameInformation = 21, FileStreamInformation = 22, FilePipeInformation = 23, FilePipeLocalInformation = 24, FilePipeRemoteInformation = 25, FileMailslotQueryInformation = 26, FileMailslotSetInformation = 27, FileCompressionInformation = 28, FileObjectIdInformation = 29, FileCompletionInformation = 30, FileMoveClusterInformation = 31, FileQuotaInformation = 32, FileReparsePointInformation = 33, FileNetworkOpenInformation = 34, FileAttributeTagInformation = 35, FileTrackingInformation = 36, FileIdBothDirectoryInformation = 37, FileIdFullDirectoryInformation = 38, FileValidDataLengthInformation = 39, FileShortNameInformation = 40, FileIoCompletionNotificationInformation = 41, FileIoStatusBlockRangeInformation = 42, FileIoPriorityHintInformation = 43, FileSfioReserveInformation = 44, FileSfioVolumeInformation = 45, FileHardLinkInformation = 46, FileProcessIdsUsingFileInformation = 47, FileNormalizedNameInformation = 48, FileNetworkPhysicalNameInformation = 49, FileIdGlobalTxDirectoryInformation = 50, FileIsRemoteDeviceInformation = 51, FileUnusedInformation = 52, FileNumaNodeInformation = 53, FileStandardLinkInformation = 54, FileRemoteProtocolInformation = 55, FileRenameInformationBypassAccessCheck = 56, FileLinkInformationBypassAccessCheck = 57, FileVolumeNameInformation = 58, FileIdInformation = 59, FileIdExtdDirectoryInformation = 60, FileReplaceCompletionInformation = 61, FileHardLinkFullIdInformation = 62, FileIdExtdBothDirectoryInformation = 63, FileMaximumInformation = 64, } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef struct _FILE_NETWORK_OPEN_INFORMATION { /* 0x0000 */ union _LARGE_INTEGER CreationTime; /* 0x0008 */ union _LARGE_INTEGER LastAccessTime; /* 0x0010 */ union _LARGE_INTEGER LastWriteTime; /* 0x0018 */ union _LARGE_INTEGER ChangeTime; /* 0x0020 */ union _LARGE_INTEGER AllocationSize; /* 0x0028 */ union _LARGE_INTEGER EndOfFile; /* 0x0030 */ unsigned long FileAttributes; /* 0x0034 */ long __PADDING__[1]; } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; /* size: 0x0038 */ typedef struct _FILE_OBJECT { /* 0x0000 */ short Type; /* 0x0002 */ short Size; /* 0x0008 */ struct _DEVICE_OBJECT* DeviceObject; /* 0x0010 */ struct _VPB* Vpb; /* 0x0018 */ void* FsContext; /* 0x0020 */ void* FsContext2; /* 0x0028 */ struct _SECTION_OBJECT_POINTERS* SectionObjectPointer; /* 0x0030 */ void* PrivateCacheMap; /* 0x0038 */ long FinalStatus; /* 0x0040 */ struct _FILE_OBJECT* RelatedFileObject; /* 0x0048 */ unsigned char LockOperation; /* 0x0049 */ unsigned char DeletePending; /* 0x004a */ unsigned char ReadAccess; /* 0x004b */ unsigned char WriteAccess; /* 0x004c */ unsigned char DeleteAccess; /* 0x004d */ unsigned char SharedRead; /* 0x004e */ unsigned char SharedWrite; /* 0x004f */ unsigned char SharedDelete; /* 0x0050 */ unsigned long Flags; /* 0x0058 */ struct _UNICODE_STRING FileName; /* 0x0068 */ union _LARGE_INTEGER CurrentByteOffset; /* 0x0070 */ unsigned long Waiters; /* 0x0074 */ unsigned long Busy; /* 0x0078 */ void* LastLock; /* 0x0080 */ struct _KEVENT Lock; /* 0x0098 */ struct _KEVENT Event; /* 0x00b0 */ struct _IO_COMPLETION_CONTEXT* CompletionContext; /* 0x00b8 */ unsigned __int64 IrpListLock; /* 0x00c0 */ struct _LIST_ENTRY IrpList; /* 0x00d0 */ void* FileObjectExtension; } FILE_OBJECT, *PFILE_OBJECT; /* size: 0x00d8 */ typedef struct _FILE_STANDARD_INFORMATION { /* 0x0000 */ union _LARGE_INTEGER AllocationSize; /* 0x0008 */ union _LARGE_INTEGER EndOfFile; /* 0x0010 */ unsigned long NumberOfLinks; /* 0x0014 */ unsigned char DeletePending; /* 0x0015 */ unsigned char Directory; /* 0x0016 */ char __PADDING__[2]; } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; /* size: 0x0018 */ typedef enum _FSINFOCLASS { FileFsVolumeInformation = 1, FileFsLabelInformation = 2, FileFsSizeInformation = 3, FileFsDeviceInformation = 4, FileFsAttributeInformation = 5, FileFsControlInformation = 6, FileFsFullSizeInformation = 7, FileFsObjectIdInformation = 8, FileFsDriverPathInformation = 9, FileFsVolumeFlagsInformation = 10, FileFsSectorSizeInformation = 11, FileFsDataCopyInformation = 12, FileFsMetadataSizeInformation = 13, FileFsMaximumInformation = 14, } FSINFOCLASS, *PFSINFOCLASS; typedef struct _GENERAL_LOOKASIDE { union { /* 0x0000 */ union _SLIST_HEADER ListHead; /* 0x0000 */ struct _SINGLE_LIST_ENTRY SingleListHead; }; /* size: 0x0010 */ /* 0x0010 */ unsigned short Depth; /* 0x0012 */ unsigned short MaximumDepth; /* 0x0014 */ unsigned long TotalAllocates; union { /* 0x0018 */ unsigned long AllocateMisses; /* 0x0018 */ unsigned long AllocateHits; }; /* size: 0x0004 */ /* 0x001c */ unsigned long TotalFrees; union { /* 0x0020 */ unsigned long FreeMisses; /* 0x0020 */ unsigned long FreeHits; }; /* size: 0x0004 */ /* 0x0024 */ enum _POOL_TYPE Type; /* 0x0028 */ unsigned long Tag; /* 0x002c */ unsigned long Size; union { /* 0x0030 */ void* AllocateEx /* function */; /* 0x0030 */ void* Allocate /* function */; }; /* size: 0x0008 */ union { /* 0x0038 */ void* FreeEx /* function */; /* 0x0038 */ void* Free /* function */; }; /* size: 0x0008 */ /* 0x0040 */ struct _LIST_ENTRY ListEntry; /* 0x0050 */ unsigned long LastTotalAllocates; union { /* 0x0054 */ unsigned long LastAllocateMisses; /* 0x0054 */ unsigned long LastAllocateHits; }; /* size: 0x0004 */ /* 0x0058 */ unsigned long Future[2]; /* 0x0060 */ long __PADDING__[8]; } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; /* size: 0x0080 */ typedef struct _GENERAL_LOOKASIDE_POOL { union { /* 0x0000 */ union _SLIST_HEADER ListHead; /* 0x0000 */ struct _SINGLE_LIST_ENTRY SingleListHead; }; /* size: 0x0010 */ /* 0x0010 */ unsigned short Depth; /* 0x0012 */ unsigned short MaximumDepth; /* 0x0014 */ unsigned long TotalAllocates; union { /* 0x0018 */ unsigned long AllocateMisses; /* 0x0018 */ unsigned long AllocateHits; }; /* size: 0x0004 */ /* 0x001c */ unsigned long TotalFrees; union { /* 0x0020 */ unsigned long FreeMisses; /* 0x0020 */ unsigned long FreeHits; }; /* size: 0x0004 */ /* 0x0024 */ enum _POOL_TYPE Type; /* 0x0028 */ unsigned long Tag; /* 0x002c */ unsigned long Size; union { /* 0x0030 */ void* AllocateEx /* function */; /* 0x0030 */ void* Allocate /* function */; }; /* size: 0x0008 */ union { /* 0x0038 */ void* FreeEx /* function */; /* 0x0038 */ void* Free /* function */; }; /* size: 0x0008 */ /* 0x0040 */ struct _LIST_ENTRY ListEntry; /* 0x0050 */ unsigned long LastTotalAllocates; union { /* 0x0054 */ unsigned long LastAllocateMisses; /* 0x0054 */ unsigned long LastAllocateHits; }; /* size: 0x0004 */ /* 0x0058 */ unsigned long Future[2]; } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; /* size: 0x0060 */ typedef struct _GEN_ADDR { /* 0x0000 */ unsigned char AddressSpaceID; /* 0x0001 */ unsigned char BitWidth; /* 0x0002 */ unsigned char BitOffset; /* 0x0003 */ unsigned char AccessSize; /* 0x0004 */ union _LARGE_INTEGER Address; } GEN_ADDR, *PGEN_ADDR; /* size: 0x000c */ typedef struct _GROUP_AFFINITY { /* 0x0000 */ unsigned __int64 Mask; /* 0x0008 */ unsigned short Group; /* 0x000a */ unsigned short Reserved[3]; } GROUP_AFFINITY, *PGROUP_AFFINITY; /* size: 0x0010 */ typedef struct _GUID { /* 0x0000 */ unsigned long Data1; /* 0x0004 */ unsigned short Data2; /* 0x0006 */ unsigned short Data3; /* 0x0008 */ unsigned char Data4[8]; } GUID, *PGUID; /* size: 0x0010 */ typedef struct _HALP_ALLOC_CONTEXT { /* 0x0000 */ struct _LIST_ENTRY BufferList; /* 0x0010 */ unsigned __int64 Lock; } HALP_ALLOC_CONTEXT, *PHALP_ALLOC_CONTEXT; /* size: 0x0018 */ typedef enum _HALP_DMA_MAP_BUFFER_TYPE { HalpDmaContiguousMapBuffer = 0, HalpDmaNonContiguousMapBuffer = 1, HalpDmaMaximumMapBufferType = 2, } HALP_DMA_MAP_BUFFER_TYPE, *PHALP_DMA_MAP_BUFFER_TYPE; typedef enum _HAL_DMA_CRASH_DUMP_REGISTER_TYPE { HalDmaCrashDumpRegisterSet1 = 0, HalDmaCrashDumpRegisterSet2 = 1, HalDmaCrashDumpRegisterSetMax = 2, } HAL_DMA_CRASH_DUMP_REGISTER_TYPE, *PHAL_DMA_CRASH_DUMP_REGISTER_TYPE; typedef struct _HAL_HV_SVM_DEVICE_CAPABILITIES { struct /* bitfield */ { /* 0x0000 */ unsigned long SvmSupported : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long PciExecute : 1; /* bit position: 1 */ /* 0x0000 */ unsigned long NoExecute : 1; /* bit position: 2 */ /* 0x0000 */ unsigned long Reserved : 28; /* bit position: 3 */ /* 0x0000 */ unsigned long OverflowPossible : 1; /* bit position: 31 */ }; /* bitfield */ /* 0x0004 */ unsigned long PasidCount; /* 0x0008 */ unsigned long IommuIndex; } HAL_HV_SVM_DEVICE_CAPABILITIES, *PHAL_HV_SVM_DEVICE_CAPABILITIES; /* size: 0x000c */ typedef struct _HAL_HV_SVM_SYSTEM_CAPABILITIES { struct /* bitfield */ { /* 0x0000 */ unsigned long SvmSupported : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long GpaAlwaysValid : 1; /* bit position: 1 */ }; /* bitfield */ /* 0x0004 */ unsigned long MaxPasidSpaceCount; /* 0x0008 */ unsigned long MaxPasidSpacePasidCount; /* 0x000c */ unsigned long MaxPrqSize; /* 0x0010 */ unsigned long IommuCount; /* 0x0014 */ unsigned long MinIommuPasidCount; } HAL_HV_SVM_SYSTEM_CAPABILITIES, *PHAL_HV_SVM_SYSTEM_CAPABILITIES; /* size: 0x0018 */ typedef enum _HAL_INIT_PHASE { HalInitPhaseBspProcEarly = 0, HalInitPhaseBspProcEarlyMmReady = 1, HalInitPhaseBspProcEarlyTimerReady = 2, HalInitPhaseBspProcEarlyEnd = 3, HalInitPhasePnProcEarly = 4, HalInitPhasePnProcEarlyEnd = 5, HalInitPhaseBspSystemEarly = 6, HalInitPhaseBspSystemEarlyAcpiReady = 7, HalInitPhaseBspSystemEarlyHalExtensionsReady = 8, HalInitPhaseBspSystemEarlyInterruptsAlmostReady = 9, HalInitPhaseBspSystemEarlyIommusReady = 10, HalInitPhaseBspSystemEarlyInterruptsReady = 11, HalInitPhaseBspSystemEarlyDmaReady = 11, HalInitPhaseBspSystemEarlyProcReady = 12, HalInitPhaseBspSystemEarlyHwPerfCntReady = 13, HalInitPhaseBspSystemEarlyEnd = 14, HalInitPhaseBspSystemLate = 15, HalInitPhaseBspSystemLateEnd = 16, HalInitPhasePnSystemLate = 17, HalInitPhasePnSystemLateEnd = 18, HalInitPhaseAllProcStartComplete = 19, HalInitPhaseAllProcStartCompleteEnd = 20, HalInitPhaseAcpiPdoStarted = 21, HalInitPhaseAcpiPdoStartedEnd = 22, HalInitPhaseReportResources = 23, HalInitPhaseReportResourcesEnd = 24, HalInitPhaseReportCoreSystemResources = 25, HalInitPhaseReportCoreSystemResourcesEnd = 26, HalInitPhaseInitializeTelemetry = 27, HalInitPhaseTelemetryReady = 28, HalInitPhaseTelemetryEnd = 29, } HAL_INIT_PHASE, *PHAL_INIT_PHASE; typedef struct _HAL_INTEL_ENLIGHTENMENT_INFORMATION { /* 0x0000 */ unsigned long Enlightenments; /* 0x0004 */ unsigned long HypervisorConnected; /* 0x0008 */ void* EndOfInterrupt /* function */; /* 0x0010 */ void* ApicWriteIcr /* function */; /* 0x0018 */ unsigned long Reserved0; /* 0x001c */ unsigned long SpinCountMask; /* 0x0020 */ void* LongSpinWait /* function */; /* 0x0028 */ void* GetReferenceTime /* function */; /* 0x0030 */ void* SetSystemSleepProperty /* function */; /* 0x0038 */ void* EnterSleepState /* function */; /* 0x0040 */ void* NotifyDebugDeviceAvailable /* function */; /* 0x0048 */ void* MapDeviceInterrupt /* function */; /* 0x0050 */ void* UnmapDeviceInterrupt /* function */; /* 0x0058 */ void* RetargetDeviceInterrupt /* function */; /* 0x0060 */ void* SetHpetConfig /* function */; /* 0x0068 */ void* NotifyHpetEnabled /* function */; /* 0x0070 */ void* QueryAssociatedProcessors /* function */; /* 0x0078 */ void* ReadMultipleMsr /* function */; /* 0x0080 */ void* WriteMultipleMsr /* function */; /* 0x0088 */ void* ReadCpuid /* function */; /* 0x0090 */ void* LpWritebackInvalidate /* function */; /* 0x0098 */ void* GetMachineCheckContext /* function */; /* 0x00a0 */ void* SuspendPartition /* function */; /* 0x00a8 */ void* ResumePartition /* function */; /* 0x00b0 */ void* SetSystemMachineCheckProperty /* function */; /* 0x00b8 */ void* WheaErrorNotification /* function */; /* 0x00c0 */ void* GetProcessorIndexFromVpIndex /* function */; /* 0x00c8 */ void* SyntheticClusterIpi /* function */; /* 0x00d0 */ void* VpStartEnabled /* function */; /* 0x00d8 */ void* StartVirtualProcessor /* function */; /* 0x00e0 */ void* GetVpIndexFromApicId /* function */; /* 0x00e8 */ void* IumEfiRuntimeService /* function */; /* 0x00f0 */ void* SvmGetSystemCapabilities /* function */; /* 0x00f8 */ void* SvmGetDeviceCapabilities /* function */; /* 0x0100 */ void* SvmCreatePasidSpace /* function */; /* 0x0108 */ void* SvmSetPasidAddressSpace /* function */; /* 0x0110 */ void* SvmFlushPasid /* function */; /* 0x0118 */ void* SvmAttachPasidSpace /* function */; /* 0x0120 */ void* SvmDetachPasidSpace /* function */; /* 0x0128 */ void* SvmEnablePasid /* function */; /* 0x0130 */ void* SvmDisablePasid /* function */; /* 0x0138 */ void* SvmAcknowledgePageRequest /* function */; /* 0x0140 */ void* SvmCreatePrQueue /* function */; /* 0x0148 */ void* SvmDeletePrQueue /* function */; /* 0x0150 */ void* SvmClearPrqStalled /* function */; /* 0x0158 */ void* SvmSetDeviceEnabled /* function */; } HAL_INTEL_ENLIGHTENMENT_INFORMATION, *PHAL_INTEL_ENLIGHTENMENT_INFORMATION; /* size: 0x0160 */ typedef struct _HARDWARE_PTE { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 1 */ /* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */ /* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */ /* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */ /* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */ /* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */ /* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */ /* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */ /* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */ /* 0x0000 */ unsigned __int64 Prototype : 1; /* bit position: 10 */ /* 0x0000 */ unsigned __int64 reserved0 : 1; /* bit position: 11 */ /* 0x0000 */ unsigned __int64 PageFrameNumber : 36; /* bit position: 12 */ /* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */ /* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */ /* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */ }; /* bitfield */ } HARDWARE_PTE, *PHARDWARE_PTE; /* size: 0x0008 */ typedef struct _INITIAL_PRIVILEGE_SET { /* 0x0000 */ unsigned long PrivilegeCount; /* 0x0004 */ unsigned long Control; /* 0x0008 */ struct _LUID_AND_ATTRIBUTES Privilege[3]; } INITIAL_PRIVILEGE_SET, *PINITIAL_PRIVILEGE_SET; /* size: 0x002c */ typedef struct _INTERFACE { /* 0x0000 */ unsigned short Size; /* 0x0002 */ unsigned short Version; /* 0x0008 */ void* Context; /* 0x0010 */ void* InterfaceReference /* function */; /* 0x0018 */ void* InterfaceDereference /* function */; } INTERFACE, *PINTERFACE; /* size: 0x0020 */ typedef enum _INTERFACE_TYPE { InterfaceTypeUndefined = -1, Internal = 0, Isa = 1, Eisa = 2, MicroChannel = 3, TurboChannel = 4, PCIBus = 5, VMEBus = 6, NuBus = 7, PCMCIABus = 8, CBus = 9, MPIBus = 10, MPSABus = 11, ProcessorInternal = 12, InternalPowerBus = 13, PNPISABus = 14, PNPBus = 15, Vmcs = 16, ACPIBus = 17, MaximumInterfaceType = 18, } INTERFACE_TYPE, *PINTERFACE_TYPE; typedef enum _INTERLOCKED_RESULT { ResultNegative = 1, ResultZero = 0, ResultPositive = 2, } INTERLOCKED_RESULT, *PINTERLOCKED_RESULT; typedef struct _INTERRUPT_FUNCTION_TABLE { /* 0x0000 */ void* InitializeLocalUnit /* function */; /* 0x0008 */ void* InitializeIoUnit /* function */; /* 0x0010 */ void* SetPriority /* function */; /* 0x0018 */ void* GetLocalUnitError /* function */; /* 0x0020 */ void* ClearLocalUnitError /* function */; /* 0x0028 */ void* GetLogicalId /* function */; /* 0x0030 */ void* SetLogicalId /* function */; /* 0x0038 */ void* AcceptAndGetSource /* function */; /* 0x0040 */ void* EndOfInterrupt /* function */; /* 0x0048 */ void* FastEndOfInterrupt /* function */; /* 0x0050 */ void* SetLineState /* function */; /* 0x0058 */ void* RequestInterrupt /* function */; /* 0x0060 */ void* StartProcessor /* function */; /* 0x0068 */ void* GenerateMessage /* function */; /* 0x0070 */ void* ConvertId /* function */; /* 0x0078 */ void* SaveLocalInterrupts /* function */; /* 0x0080 */ void* ReplayLocalInterrupts /* function */; /* 0x0088 */ void* DeinitializeLocalUnit /* function */; /* 0x0090 */ void* DeinitializeIoUnit /* function */; /* 0x0098 */ void* QueryAndGetSource /* function */; } INTERRUPT_FUNCTION_TABLE, *PINTERRUPT_FUNCTION_TABLE; /* size: 0x00a0 */ typedef struct _INTERRUPT_LINE { /* 0x0000 */ unsigned long UnitId; /* 0x0004 */ long Line; } INTERRUPT_LINE, *PINTERRUPT_LINE; /* size: 0x0008 */ typedef struct _INTERRUPT_LINE_STATE { /* 0x0000 */ enum _KINTERRUPT_POLARITY Polarity; /* 0x0004 */ unsigned char EmulateActiveBoth; /* 0x0008 */ enum _KINTERRUPT_MODE TriggerMode; /* 0x000c */ unsigned long Flags; /* 0x0010 */ struct _INTERRUPT_LINE Routing; /* 0x0018 */ struct _INTERRUPT_TARGET ProcessorTarget; /* 0x0030 */ unsigned long Vector; /* 0x0034 */ unsigned long Priority; } INTERRUPT_LINE_STATE, *PINTERRUPT_LINE_STATE; /* size: 0x0038 */ typedef enum _INTERRUPT_PROBLEM { InterruptProblemNone = 0, InterruptProblemMadtParsingFailure = 1, InterruptProblemNoControllersFound = 2, InterruptProblemFailedDiscovery = 3, InterruptProblemInitializeLocalUnitFailed = 4, InterruptProblemInitializeIoUnitFailed = 5, InterruptProblemSetLogicalIdFailed = 6, InterruptProblemSetLineStateFailed = 7, InterruptProblemGenerateMessageFailed = 8, InterruptProblemConvertIdFailed = 9, InterruptProblemCmciSetupFailed = 10, InterruptProblemQueryMaxProcessorsCalledTooEarly = 11, InterruptProblemProcessorReset = 12, InterruptProblemStartProcessorFailed = 13, InterruptProblemProcessorNotAlive = 14, InterruptProblemLowerIrqlViolation = 15, InterruptProblemInvalidIrql = 16, InterruptProblemNoSuchController = 17, InterruptProblemNoSuchLines = 18, InterruptProblemBadConnectionData = 19, InterruptProblemBadRoutingData = 20, InterruptProblemInvalidProcessor = 21, InterruptProblemFailedToAttainTarget = 22, InterruptProblemUnsupportedWiringConfiguration = 23, InterruptProblemSpareAlreadyStarted = 24, InterruptProblemClusterNotFullyReplaced = 25, InterruptProblemNewClusterAlreadyActive = 26, InterruptProblemNewClusterTooLarge = 27, InterruptProblemCannotHardwareQuiesce = 28, InterruptProblemIpiDestinationUpdateFailed = 29, InterruptProblemNoMemory = 30, InterruptProblemNoIrtEntries = 31, InterruptProblemConnectionDataBaitAndSwitch = 32, InterruptProblemInvalidLogicalFlatId = 33, InterruptProblemDeinitializeLocalUnitFailed = 34, InterruptProblemDeinitializeIoUnitFailed = 35, InterruptProblemMismatchedThermalLvtIsr = 36, } INTERRUPT_PROBLEM, *PINTERRUPT_PROBLEM; typedef enum _INTERRUPT_RESULT { InterruptBeginFatalError = 0, InterruptBeginLine = 1, InterruptBeginSpurious = 2, InterruptBeginVector = 3, InterruptBeginNone = 4, } INTERRUPT_RESULT, *PINTERRUPT_RESULT; typedef struct _INTERRUPT_TARGET { /* 0x0000 */ enum _INTERRUPT_TARGET_TYPE Target; union { /* 0x0008 */ unsigned long PhysicalTarget; /* 0x0008 */ unsigned long LogicalFlatTarget; /* 0x0008 */ unsigned long RemapIndex; struct { /* 0x0008 */ unsigned long ClusterId; /* 0x000c */ unsigned long ClusterMask; }; /* size: 0x0008 */ struct // _TAG_UNNAMED_17 { /* 0x0008 */ unsigned long Low32; /* 0x000c */ unsigned long High32; /* 0x0010 */ unsigned __int64 InterruptData; } /* size: 0x0010 */ HypervisorTarget; }; /* size: 0x0010 */ } INTERRUPT_TARGET, *PINTERRUPT_TARGET; /* size: 0x0018 */ typedef enum _INTERRUPT_TARGET_TYPE { InterruptTargetInvalid = 0, InterruptTargetAllIncludingSelf = 1, InterruptTargetAllExcludingSelf = 2, InterruptTargetSelfOnly = 3, InterruptTargetPhysical = 4, InterruptTargetLogicalFlat = 5, InterruptTargetLogicalClustered = 6, InterruptTargetRemapIndex = 7, InterruptTargetHypervisor = 8, } INTERRUPT_TARGET_TYPE, *PINTERRUPT_TARGET_TYPE; typedef struct _IOAPIC { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned char IOAPICID; /* 0x0003 */ unsigned char Reserved; /* 0x0004 */ unsigned long IOAPICAddress; /* 0x0008 */ unsigned long SystemVectorBase; } IOAPIC, *PIOAPIC; /* size: 0x000c */ typedef struct _IOSAPIC { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned char IOSAPICID; /* 0x0003 */ unsigned char Reserved; /* 0x0004 */ unsigned long SystemVectorBase; /* 0x0008 */ unsigned __int64 IOSAPICAddress; } IOSAPIC, *PIOSAPIC; /* size: 0x0010 */ typedef enum _IO_ALLOCATION_ACTION { KeepObject = 1, DeallocateObject = 2, DeallocateObjectKeepRegisters = 3, } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef struct _IO_APIC_DATA { /* 0x0000 */ unsigned __int64 PhysicalAddress; /* 0x0008 */ unsigned long Identifier; /* 0x0010 */ struct _IO_APIC_REGISTERS* BaseAddress; /* 0x0018 */ unsigned char Version; /* 0x0019 */ unsigned char PinCount; /* 0x001a */ unsigned char Initialized; /* 0x001b */ unsigned char InitializedFirstLocalUnit; /* 0x001c */ unsigned long GsiBase; /* 0x0020 */ unsigned long CmciRegister; /* 0x0024 */ unsigned char IoUnitMissing; /* 0x0025 */ char __PADDING__[3]; } IO_APIC_DATA, *PIO_APIC_DATA; /* size: 0x0028 */ typedef struct _IO_APIC_REGISTERS { /* 0x0000 */ volatile unsigned long RegisterIndex; /* 0x0004 */ volatile unsigned long Reserved1[3]; /* 0x0010 */ volatile unsigned long RegisterValue; } IO_APIC_REGISTERS, *PIO_APIC_REGISTERS; /* size: 0x0014 */ typedef struct _IO_COMPLETION_CONTEXT { /* 0x0000 */ void* Port; /* 0x0008 */ void* Key; } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT; /* size: 0x0010 */ typedef struct _IO_DRIVER_CREATE_CONTEXT { /* 0x0000 */ short Size; /* 0x0008 */ struct _ECP_LIST* ExtraCreateParameter; /* 0x0010 */ void* DeviceObjectHint; /* 0x0018 */ struct _TXN_PARAMETER_BLOCK* TxnParameters; /* 0x0020 */ struct _ESILO* SiloContext; } IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT; /* size: 0x0028 */ typedef struct _IO_NMISOURCE { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned short Flags; /* 0x0004 */ unsigned long GlobalSystemInterruptVector; } IO_NMISOURCE, *PIO_NMISOURCE; /* size: 0x0008 */ typedef struct _IO_RESOURCE_DESCRIPTOR { /* 0x0000 */ unsigned char Option; /* 0x0001 */ unsigned char Type; /* 0x0002 */ unsigned char ShareDisposition; /* 0x0003 */ unsigned char Spare1; /* 0x0004 */ unsigned short Flags; /* 0x0006 */ unsigned short Spare2; union // _TAG_UNNAMED_18 { union { struct // _TAG_UNNAMED_19 { /* 0x0008 */ unsigned long Length; /* 0x000c */ unsigned long Alignment; /* 0x0010 */ union _LARGE_INTEGER MinimumAddress; /* 0x0018 */ union _LARGE_INTEGER MaximumAddress; } /* size: 0x0018 */ Port; struct // _TAG_UNNAMED_19 { /* 0x0008 */ unsigned long Length; /* 0x000c */ unsigned long Alignment; /* 0x0010 */ union _LARGE_INTEGER MinimumAddress; /* 0x0018 */ union _LARGE_INTEGER MaximumAddress; } /* size: 0x0018 */ Memory; struct // _TAG_UNNAMED_20 { /* 0x0008 */ unsigned long MinimumVector; /* 0x000c */ unsigned long MaximumVector; /* 0x0010 */ unsigned short AffinityPolicy; /* 0x0012 */ unsigned short Group; /* 0x0014 */ enum _IRQ_PRIORITY PriorityPolicy; /* 0x0018 */ unsigned __int64 TargetedProcessors; } /* size: 0x0018 */ Interrupt; struct // _TAG_UNNAMED_21 { /* 0x0008 */ unsigned long MinimumChannel; /* 0x000c */ unsigned long MaximumChannel; } /* size: 0x0008 */ Dma; struct // _TAG_UNNAMED_22 { /* 0x0008 */ unsigned long RequestLine; /* 0x000c */ unsigned long Reserved; /* 0x0010 */ unsigned long Channel; /* 0x0014 */ unsigned long TransferWidth; } /* size: 0x0010 */ DmaV3; struct // _TAG_UNNAMED_19 { /* 0x0008 */ unsigned long Length; /* 0x000c */ unsigned long Alignment; /* 0x0010 */ union _LARGE_INTEGER MinimumAddress; /* 0x0018 */ union _LARGE_INTEGER MaximumAddress; } /* size: 0x0018 */ Generic; struct // _TAG_UNNAMED_9 { /* 0x0008 */ unsigned long Data[3]; } /* size: 0x000c */ DevicePrivate; struct // _TAG_UNNAMED_23 { /* 0x0008 */ unsigned long Length; /* 0x000c */ unsigned long MinBusNumber; /* 0x0010 */ unsigned long MaxBusNumber; /* 0x0014 */ unsigned long Reserved; } /* size: 0x0010 */ BusNumber; struct // _TAG_UNNAMED_24 { /* 0x0008 */ unsigned long Priority; /* 0x000c */ unsigned long Reserved1; /* 0x0010 */ unsigned long Reserved2; } /* size: 0x000c */ ConfigData; struct // _TAG_UNNAMED_25 { /* 0x0008 */ unsigned long Length40; /* 0x000c */ unsigned long Alignment40; /* 0x0010 */ union _LARGE_INTEGER MinimumAddress; /* 0x0018 */ union _LARGE_INTEGER MaximumAddress; } /* size: 0x0018 */ Memory40; struct // _TAG_UNNAMED_26 { /* 0x0008 */ unsigned long Length48; /* 0x000c */ unsigned long Alignment48; /* 0x0010 */ union _LARGE_INTEGER MinimumAddress; /* 0x0018 */ union _LARGE_INTEGER MaximumAddress; } /* size: 0x0018 */ Memory48; struct // _TAG_UNNAMED_27 { /* 0x0008 */ unsigned long Length64; /* 0x000c */ unsigned long Alignment64; /* 0x0010 */ union _LARGE_INTEGER MinimumAddress; /* 0x0018 */ union _LARGE_INTEGER MaximumAddress; } /* size: 0x0018 */ Memory64; struct // _TAG_UNNAMED_15 { /* 0x0008 */ unsigned char Class; /* 0x0009 */ unsigned char Type; /* 0x000a */ unsigned char Reserved1; /* 0x000b */ unsigned char Reserved2; /* 0x000c */ unsigned long IdLowPart; /* 0x0010 */ unsigned long IdHighPart; } /* size: 0x000c */ Connection; }; /* size: 0x0018 */ } /* size: 0x0018 */ u; } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; /* size: 0x0020 */ typedef struct _IO_RESOURCE_LIST { /* 0x0000 */ unsigned short Version; /* 0x0002 */ unsigned short Revision; /* 0x0004 */ unsigned long Count; /* 0x0008 */ struct _IO_RESOURCE_DESCRIPTOR Descriptors[1]; } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST; /* size: 0x0028 */ typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { /* 0x0000 */ unsigned long ListSize; /* 0x0004 */ enum _INTERFACE_TYPE InterfaceType; /* 0x0008 */ unsigned long BusNumber; /* 0x000c */ unsigned long SlotNumber; /* 0x0010 */ unsigned long Reserved[3]; /* 0x001c */ unsigned long AlternativeLists; /* 0x0020 */ struct _IO_RESOURCE_LIST List[1]; } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; /* size: 0x0048 */ typedef struct _IO_SECURITY_CONTEXT { /* 0x0000 */ struct _SECURITY_QUALITY_OF_SERVICE* SecurityQos; /* 0x0008 */ struct _ACCESS_STATE* AccessState; /* 0x0010 */ unsigned long DesiredAccess; /* 0x0014 */ unsigned long FullCreateOptions; } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT; /* size: 0x0018 */ typedef struct _IO_STACK_LOCATION { /* 0x0000 */ unsigned char MajorFunction; /* 0x0001 */ unsigned char MinorFunction; /* 0x0002 */ unsigned char Flags; /* 0x0003 */ unsigned char Control; union // _TAG_UNNAMED_28 { union { struct // _TAG_UNNAMED_29 { /* 0x0008 */ struct _IO_SECURITY_CONTEXT* SecurityContext; /* 0x0010 */ unsigned long Options; /* 0x0018 */ unsigned short FileAttributes; /* 0x001a */ unsigned short ShareAccess; /* 0x0020 */ unsigned long EaLength; /* 0x0024 */ long __PADDING__[1]; } /* size: 0x0020 */ Create; struct // _TAG_UNNAMED_30 { /* 0x0008 */ struct _IO_SECURITY_CONTEXT* SecurityContext; /* 0x0010 */ unsigned long Options; /* 0x0018 */ unsigned short Reserved; /* 0x001a */ unsigned short ShareAccess; /* 0x0020 */ struct _NAMED_PIPE_CREATE_PARAMETERS* Parameters; } /* size: 0x0020 */ CreatePipe; struct // _TAG_UNNAMED_31 { /* 0x0008 */ struct _IO_SECURITY_CONTEXT* SecurityContext; /* 0x0010 */ unsigned long Options; /* 0x0018 */ unsigned short Reserved; /* 0x001a */ unsigned short ShareAccess; /* 0x0020 */ struct _MAILSLOT_CREATE_PARAMETERS* Parameters; } /* size: 0x0020 */ CreateMailslot; struct // _TAG_UNNAMED_32 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ unsigned long Key; /* 0x0018 */ union _LARGE_INTEGER ByteOffset; } /* size: 0x0018 */ Read; struct // _TAG_UNNAMED_32 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ unsigned long Key; /* 0x0018 */ union _LARGE_INTEGER ByteOffset; } /* size: 0x0018 */ Write; struct // _TAG_UNNAMED_33 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ struct _UNICODE_STRING* FileName; /* 0x0018 */ enum _FILE_INFORMATION_CLASS FileInformationClass; /* 0x0020 */ unsigned long FileIndex; /* 0x0024 */ long __PADDING__[1]; } /* size: 0x0020 */ QueryDirectory; struct // _TAG_UNNAMED_34 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ unsigned long CompletionFilter; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ NotifyDirectory; struct // _TAG_UNNAMED_35 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ enum _FILE_INFORMATION_CLASS FileInformationClass; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ QueryFile; struct // _TAG_UNNAMED_36 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ enum _FILE_INFORMATION_CLASS FileInformationClass; /* 0x0018 */ struct _FILE_OBJECT* FileObject; union { struct { /* 0x0020 */ unsigned char ReplaceIfExists; /* 0x0021 */ unsigned char AdvanceOnly; }; /* size: 0x0002 */ /* 0x0020 */ unsigned long ClusterCount; /* 0x0020 */ void* DeleteHandle; }; /* size: 0x0008 */ } /* size: 0x0020 */ SetFile; struct // _TAG_UNNAMED_37 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ void* EaList; /* 0x0018 */ unsigned long EaListLength; /* 0x0020 */ unsigned long EaIndex; /* 0x0024 */ long __PADDING__[1]; } /* size: 0x0020 */ QueryEa; struct // _TAG_UNNAMED_38 { /* 0x0008 */ unsigned long Length; } /* size: 0x0004 */ SetEa; struct // _TAG_UNNAMED_39 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ enum _FSINFOCLASS FsInformationClass; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ QueryVolume; struct // _TAG_UNNAMED_39 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ enum _FSINFOCLASS FsInformationClass; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ SetVolume; struct // _TAG_UNNAMED_40 { /* 0x0008 */ unsigned long OutputBufferLength; /* 0x0010 */ unsigned long InputBufferLength; /* 0x0018 */ unsigned long FsControlCode; /* 0x0020 */ void* Type3InputBuffer; } /* size: 0x0020 */ FileSystemControl; struct // _TAG_UNNAMED_41 { /* 0x0008 */ union _LARGE_INTEGER* Length; /* 0x0010 */ unsigned long Key; /* 0x0018 */ union _LARGE_INTEGER ByteOffset; } /* size: 0x0018 */ LockControl; struct // _TAG_UNNAMED_42 { /* 0x0008 */ unsigned long OutputBufferLength; /* 0x0010 */ unsigned long InputBufferLength; /* 0x0018 */ unsigned long IoControlCode; /* 0x0020 */ void* Type3InputBuffer; } /* size: 0x0020 */ DeviceIoControl; struct // _TAG_UNNAMED_43 { /* 0x0008 */ unsigned long SecurityInformation; /* 0x0010 */ unsigned long Length; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ QuerySecurity; struct // _TAG_UNNAMED_44 { /* 0x0008 */ unsigned long SecurityInformation; /* 0x0010 */ void* SecurityDescriptor; } /* size: 0x0010 */ SetSecurity; struct // _TAG_UNNAMED_45 { /* 0x0008 */ struct _VPB* Vpb; /* 0x0010 */ struct _DEVICE_OBJECT* DeviceObject; } /* size: 0x0010 */ MountVolume; struct // _TAG_UNNAMED_45 { /* 0x0008 */ struct _VPB* Vpb; /* 0x0010 */ struct _DEVICE_OBJECT* DeviceObject; } /* size: 0x0010 */ VerifyVolume; struct // _TAG_UNNAMED_46 { /* 0x0008 */ struct _SCSI_REQUEST_BLOCK* Srb; } /* size: 0x0008 */ Scsi; struct // _TAG_UNNAMED_47 { /* 0x0008 */ unsigned long Length; /* 0x0010 */ void* StartSid; /* 0x0018 */ struct _FILE_GET_QUOTA_INFORMATION* SidList; /* 0x0020 */ unsigned long SidListLength; /* 0x0024 */ long __PADDING__[1]; } /* size: 0x0020 */ QueryQuota; struct // _TAG_UNNAMED_38 { /* 0x0008 */ unsigned long Length; } /* size: 0x0004 */ SetQuota; struct // _TAG_UNNAMED_48 { /* 0x0008 */ enum _DEVICE_RELATION_TYPE Type; } /* size: 0x0004 */ QueryDeviceRelations; struct // _TAG_UNNAMED_49 { /* 0x0008 */ const struct _GUID* InterfaceType; /* 0x0010 */ unsigned short Size; /* 0x0012 */ unsigned short Version; /* 0x0018 */ struct _INTERFACE* Interface; /* 0x0020 */ void* InterfaceSpecificData; } /* size: 0x0020 */ QueryInterface; struct // _TAG_UNNAMED_50 { /* 0x0008 */ struct _DEVICE_CAPABILITIES* Capabilities; } /* size: 0x0008 */ DeviceCapabilities; struct // _TAG_UNNAMED_51 { /* 0x0008 */ struct _IO_RESOURCE_REQUIREMENTS_LIST* IoResourceRequirementList; } /* size: 0x0008 */ FilterResourceRequirements; struct // _TAG_UNNAMED_52 { /* 0x0008 */ unsigned long WhichSpace; /* 0x0010 */ void* Buffer; /* 0x0018 */ unsigned long Offset; /* 0x0020 */ unsigned long Length; /* 0x0024 */ long __PADDING__[1]; } /* size: 0x0020 */ ReadWriteConfig; struct // _TAG_UNNAMED_53 { /* 0x0008 */ unsigned char Lock; } /* size: 0x0001 */ SetLock; struct // _TAG_UNNAMED_54 { /* 0x0008 */ enum BUS_QUERY_ID_TYPE IdType; } /* size: 0x0004 */ QueryId; struct // _TAG_UNNAMED_55 { /* 0x0008 */ enum DEVICE_TEXT_TYPE DeviceTextType; /* 0x0010 */ unsigned long LocaleId; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ QueryDeviceText; struct // _TAG_UNNAMED_56 { /* 0x0008 */ unsigned char InPath; /* 0x0009 */ unsigned char Reserved[3]; /* 0x0010 */ enum _DEVICE_USAGE_NOTIFICATION_TYPE Type; /* 0x0014 */ long __PADDING__[1]; } /* size: 0x0010 */ UsageNotification; struct // _TAG_UNNAMED_57 { /* 0x0008 */ enum _SYSTEM_POWER_STATE PowerState; } /* size: 0x0004 */ WaitWake; struct // _TAG_UNNAMED_58 { /* 0x0008 */ struct _POWER_SEQUENCE* PowerSequence; } /* size: 0x0008 */ PowerSequence; struct // _TAG_UNNAMED_59 { union { /* 0x0008 */ unsigned long SystemContext; /* 0x0008 */ struct _SYSTEM_POWER_STATE_CONTEXT SystemPowerStateContext; }; /* size: 0x0004 */ /* 0x0010 */ enum _POWER_STATE_TYPE Type; /* 0x0018 */ union _POWER_STATE State; /* 0x0020 */ enum POWER_ACTION ShutdownType; /* 0x0024 */ long __PADDING__[1]; } /* size: 0x0020 */ Power; struct // _TAG_UNNAMED_60 { /* 0x0008 */ struct _CM_RESOURCE_LIST* AllocatedResources; /* 0x0010 */ struct _CM_RESOURCE_LIST* AllocatedResourcesTranslated; } /* size: 0x0010 */ StartDevice; struct // _TAG_UNNAMED_61 { /* 0x0008 */ unsigned __int64 ProviderId; /* 0x0010 */ void* DataPath; /* 0x0018 */ unsigned long BufferSize; /* 0x0020 */ void* Buffer; } /* size: 0x0020 */ WMI; struct // _TAG_UNNAMED_62 { /* 0x0008 */ void* Argument1; /* 0x0010 */ void* Argument2; /* 0x0018 */ void* Argument3; /* 0x0020 */ void* Argument4; } /* size: 0x0020 */ Others; }; /* size: 0x0020 */ } /* size: 0x0020 */ Parameters; /* 0x0028 */ struct _DEVICE_OBJECT* DeviceObject; /* 0x0030 */ struct _FILE_OBJECT* FileObject; /* 0x0038 */ void* CompletionRoutine /* function */; /* 0x0040 */ void* Context; } IO_STACK_LOCATION, *PIO_STACK_LOCATION; /* size: 0x0048 */ typedef struct _IO_STATUS_BLOCK { union { /* 0x0000 */ long Status; /* 0x0000 */ void* Pointer; }; /* size: 0x0008 */ /* 0x0008 */ unsigned __int64 Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; /* size: 0x0010 */ struct _IO_TIMER; typedef struct _IRP { /* 0x0000 */ short Type; /* 0x0002 */ unsigned short Size; /* 0x0008 */ struct _MDL* MdlAddress; /* 0x0010 */ unsigned long Flags; union // _TAG_UNNAMED_63 { union { /* 0x0018 */ struct _IRP* MasterIrp; /* 0x0018 */ long IrpCount; /* 0x0018 */ void* SystemBuffer; }; /* size: 0x0008 */ } /* size: 0x0008 */ AssociatedIrp; /* 0x0020 */ struct _LIST_ENTRY ThreadListEntry; /* 0x0030 */ struct _IO_STATUS_BLOCK IoStatus; /* 0x0040 */ char RequestorMode; /* 0x0041 */ unsigned char PendingReturned; /* 0x0042 */ char StackCount; /* 0x0043 */ char CurrentLocation; /* 0x0044 */ unsigned char Cancel; /* 0x0045 */ unsigned char CancelIrql; /* 0x0046 */ char ApcEnvironment; /* 0x0047 */ unsigned char AllocationFlags; /* 0x0048 */ struct _IO_STATUS_BLOCK* UserIosb; /* 0x0050 */ struct _KEVENT* UserEvent; union // _TAG_UNNAMED_64 { union { struct // _TAG_UNNAMED_65 { union { /* 0x0058 */ void* UserApcRoutine /* function */; /* 0x0058 */ void* IssuingProcess; }; /* size: 0x0008 */ /* 0x0060 */ void* UserApcContext; } /* size: 0x0010 */ AsynchronousParameters; /* 0x0058 */ union _LARGE_INTEGER AllocationSize; }; /* size: 0x0010 */ } /* size: 0x0010 */ Overlay; /* 0x0068 */ void* CancelRoutine /* function */; /* 0x0070 */ void* UserBuffer; union // _TAG_UNNAMED_66 { union { struct // _TAG_UNNAMED_67 { union { /* 0x0078 */ struct _KDEVICE_QUEUE_ENTRY DeviceQueueEntry; /* 0x0078 */ void* DriverContext[4]; }; /* size: 0x0020 */ /* 0x0098 */ struct _ETHREAD* Thread; /* 0x00a0 */ char* AuxiliaryBuffer; /* 0x00a8 */ struct _LIST_ENTRY ListEntry; union { /* 0x00b8 */ struct _IO_STACK_LOCATION* CurrentStackLocation; /* 0x00b8 */ unsigned long PacketType; }; /* size: 0x0008 */ /* 0x00c0 */ struct _FILE_OBJECT* OriginalFileObject; } /* size: 0x0050 */ Overlay; /* 0x0078 */ struct _KAPC Apc; /* 0x0078 */ void* CompletionKey; }; /* size: 0x0058 */ } /* size: 0x0058 */ Tail; } IRP, *PIRP; /* size: 0x00d0 */ typedef enum _IRQ_PRIORITY { IrqPriorityUndefined = 0, IrqPriorityLow = 1, IrqPriorityNormal = 2, IrqPriorityHigh = 3, } IRQ_PRIORITY, *PIRQ_PRIORITY; typedef struct _ISA_VECTOR { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned char Bus; /* 0x0003 */ unsigned char Source; /* 0x0004 */ unsigned long GlobalSystemInterruptVector; /* 0x0008 */ unsigned short Flags; } ISA_VECTOR, *PISA_VECTOR; /* size: 0x000a */ typedef struct _KAFFINITY_EX { /* 0x0000 */ unsigned short Count; /* 0x0002 */ unsigned short Size; /* 0x0004 */ unsigned long Reserved; /* 0x0008 */ unsigned __int64 Bitmap[20]; } KAFFINITY_EX, *PKAFFINITY_EX; /* size: 0x00a8 */ typedef struct _KAPC { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char SpareByte0; /* 0x0002 */ unsigned char Size; /* 0x0003 */ unsigned char SpareByte1; /* 0x0004 */ unsigned long SpareLong0; /* 0x0008 */ struct _KTHREAD* Thread; /* 0x0010 */ struct _LIST_ENTRY ApcListEntry; /* 0x0020 */ void* Reserved[3]; /* 0x0038 */ void* NormalContext; /* 0x0040 */ void* SystemArgument1; /* 0x0048 */ void* SystemArgument2; /* 0x0050 */ char ApcStateIndex; /* 0x0051 */ char ApcMode; /* 0x0052 */ unsigned char Inserted; /* 0x0053 */ char __PADDING__[5]; } KAPC, *PKAPC; /* size: 0x0058 */ typedef struct _KDESCRIPTOR { /* 0x0000 */ unsigned short Pad[3]; /* 0x0006 */ unsigned short Limit; /* 0x0008 */ void* Base; } KDESCRIPTOR, *PKDESCRIPTOR; /* size: 0x0010 */ typedef struct _KDEVICE_QUEUE { /* 0x0000 */ short Type; /* 0x0002 */ short Size; /* 0x0008 */ struct _LIST_ENTRY DeviceListHead; /* 0x0018 */ unsigned __int64 Lock; union { /* 0x0020 */ unsigned char Busy; struct /* bitfield */ { /* 0x0020 */ __int64 Reserved : 8; /* bit position: 0 */ /* 0x0020 */ __int64 Hint : 56; /* bit position: 8 */ }; /* bitfield */ }; /* size: 0x0008 */ } KDEVICE_QUEUE, *PKDEVICE_QUEUE; /* size: 0x0028 */ typedef struct _KDEVICE_QUEUE_ENTRY { /* 0x0000 */ struct _LIST_ENTRY DeviceListEntry; /* 0x0010 */ unsigned long SortKey; /* 0x0014 */ unsigned char Inserted; /* 0x0015 */ char __PADDING__[3]; } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY; /* size: 0x0018 */ typedef struct _KDPC { union { /* 0x0000 */ unsigned long TargetInfoAsUlong; struct { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Importance; /* 0x0002 */ volatile unsigned short Number; }; /* size: 0x0004 */ }; /* size: 0x0004 */ /* 0x0008 */ struct _SINGLE_LIST_ENTRY DpcListEntry; /* 0x0010 */ unsigned __int64 ProcessorHistory; /* 0x0018 */ void* DeferredRoutine /* function */; /* 0x0020 */ void* DeferredContext; /* 0x0028 */ void* SystemArgument1; /* 0x0030 */ void* SystemArgument2; /* 0x0038 */ void* DpcData; } KDPC, *PKDPC; /* size: 0x0040 */ typedef struct _KEVENT { /* 0x0000 */ struct _DISPATCHER_HEADER Header; } KEVENT, *PKEVENT; /* size: 0x0018 */ typedef struct _KFLOATING_SAVE { /* 0x0000 */ unsigned long Dummy; } KFLOATING_SAVE, *PKFLOATING_SAVE; /* size: 0x0004 */ typedef union _KGDTENTRY64 { union { struct { /* 0x0000 */ unsigned short LimitLow; /* 0x0002 */ unsigned short BaseLow; union { struct // _TAG_UNNAMED_68 { /* 0x0004 */ unsigned char BaseMiddle; /* 0x0005 */ unsigned char Flags1; /* 0x0006 */ unsigned char Flags2; /* 0x0007 */ unsigned char BaseHigh; } /* size: 0x0004 */ Bytes; struct { struct // _TAG_UNNAMED_69 { struct /* bitfield */ { /* 0x0004 */ unsigned long BaseMiddle : 8; /* bit position: 0 */ /* 0x0004 */ unsigned long Type : 5; /* bit position: 8 */ /* 0x0004 */ unsigned long Dpl : 2; /* bit position: 13 */ /* 0x0004 */ unsigned long Present : 1; /* bit position: 15 */ /* 0x0004 */ unsigned long LimitHigh : 4; /* bit position: 16 */ /* 0x0004 */ unsigned long System : 1; /* bit position: 20 */ /* 0x0004 */ unsigned long LongMode : 1; /* bit position: 21 */ /* 0x0004 */ unsigned long DefaultBig : 1; /* bit position: 22 */ /* 0x0004 */ unsigned long Granularity : 1; /* bit position: 23 */ /* 0x0004 */ unsigned long BaseHigh : 8; /* bit position: 24 */ }; /* bitfield */ } /* size: 0x0004 */ Bits; /* 0x0008 */ unsigned long BaseUpper; /* 0x000c */ unsigned long MustBeZero; }; /* size: 0x000c */ }; /* size: 0x000c */ }; /* size: 0x0010 */ struct { /* 0x0000 */ __int64 DataLow; /* 0x0008 */ __int64 DataHigh; }; /* size: 0x0010 */ }; /* size: 0x0010 */ } KGDTENTRY64, *PKGDTENTRY64; /* size: 0x0010 */ typedef union _KIDTENTRY64 { union { struct { /* 0x0000 */ unsigned short OffsetLow; /* 0x0002 */ unsigned short Selector; struct /* bitfield */ { /* 0x0004 */ unsigned short IstIndex : 3; /* bit position: 0 */ /* 0x0004 */ unsigned short Reserved0 : 5; /* bit position: 3 */ /* 0x0004 */ unsigned short Type : 5; /* bit position: 8 */ /* 0x0004 */ unsigned short Dpl : 2; /* bit position: 13 */ /* 0x0004 */ unsigned short Present : 1; /* bit position: 15 */ }; /* bitfield */ /* 0x0006 */ unsigned short OffsetMiddle; /* 0x0008 */ unsigned long OffsetHigh; /* 0x000c */ unsigned long Reserved1; }; /* size: 0x0010 */ /* 0x0000 */ unsigned __int64 Alignment; }; /* size: 0x0010 */ } KIDTENTRY64, *PKIDTENTRY64; /* size: 0x0010 */ typedef enum _KINTERRUPT_MODE { LevelSensitive = 0, Latched = 1, } KINTERRUPT_MODE, *PKINTERRUPT_MODE; typedef enum _KINTERRUPT_POLARITY { InterruptPolarityUnknown = 0, InterruptActiveHigh = 1, InterruptRisingEdge = 1, InterruptActiveLow = 2, InterruptFallingEdge = 2, InterruptActiveBoth = 3, InterruptActiveBothTriggerLow = 3, InterruptActiveBothTriggerHigh = 4, } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY; struct _KNODE; typedef enum _KNOWN_CONTROLLER_TYPE { InterruptControllerInvalid = 0, InterruptControllerPic = 1, InterruptControllerApic = 2, InterruptControllerGic = 3, InterruptControllerBcm = 4, InterruptControllerUnknown = 4096, } KNOWN_CONTROLLER_TYPE, *PKNOWN_CONTROLLER_TYPE; typedef struct _KPCR { union { /* 0x0000 */ struct _NT_TIB NtTib; struct { /* 0x0000 */ union _KGDTENTRY64* GdtBase; /* 0x0008 */ struct _KTSS64* TssBase; /* 0x0010 */ unsigned __int64 UserRsp; /* 0x0018 */ struct _KPCR* Self; /* 0x0020 */ struct _KPRCB* CurrentPrcb; /* 0x0028 */ struct _KSPIN_LOCK_QUEUE* LockArray; /* 0x0030 */ void* Used_Self; }; /* size: 0x0038 */ }; /* size: 0x0038 */ /* 0x0038 */ union _KIDTENTRY64* IdtBase; /* 0x0040 */ unsigned __int64 Unused[2]; /* 0x0050 */ unsigned char Irql; /* 0x0051 */ unsigned char SecondLevelCacheAssociativity; /* 0x0052 */ unsigned char ObsoleteNumber; /* 0x0053 */ unsigned char Fill0; /* 0x0054 */ unsigned long Unused0[3]; /* 0x0060 */ unsigned short MajorVersion; /* 0x0062 */ unsigned short MinorVersion; /* 0x0064 */ unsigned long StallScaleFactor; /* 0x0068 */ void* Unused1[3]; /* 0x0080 */ unsigned long KernelReserved[15]; /* 0x00bc */ unsigned long SecondLevelCacheSize; /* 0x00c0 */ unsigned long HalReserved[16]; /* 0x0100 */ unsigned long Unused2; /* 0x0108 */ void* KdVersionBlock; /* 0x0110 */ void* Unused3; /* 0x0118 */ unsigned long PcrAlign1[24]; } KPCR, *PKPCR; /* size: 0x0178 */ typedef struct _KPRCB { /* 0x0000 */ unsigned long MxCsr; /* 0x0004 */ unsigned char LegacyNumber; /* 0x0005 */ unsigned char ReservedMustBeZero; /* 0x0006 */ unsigned char InterruptRequest; /* 0x0007 */ unsigned char IdleHalt; /* 0x0008 */ struct _KTHREAD* CurrentThread; /* 0x0010 */ struct _KTHREAD* NextThread; /* 0x0018 */ struct _KTHREAD* IdleThread; /* 0x0020 */ unsigned char NestingLevel; /* 0x0021 */ unsigned char ClockOwner; union { /* 0x0022 */ unsigned char PendingTickFlags; struct /* bitfield */ { /* 0x0022 */ unsigned char PendingTick : 1; /* bit position: 0 */ /* 0x0022 */ unsigned char PendingBackupTick : 1; /* bit position: 1 */ }; /* bitfield */ }; /* size: 0x0001 */ /* 0x0023 */ unsigned char IdleState; /* 0x0024 */ unsigned long Number; /* 0x0028 */ unsigned __int64 RspBase; /* 0x0030 */ unsigned __int64 PrcbLock; /* 0x0038 */ char* PriorityState; /* 0x0040 */ struct _KPROCESSOR_STATE ProcessorState; /* 0x05f0 */ char CpuType; /* 0x05f1 */ char CpuID; union { /* 0x05f2 */ unsigned short CpuStep; struct { /* 0x05f2 */ unsigned char CpuStepping; /* 0x05f3 */ unsigned char CpuModel; }; /* size: 0x0002 */ }; /* size: 0x0002 */ /* 0x05f4 */ unsigned long MHz; /* 0x05f8 */ unsigned __int64 HalReserved[8]; /* 0x0638 */ unsigned short MinorVersion; /* 0x063a */ unsigned short MajorVersion; /* 0x063c */ unsigned char BuildType; /* 0x063d */ unsigned char CpuVendor; /* 0x063e */ unsigned char CoresPerPhysicalProcessor; /* 0x063f */ unsigned char LogicalProcessorsPerCore; /* 0x0640 */ struct _KNODE* ParentNode; /* 0x0648 */ unsigned __int64 GroupSetMember; /* 0x0650 */ unsigned char Group; /* 0x0651 */ unsigned char GroupIndex; /* 0x0652 */ unsigned char PrcbPad05[2]; /* 0x0654 */ unsigned long InitialApicId; /* 0x0658 */ unsigned long ScbOffset; /* 0x065c */ unsigned long ApicMask; /* 0x0660 */ void* AcpiReserved; /* 0x0668 */ unsigned long CFlushSize; /* 0x066c */ unsigned long PrcbPad10; } KPRCB, *PKPRCB; /* size: 0x0670 */ struct _KPROCESS; typedef struct _KPROCESSOR_STATE { /* 0x0000 */ struct _KSPECIAL_REGISTERS SpecialRegisters; /* 0x00e0 */ struct _CONTEXT ContextFrame; } KPROCESSOR_STATE, *PKPROCESSOR_STATE; /* size: 0x05b0 */ typedef struct _KSPECIAL_REGISTERS { /* 0x0000 */ unsigned __int64 Cr0; /* 0x0008 */ unsigned __int64 Cr2; /* 0x0010 */ unsigned __int64 Cr3; /* 0x0018 */ unsigned __int64 Cr4; /* 0x0020 */ unsigned __int64 KernelDr0; /* 0x0028 */ unsigned __int64 KernelDr1; /* 0x0030 */ unsigned __int64 KernelDr2; /* 0x0038 */ unsigned __int64 KernelDr3; /* 0x0040 */ unsigned __int64 KernelDr6; /* 0x0048 */ unsigned __int64 KernelDr7; /* 0x0050 */ struct _KDESCRIPTOR Gdtr; /* 0x0060 */ struct _KDESCRIPTOR Idtr; /* 0x0070 */ unsigned short Tr; /* 0x0072 */ unsigned short Ldtr; /* 0x0074 */ unsigned long MxCsr; /* 0x0078 */ unsigned __int64 DebugControl; /* 0x0080 */ unsigned __int64 LastBranchToRip; /* 0x0088 */ unsigned __int64 LastBranchFromRip; /* 0x0090 */ unsigned __int64 LastExceptionToRip; /* 0x0098 */ unsigned __int64 LastExceptionFromRip; /* 0x00a0 */ unsigned __int64 Cr8; /* 0x00a8 */ unsigned __int64 MsrGsBase; /* 0x00b0 */ unsigned __int64 MsrGsSwap; /* 0x00b8 */ unsigned __int64 MsrStar; /* 0x00c0 */ unsigned __int64 MsrLStar; /* 0x00c8 */ unsigned __int64 MsrCStar; /* 0x00d0 */ unsigned __int64 MsrSyscallMask; /* 0x00d8 */ unsigned __int64 Xcr0; } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS; /* size: 0x00e0 */ typedef struct _KSPIN_LOCK_QUEUE { /* 0x0000 */ struct _KSPIN_LOCK_QUEUE* volatile Next; /* 0x0008 */ unsigned __int64* volatile Lock; } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; /* size: 0x0010 */ typedef struct _KTB_FLUSH_VA { union // _TAG_UNNAMED_70 { union { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 NumberOfEntries : 11; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 PageSize : 1; /* bit position: 11 */ }; /* bitfield */ /* 0x0000 */ void* Va; /* 0x0000 */ unsigned __int64 VaLong; }; /* size: 0x0008 */ } /* size: 0x0008 */ u1; } KTB_FLUSH_VA, *PKTB_FLUSH_VA; /* size: 0x0008 */ struct _KTHREAD; typedef struct _KTSS64 { /* 0x0000 */ unsigned long Reserved0; /* 0x0004 */ unsigned __int64 Rsp0; /* 0x000c */ unsigned __int64 Rsp1; /* 0x0014 */ unsigned __int64 Rsp2; /* 0x001c */ unsigned __int64 Ist[8]; /* 0x005c */ unsigned __int64 Reserved1; /* 0x0064 */ unsigned short Reserved2; /* 0x0066 */ unsigned short IoMapBase; } KTSS64, *PKTSS64; /* size: 0x0068 */ typedef struct _KWAIT_CHAIN { /* 0x0000 */ struct _SINGLE_LIST_ENTRY Head; } KWAIT_CHAIN, *PKWAIT_CHAIN; /* size: 0x0008 */ typedef union _LARGE_INTEGER { union { struct { /* 0x0000 */ unsigned long LowPart; /* 0x0004 */ long HighPart; }; /* size: 0x0008 */ struct // _TAG_UNNAMED_71 { /* 0x0000 */ unsigned long LowPart; /* 0x0004 */ long HighPart; } /* size: 0x0008 */ u; /* 0x0000 */ __int64 QuadPart; }; /* size: 0x0008 */ } LARGE_INTEGER, *PLARGE_INTEGER; /* size: 0x0008 */ typedef struct _LIST_ENTRY { /* 0x0000 */ struct _LIST_ENTRY* Flink; /* 0x0008 */ struct _LIST_ENTRY* Blink; } LIST_ENTRY, *PLIST_ENTRY; /* size: 0x0010 */ typedef struct _LOCAL_NMISOURCE { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned char ProcessorID; /* 0x0003 */ unsigned short Flags; /* 0x0005 */ unsigned char LINTIN; } LOCAL_NMISOURCE, *PLOCAL_NMISOURCE; /* size: 0x0006 */ typedef struct _LOOKASIDE_LIST_EX { /* 0x0000 */ struct _GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX, *PLOOKASIDE_LIST_EX; /* size: 0x0060 */ typedef struct _LUID { /* 0x0000 */ unsigned long LowPart; /* 0x0004 */ long HighPart; } LUID, *PLUID; /* size: 0x0008 */ typedef struct _LUID_AND_ATTRIBUTES { /* 0x0000 */ struct _LUID Luid; /* 0x0008 */ unsigned long Attributes; } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; /* size: 0x000c */ typedef struct _M128A { /* 0x0000 */ unsigned __int64 Low; /* 0x0008 */ __int64 High; } M128A, *PM128A; /* size: 0x0010 */ typedef struct _MAILSLOT_CREATE_PARAMETERS { /* 0x0000 */ unsigned long MailslotQuota; /* 0x0004 */ unsigned long MaximumMessageSize; /* 0x0008 */ union _LARGE_INTEGER ReadTimeout; /* 0x0010 */ unsigned char TimeoutSpecified; /* 0x0011 */ char __PADDING__[7]; } MAILSLOT_CREATE_PARAMETERS, *PMAILSLOT_CREATE_PARAMETERS; /* size: 0x0018 */ typedef struct _MAPIC { /* 0x0000 */ struct _DESCRIPTION_HEADER Header; /* 0x0024 */ unsigned long LocalAPICAddress; /* 0x0028 */ unsigned long Flags; /* 0x002c */ unsigned long APICTables[1]; } MAPIC, *PMAPIC; /* size: 0x0030 */ typedef union _MCG_STATUS { union { struct { struct /* bitfield */ { /* 0x0000 */ unsigned long RestartIpValid : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long ErrorIpValid : 1; /* bit position: 1 */ /* 0x0000 */ unsigned long MachineCheckInProgress : 1; /* bit position: 2 */ /* 0x0000 */ unsigned long Reserved1 : 29; /* bit position: 3 */ }; /* bitfield */ /* 0x0004 */ unsigned long Reserved2; }; /* size: 0x0008 */ /* 0x0000 */ unsigned __int64 QuadPart; }; /* size: 0x0008 */ } MCG_STATUS, *PMCG_STATUS; /* size: 0x0008 */ typedef union _MCI_STATUS { union { struct { /* 0x0000 */ unsigned short McaErrorCode; /* 0x0002 */ unsigned short ModelErrorCode; struct /* bitfield */ { /* 0x0004 */ unsigned long OtherInformation : 23; /* bit position: 0 */ /* 0x0004 */ unsigned long ActionRequired : 1; /* bit position: 23 */ /* 0x0004 */ unsigned long Signalling : 1; /* bit position: 24 */ /* 0x0004 */ unsigned long ContextCorrupt : 1; /* bit position: 25 */ /* 0x0004 */ unsigned long AddressValid : 1; /* bit position: 26 */ /* 0x0004 */ unsigned long MiscValid : 1; /* bit position: 27 */ /* 0x0004 */ unsigned long ErrorEnabled : 1; /* bit position: 28 */ /* 0x0004 */ unsigned long UncorrectedError : 1; /* bit position: 29 */ /* 0x0004 */ unsigned long StatusOverFlow : 1; /* bit position: 30 */ /* 0x0004 */ unsigned long Valid : 1; /* bit position: 31 */ }; /* bitfield */ }; /* size: 0x0008 */ /* 0x0000 */ unsigned __int64 QuadPart; }; /* size: 0x0008 */ } MCI_STATUS, *PMCI_STATUS; /* size: 0x0008 */ typedef struct _MDL { /* 0x0000 */ struct _MDL* Next; /* 0x0008 */ short Size; /* 0x000a */ short MdlFlags; /* 0x0010 */ struct _EPROCESS* Process; /* 0x0018 */ void* MappedSystemVa; /* 0x0020 */ void* StartVa; /* 0x0028 */ unsigned long ByteCount; /* 0x002c */ unsigned long ByteOffset; } MDL, *PMDL; /* size: 0x0030 */ typedef enum _MEMORY_CACHING_TYPE { MmNonCached = 0, MmCached = 1, MmWriteCombined = 2, MmHardwareCoherentCached = 3, MmNonCachedUnordered = 4, MmUSWCCached = 5, MmMaximumCacheType = 6, MmNotMapped = -1, } MEMORY_CACHING_TYPE, *PMEMORY_CACHING_TYPE; typedef enum _MEMORY_CACHING_TYPE_ORIG { MmFrameBufferCached = 2, } MEMORY_CACHING_TYPE_ORIG, *PMEMORY_CACHING_TYPE_ORIG; typedef enum _MODE { KernelMode = 0, UserMode = 1, MaximumMode = 2, } MODE, *PMODE; typedef struct _NAMED_PIPE_CREATE_PARAMETERS { /* 0x0000 */ unsigned long NamedPipeType; /* 0x0004 */ unsigned long ReadMode; /* 0x0008 */ unsigned long CompletionMode; /* 0x000c */ unsigned long MaximumInstances; /* 0x0010 */ unsigned long InboundQuota; /* 0x0014 */ unsigned long OutboundQuota; /* 0x0018 */ union _LARGE_INTEGER DefaultTimeout; /* 0x0020 */ unsigned char TimeoutSpecified; /* 0x0021 */ char __PADDING__[7]; } NAMED_PIPE_CREATE_PARAMETERS, *PNAMED_PIPE_CREATE_PARAMETERS; /* size: 0x0028 */ typedef struct _NPAGED_LOOKASIDE_LIST { /* 0x0000 */ struct _GENERAL_LOOKASIDE L; } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; /* size: 0x0080 */ typedef struct _NT_TIB { /* 0x0000 */ struct _EXCEPTION_REGISTRATION_RECORD* ExceptionList; /* 0x0008 */ void* StackBase; /* 0x0010 */ void* StackLimit; /* 0x0018 */ void* SubSystemTib; union { /* 0x0020 */ void* FiberData; /* 0x0020 */ unsigned long Version; }; /* size: 0x0008 */ /* 0x0028 */ void* ArbitraryUserPointer; /* 0x0030 */ struct _NT_TIB* Self; } NT_TIB, *PNT_TIB; /* size: 0x0038 */ typedef struct _OWNER_ENTRY { /* 0x0000 */ unsigned __int64 OwnerThread; union { struct /* bitfield */ { /* 0x0008 */ unsigned long IoPriorityBoosted : 1; /* bit position: 0 */ /* 0x0008 */ unsigned long OwnerReferenced : 1; /* bit position: 1 */ /* 0x0008 */ unsigned long OwnerCount : 30; /* bit position: 2 */ }; /* bitfield */ /* 0x0008 */ unsigned long TableSize; }; /* size: 0x0004 */ /* 0x000c */ long __PADDING__[1]; } OWNER_ENTRY, *POWNER_ENTRY; /* size: 0x0010 */ typedef struct _PAGED_LOOKASIDE_LIST { /* 0x0000 */ struct _GENERAL_LOOKASIDE L; } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; /* size: 0x0080 */ typedef struct _PLATFORM_INTERRUPT { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned short Flags; /* 0x0004 */ unsigned char InterruptType; /* 0x0005 */ unsigned char APICID; /* 0x0006 */ unsigned char ACPIEID; /* 0x0007 */ unsigned char IOSAPICVector; /* 0x0008 */ unsigned long GlobalVector; /* 0x000c */ unsigned long Reserved; } PLATFORM_INTERRUPT, *PPLATFORM_INTERRUPT; /* size: 0x0010 */ typedef enum _POOL_TYPE { NonPagedPool = 0, NonPagedPoolExecute = 0, PagedPool = 1, NonPagedPoolMustSucceed = 2, DontUseThisType = 3, NonPagedPoolCacheAligned = 4, PagedPoolCacheAligned = 5, NonPagedPoolCacheAlignedMustS = 6, MaxPoolType = 7, NonPagedPoolBase = 0, NonPagedPoolBaseMustSucceed = 2, NonPagedPoolBaseCacheAligned = 4, NonPagedPoolBaseCacheAlignedMustS = 6, NonPagedPoolSession = 32, PagedPoolSession = 33, NonPagedPoolMustSucceedSession = 34, DontUseThisTypeSession = 35, NonPagedPoolCacheAlignedSession = 36, PagedPoolCacheAlignedSession = 37, NonPagedPoolCacheAlignedMustSSession = 38, NonPagedPoolNx = 512, NonPagedPoolNxCacheAligned = 516, NonPagedPoolSessionNx = 544, } POOL_TYPE, *PPOOL_TYPE; typedef struct _POWER_SEQUENCE { /* 0x0000 */ unsigned long SequenceD1; /* 0x0004 */ unsigned long SequenceD2; /* 0x0008 */ unsigned long SequenceD3; } POWER_SEQUENCE, *PPOWER_SEQUENCE; /* size: 0x000c */ typedef union _POWER_STATE { union { /* 0x0000 */ enum _SYSTEM_POWER_STATE SystemState; /* 0x0000 */ enum _DEVICE_POWER_STATE DeviceState; }; /* size: 0x0004 */ } POWER_STATE, *PPOWER_STATE; /* size: 0x0004 */ typedef enum _POWER_STATE_TYPE { SystemPowerState = 0, DevicePowerState = 1, } POWER_STATE_TYPE, *PPOWER_STATE_TYPE; typedef struct _PRIVILEGE_SET { /* 0x0000 */ unsigned long PrivilegeCount; /* 0x0004 */ unsigned long Control; /* 0x0008 */ struct _LUID_AND_ATTRIBUTES Privilege[1]; } PRIVILEGE_SET, *PPRIVILEGE_SET; /* size: 0x0014 */ typedef struct _PROCLOCALAPIC { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned char ACPIProcessorID; /* 0x0003 */ unsigned char APICID; /* 0x0004 */ unsigned long Flags; } PROCLOCALAPIC, *PPROCLOCALAPIC; /* size: 0x0008 */ typedef struct _PROCLOCALSAPIC { /* 0x0000 */ unsigned char Type; /* 0x0001 */ unsigned char Length; /* 0x0002 */ unsigned char ACPIProcessorID; /* 0x0003 */ unsigned char APICID; /* 0x0004 */ unsigned char APICEID; /* 0x0005 */ unsigned char Reserved[3]; /* 0x0008 */ unsigned long Flags; /* 0x000c */ unsigned long ACPIProcessorUIDInteger; /* 0x0010 */ char ACPIProcessorUIDString[1]; } PROCLOCALSAPIC, *PPROCLOCALSAPIC; /* size: 0x0011 */ typedef struct _REGISTERED_INTERRUPT_CONTROLLER { /* 0x0000 */ struct _LIST_ENTRY ListEntry; /* 0x0010 */ void* InternalData; /* 0x0018 */ unsigned long InternalDataSize; /* 0x0020 */ struct _INTERRUPT_FUNCTION_TABLE FunctionTable; /* 0x00c0 */ enum _KNOWN_CONTROLLER_TYPE KnownType; /* 0x00c4 */ unsigned long Capabilities; /* 0x00c8 */ unsigned long Flags; /* 0x00cc */ unsigned long MaxPriority; /* 0x00d0 */ unsigned long UnitId; /* 0x00d8 */ struct _LIST_ENTRY LinesHead; /* 0x00e8 */ struct _LIST_ENTRY OutputLinesHead; /* 0x00f8 */ long MinLine; /* 0x00fc */ long MaxLine; /* 0x0100 */ unsigned long MaxClusterSize; /* 0x0104 */ unsigned long MaxClusters; /* 0x0108 */ unsigned long InterruptReplayDataSize; /* 0x010c */ enum _INTERRUPT_PROBLEM Problem; /* 0x0110 */ long ProblemStatus; /* 0x0118 */ const char* ProblemSourceFile; /* 0x0120 */ unsigned long ProblemSourceLine; /* 0x0124 */ unsigned long CustomProblem; /* 0x0128 */ long CustomProblemStatus; /* 0x0130 */ struct _UNICODE_STRING ResourceId; /* 0x0140 */ struct POHANDLE__* PowerHandle; } REGISTERED_INTERRUPT_CONTROLLER, *PREGISTERED_INTERRUPT_CONTROLLER; /* size: 0x0148 */ typedef enum _REG_NOTIFY_CLASS { RegNtDeleteKey = 0, RegNtPreDeleteKey = 0, RegNtSetValueKey = 1, RegNtPreSetValueKey = 1, RegNtDeleteValueKey = 2, RegNtPreDeleteValueKey = 2, RegNtSetInformationKey = 3, RegNtPreSetInformationKey = 3, RegNtRenameKey = 4, RegNtPreRenameKey = 4, RegNtEnumerateKey = 5, RegNtPreEnumerateKey = 5, RegNtEnumerateValueKey = 6, RegNtPreEnumerateValueKey = 6, RegNtQueryKey = 7, RegNtPreQueryKey = 7, RegNtQueryValueKey = 8, RegNtPreQueryValueKey = 8, RegNtQueryMultipleValueKey = 9, RegNtPreQueryMultipleValueKey = 9, RegNtPreCreateKey = 10, RegNtPostCreateKey = 11, RegNtPreOpenKey = 12, RegNtPostOpenKey = 13, RegNtKeyHandleClose = 14, RegNtPreKeyHandleClose = 14, RegNtPostDeleteKey = 15, RegNtPostSetValueKey = 16, RegNtPostDeleteValueKey = 17, RegNtPostSetInformationKey = 18, RegNtPostRenameKey = 19, RegNtPostEnumerateKey = 20, RegNtPostEnumerateValueKey = 21, RegNtPostQueryKey = 22, RegNtPostQueryValueKey = 23, RegNtPostQueryMultipleValueKey = 24, RegNtPostKeyHandleClose = 25, RegNtPreCreateKeyEx = 26, RegNtPostCreateKeyEx = 27, RegNtPreOpenKeyEx = 28, RegNtPostOpenKeyEx = 29, RegNtPreFlushKey = 30, RegNtPostFlushKey = 31, RegNtPreLoadKey = 32, RegNtPostLoadKey = 33, RegNtPreUnLoadKey = 34, RegNtPostUnLoadKey = 35, RegNtPreQueryKeySecurity = 36, RegNtPostQueryKeySecurity = 37, RegNtPreSetKeySecurity = 38, RegNtPostSetKeySecurity = 39, RegNtCallbackObjectContextCleanup = 40, RegNtPreRestoreKey = 41, RegNtPostRestoreKey = 42, RegNtPreSaveKey = 43, RegNtPostSaveKey = 44, RegNtPreReplaceKey = 45, RegNtPostReplaceKey = 46, RegNtPreQueryKeyName = 47, RegNtPostQueryKeyName = 48, MaxRegNtNotifyClass = 49, } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef struct _RSDP { /* 0x0000 */ unsigned __int64 Signature; /* 0x0008 */ unsigned char Checksum; /* 0x0009 */ unsigned char OEMID[6]; /* 0x000f */ unsigned char Revision; /* 0x0010 */ unsigned long RsdtAddress; /* 0x0014 */ unsigned long Length; /* 0x0018 */ union _LARGE_INTEGER XsdtAddress; /* 0x0020 */ unsigned char XChecksum; /* 0x0021 */ unsigned char Reserved[3]; } RSDP, *PRSDP; /* size: 0x0024 */ typedef struct _RSDT_32 { /* 0x0000 */ struct _DESCRIPTION_HEADER Header; /* 0x0024 */ unsigned long Tables[1]; } RSDT_32, *PRSDT_32; /* size: 0x0028 */ typedef struct _RTL_AVL_TREE { /* 0x0000 */ struct _RTL_BALANCED_NODE* Root; } RTL_AVL_TREE, *PRTL_AVL_TREE; /* size: 0x0008 */ typedef struct _RTL_BALANCED_NODE { union { /* 0x0000 */ struct _RTL_BALANCED_NODE* Children[2]; struct { /* 0x0000 */ struct _RTL_BALANCED_NODE* Left; /* 0x0008 */ struct _RTL_BALANCED_NODE* Right; }; /* size: 0x0010 */ }; /* size: 0x0010 */ union { /* 0x0010 */ unsigned char Red : 1; /* bit position: 0 */ /* 0x0010 */ unsigned char Balance : 2; /* bit position: 0 */ /* 0x0010 */ unsigned __int64 ParentValue; }; /* size: 0x0008 */ } RTL_BALANCED_NODE, *PRTL_BALANCED_NODE; /* size: 0x0018 */ typedef struct _RTL_BITMAP { /* 0x0000 */ unsigned long SizeOfBitMap; /* 0x0008 */ unsigned long* Buffer; } RTL_BITMAP, *PRTL_BITMAP; /* size: 0x0010 */ typedef struct _RTL_DYNAMIC_HASH_TABLE { /* 0x0000 */ unsigned long Flags; /* 0x0004 */ unsigned long Shift; /* 0x0008 */ unsigned long TableSize; /* 0x000c */ unsigned long Pivot; /* 0x0010 */ unsigned long DivisorMask; /* 0x0014 */ unsigned long NumEntries; /* 0x0018 */ unsigned long NonEmptyBuckets; /* 0x001c */ unsigned long NumEnumerators; /* 0x0020 */ void* Directory; } RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE; /* size: 0x0028 */ typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT { /* 0x0000 */ struct _LIST_ENTRY* ChainHead; /* 0x0008 */ struct _LIST_ENTRY* PrevLinkage; /* 0x0010 */ unsigned __int64 Signature; } RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT; /* size: 0x0018 */ typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY { /* 0x0000 */ struct _LIST_ENTRY Linkage; /* 0x0010 */ unsigned __int64 Signature; } RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY; /* size: 0x0018 */ typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR { union { /* 0x0000 */ struct _RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry; /* 0x0000 */ struct _LIST_ENTRY* CurEntry; }; /* size: 0x0018 */ /* 0x0018 */ struct _LIST_ENTRY* ChainHead; /* 0x0020 */ unsigned long BucketIndex; /* 0x0024 */ long __PADDING__[1]; } RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR; /* size: 0x0028 */ typedef struct _RTL_QUERY_REGISTRY_TABLE { /* 0x0000 */ void* QueryRoutine /* function */; /* 0x0008 */ unsigned long Flags; /* 0x0010 */ unsigned short* Name; /* 0x0018 */ void* EntryContext; /* 0x0020 */ unsigned long DefaultType; /* 0x0028 */ void* DefaultData; /* 0x0030 */ unsigned long DefaultLength; /* 0x0034 */ long __PADDING__[1]; } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE; /* size: 0x0038 */ typedef struct _RTL_RB_TREE { /* 0x0000 */ struct _RTL_BALANCED_NODE* Root; /* 0x0008 */ struct _RTL_BALANCED_NODE* Min; } RTL_RB_TREE, *PRTL_RB_TREE; /* size: 0x0010 */ typedef struct _RTL_SPLAY_LINKS { /* 0x0000 */ struct _RTL_SPLAY_LINKS* Parent; /* 0x0008 */ struct _RTL_SPLAY_LINKS* LeftChild; /* 0x0010 */ struct _RTL_SPLAY_LINKS* RightChild; } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; /* size: 0x0018 */ struct _SCSI_REQUEST_BLOCK; typedef struct _SECONDARY_IC_LIST_ENTRY { /* 0x0000 */ struct _LIST_ENTRY ListEntry; /* 0x0010 */ unsigned long GsivBase; /* 0x0014 */ unsigned long GsivSize; /* 0x0018 */ struct _SECONDARY_INTERRUPT_PROVIDER_INTERFACE Interface; /* 0x0070 */ volatile long BusyCount; /* 0x0074 */ volatile long ExclusiveWaiterCount; /* 0x0078 */ struct _KEVENT NotificationEvent; /* 0x0090 */ struct _LIST_ENTRY SignalListEntry; /* 0x00a0 */ struct _SECONDARY_INTERRUPT_LINE_STATE State[1]; } SECONDARY_IC_LIST_ENTRY, *PSECONDARY_IC_LIST_ENTRY; /* size: 0x00b0 */ typedef struct _SECONDARY_INTERRUPT_LINE_STATE { /* 0x0000 */ enum _KINTERRUPT_POLARITY Polarity; /* 0x0004 */ enum _KINTERRUPT_MODE Mode; /* 0x0008 */ unsigned long Vector; /* 0x000c */ unsigned char Unmasked; /* 0x000d */ char __PADDING__[3]; } SECONDARY_INTERRUPT_LINE_STATE, *PSECONDARY_INTERRUPT_LINE_STATE; /* size: 0x0010 */ typedef struct _SECONDARY_INTERRUPT_PROVIDER_INTERFACE { /* 0x0000 */ unsigned short Size; /* 0x0002 */ unsigned short Version; /* 0x0008 */ void* Context; /* 0x0010 */ unsigned long GsivBase; /* 0x0014 */ unsigned short GsivSize; /* 0x0018 */ struct _DRIVER_OBJECT* DriverObject; /* 0x0020 */ void* Reserved1; /* 0x0028 */ void* Reserved2; /* 0x0030 */ void* Reserved3; /* 0x0038 */ void* Reserved4; /* 0x0040 */ void* Reserved5; /* 0x0048 */ void* Reserved6; /* 0x0050 */ void* Reserved7; } SECONDARY_INTERRUPT_PROVIDER_INTERFACE, *PSECONDARY_INTERRUPT_PROVIDER_INTERFACE; /* size: 0x0058 */ typedef struct _SECTION_OBJECT_POINTERS { /* 0x0000 */ void* DataSectionObject; /* 0x0008 */ void* SharedCacheMap; /* 0x0010 */ void* ImageSectionObject; } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS; /* size: 0x0018 */ typedef enum _SECURITY_IMPERSONATION_LEVEL { SecurityAnonymous = 0, SecurityIdentification = 1, SecurityImpersonation = 2, SecurityDelegation = 3, } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL; typedef struct _SECURITY_QUALITY_OF_SERVICE { /* 0x0000 */ unsigned long Length; /* 0x0004 */ enum _SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; /* 0x0008 */ unsigned char ContextTrackingMode; /* 0x0009 */ unsigned char EffectiveOnly; /* 0x000a */ char __PADDING__[2]; } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE; /* size: 0x000c */ typedef struct _SECURITY_SUBJECT_CONTEXT { /* 0x0000 */ void* ClientToken; /* 0x0008 */ enum _SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; /* 0x0010 */ void* PrimaryToken; /* 0x0018 */ void* ProcessAuditId; } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT; /* size: 0x0020 */ typedef struct _SINGLE_LIST_ENTRY { /* 0x0000 */ struct _SINGLE_LIST_ENTRY* Next; } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; /* size: 0x0008 */ typedef struct _SLIST_ENTRY { /* 0x0000 */ struct _SLIST_ENTRY* Next; /* 0x0008 */ long __PADDING__[2]; } SLIST_ENTRY, *PSLIST_ENTRY; /* size: 0x0010 */ typedef union _SLIST_HEADER { union { struct { /* 0x0000 */ unsigned __int64 Alignment; /* 0x0008 */ unsigned __int64 Region; }; /* size: 0x0010 */ struct // _TAG_UNNAMED_72 { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 Depth : 16; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 Sequence : 48; /* bit position: 16 */ }; /* bitfield */ struct /* bitfield */ { /* 0x0008 */ unsigned __int64 Reserved : 4; /* bit position: 0 */ /* 0x0008 */ unsigned __int64 NextEntry : 60; /* bit position: 4 */ }; /* bitfield */ } /* size: 0x0010 */ HeaderX64; }; /* size: 0x0010 */ } SLIST_HEADER, *PSLIST_HEADER; /* size: 0x0010 */ typedef struct _STRING { /* 0x0000 */ unsigned short Length; /* 0x0002 */ unsigned short MaximumLength; /* 0x0008 */ char* Buffer; } STRING, *PSTRING; /* size: 0x0010 */ typedef enum _SYSTEM_POWER_STATE { PowerSystemUnspecified = 0, PowerSystemWorking = 1, PowerSystemSleeping1 = 2, PowerSystemSleeping2 = 3, PowerSystemSleeping3 = 4, PowerSystemHibernate = 5, PowerSystemShutdown = 6, PowerSystemMaximum = 7, } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE; typedef struct _SYSTEM_POWER_STATE_CONTEXT { union { struct /* bitfield */ { /* 0x0000 */ unsigned long Reserved1 : 8; /* bit position: 0 */ /* 0x0000 */ unsigned long TargetSystemState : 4; /* bit position: 8 */ /* 0x0000 */ unsigned long EffectiveSystemState : 4; /* bit position: 12 */ /* 0x0000 */ unsigned long CurrentSystemState : 4; /* bit position: 16 */ /* 0x0000 */ unsigned long IgnoreHibernationPath : 1; /* bit position: 20 */ /* 0x0000 */ unsigned long PseudoTransition : 1; /* bit position: 21 */ /* 0x0000 */ unsigned long Reserved2 : 10; /* bit position: 22 */ }; /* bitfield */ /* 0x0000 */ unsigned long ContextAsUlong; }; /* size: 0x0004 */ } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; /* size: 0x0004 */ typedef struct _TXN_PARAMETER_BLOCK { /* 0x0000 */ unsigned short Length; /* 0x0002 */ unsigned short TxFsContext; /* 0x0008 */ void* TransactionObject; } TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK; /* size: 0x0010 */ typedef union _ULARGE_INTEGER { union { struct { /* 0x0000 */ unsigned long LowPart; /* 0x0004 */ unsigned long HighPart; }; /* size: 0x0008 */ struct // _TAG_UNNAMED_73 { /* 0x0000 */ unsigned long LowPart; /* 0x0004 */ unsigned long HighPart; } /* size: 0x0008 */ u; /* 0x0000 */ unsigned __int64 QuadPart; }; /* size: 0x0008 */ } ULARGE_INTEGER, *PULARGE_INTEGER; /* size: 0x0008 */ typedef struct _UNICODE_STRING { /* 0x0000 */ unsigned short Length; /* 0x0002 */ unsigned short MaximumLength; /* 0x0008 */ unsigned short* Buffer; } UNICODE_STRING, *PUNICODE_STRING; /* size: 0x0010 */ typedef enum _USER_ACTIVITY_PRESENCE { PowerUserPresent = 0, PowerUserNotPresent = 1, PowerUserInactive = 2, PowerUserMaximum = 3, PowerUserInvalid = 3, } USER_ACTIVITY_PRESENCE, *PUSER_ACTIVITY_PRESENCE; typedef struct _VPB { /* 0x0000 */ short Type; /* 0x0002 */ short Size; /* 0x0004 */ unsigned short Flags; /* 0x0006 */ unsigned short VolumeLabelLength; /* 0x0008 */ struct _DEVICE_OBJECT* DeviceObject; /* 0x0010 */ struct _DEVICE_OBJECT* RealDevice; /* 0x0018 */ unsigned long SerialNumber; /* 0x001c */ unsigned long ReferenceCount; /* 0x0020 */ wchar_t VolumeLabel[32]; } VPB, *PVPB; /* size: 0x0060 */ typedef struct _WAIT_CONTEXT_BLOCK { union { /* 0x0000 */ struct _KDEVICE_QUEUE_ENTRY WaitQueueEntry; struct { /* 0x0000 */ struct _LIST_ENTRY DmaWaitEntry; /* 0x0010 */ unsigned long NumberOfChannels; struct /* bitfield */ { /* 0x0014 */ unsigned long SyncCallback : 1; /* bit position: 0 */ /* 0x0014 */ unsigned long DmaContext : 1; /* bit position: 1 */ /* 0x0014 */ unsigned long Reserved : 30; /* bit position: 2 */ }; /* bitfield */ }; /* size: 0x0018 */ }; /* size: 0x0018 */ /* 0x0018 */ void* DeviceRoutine /* function */; /* 0x0020 */ void* DeviceContext; /* 0x0028 */ unsigned long NumberOfMapRegisters; /* 0x0030 */ void* DeviceObject; /* 0x0038 */ void* CurrentIrp; /* 0x0040 */ struct _KDPC* BufferChainingDpc; } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; /* size: 0x0048 */ typedef enum _WHEA_CPU_VENDOR { WheaCpuVendorOther = 0, WheaCpuVendorIntel = 1, WheaCpuVendorAmd = 2, } WHEA_CPU_VENDOR, *PWHEA_CPU_VENDOR; typedef enum _WHEA_ERROR_PACKET_DATA_FORMAT { WheaDataFormatIPFSalRecord = 0, WheaDataFormatXPFMCA = 1, WheaDataFormatMemory = 2, WheaDataFormatPCIExpress = 3, WheaDataFormatNMIPort = 4, WheaDataFormatPCIXBus = 5, WheaDataFormatPCIXDevice = 6, WheaDataFormatGeneric = 7, WheaDataFormatMax = 8, } WHEA_ERROR_PACKET_DATA_FORMAT, *PWHEA_ERROR_PACKET_DATA_FORMAT; typedef union _WHEA_ERROR_PACKET_FLAGS { union { struct /* bitfield */ { /* 0x0000 */ unsigned long PreviousError : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long Reserved1 : 1; /* bit position: 1 */ /* 0x0000 */ unsigned long HypervisorError : 1; /* bit position: 2 */ /* 0x0000 */ unsigned long Simulated : 1; /* bit position: 3 */ /* 0x0000 */ unsigned long PlatformPfaControl : 1; /* bit position: 4 */ /* 0x0000 */ unsigned long PlatformDirectedOffline : 1; /* bit position: 5 */ /* 0x0000 */ unsigned long Reserved2 : 26; /* bit position: 6 */ }; /* bitfield */ /* 0x0000 */ unsigned long AsULONG; }; /* size: 0x0004 */ } WHEA_ERROR_PACKET_FLAGS, *PWHEA_ERROR_PACKET_FLAGS; /* size: 0x0004 */ typedef struct _WHEA_ERROR_PACKET_V2 { /* 0x0000 */ unsigned long Signature; /* 0x0004 */ unsigned long Version; /* 0x0008 */ unsigned long Length; /* 0x000c */ union _WHEA_ERROR_PACKET_FLAGS Flags; /* 0x0010 */ enum _WHEA_ERROR_TYPE ErrorType; /* 0x0014 */ enum _WHEA_ERROR_SEVERITY ErrorSeverity; /* 0x0018 */ unsigned long ErrorSourceId; /* 0x001c */ enum _WHEA_ERROR_SOURCE_TYPE ErrorSourceType; /* 0x0020 */ struct _GUID NotifyType; /* 0x0030 */ unsigned __int64 Context; /* 0x0038 */ enum _WHEA_ERROR_PACKET_DATA_FORMAT DataFormat; /* 0x003c */ unsigned long Reserved1; /* 0x0040 */ unsigned long DataOffset; /* 0x0044 */ unsigned long DataLength; /* 0x0048 */ unsigned long PshedDataOffset; /* 0x004c */ unsigned long PshedDataLength; } WHEA_ERROR_PACKET_V2, *PWHEA_ERROR_PACKET_V2; /* size: 0x0050 */ typedef struct _WHEA_ERROR_RECORD { /* 0x0000 */ struct _WHEA_ERROR_RECORD_HEADER Header; /* 0x0080 */ struct _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR SectionDescriptor[1]; } WHEA_ERROR_RECORD, *PWHEA_ERROR_RECORD; /* size: 0x00c8 */ typedef struct _WHEA_ERROR_RECORD_HEADER { /* 0x0000 */ unsigned long Signature; /* 0x0004 */ union _WHEA_REVISION Revision; /* 0x0006 */ unsigned long SignatureEnd; /* 0x000a */ unsigned short SectionCount; /* 0x000c */ enum _WHEA_ERROR_SEVERITY Severity; /* 0x0010 */ union _WHEA_ERROR_RECORD_HEADER_VALIDBITS ValidBits; /* 0x0014 */ unsigned long Length; /* 0x0018 */ union _WHEA_TIMESTAMP Timestamp; /* 0x0020 */ struct _GUID PlatformId; /* 0x0030 */ struct _GUID PartitionId; /* 0x0040 */ struct _GUID CreatorId; /* 0x0050 */ struct _GUID NotifyType; /* 0x0060 */ unsigned __int64 RecordId; /* 0x0068 */ union _WHEA_ERROR_RECORD_HEADER_FLAGS Flags; /* 0x006c */ union _WHEA_PERSISTENCE_INFO PersistenceInfo; /* 0x0074 */ unsigned char Reserved[12]; } WHEA_ERROR_RECORD_HEADER, *PWHEA_ERROR_RECORD_HEADER; /* size: 0x0080 */ typedef union _WHEA_ERROR_RECORD_HEADER_FLAGS { union { struct /* bitfield */ { /* 0x0000 */ unsigned long Recovered : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long PreviousError : 1; /* bit position: 1 */ /* 0x0000 */ unsigned long Simulated : 1; /* bit position: 2 */ /* 0x0000 */ unsigned long Reserved : 29; /* bit position: 3 */ }; /* bitfield */ /* 0x0000 */ unsigned long AsULONG; }; /* size: 0x0004 */ } WHEA_ERROR_RECORD_HEADER_FLAGS, *PWHEA_ERROR_RECORD_HEADER_FLAGS; /* size: 0x0004 */ typedef union _WHEA_ERROR_RECORD_HEADER_VALIDBITS { union { struct /* bitfield */ { /* 0x0000 */ unsigned long PlatformId : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long Timestamp : 1; /* bit position: 1 */ /* 0x0000 */ unsigned long PartitionId : 1; /* bit position: 2 */ /* 0x0000 */ unsigned long Reserved : 29; /* bit position: 3 */ }; /* bitfield */ /* 0x0000 */ unsigned long AsULONG; }; /* size: 0x0004 */ } WHEA_ERROR_RECORD_HEADER_VALIDBITS, *PWHEA_ERROR_RECORD_HEADER_VALIDBITS; /* size: 0x0004 */ typedef struct _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR { /* 0x0000 */ unsigned long SectionOffset; /* 0x0004 */ unsigned long SectionLength; /* 0x0008 */ union _WHEA_REVISION Revision; /* 0x000a */ union _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS ValidBits; /* 0x000b */ unsigned char Reserved; /* 0x000c */ union _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS Flags; /* 0x0010 */ struct _GUID SectionType; /* 0x0020 */ struct _GUID FRUId; /* 0x0030 */ enum _WHEA_ERROR_SEVERITY SectionSeverity; /* 0x0034 */ char FRUText[20]; } WHEA_ERROR_RECORD_SECTION_DESCRIPTOR, *PWHEA_ERROR_RECORD_SECTION_DESCRIPTOR; /* size: 0x0048 */ typedef union _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS { union { struct /* bitfield */ { /* 0x0000 */ unsigned long Primary : 1; /* bit position: 0 */ /* 0x0000 */ unsigned long ContainmentWarning : 1; /* bit position: 1 */ /* 0x0000 */ unsigned long Reset : 1; /* bit position: 2 */ /* 0x0000 */ unsigned long ThresholdExceeded : 1; /* bit position: 3 */ /* 0x0000 */ unsigned long ResourceNotAvailable : 1; /* bit position: 4 */ /* 0x0000 */ unsigned long LatentError : 1; /* bit position: 5 */ /* 0x0000 */ unsigned long Reserved : 26; /* bit position: 6 */ }; /* bitfield */ /* 0x0000 */ unsigned long AsULONG; }; /* size: 0x0004 */ } WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS, *PWHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS; /* size: 0x0004 */ typedef union _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS { union { struct /* bitfield */ { /* 0x0000 */ unsigned char FRUId : 1; /* bit position: 0 */ /* 0x0000 */ unsigned char FRUText : 1; /* bit position: 1 */ /* 0x0000 */ unsigned char Reserved : 6; /* bit position: 2 */ }; /* bitfield */ /* 0x0000 */ unsigned char AsUCHAR; }; /* size: 0x0001 */ } WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS, *PWHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS; /* size: 0x0001 */ typedef enum _WHEA_ERROR_SEVERITY { WheaErrSevRecoverable = 0, WheaErrSevFatal = 1, WheaErrSevCorrected = 2, WheaErrSevInformational = 3, } WHEA_ERROR_SEVERITY, *PWHEA_ERROR_SEVERITY; typedef enum _WHEA_ERROR_SOURCE_TYPE { WheaErrSrcTypeMCE = 0, WheaErrSrcTypeCMC = 1, WheaErrSrcTypeCPE = 2, WheaErrSrcTypeNMI = 3, WheaErrSrcTypePCIe = 4, WheaErrSrcTypeGeneric = 5, WheaErrSrcTypeINIT = 6, WheaErrSrcTypeBOOT = 7, WheaErrSrcTypeSCIGeneric = 8, WheaErrSrcTypeIPFMCA = 9, WheaErrSrcTypeIPFCMC = 10, WheaErrSrcTypeIPFCPE = 11, WheaErrSrcTypeMax = 12, } WHEA_ERROR_SOURCE_TYPE, *PWHEA_ERROR_SOURCE_TYPE; typedef enum _WHEA_ERROR_TYPE { WheaErrTypeProcessor = 0, WheaErrTypeMemory = 1, WheaErrTypePCIExpress = 2, WheaErrTypeNMI = 3, WheaErrTypePCIXBus = 4, WheaErrTypePCIXDevice = 5, WheaErrTypeGeneric = 6, } WHEA_ERROR_TYPE, *PWHEA_ERROR_TYPE; typedef union _WHEA_PERSISTENCE_INFO { union { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 Signature : 16; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 Length : 24; /* bit position: 16 */ /* 0x0000 */ unsigned __int64 Identifier : 16; /* bit position: 40 */ /* 0x0000 */ unsigned __int64 Attributes : 2; /* bit position: 56 */ /* 0x0000 */ unsigned __int64 DoNotLog : 1; /* bit position: 58 */ /* 0x0000 */ unsigned __int64 Reserved : 5; /* bit position: 59 */ }; /* bitfield */ /* 0x0000 */ unsigned __int64 AsULONGLONG; }; /* size: 0x0008 */ } WHEA_PERSISTENCE_INFO, *PWHEA_PERSISTENCE_INFO; /* size: 0x0008 */ typedef struct _WHEA_PROCESSOR_GENERIC_ERROR_SECTION { /* 0x0000 */ union _WHEA_PROCESSOR_GENERIC_ERROR_SECTION_VALIDBITS ValidBits; /* 0x0008 */ unsigned char ProcessorType; /* 0x0009 */ unsigned char InstructionSet; /* 0x000a */ unsigned char ErrorType; /* 0x000b */ unsigned char Operation; /* 0x000c */ unsigned char Flags; /* 0x000d */ unsigned char Level; /* 0x000e */ unsigned short Reserved; /* 0x0010 */ unsigned __int64 CPUVersion; /* 0x0018 */ unsigned char CPUBrandString[128]; /* 0x0098 */ unsigned __int64 ProcessorId; /* 0x00a0 */ unsigned __int64 TargetAddress; /* 0x00a8 */ unsigned __int64 RequesterId; /* 0x00b0 */ unsigned __int64 ResponderId; /* 0x00b8 */ unsigned __int64 InstructionPointer; } WHEA_PROCESSOR_GENERIC_ERROR_SECTION, *PWHEA_PROCESSOR_GENERIC_ERROR_SECTION; /* size: 0x00c0 */ typedef union _WHEA_PROCESSOR_GENERIC_ERROR_SECTION_VALIDBITS { union { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 ProcessorType : 1; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 InstructionSet : 1; /* bit position: 1 */ /* 0x0000 */ unsigned __int64 ErrorType : 1; /* bit position: 2 */ /* 0x0000 */ unsigned __int64 Operation : 1; /* bit position: 3 */ /* 0x0000 */ unsigned __int64 Flags : 1; /* bit position: 4 */ /* 0x0000 */ unsigned __int64 Level : 1; /* bit position: 5 */ /* 0x0000 */ unsigned __int64 CPUVersion : 1; /* bit position: 6 */ /* 0x0000 */ unsigned __int64 CPUBrandString : 1; /* bit position: 7 */ /* 0x0000 */ unsigned __int64 ProcessorId : 1; /* bit position: 8 */ /* 0x0000 */ unsigned __int64 TargetAddress : 1; /* bit position: 9 */ /* 0x0000 */ unsigned __int64 RequesterId : 1; /* bit position: 10 */ /* 0x0000 */ unsigned __int64 ResponderId : 1; /* bit position: 11 */ /* 0x0000 */ unsigned __int64 InstructionPointer : 1; /* bit position: 12 */ /* 0x0000 */ unsigned __int64 Reserved : 51; /* bit position: 13 */ }; /* bitfield */ /* 0x0000 */ unsigned __int64 ValidBits; }; /* size: 0x0008 */ } WHEA_PROCESSOR_GENERIC_ERROR_SECTION_VALIDBITS, *PWHEA_PROCESSOR_GENERIC_ERROR_SECTION_VALIDBITS; /* size: 0x0008 */ typedef struct _WHEA_RECOVERY_CONTEXT { struct // _TAG_UNNAMED_74 { /* 0x0000 */ unsigned __int64 Address; /* 0x0008 */ unsigned char Consumed; /* 0x000a */ unsigned short ErrorCode; /* 0x000c */ unsigned char ErrorIpValid; /* 0x000d */ unsigned char RestartIpValid; /* 0x000e */ char __PADDING__[2]; } /* size: 0x0010 */ MemoryError; /* 0x0010 */ unsigned __int64 PartitionId; /* 0x0018 */ unsigned int VpIndex; /* 0x001c */ long __PADDING__[1]; } WHEA_RECOVERY_CONTEXT, *PWHEA_RECOVERY_CONTEXT; /* size: 0x0020 */ typedef union _WHEA_REVISION { union { struct { /* 0x0000 */ unsigned char MinorRevision; /* 0x0001 */ unsigned char MajorRevision; }; /* size: 0x0002 */ /* 0x0000 */ unsigned short AsUSHORT; }; /* size: 0x0002 */ } WHEA_REVISION, *PWHEA_REVISION; /* size: 0x0002 */ typedef union _WHEA_TIMESTAMP { union { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 Seconds : 8; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 Minutes : 8; /* bit position: 8 */ /* 0x0000 */ unsigned __int64 Hours : 8; /* bit position: 16 */ /* 0x0000 */ unsigned __int64 Precise : 1; /* bit position: 24 */ /* 0x0000 */ unsigned __int64 Reserved : 7; /* bit position: 25 */ /* 0x0000 */ unsigned __int64 Day : 8; /* bit position: 32 */ /* 0x0000 */ unsigned __int64 Month : 8; /* bit position: 40 */ /* 0x0000 */ unsigned __int64 Year : 8; /* bit position: 48 */ /* 0x0000 */ unsigned __int64 Century : 8; /* bit position: 56 */ }; /* bitfield */ /* 0x0000 */ union _LARGE_INTEGER AsLARGE_INTEGER; }; /* size: 0x0008 */ } WHEA_TIMESTAMP, *PWHEA_TIMESTAMP; /* size: 0x0008 */ typedef struct _WHEA_XPF_MCA_SECTION { /* 0x0000 */ unsigned long VersionNumber; /* 0x0004 */ enum _WHEA_CPU_VENDOR CpuVendor; /* 0x0008 */ union _LARGE_INTEGER Timestamp; /* 0x0010 */ unsigned long ProcessorNumber; /* 0x0014 */ union _MCG_STATUS GlobalStatus; /* 0x001c */ unsigned __int64 InstructionPointer; /* 0x0024 */ unsigned long BankNumber; /* 0x0028 */ union _MCI_STATUS Status; /* 0x0030 */ unsigned __int64 Address; /* 0x0038 */ unsigned __int64 Misc; /* 0x0040 */ unsigned long ExtendedRegisterCount; /* 0x0044 */ unsigned long Reserved2; /* 0x0048 */ unsigned __int64 ExtendedRegisters[24]; } WHEA_XPF_MCA_SECTION, *PWHEA_XPF_MCA_SECTION; /* size: 0x0108 */ typedef struct _WHEA_XPF_PROCESSOR_ERROR_SECTION { /* 0x0000 */ union _WHEA_XPF_PROCESSOR_ERROR_SECTION_VALIDBITS ValidBits; /* 0x0008 */ unsigned __int64 LocalAPICId; /* 0x0010 */ unsigned char CpuId[48]; /* 0x0040 */ unsigned char VariableInfo[1]; } WHEA_XPF_PROCESSOR_ERROR_SECTION, *PWHEA_XPF_PROCESSOR_ERROR_SECTION; /* size: 0x0041 */ typedef union _WHEA_XPF_PROCESSOR_ERROR_SECTION_VALIDBITS { union { struct /* bitfield */ { /* 0x0000 */ unsigned __int64 LocalAPICId : 1; /* bit position: 0 */ /* 0x0000 */ unsigned __int64 CpuId : 1; /* bit position: 1 */ /* 0x0000 */ unsigned __int64 ProcInfoCount : 6; /* bit position: 2 */ /* 0x0000 */ unsigned __int64 ContextInfoCount : 6; /* bit position: 8 */ /* 0x0000 */ unsigned __int64 Reserved : 50; /* bit position: 14 */ }; /* bitfield */ /* 0x0000 */ unsigned __int64 ValidBits; }; /* size: 0x0008 */ } WHEA_XPF_PROCESSOR_ERROR_SECTION_VALIDBITS, *PWHEA_XPF_PROCESSOR_ERROR_SECTION_VALIDBITS; /* size: 0x0008 */ typedef struct _WORK_QUEUE_ITEM { /* 0x0000 */ struct _LIST_ENTRY List; /* 0x0010 */ void* WorkerRoutine /* function */; /* 0x0018 */ void* Parameter; } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; /* size: 0x0020 */ typedef struct _XSAVE_FORMAT { /* 0x0000 */ unsigned short ControlWord; /* 0x0002 */ unsigned short StatusWord; /* 0x0004 */ unsigned char TagWord; /* 0x0005 */ unsigned char Reserved1; /* 0x0006 */ unsigned short ErrorOpcode; /* 0x0008 */ unsigned long ErrorOffset; /* 0x000c */ unsigned short ErrorSelector; /* 0x000e */ unsigned short Reserved2; /* 0x0010 */ unsigned long DataOffset; /* 0x0014 */ unsigned short DataSelector; /* 0x0016 */ unsigned short Reserved3; /* 0x0018 */ unsigned long MxCsr; /* 0x001c */ unsigned long MxCsr_Mask; /* 0x0020 */ struct _M128A FloatRegisters[8]; /* 0x00a0 */ struct _M128A XmmRegisters[16]; /* 0x01a0 */ unsigned char Reserved4[96]; } XSAVE_FORMAT, *PXSAVE_FORMAT; /* size: 0x0200 */ typedef struct _XSDT { /* 0x0000 */ struct _DESCRIPTION_HEADER Header; /* 0x0024 */ union _LARGE_INTEGER Tables[1]; } XSDT, *PXSDT; /* size: 0x002c */ /* Amd64AllocateCounter Amd64ConfigureCounter Amd64DisableMonitoring Amd64EnableMonitoring Amd64FreeCounter Amd64GetProfileDescriptor Amd64InitializeProfiling Amd64OverflowHandler Amd64PauseProfiling Amd64QueryInformation Amd64RestartProfiling Amd64ResumeProfiling Amd64SetInterval ArbDeleteMmConfigRange ArbInitializeMmConfigRange CMOS_READ CMOS_WRITE DefaultDisableMonitoring DefaultEnableMonitoring DefaultInitializeProfiling DefaultOverflowHandler DefaultQueryInformation DefaultRestartProfiling DefaultSetInterval EmonAllocateCounter EmonConfigureCounter EmonDisableMonitoring EmonEnableMonitoring EmonFreeCounter EmonGetProfileDescriptor EmonInitializeProfiling EmonOverflowHandler EmonPauseProfiling EmonQueryInformation EmonRestartProfiling EmonResumeProfiling EmonSetInterval HalAcpiEmCheckOperator HalAcpiGetAllTablesDispatch HalAcpiGetFacsMappingDispatch HalAcpiGetRsdpDispatch HalAcpiGetTable HalAcpiGetTableDispatch HalAcpiGetTableEx HalAcquireDisplayOwnership HalAdjustResourceList HalAllProcessorsStarted HalAllocateAdapterChannel HalAllocateAdapterChannelEx HalAllocateAdapterChannelV2 HalAllocateCommonBuffer HalAllocateCommonBufferEx HalAllocateCommonBufferV2 HalAllocateCrashDumpRegisters HalAllocateDomainCommonBuffer HalAllocateHardwareCounters HalAssignSlotResources HalBugCheckSystem HalBuildMdlFromScatterGatherListV2 HalBuildMdlFromScatterGatherListV3 HalBuildScatterGatherListEx HalBuildScatterGatherListV2 HalBuildScatterGatherListV3 HalCalculateScatterGatherListSizeV2 HalCalculateScatterGatherListSizeV3 HalCalibratePerformanceCounter HalCancelAdapterChannel HalCancelMappedTransfer HalClearSoftwareInterrupt HalConfigureAdapterChannel HalConvertDeviceIdtToIrql HalDisableInterrupt HalDisplayString HalDmaAllocateCrashDumpRegistersEx HalDmaFreeCrashDumpRegistersEx HalEfiGetEnvironmentVariable HalEfiGetTime HalEfiQueryCapsuleCapabilities HalEfiQueryVariableInfo HalEfiResetSystem HalEfiSetEnvironmentVariable HalEfiSetTime HalEfiUpdateCapsule HalEnableInterrupt HalEnumerateEnvironmentVariablesEx HalEnumerateProcessors HalFixInterruptLine HalFlushAdapterBuffersEx HalFlushCommonBuffer HalFlushDmaBuffer HalFreeAdapterObject HalFreeCommonBuffer HalFreeCommonBufferV3 HalFreeHardwareCounters HalGetAdapter HalGetAdapterV2 HalGetAdapterV3 HalGetBusData HalGetBusDataByOffset HalGetDmaAdapterInfo HalGetDmaAlignment HalGetDmaDomain HalGetDmaTransferInfo HalGetEnvironmentVariable HalGetEnvironmentVariableEx HalGetInterruptTargetInformation HalGetInterruptVector HalGetMemoryCachingRequirements HalGetMessageRoutingInfo HalGetProcessorIdByNtNumber HalGetScatterGatherList HalGetScatterGatherListEx HalGetVectorInput HalHandleMcheck HalHandleNMI HalInitSystem HalInitializeBios HalInitializeDmaTransferContext HalInitializeOnResume HalInitializeProcessor HalIsHyperThreadingEnabled HalJoinDmaDomain HalLeaveDmaDomain HalMakeBeep HalMapIoSpace HalMapTransferEx HalMatchAcpiCreatorRevision HalMatchAcpiFADTBootArch HalMatchAcpiOemId HalMatchAcpiOemRevision HalMatchAcpiOemTableId HalMatchAcpiRevision HalMcUpdateReadPCIConfig HalPerformEndOfInterrupt HalPnpGetDmaAdapter HalPnpInterfaceNullReference HalProcessorIdle HalPutDmaAdapter HalPutScatterGatherList HalPutScatterGatherListV3 HalQueryDisplayParameters HalQueryEnvironmentVariableInfoEx HalQueryMaximumProcessorCount HalQueryRealTimeClock HalReadBootRegister HalReadDmaCounter HalReadDmaCounterV3 HalRealAllocateAdapterChannelV2 HalRealAllocateAdapterChannelV3 HalRegisterDynamicProcessor HalRegisterErrataCallbacks HalRegisterPermanentAddressUsage HalReportResourceUsage HalRequestClockInterrupt HalRequestDeferredRecoveryServiceInterrupt HalRequestIpi HalRequestIpiSpecifyVector HalRequestSoftwareInterrupt HalReturnToFirmware HalSendNMI HalSendSoftwareInterrupt HalSetBusData HalSetBusDataByOffset HalSetDisplayParameters HalSetEnvironmentVariable HalSetEnvironmentVariableEx HalSetProfileInterval HalSetRealTimeClock HalSetTimerProblem HalSocGetAcpiTable HalSocRequestApi HalSocRequestConfigurationData HalStartDynamicProcessor HalStartNextProcessor HalStartProfileInterrupt HalStopProfileInterrupt HalSystemVectorDispatchEntry HalTranslateBusAddress HalUnmapIoSpace HalUpdateTimerCapabilities HalWriteBootRegister HalacpIrqTranslatorDereference HalacpiIrqTranslateResourceRequirementsIsa HalacpiIrqTranslateResourcesIsa HalacpiIrqTranslatorReference HaliAcpiMachineStateInit HaliAcpiQueryFlags HaliAcpiSleep HaliAcpiTimerCarry HaliAddInterruptRemapping HaliGetDmaAdapter HaliGetInterruptTranslator HaliHaltSystem HaliHandlePCIConfigSpaceAccess HaliInitPnpDriver HaliInitPowerManagement HaliLocateHiberRanges HaliPciInterfaceReadConfig HaliPciInterfaceWriteConfig HaliQuerySystemInformation HaliRemoveInterruptRemapping HaliSetMaxLegacyPciBusNumber HaliSetPciErrorHandlerCallback HaliSetSystemInformation HaliSetWakeAlarm Halp8254TimerAcknowledgeInterrupt Halp8254TimerArm Halp8254TimerInitialize Halp8254TimerStop HalpAcpiAllocateMemory HalpAcpiAoacCapable HalpAcpiCacheOverrideTables HalpAcpiCacheTable HalpAcpiCalculateCacheSizeForOverrideTables HalpAcpiCheckAndMapTable HalpAcpiCopyBiosTable HalpAcpiDetectMachineSpecificActions HalpAcpiFallbackOnLegacyConfigMethod HalpAcpiFindRsdp HalpAcpiFlushCache HalpAcpiGetAllTablesWork HalpAcpiGetCachedTable HalpAcpiGetFacsMapping HalpAcpiGetRsdt HalpAcpiGetTable HalpAcpiGetTableFromBios HalpAcpiGetTableWork HalpAcpiIBMExaMatch HalpAcpiIBMVigilMatch HalpAcpiInitDiscard HalpAcpiInitSystem HalpAcpiInitializePmRegisters HalpAcpiIsCachedTableCompromised HalpAcpiPmRegisterAvailable HalpAcpiPmRegisterRead HalpAcpiPmRegisterReadPciConfigSpace HalpAcpiPmRegisterReadPort HalpAcpiPmRegisterReadRegister HalpAcpiPmRegisterWrite HalpAcpiPmRegisterWritePciConfigSpace HalpAcpiPmRegisterWritePort HalpAcpiPmRegisterWriteRegister HalpAcpiPostSleep HalpAcpiPreSleep HalpAcpiRealTimeToUtcTime HalpAcpiSetupPmRegister HalpAcpiSetupPmRegisterLegacy HalpAcpiTableCacheInit HalpAcpiValidateAcpiTable HalpAcquireCmosSpinLock HalpAcquireCmosSpinLockAndWait HalpAcquireHighLevelLock HalpAcquirePccInterface HalpAcquireSecondaryIcEntryExclusive HalpAddAdapterToList HalpAddAdapterToSystemList HalpAddDevice HalpAddMcaToMemoryErrorSection HalpAddMcaToProcessorGenericSection HalpAddMcaToProcessorSpecificSection HalpAllocPhysicalMemory HalpAllocateAdapterCallbackV2 HalpAllocateAdapterCallbackV3 HalpAllocateAdapterChannel HalpAllocateCR3Root HalpAllocateDmaChannels HalpAllocateDmaResources HalpAllocateEarlyPages HalpAllocateGsivForSecondaryInterrupt HalpAllocateHalCounters HalpAllocateKInterrupt HalpAllocateMapRegisters HalpAllocateNumaConfigData HalpAllocatePmcCounterSet HalpAllocateScratchMemory HalpApic1EndOfInterrupt HalpApic1ReadRegister HalpApic1WaitForIcr HalpApic1WriteIcr HalpApic1WriteRegister HalpApicClearLocalUnitError HalpApicConvertFromRte HalpApicConvertId HalpApicConvertToRte HalpApicDeinitializeLocalUnit HalpApicDescribeLines HalpApicDescribeLocalLines HalpApicDiscover HalpApicGenerateMessage HalpApicGetCpuInfo HalpApicGetLocalUnitError HalpApicHvUpdateCallback HalpApicInitializeIoUnit HalpApicInitializeLocalUnit HalpApicIsCmciImplemented HalpApicQueryAndGetSource HalpApicRegisterIoUnit HalpApicReplayLocalInterrupts HalpApicReplaySendSelfIpi HalpApicRequestInterrupt HalpApicSaveLocalInterrupts HalpApicSetLineState HalpApicSetLogicalId HalpApicSetPriority HalpApicSetupRegisterAccess HalpApicStartProcessor HalpApicTimerAcknowledgeInterrupt HalpApicTimerArm HalpApicTimerDiscover HalpApicTimerInitialize HalpApicTimerIsInvariant HalpApicTimerQueryCounter HalpApicTimerSetInterruptVector HalpApicTimerStop HalpApicWriteEndOfInterrupt HalpApicX2EndOfInterrupt HalpApicX2ReadRegister HalpApicX2WaitForCommand HalpApicX2WriteCommand HalpApicX2WriteRegister HalpArmAcpiWakeAlarm HalpArtAvailable HalpArtDiscover HalpArtInitialize HalpArtQueryCounter HalpAssignSlotResourcesStub HalpAuditAcpiTables HalpAuditAllocateRsdtArrayTable HalpAuditEnumerateRsdts HalpAuditEnumerateRsdtsInRange HalpAuditGetExtendedBiosDataArea HalpAuditQuerySlicAddresses HalpAuditSelectRsdtOrXsdt HalpAuditSlicTables HalpBiosDisplayReset HalpBuildResumeStructures HalpBuildScatterGatherList HalpCalculateDivisorRate HalpCalculateScatterGatherListSize HalpCalculateTickCount HalpCallWakeAlarmDriver HalpChannelAscendingSort HalpChannelAssignmentSort HalpChannelInitializeStaticConfiguration HalpChannelMpnIdSort HalpChannelPowerRequest HalpCheckFixedWakeSources HalpCheckInterruptType HalpCheckLowMemoryPreSleep HalpCheckNumaConfiguration HalpCheckPowerButton HalpCheckSecondaryInterruptSupported HalpCheckWakeupTimeAndAdjust HalpClaimDebugResource HalpCmcDeferredRoutine HalpCmcInitializeErrorPacketContents HalpCmcInitializePolling HalpCmcPollProcessor HalpCmcStartPolling HalpCmcWorkerRoutine HalpCmciDeferredRoutine HalpCmciHandler HalpCmciInit HalpCmciInitProcessor HalpCmciInitializeErrorPacket HalpCmciLoadThresholdConfiguration HalpCmciPollProcessor HalpCmciResetState HalpCmciSetProcessorConfig HalpCmciSetProcessorConfigAMD HalpCmciSetProcessorConfigIntel HalpCmciSetProcessorMiscConfigAMD HalpCmosNullReference HalpCmosRangeHandler HalpCmosReadByte HalpCmosWriteByte HalpCollectPmcCounters HalpCommitCR3Worker HalpConnectThermalInterrupt HalpConsumeLowMemory HalpConvertEfiToNtStatus HalpCopyDebugDescriptor HalpCorrectErrSrc HalpCorrectGenericErrSrc HalpCorrectMachineCheckErrSrc HalpCorrectNMIErrSrc HalpCpuID HalpCreateErrorRecord HalpCreateInterrupt HalpCreateMachineCheckErrorRecord HalpCreateMcaMemoryErrorRecord HalpCreateMcaProcessorErrorRecord HalpCreateNMIErrorRecord HalpCreateSecondaryIcEntry HalpDbgInitSystem HalpDeallocateMsiLines HalpDeleteSecondaryIcEntry HalpDeviceEquals HalpDisableCmciOnProcessor HalpDisableSecondaryInterrupt HalpDispatchPnp HalpDispatchPower HalpDispatchSystemStateTransition HalpDispatchWmi HalpDmaAcquireBufferMappings HalpDmaAllocateChildAdapterV2 HalpDmaAllocateChildAdapterV3 HalpDmaAllocateContiguousMemory HalpDmaAllocateContiguousPagesFromContiguousPool HalpDmaAllocateContiguousPagesFromContiguousPoolAtHighLevel HalpDmaAllocateContiguousPagesFromContiguousPoolAtHighLevelV2 HalpDmaAllocateContiguousPagesFromContiguousPoolAtHighLevelV3 HalpDmaAllocateContiguousPagesFromContiguousPoolV2 HalpDmaAllocateContiguousPagesFromContiguousPoolV3 HalpDmaAllocateDomain HalpDmaAllocateEmergencyResources HalpDmaAllocateLocalContiguousPool HalpDmaAllocateLocalScatterPool HalpDmaAllocateMapRegisters HalpDmaAllocateMapRegistersAtHighLevel HalpDmaAllocateMappingResources HalpDmaAllocateNewTranslationBuffer HalpDmaAllocateReservedMapping HalpDmaAllocateReservedMappingArray HalpDmaAllocateScatterMemory HalpDmaAllocateScatterPagesFromContiguousPool HalpDmaAllocateScatterPagesFromContiguousPoolAtHighLevelV2 HalpDmaAllocateScatterPagesFromContiguousPoolAtHighLevelV3 HalpDmaAllocateScatterPagesFromContiguousPoolV2 HalpDmaAllocateScatterPagesFromContiguousPoolV3 HalpDmaAllocateScatterPagesFromScatterPool HalpDmaAllocateScatterPagesFromScatterPoolAtHighLevel HalpDmaAllocateScatterPagesFromScatterPoolAtHighLevelV2 HalpDmaAllocateScatterPagesFromScatterPoolAtHighLevelV3 HalpDmaAllocateScatterPagesFromScatterPoolV2 HalpDmaAllocateScatterPagesFromScatterPoolV3 HalpDmaAllocateTranslationBuffer HalpDmaCheckAdapterToken HalpDmaCheckMdlAccessibility HalpDmaCommitContiguousMapBuffers HalpDmaCommitScatterMapBuffers HalpDmaConfigureInterrupt HalpDmaControllerCancelTransfer HalpDmaControllerDpcRoutine HalpDmaControllerFlushChannel HalpDmaControllerInitializeController HalpDmaControllerInterruptRoutine HalpDmaControllerProgramChannel HalpDmaControllerQueryMaxFragments HalpDmaControllerReadDmaCounter HalpDmaControllerValidateRequestLineBinding HalpDmaDeleteDomain HalpDmaDequeueAdapter HalpDmaFinalizeDoubleBufferingDisposition HalpDmaFindAdapterByDeviceObject HalpDmaFindDeviceObjectByToken HalpDmaFlushBuffer HalpDmaFlushBufferWithEmergencyResources HalpDmaFlushContiguousTransferV2 HalpDmaFlushContiguousTransferV3 HalpDmaFlushDriverMdl HalpDmaFlushScatterTransferV2 HalpDmaFlushScatterTransferV3 HalpDmaForceAllocation HalpDmaFreeChildAdapter HalpDmaFreeCrashDumpRegisters HalpDmaFreeMapRegisters HalpDmaFreeTranslationBuffer HalpDmaGetAdapterCacheAlignment HalpDmaGetAdapterVersion HalpDmaGetMasterAdapterVersion HalpDmaGetTranslationEntries HalpDmaGrowContiguousMapBuffers HalpDmaGrowScatterMapBuffers HalpDmaIndexToTranslationEntry HalpDmaInit HalpDmaInitDiscard HalpDmaInitMemory HalpDmaInitPowerManagement HalpDmaInitSystem HalpDmaInitializeControllers HalpDmaInitializeDomain HalpDmaInitializeMasterAdapter HalpDmaInsertDeviceObjectByToken HalpDmaIsAutomaticDomain HalpDmaIsDomainCompatible HalpDmaLinkContiguousTranslations HalpDmaLinkDeviceObjectByToken HalpDmaMapContiguousTransferV2 HalpDmaMapContiguousTransferV3 HalpDmaMapScatterTransferV2 HalpDmaMapScatterTransferV3 HalpDmaMarkHiberAdapter HalpDmaNextContiguousPiece HalpDmaNextContiguousPieceV2 HalpDmaNextContiguousPieceV3 HalpDmaPowerCriticalTransitionCallback HalpDmaPrependTranslations HalpDmaProcessMapRegisterQueueV2 HalpDmaProcessMapRegisterQueueV3 HalpDmaQueueAdapter HalpDmaReleaseBufferMappings HalpDmaRemoveAdapterFromChannelQueue HalpDmaRemoveAdapterFromMasterQueue HalpDmaRemoveWcb HalpDmaReturnPageToOwner HalpDmaReturnPageToSource HalpDmaReturnToContiguousPool HalpDmaReturnToScatterPool HalpDmaStartWcb HalpDmaSyncMapBuffers HalpDmaSyncMapBuffersWithEmergencyResources HalpDmaTranslationEntryToIndex HalpDmaZeroMapBuffers HalpDpGetInterruptReplayState HalpDpInitDiscard HalpDpInitSystem HalpDpOfflineProcessorForReplace HalpDpPostReplace HalpDpPostReplaceInitialization HalpDpPreReplace HalpDpQueryMaxHotPlugMemoryAddress HalpDpReplaceBegin HalpDpReplaceControl HalpDpReplaceEnd HalpDpReplaceTarget HalpDpReplayInterrupts HalpDpSortApicList HalpDpStartProcessor HalpDriverEntry HalpDynamicDeviceInterfaceNotification HalpECmosReadByte HalpECmosWriteByte HalpEfiBugCheckAddPagesCallback HalpEfiInitializeOnResume HalpEnableSecondaryInterrupt HalpEndOfBoot HalpErrataInitDiscard HalpErrataInitSystem HalpExtBuildResourceIdString HalpExtGetAcpiTable HalpExtGetNextResourceDescriptor HalpExtGetRegisteredResourceIdString HalpExtInitExtensions HalpExtRegisterResourceDescriptor HalpFindAdapterByRequestLine HalpFindBusAddressTranslation HalpFindDevice HalpFindDmaControllerByRequestLine HalpFindInterruptController HalpFindSecondaryIcEntry HalpFindSecondaryIcEntryFromObjectAndRange HalpFindTimer HalpFirmwareInitDiscard HalpFirmwareInitSystem HalpFlushAndWait HalpFlushMapBuffers HalpFlushTLB HalpFreeDmaChannels HalpFreeNvsBuffers HalpFreePmcCounterSet HalpFreeResumeStructures HalpGenericPolledDpcRoutine HalpGenericPolledWorkerRoutine HalpGetAcpiStaticNumaTopology HalpGetAdapter HalpGetCacheCoherency HalpGetChipHacks HalpGetCmosData HalpGetCpuInfo HalpGetDisplayBiosInformation HalpGetDynamicDevicePointer HalpGetHotPlugMemoryInfo HalpGetIrtEntryCount HalpGetMcaPcrContext HalpGetNumaProcMemoryCount HalpGetPCIData HalpGetPlatformTimerInformation HalpGetProcessorBrandString HalpGetResourceSortValue HalpGetSetCmosData HalpGrowMapBufferWorker HalpHalExtInitSystem HalpHandleMaskUnmaskSecondaryInterrupt HalpHandlePreviousMcaErrors HalpHandlePreviousMcaErrorsOnProcessor HalpHpetAcknowledgeInterrupt HalpHpetArmTimer HalpHpetDiscover HalpHpetInitialize HalpHpetQueryCounter HalpHpetSetMatchValue HalpHpetSetMessageInterruptRouting HalpHpetStop HalpHvBuildDeviceId HalpHvCounterInitialize HalpHvCounterQueryCounter HalpHvCounterUpdateCallback HalpHvCpuid HalpHvDiscover HalpHvEnterSleepState HalpHvEpCpuid HalpHvEpReadMsr HalpHvEpWriteMsr HalpHvEpWritebackInvalidate HalpHvGetApicFrequency HalpHvGetMachineCheckContext HalpHvGetTscFrequency HalpHvInitDiscard HalpHvInitMcaPcrContext HalpHvInitMcaStatusMsrCache HalpHvInitSegRegister HalpHvInitSystem HalpHvIsFrequencyAvailable HalpHvIsReferenceTscConfigured HalpHvLpReadMcaStatusMsr HalpHvLpReadMultipleMsr HalpHvMapDeviceMsiRange HalpHvMapIoApicDeviceInterrupt HalpHvMceConsumedMemoryErrorRecovery HalpHvNotifyDebugDeviceAvailable HalpHvQueryAssociatedProcessors HalpHvSetMachineCheckHandlerState HalpHvSetMachineCheckRecoveryState HalpHvSetSleepStateProperty HalpHvStartProcessor HalpHvTimerAcknowledgeInterrupt HalpHvTimerArm HalpHvTimerInitialize HalpHvTimerSetInterruptVector HalpHvTimerStop HalpHvUnmapDeviceMsiRange HalpHvUnmapIoApicDeviceInterrupt HalpHvVpStartEnabled HalpHwPerfCntInitSystem HalpInitBootTable HalpInitChipHacks HalpInitGenericErrorSourceEntry HalpInitGenericErrorSourcePollingRoutine HalpInitMemoryCachingRequirementsTable HalpInitNonBusHandler HalpInitSystemHelper HalpInitSystemPhase0 HalpInitSystemPhase1 HalpInitializeCmc HalpInitializeCmciVector HalpInitializeConfigurationFromMadt HalpInitializeErrSrc HalpInitializeGenericErrorSource HalpInitializeInterruptRemappingBspLate HalpInitializeInterrupts HalpInitializeInterruptsBspLate HalpInitializeInterruptsPn HalpInitializeMce HalpInitializeNMI HalpInitializePnTimers HalpInitializeProfiling HalpInitializeSecondaryInterruptServices HalpInitializeTelemetry HalpInitializeTimers HalpInsertSecondarySignalList HalpInterruptAddTarget HalpInterruptApplyOverrides HalpInterruptBuildGlobalStartupStub HalpInterruptBuildStartupStub HalpInterruptCmciService HalpInterruptConnect HalpInterruptControllerInUse HalpInterruptCreateGdtEntry32 HalpInterruptDeferredRecoveryService HalpInterruptDestinationToTarget HalpInterruptDpReplaceBegin HalpInterruptEnableNmi HalpInterruptEnablePerformanceEvents HalpInterruptEnsureLineSwapComplete HalpInterruptEnumerateUnmaskedInterrupts HalpInterruptEnumerateUnmaskedSecondaryInterrupts HalpInterruptFindBestRouting HalpInterruptFindLines HalpInterruptFindLinesForGsiRange HalpInterruptForceClusterMode HalpInterruptGenerateMessage HalpInterruptGetApicVersion HalpInterruptGetHighestPriorityInterrupt HalpInterruptGetIrtInfo HalpInterruptGetLocalIdentifier HalpInterruptGetNextProcessorLocalId HalpInterruptGetParkingPageInformation HalpInterruptGetPriority HalpInterruptGetX2ApicPolicy HalpInterruptGsiToLine HalpInterruptInitDiscard HalpInterruptInitPowerManagement HalpInterruptInitSystem HalpInterruptInitializeController HalpInterruptInitializeGlobals HalpInterruptInitializeIpis HalpInterruptInitializeLocalUnit HalpInterruptIsCmciSupported HalpInterruptIsGsiValid HalpInterruptIsMsiSupported HalpInterruptIsPicStateIntact HalpInterruptIsRemappingRequired HalpInterruptLineToGsi HalpInterruptLocalErrorService HalpInterruptLookupController HalpInterruptMapParkedPage HalpInterruptMarkProcessorStarted HalpInterruptMaskAcpi HalpInterruptMaskLevelTriggeredLines HalpInterruptModel HalpInterruptOfflineProcessor HalpInterruptParseAcpiTables HalpInterruptParseMadt HalpInterruptPicLine HalpInterruptPowerChange HalpInterruptPowerComponentActiveCallback HalpInterruptPowerComponentIdleCallback HalpInterruptPowerCriticalTransitionCallback HalpInterruptQueryControllerInfo HalpInterruptQueryProcessorRestartEntryPoint HalpInterruptRebootService HalpInterruptRegisterController HalpInterruptRegisterDynamicProcessor HalpInterruptRegisterLine HalpInterruptReinitialize HalpInterruptReinitializeThisProcessor HalpInterruptRemap HalpInterruptRequestInterrupt HalpInterruptRequestSecondaryInterrupt HalpInterruptResetAllProcessors HalpInterruptResetThisProcessor HalpInterruptRestoreAllControllerState HalpInterruptRestoreClock HalpInterruptRestoreController HalpInterruptSaveReplayState HalpInterruptSelectController HalpInterruptSendIpi HalpInterruptServiceActiveBoth HalpInterruptSetDestination HalpInterruptSetDestinationInternal HalpInterruptSetIdtEntry HalpInterruptSetLineState HalpInterruptSetLineStateInternal HalpInterruptSetMsiOverride HalpInterruptSetProblemEx HalpInterruptSetProcessorStartContext HalpInterruptSetRemappedDestination HalpInterruptSetRemappedLineState HalpInterruptSetRemappedLineStateInternal HalpInterruptSortProcessorTable HalpInterruptSpuriousService HalpInterruptStandardEndOfInterrupt HalpInterruptStartProcessor HalpInterruptStubService HalpInterruptSwapProcessorIdentifiers HalpInterruptThermalService HalpInterruptUnmap HalpInterruptUnmaskLevelTriggeredLines HalpInterruptUpdateLinesPostSwap HalpInterruptUpdateLocalUnitIdentifier HalpInterruptVectorDataToGsiv HalpInvokeIsrForGsiv HalpIoDelay HalpIommuConfigureInterrupt HalpIommuExtMarkHiberMemory HalpIommuGetNextFlushDevice HalpIommuHsaDiscover HalpIommuInitDiscard HalpIommuInitSystem HalpIommuInitializeAll HalpIommuInterruptRoutine HalpIommuLocateFromDevice HalpIommuRegister HalpIommuRegisterDispatchTable HalpIommuSetupMessageInterruptRouting HalpIommuSupportEnabled HalpIommuUpdateRemappingDestination HalpIommuUpdateRemappingTableEntry HalpIrtAllocateIndex HalpIrtFreeIndex HalpIsCmciImplemented HalpIsEFIRuntimeActive HalpIsHvUsedForReboot HalpIsInterruptTypeSecondary HalpIsMicrosoftCompatibleHvLoaded HalpIsPartitionCpuManager HalpIsUefiFirmwareResourceTablePresent HalpIumGetNextVariableName HalpIumGetTime HalpIumGetVariable HalpIumQueryCapsuleCapabilities HalpIumQueryVariableInfo HalpIumResetSystem HalpIumSetTime HalpIumSetVariable HalpIumUpdateCapsule HalpIvtCheckPathMatch HalpIvtProcessDmarTable HalpIvtProcessDrhdEntry HalpIvtValidateDeviceScope HalpKdEnumerateDebuggingDevices HalpKdReadPCIConfig HalpKdReleaseDebuggingDevice HalpKdSetupDebuggingDevice HalpKdWritePCIConfig HalpLMIdentityStub HalpLMStub HalpLMStubForVM HalpLegacyShutdown HalpLoadMicrocode HalpMap HalpMapCR3Ex HalpMapEarlyPages HalpMapNvsArea HalpMapPhysicalMemory64 HalpMapPhysicalMemoryWriteThrough64 HalpMapTransferV2 HalpMapTransferV3 HalpMaskInterrupt HalpMcUpdateFindDataTableEntry HalpMcUpdateInitialize HalpMcUpdateLock HalpMcUpdateMicrocode HalpMcUpdatePostUpdate HalpMcUpdateUnlock HalpMcaClearError HalpMcaInitializePcrContext HalpMcaQueueDpc HalpMcaReadError HalpMcaReadErrorPresence HalpMcaReportError HalpMcaResumeProcessorConfig HalpMcaSetFeatureFlags HalpMcaSetProcessorConfig HalpMceBarrierWait HalpMceHandler HalpMceHandlerCore HalpMceHandlerWithRendezvous HalpMceInit HalpMceInitProcessor HalpMceInitializeErrorPacket HalpMceInitializeErrorPacketContents HalpMceInitializeRecovery HalpMceMemoryErrorDeferredHandler HalpMceMemoryErrorDeferredRecovery HalpMceRecovery HalpMiscBugCheckCallback HalpMiscGetParameters HalpMiscInitDiscard HalpMiscInitSystem HalpMiscInitializeTelemetry HalpMiscIsLegacyPcType HalpMmAllocCtxAlloc HalpMmAllocCtxAllocBuffer HalpMmAllocCtxBufferCleanup HalpMmAllocCtxFree HalpMmAllocCtxInit HalpMmAllocCtxMarkHiberPhase HalpMmAllocateMemory HalpMmAllocateMemoryInternal HalpMmAllocatePerProcessorMemory HalpMmBuildTiledMemoryMap HalpMmFreeTiledMemoryMap HalpMmInitSystem HalpMpsValueAscendingSort HalpNmiGenericErrorHandler HalpNmiReboot HalpNodeCostSort HalpNullReadWriteBusData HalpNumaAddRangeProximity HalpNumaInitializeStaticConfiguration HalpNumaQueryNodeCapacity HalpNumaQueryNodeDistance HalpNumaQueryProcessorNode HalpNumaQueryProximityId HalpNumaQueryProximityNode HalpNumaSwapP0NodeToFront HalpPCIConfig HalpPCIPerformConfigAccess HalpParseChannelCount HalpPassIrpFromFdoToPdo HalpPciAccessIoConfigSpace HalpPciCheckAmdK8 HalpPciGetHpetInterruptSource HalpPciGetHpetInterruptSourceAmd HalpPciGetHpetInterruptSourceIntel HalpPciGetMmConfigPhysicalAddress HalpPciInitSystem HalpPciInitializeMmConfigAccess HalpPciMapMmConfigPhysicalAddress HalpPciMarkHiberPhase HalpPciReadIoConfigUchar HalpPciReadIoConfigUlong HalpPciReadIoConfigUshort HalpPciReadMmConfigUchar HalpPciReadMmConfigUlong HalpPciReadMmConfigUshort HalpPciReportMmConfigAddressRange HalpPciWriteIoConfigUchar HalpPciWriteIoConfigUlong HalpPciWriteIoConfigUshort HalpPciWriteMmConfigUchar HalpPciWriteMmConfigUlong HalpPciWriteMmConfigUshort HalpPerfInterrupt HalpPicDiscover HalpPicInitializeIoUnit HalpPicRequestInterrupt HalpPicSetLineState HalpPicWriteEndOfInterrupt HalpPiix4Detect HalpPmTimerConfigure HalpPmTimerDiscover HalpPmTimerInitialize HalpPmTimerQueryCounterIoPort HalpPmTimerQueryCounterMemory HalpPnpInitSystem HalpPopulateMsiMessages HalpPostPnpInitialize HalpPostSleepMP HalpPowerEarlyRestore HalpPowerInitDiscard HalpPowerInitFwPerformanceTableMappings HalpPowerInitNvsRegionData HalpPowerInitSystem HalpPowerSetRebootHandler HalpPowerStateCallback HalpPowerWriteResetCommand HalpPreAllocateKInterrupts HalpPrepareForBugcheck HalpPreserveNvsArea HalpProcGetFeatureBits HalpProcInitDiscard HalpProcInitSystem HalpProcessSecondarySignalList HalpProcessorFence HalpProcessorPrepareForIdle HalpProcessorResumeFromIdle HalpPteReserveResources HalpPutAcpiHacksInRegistry HalpQueryAcpiRealTimeClock HalpQueryAcpiResourceRequirements HalpQueryCapsuleCapabilities HalpQueryChannelTopologyInformation HalpQueryDebuggerInformation HalpQueryDeviceRelations HalpQueryIdFdo HalpQueryIdPdo HalpQueryInterface HalpQueryIommuReservedRegionInformation HalpQueryMaximumGsiv HalpQueryMaximumRegisteredProcessorCount HalpQueryNumaRangeTableInformation HalpQueryPccInterface HalpQueryPrimaryInterruptInformation HalpQueryProfileSourceList HalpQueryResources HalpQuerySecondaryInterruptInformation HalpQueryVirtualRtc HalpQueueMapBufferWorker HalpReadCmosTime HalpReadGenericErrorInfo HalpReadPCIConfig HalpReadPartitionTable HalpReadRtcStdPCAT HalpReadStdCmosData HalpReadWheaPhysicalMemory HalpReadWriteWheaPhysicalMemory HalpReboot HalpRecordSecondaryGsivRange HalpReenableAcpi HalpRegisterDeviceInUse HalpRegisterDmaChannel HalpRegisterDmaController HalpRegisterKdSupportFunctions HalpRegisterSecondaryIcInterface HalpRegisterUsbController HalpReleaseHighLevelLock HalpReleaseSecondaryIcEntryShared HalpReportResourceUsage HalpReserveHalPtes HalpResetSBF HalpRestartProfiling HalpRestoreDmaControllerState HalpRestoreHvEnlightenment HalpRestoreNvsArea HalpRtcAcknowledgeInterrupt HalpRtcArmTimer HalpRtcDiscover HalpRtcFixedStall HalpRtcInitialize HalpRtcSetDivisor HalpRtcStop HalpSaveAndDisableEnlightenment HalpSaveDmaControllerState HalpSaveProcessorState HalpSecondaryInterruptQueryPrimaryInformation HalpSelectFeasibleLowPowerState HalpSendPccCommand HalpSetAcpiRealTimeClock HalpSetClockAfterSleep HalpSetClockBeforeSleep HalpSetCmosData HalpSetIrtEntry HalpSetPCIData HalpSetPartitionInformation HalpSetPlatformFlags HalpSetProfileSourceInterval HalpSetResumeTime HalpSetSystemInformation HalpSetTimer HalpSetTimerAnyMode HalpSetVirtualRtc HalpSetWakeAlarm HalpSetupAcpiPhase0 HalpSetupRealModeResume HalpSfiTimerAcknowledgeInterrupt HalpSfiTimerArm HalpSfiTimerDiscover HalpSfiTimerInitialize HalpSfiTimerQueryCounter HalpSfiTimerStop HalpShutdown HalpSimpleCheck HalpSocApiAllocatePhysicalMemory HalpStopLegacyUsbInterrupts HalpStopLegacyUsbInterruptsInternal HalpStopOhciInterrupt HalpStopUhciInterrupt HalpStopXhciInterrupt HalpStoreFreeCr3 HalpTimerAlwaysOnClockInterrupt HalpTimerCalculateMaximumAllowableDrift HalpTimerCalibratePerformanceCounter HalpTimerCaptureCloestAuxiliaryQpcPair HalpTimerCaptureCurrentAuxiliaryQpcPair HalpTimerClearProblem HalpTimerClockActivate HalpTimerClockArm HalpTimerClockInitialize HalpTimerClockInterrupt HalpTimerClockInterruptStub HalpTimerClockIpiRoutine HalpTimerClockPowerChange HalpTimerClockStart HalpTimerClockStop HalpTimerConfigureInterrupt HalpTimerConfigureQpcBypass HalpTimerConvertAuxiliaryCounter HalpTimerConvertAuxiliaryCounterToPerformanceCounter HalpTimerConvertPerformanceCounterToAuxiliaryCounter HalpTimerDelayedQueryCounter HalpTimerDetermineValidTimerPairReadLatency HalpTimerDpcRoutine HalpTimerEnableHypervisorTimer HalpTimerFindBestAlwaysOnTimer HalpTimerFindIdealClockSource HalpTimerFindIdealPerformanceCounterSource HalpTimerFindIdealWatchdog HalpTimerGetClockConfiguration HalpTimerGetClockRates HalpTimerGetInternalData HalpTimerGetProfilingHandler HalpTimerGetProfilingTarget HalpTimerGetSavedPerformanceCounter HalpTimerHypervisorInterrupt HalpTimerHypervisorInterruptStub HalpTimerInitPowerManagement HalpTimerInitSystem HalpTimerInitialize HalpTimerInitializeClock HalpTimerInitializeClockPn HalpTimerInitializeEarlyStallSource HalpTimerInitializeHypervisorTimer HalpTimerInitializeProfiling HalpTimerInitializeSystemWatchdog HalpTimerMarkWake HalpTimerMeasureAllProcessorFrequencies HalpTimerMeasureFrequencies HalpTimerMeasureProcessorsWorker HalpTimerNoteHpetMaskingBehavior HalpTimerNotifyProcessorFreeze HalpTimerOnlyClockInterruptPending HalpTimerPerformanceCounterPowerChange HalpTimerPowerChange HalpTimerPowerComponentActiveCallback HalpTimerPowerComponentIdleCallback HalpTimerPowerCriticalTransitionCallback HalpTimerPrepareClockInterrupt HalpTimerProfileInterrupt HalpTimerProfilePowerChange HalpTimerQueryAuxiliaryCounterFrequency HalpTimerQueryCycleCounter HalpTimerQueryWakeTime HalpTimerReadTimerPairWithLatencyLimit HalpTimerRegister HalpTimerRegisterBuiltinPlugins HalpTimerRegisterBuiltinPluginsCommon HalpTimerReportIdleStateUsage HalpTimerResetProfileAdjustment HalpTimerRestartProfileInterrupt HalpTimerRestorePerformanceCounter HalpTimerRestoreProcessorCounter HalpTimerSavePerformanceCounter HalpTimerSaveProcessorFrequency HalpTimerScaleCounter HalpTimerSchedulePeriodicQueries HalpTimerSelectRoles HalpTimerSetProblemEx HalpTimerSetProfilingHandler HalpTimerSetProfilingTarget HalpTimerSetTimerBackedProfileInterval HalpTimerSetupMessageInterruptRouting HalpTimerStallCounterPowerChange HalpTimerStallExecutionProcessor HalpTimerStartProfileInterrupt HalpTimerStopProfileInterrupt HalpTimerSwitchStallSource HalpTimerSwitchToNormalClock HalpTimerTestHypervisorTimer HalpTimerTraceTimingHardware HalpTimerUnmapInterrupt HalpTimerUpdateApiConsumers HalpTimerWaitForPhase0Interrupt HalpTimerWatchdogGeneratedLastReset HalpTimerWatchdogInitWakeTimer HalpTimerWatchdogLogReset HalpTimerWatchdogPreResetInterrupt HalpTimerWatchdogResetCountdown HalpTimerWatchdogStart HalpTimerWatchdogStop HalpTimerWatchdogTriggerSystemReset HalpTranslateBusAddress HalpTranslateToLegacyMcaException HalpTscAdjustToLeader HalpTscAdjustToTarget HalpTscAdvSynchCalculateRemoteDelta HalpTscAdvSynchCalculateRemoteDeltas HalpTscAdvSynchComputeMinimumDelta HalpTscAdvSynchComputeMinimumDeltaAlternate HalpTscAdvSynchLeader HalpTscAdvSynchReadTimeStamp HalpTscAdvSynchSkewCounter HalpTscAdvSynchTarget HalpTscAdvSynchToLeader HalpTscAdvSynchToTarget HalpTscCheckAdjustMsrCapability HalpTscCompatibilitySynchronization HalpTscDiscover HalpTscFallback HalpTscFallbackToPlatformSource HalpTscGetAttributes HalpTscInitialize HalpTscInitializeSynchronizationContext HalpTscQueryCounter HalpTscReportSyncStatus HalpTscReserveResources HalpTscSynchronization HalpTscSynchronizationWorker HalpTscTraceProcessorSynchronization HalpTscTraceStatus HalpUnloadMicrocode HalpUnmapVirtualAddress HalpUnmaskInterrupt HalpUnregisterSecondaryIcInterface HalpUpdateCapsule HalpUpdateConfigurationFromMsct HalpUpdateCoolingPacket HalpUpdateIrtDestinationId HalpUpdateNumaConfiguration HalpUtcTimeToAcpiRealTime HalpValidPCISlot HalpValidateInterface HalpValidateMpns HalpVerifySratEntryLengthAndFlag HalpVpptAcknowledgeInterrupt HalpVpptArmTimer HalpVpptInitialize HalpVpptStop HalpVpptTimerRegister HalpVpptUpdatePhysicalTimer HalpWatchdoWakeTimerDpcRoutine HalpWatchdogWakeTimerCallback HalpWdatArmTimer HalpWdatDiscover HalpWdatExecuteActionBeforeInitialize HalpWdatInitialize HalpWdatInitializeWdat HalpWdatInitializeWdrt HalpWdatProcessWdatInternalData HalpWdatProcessWdrtInternalData HalpWdatStop HalpWhackICHUsbSmi HalpWheaInitDiscard HalpWheaInitProcessorGenericSection HalpWheaInitSystem HalpWheaNativeCpuid HalpWheaNativeReadMsr HalpWheaNativeWriteMsr HalpWheaNativeWritebackInvalidate HalpWriteCmosTime HalpWritePCIConfig HalpWritePartitionTable HalpWriteRtcStdPCAT HalpWriteStdCmosData HalpWriteWheaPhysicalMemory HalpcGetCmosDataByType HalpcSetCmosDataByType HsaDisableInterrupt HsaDismissPageFault HsaEnableInterrupt HsaEnsureNoPendingFaults HsaFindDevice HsaFlushDeviceTbOnly HsaFlushTb HsaGetPageFault HsaGrowPasidTable HsaHandleInterrupt HsaInitializeIommu HsaInvalidateDTE HsaIommuSendCommand HsaMarkHiberRegions HsaSetDevicePasidTable HsaSetDeviceSvmCapabilities HsaSetMessageInterruptRouting HsaSetPasidAddressSpace HviGetHardwareFeatures IoFlushAdapterBuffers IoFlushAdapterBuffersV2 IoFlushAdapterBuffersV3 IoFreeAdapterChannel IoFreeAdapterChannelV2 IoFreeAdapterChannelV3 IoFreeMapRegisters IoFreeMapRegistersV2 IoFreeMapRegistersV3 IoMapTransfer IoMapTransferInternal IommuDevicePowerChange IommuDisableDevicePasid IommuEnableDevicePasid IommuFlushAllPasid IommuFlushTb IommuGetConfiguration IommuGetLibraryContext IommuHvDevicePowerChange IommuHvFlushAllPasid IommuHvFlushTb IommuHvGetConfiguration IommuHvSetAddressSpace IommuInitializeLibrary IommuMapDevice IommuProcessPageRequestQueue IommuSetAddressSpace IommuUnmapDevice IommupGetSystemContext IommupHvDismissPageFault IommupHvGetDeviceCapabilities IommupHvGetPageFault IommupHvInitializeLibrary IommupHvInterruptRoutine IommupHvUnmapDevice IvtBuildContextEntry IvtCheckForReservedRegion IvtDisableInterrupt IvtDismissPageFault IvtEnableInterrupt IvtEnsureNoPendingFaults IvtFindDevice IvtFlushDeviceTbOnly IvtFlushTb IvtFlushTbInternal IvtGetPageFault IvtGrowPasidTable IvtHandleInterrupt IvtInitializeIommu IvtInitializeMTRR IvtInvalidateAllContextEntries IvtInvalidateContextEntry IvtInvalidateRemappingTableEntries IvtInvalidateRemappingTableEntry IvtIommuSendCommand IvtMarkHiberRegions IvtSetDevicePasidTable IvtSetDeviceSvmCapabilities IvtSetMessageInterruptRouting IvtSetPasidAddressSpace IvtUpdateContextEntryPasidTable IvtUpdateExtendedDestination IvtUpdateGlobalCommand IvtUpdateRemappingDestination IvtUpdateRemappingTableEntry IvtUpdateSingleTargetExtendedDestination IvtpGetNextDeviceScope IvtpGetNextDrhdDeviceScope IvtpGetNextInternalDeviceScope IvtpGetNextRemappingStructure KeFlushWriteBuffer KeQueryPerformanceCounter KeSaveStateForHibernate KeStallExecutionProcessor MmLockPagableDataSection MmLockPagableSectionByHandle MmUnlockPagableImageSection PcAllocateChannelAdapter PcFlushChannel PcGetChannelAdapter PcInitializeDmaHW PcMapTransfer PcReadCounter PcValidateDmaAdapterRequest PcValidateDmaScatterTransfer READ_PORT_USHORT_PAIR RtlCopyMemoryNonTemporal RtlMoveMemory RtlQueryRegistryValues RtlRaiseException TraceLoggingRegisterEx TranslateGlobalVectorToIsaVector WRITE_PORT_USHORT_PAIR WdHwCreateHardwareRegister WdHwDestroyHardwareRegister WdHwpGetReadMethod WdHwpGetWriteMethod WdHwpReadPortUChar WdHwpReadPortULong WdHwpReadPortUShort WdHwpReadRegisterUChar WdHwpReadRegisterULong WdHwpReadRegisterUShort WdHwpWritePortUChar WdHwpWritePortULong WdHwpWritePortUShort WdHwpWriteRegisterUChar WdHwpWriteRegisterULong WdHwpWriteRegisterUShort WdInstrDestroyInstruction WdInstrExecuteAction WdInstrExecuteInstruction WdInstrInitializeInstruction XmAaaOp XmAadOp XmAamOp XmAasOp XmAccumImmediate XmAccumRegister XmAdcOp XmAddOp XmAddOperands XmAndOp XmBitScanGeneral XmBoundOp XmBsfOp XmBsrOp XmBswapOp XmBtOp XmBtcOp XmBtrOp XmBtsOp XmByteImmediate XmCallOp XmCbwOp XmClcOp XmCldOp XmCliOp XmCmcOp XmCmpOp XmCmpsOp XmCmpxchgOp XmCompareOperands XmCwdOp XmDaaOp XmDasOp XmDecOp XmDivOp XmEffectiveOffset XmEmulateInterrupt XmEmulateStream XmEnterOp XmEvaluateAddressSpecifier XmEvaluateIndexSpecifier XmExecuteInt1a XmFlagsRegister XmGeneralBitOffset XmGeneralRegister XmGetCodeByte XmGetImmediateSourceValue XmGetLongImmediate XmGetOffsetAddress XmGetRegisterAddress XmGetStringAddress XmGetStringAddressRange XmGetWordImmediate XmGroup1General XmGroup1Immediate XmGroup2By1 XmGroup2ByByte XmGroup2ByCL XmGroup3General XmGroup45General XmGroup7General XmGroup8BitOffset XmHltOp XmIdivOp XmIllOp XmImmediateEnter XmImmediateJump XmImulImmediate XmImulOp XmImulxOp XmInOp XmIncOp XmInitializeEmulator XmInsOp XmInt1aFindPciClassCode XmInt1aFindPciDevice XmInt1aReadConfigRegister XmInt1aWriteConfigRegister XmIntOp XmIretOp XmJcxzOp XmJmpOp XmJxxOp XmLahfOp XmLeaveOp XmLoadSegment XmLodsOp XmLongJump XmLoopOp XmMovOp XmMoveGeneral XmMoveImmediate XmMoveRegImmediate XmMoveSegment XmMoveXxGeneral XmMovsOp XmMulOp XmNegOp XmNoOperands XmNopOp XmNotOp XmOpcodeEscape XmOpcodeRegister XmOrOp XmOutOp XmOutsOp XmPopGeneral XmPopOp XmPopStack XmPopaOp XmPortDX XmPortImmediate XmPrefixOpcode XmPushImmediate XmPushOp XmPushPopSegment XmPushStack XmPushaOp XmRclOp XmRcrOp XmRdtscOp XmRetOp XmRolOp XmRorOp XmSahfOp XmSarOp XmSbbOp XmScasOp XmSegmentOffset XmSetDataType XmSetDestinationValue XmSetLogicalResult XmSetSourceValue XmSetccByte XmShiftDouble XmShlOp XmShldOp XmShortJump XmShrOp XmShrdOp XmSmswOp XmStcOp XmStdOp XmStiOp XmStoreResult XmStosOp XmStringOperands XmSubOp XmSubOperands XmSxxOp XmTestOp XmXaddOp XmXchgOp XmXlatOpcode XmXorOp ZwClose ZwOpenKey ZwSetValueKey _TlgEnableCallback _TlgKeywordOn _TlgWrite __GSHandlerCheck __GSHandlerCheckCommon __chkstk __report_gsfailure __security_check_cookie __security_init_cookie _guard_check_icall_nop _guard_dispatch_icall_nop _setjmp memcmp memcpy memmove memset strcmp x86BiosAllocateBuffer x86BiosCall x86BiosExecuteInterruptShadowed x86BiosFreeBuffer x86BiosGetPciBusData x86BiosInitializeBiosEx x86BiosReadCmosPort x86BiosReadCmosPortByte x86BiosReadIoSpace x86BiosReadMemory x86BiosReadPciAddressPort x86BiosReadPciDataPort x86BiosSetPciBusData x86BiosTranslateAddress x86BiosWriteCmosPort x86BiosWriteCmosPortByte x86BiosWriteIoSpace x86BiosWriteMemory x86BiosWritePciAddressPort x86BiosWritePciDataPort */
[ "w.benny@outlook.com" ]
w.benny@outlook.com
6035cafa88364518e5bca3786ea93973a01d3c33
b6f243f2350fc859980946a33c794bd75cdbc953
/src/audio/opus-1.2.1/warped_autocorrelation_FIX.c
30ed61581518875b6a2b43e41b0da1ea274d553b
[]
no_license
ubicore/nrf52_audio_opus_sgtl5000
83b8ea3bc4b33567d2b0c164e0121af3e0a80037
dd7d363e0aff573b7e005ed0cab36c1426fb869f
refs/heads/master
2020-05-04T00:31:41.330571
2019-04-01T16:43:24
2019-04-01T16:43:24
178,886,385
9
0
null
null
null
null
UTF-8
C
false
false
4,746
c
/*********************************************************************** Copyright (c) 2006-2011, Skype Limited. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Internet Society, IETF or IETF Trust, nor the names of specific contributors, may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "main_FIX.h" #if defined(MIPSr1_ASM) #include "mips/warped_autocorrelation_FIX_mipsr1.h" #endif /* Autocorrelations for a warped frequency axis */ void silk_warped_autocorrelation_FIX_c( opus_int32 *corr, /* O Result [order + 1] */ opus_int *scale, /* O Scaling of the correlation vector */ const opus_int16 *input, /* I Input data to correlate */ const opus_int warping_Q16, /* I Warping coefficient */ const opus_int length, /* I Length of input */ const opus_int order /* I Correlation order (even) */ ) { opus_int n, i, lsh; opus_int32 tmp1_QS, tmp2_QS; opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; /* Order must be even */ silk_assert( ( order & 1 ) == 0 ); silk_assert( 2 * QS - QC >= 0 ); /* Loop over samples */ for( n = 0; n < length; n++ ) { tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); /* Loop over allpass sections */ for( i = 0; i < order; i += 2 ) { /* Output of allpass section */ tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); state_QS[ i ] = tmp1_QS; corr_QC[ i ] += silk_RSHIFT64( silk_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC ); /* Output of allpass section */ tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); state_QS[ i + 1 ] = tmp2_QS; corr_QC[ i + 1 ] += silk_RSHIFT64( silk_SMULL( tmp2_QS, state_QS[ 0 ] ), 2 * QS - QC ); } state_QS[ order ] = tmp1_QS; corr_QC[ order ] += silk_RSHIFT64( silk_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC ); } lsh = silk_CLZ64( corr_QC[ 0 ] ) - 35; lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC ); *scale = -( QC + lsh ); silk_assert( *scale >= -30 && *scale <= 12 ); if( lsh >= 0 ) { for( i = 0; i < order + 1; i++ ) { corr[ i ] = (opus_int32)silk_CHECK_FIT32( silk_LSHIFT64( corr_QC[ i ], lsh ) ); } } else { for( i = 0; i < order + 1; i++ ) { corr[ i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( corr_QC[ i ], -lsh ) ); } } silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/ }
[ "nicolas.lantz@ubicore.net" ]
nicolas.lantz@ubicore.net
b4b50e5c43c975540144d0ce9d857e9991ad805d
f7f0e3e5a2938997ea417c79436e2813a47951d1
/Pods/Headers/Private/MBDataEnvironment/MBMLRegexFunctions.h
264c53e68d8f2674bc97cfee9dddd3a0face48d7
[]
no_license
emaloney/Boilerplate
1240fadd4f9e4a0fd51fdda44646dee6b5a53d3c
07922d3a3c74c407d484e482c1c0ee015d5ae093
refs/heads/master
2021-01-16T21:46:28.795685
2016-12-13T15:20:40
2016-12-13T15:20:40
38,087,473
0
0
null
null
null
null
UTF-8
C
false
false
77
h
../../../MBDataEnvironment/Code/Functions/Implementation/MBMLRegexFunctions.h
[ "emaloney@gilt.com" ]
emaloney@gilt.com
872c6f5c25bfa463f7ff174bac4321c79b57bb47
cb44d748dc4074a4979019a3cadfa7fde337a0b3
/socket_inet_netof.c
77480986e21029faddc8297d779ce6dbde30dbf5
[]
no_license
sba1/clib2
dbb42f0875d510cfd9b92ab890855cfc2277519f
f1db9d75872d2618100961b9f000410f25a430ce
refs/heads/master
2020-05-25T11:45:19.923616
2015-04-03T17:54:40
2015-04-03T17:54:40
32,605,450
1
0
null
null
null
null
UTF-8
C
false
false
2,120
c
/* * $Id$ * * :ts=4 * * Portable ISO 'C' (1994) runtime library for the Amiga computer * Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Neither the name of Olaf Barthel nor the names of contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #if defined(SOCKET_SUPPORT) /****************************************************************************/ #ifndef _SOCKET_HEADERS_H #include "socket_headers.h" #endif /* _SOCKET_HEADERS_H */ /****************************************************************************/ in_addr_t inet_netof(struct in_addr in) { in_addr_t result; ENTER(); assert(__SocketBase != NULL); PROFILE_OFF(); result = __Inet_NetOf(in.s_addr); PROFILE_ON(); if(__check_abort_enabled) __check_abort(); RETURN(result); return(result); } /****************************************************************************/ #endif /* SOCKET_SUPPORT */
[ "obarthel" ]
obarthel
5c0e9080894923a5ba84036b28af5ba33bf042be
65bf3ac6edd22aa104bc6576d05f6f39e9a14bc0
/runcodes/binary_tree/bt.c
7984998fb837eb553a290540ed7661e3ccfdfe1d
[]
no_license
LuisFelipeJorge/Algoritmos-Estruturas_de_Dados
de812bfe27969b2dcbec6a82bb466c3596db0fd9
a24eb7c3a55a65d7902f82c00af2bda1249d5eb1
refs/heads/main
2023-02-04T19:04:02.457188
2020-12-29T17:16:14
2020-12-29T17:16:14
324,878,798
0
0
null
null
null
null
UTF-8
C
false
false
3,176
c
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include "bt.h" struct tnode { elem info; tnode_t *left,*right; }; tnode_t* create_tnode(elem x) { tnode_t *new_node = (tnode_t*)malloc(sizeof(tnode_t)); assert(new_node != NULL); new_node->info = x; new_node->left = NULL; new_node->right = NULL; return new_node; } tree_t* create_tree() { tree_t *new_tree = (tree_t*)malloc(sizeof(tree_t)); assert(new_tree != NULL); new_tree->root = NULL; return new_tree; } int tree_is_empty(tree_t *tree) { assert(tree != NULL); if (tree->root == NULL) return 1; return 0; } void free_tree(tnode_t *root) { if (root != NULL) { free_tree(root->left); free_tree(root->right); free(root); } } int insert_left(tree_t *t, elem x, elem parent) { tnode_t *new_node = create_tnode(x); if(parent == -1) { if (tree_is_empty(t)) t->root = new_node; else { free(new_node); return 0; } }else { tnode_t *parent_node = search_elem(t->root, parent); if (parent_node != NULL && parent_node->left == NULL) { parent_node->left = new_node; }else { free(new_node); return 0; } } return 1; } int insert_right(tree_t *t, elem x, elem parent) { tnode_t *new_node = create_tnode(x); if(parent == -1) { if (tree_is_empty(t)) t->root = new_node; else { free(new_node); return 0; } }else { tnode_t *parent_node = search_elem(t->root, parent); if (parent_node != NULL && parent_node->right == NULL) { parent_node->right = new_node; }else { free(new_node); return 0; } } return 1; } tnode_t* search_elem(tnode_t *root, elem x) { if (root == NULL) return NULL; if(root->info == x) return root; tnode_t *current_node = search_elem(root->left, x); if (current_node == NULL) current_node = search_elem(root->right, x); return current_node; } int get_height(tnode_t *root) { if (root == NULL) return 0; int left_height = 1 + get_height(root->left); int right_height = 1 + get_height(root->right); return (left_height>right_height)?left_height:right_height; } int get_grade(tnode_t *root) { int count = 0; if(root->left != NULL) count++; if(root->right != NULL) count++; return count; } char* get_type(tnode_t *root, int parent) { char *type = (char*)malloc(sizeof(char)*10); if (parent == -1) strcpy(type, "raiz"); else if (root->left == NULL && root->right == NULL) strcpy(type, "folha"); else strcpy(type, "interno"); return type; } void print_tree(tnode_t *root, int parent) { if (root == NULL) return; char *t = get_type(root, parent); int left, right; left = right = -1; if (root->left != NULL) left = root->left->info; if (root->right != NULL) right = root->right->info; printf("no %d: ", root->info); printf("pai = %d, ", parent); printf("altura = %d, ", get_height(root)); printf("grau = %d, ", get_grade(root)); printf("filhos = (%d,%d), ", left, right); printf("tipo = %s\n", t); free(t); print_tree(root->left, root->info); print_tree(root->right, root->info); }
[ "luisfelipe.jorge123@gmail.com" ]
luisfelipe.jorge123@gmail.com
c30c4a0db83a18aac98d5fa2c1f4c53594c607c6
e369c7b16495b0d913f46a1a3e293d7ff5368d92
/src/univalue/lib/univalue_escapes.h
1c8b5dd372c32209bca39c2ffabe27ce58f8a4a3
[ "MIT" ]
permissive
giracoin/girauno
be459789d8e00e424f4a6b881b27008479ab3276
cee08e12174831a08967c6764f612ba73cf0d7e8
refs/heads/master
2020-03-17T06:19:37.157684
2018-05-14T11:34:54
2018-05-14T11:34:54
133,350,681
3
0
null
null
null
null
UTF-8
C
false
false
2,165
h
// Automatically generated file. Do not modify. #ifndef GIRACOIN_UNIVALUE_UNIVALUE_ESCAPES_H #define GIRACOIN_UNIVALUE_UNIVALUE_ESCAPES_H static const char *escapes[256] = { "\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", "\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b", "\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011", "\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001a", "\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f", NULL, NULL, "\\\"", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "\\\\", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "\\u007f", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; #endif // GIRACOIN_UNIVALUE_UNIVALUE_ESCAPES_H
[ "info@giracoin.com" ]
info@giracoin.com
6ea162c9a2f7bdc3dcb958629cf9f01b5ffe325a
517848af126ed8f198b890a07a6bc5b7b1b94683
/sys/dev/siba/siba_pcib.c
d43f54c9c0a4361ce230fe4b8aebd9f58f59432f
[]
no_license
coolgoose85/FreeBSD
e9dbd33b95bf0a472a3e291451c273054b843a1f
ef72c1183400fd106d838c8ed0702649bc1b1b4e
refs/heads/master
2021-01-15T22:29:25.584742
2014-08-03T17:32:40
2014-08-03T17:32:40
22,535,409
2
1
null
null
null
null
UTF-8
C
false
false
11,838
c
/*- * Copyright (c) 2007 Bruce M. Simpson. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. */ /* * Child driver for PCI host bridge core. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> #include <sys/kernel.h> #include <sys/module.h> #include <sys/rman.h> #include <sys/malloc.h> #include <sys/endian.h> #include <vm/vm.h> #include <vm/pmap.h> #include <vm/vm_extern.h> #include <machine/bus.h> #include <machine/cpu.h> #include <machine/pcb.h> #include <machine/pmap.h> #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcib_private.h> #include "pcib_if.h" #include <dev/siba/sibavar.h> #include <dev/siba/sibareg.h> #include <dev/siba/siba_ids.h> #include <dev/siba/siba_pcibvar.h> #ifndef MIPS_MEM_RID #define MIPS_MEM_RID 0x20 #endif #define SBPCI_SLOTMAX 15 #define SBPCI_READ_4(sc, reg) \ bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg)) #define SBPCI_WRITE_4(sc, reg, val) \ bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg), (val)) /* * PCI Configuration space window (64MB). * contained in SBTOPCI1 window. */ #define SBPCI_CFGBASE 0x0C000000 #define SBPCI_CFGSIZE 0x01000000 #define SBPCI_SBTOPCI0 0x100 #define SBPCI_SBTOPCI1 0x104 #define SBPCI_SBTOPCI2 0x108 /* * TODO: implement type 1 config space access (ie beyond bus 0) * we may need to tweak the windows to do this * TODO: interrupt routing. * TODO: fully implement bus allocation. * TODO: implement resource managers. * TODO: code cleanup. */ static int siba_pcib_activate_resource(device_t, device_t, int, int, struct resource *); static struct resource * siba_pcib_alloc_resource(device_t, device_t, int, int *, u_long , u_long, u_long, u_int); static int siba_pcib_attach(device_t); static int siba_pcib_deactivate_resource(device_t, device_t, int, int, struct resource *); static int siba_pcib_maxslots(device_t); static int siba_pcib_probe(device_t); static u_int32_t siba_pcib_read_config(device_t, u_int, u_int, u_int, u_int, int); static int siba_pcib_read_ivar(device_t, device_t, int, uintptr_t *); static int siba_pcib_release_resource(device_t, device_t, int, int, struct resource *); static int siba_pcib_route_interrupt(device_t, device_t, int); static int siba_pcib_setup_intr(device_t, device_t, struct resource *, int, driver_filter_t *, driver_intr_t *, void *, void **); static int siba_pcib_teardown_intr(device_t, device_t, struct resource *, void *); static void siba_pcib_write_config(device_t, u_int, u_int, u_int, u_int, u_int32_t, int); static int siba_pcib_write_ivar(device_t, device_t, int, uintptr_t); static int siba_pcib_probe(device_t dev) { /* TODO: support earlier cores. */ /* TODO: Check if PCI host mode is enabled in the SPROM. */ if (siba_get_vendor(dev) == SIBA_VID_BROADCOM && siba_get_device(dev) == SIBA_DEVID_PCI) { device_set_desc(dev, "SiBa-to-PCI host bridge"); return (BUS_PROBE_DEFAULT); } return (ENXIO); } //extern int rman_debug; static int siba_pcib_attach(device_t dev) { struct siba_pcib_softc *sc = device_get_softc(dev); int rid; /* * Allocate the resources which the parent bus has already * determined for us. */ rid = MIPS_MEM_RID; /* XXX */ //rman_debug = 1; sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->sc_mem == NULL) { device_printf(dev, "unable to allocate memory\n"); return (ENXIO); } sc->sc_bt = rman_get_bustag(sc->sc_mem); sc->sc_bh = rman_get_bushandle(sc->sc_mem); device_printf(dev, "bridge registers addr 0x%08x vaddr %p\n", (uint32_t)sc->sc_bh, rman_get_virtual(sc->sc_mem)); SBPCI_WRITE_4(sc, 0x0000, 0x05); SBPCI_WRITE_4(sc, 0x0000, 0x0D); DELAY(150); SBPCI_WRITE_4(sc, 0x0000, 0x0F); SBPCI_WRITE_4(sc, 0x0010, 0x01); DELAY(1); bus_space_handle_t sc_cfg_hand; int error; /* * XXX this doesn't actually do anything on mips; however... should * we not be mapping to KSEG1? we need to wire down the range. */ error = bus_space_map(sc->sc_bt, SBPCI_CFGBASE, SBPCI_CFGSIZE, 0, &sc_cfg_hand); if (error) { device_printf(dev, "cannot map PCI configuration space\n"); return (ENXIO); } device_printf(dev, "mapped pci config space at 0x%08x\n", (uint32_t)sc_cfg_hand); /* * Setup configuration, io, and dma space windows. * XXX we need to be able to do type 1 too. * we probably don't need to be able to do i/o cycles. */ SBPCI_WRITE_4(sc, SBPCI_SBTOPCI0, 1); /* I/O read/write window */ SBPCI_WRITE_4(sc, SBPCI_SBTOPCI1, 2); /* type 0 configuration only */ SBPCI_WRITE_4(sc, SBPCI_SBTOPCI2, 1 << 30); /* memory only */ DELAY(500); /* XXX resource managers */ device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } /* bus functions */ static int siba_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) { struct siba_pcib_softc *sc; sc = device_get_softc(dev); switch (which) { case PCIB_IVAR_BUS: *result = sc->sc_bus; return (0); } return (ENOENT); } static int siba_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) { struct siba_pcib_softc *sc; sc = device_get_softc(dev); switch (which) { case PCIB_IVAR_BUS: sc->sc_bus = value; return (0); } return (ENOENT); } static int siba_pcib_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep) { return (BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, filt, intr, arg, cookiep)); } static int siba_pcib_teardown_intr(device_t dev, device_t child, struct resource *vec, void *cookie) { return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec, cookie)); } static struct resource * siba_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { #if 1 //device_printf(bus, "%s: not yet implemented\n", __func__); return (NULL); #else bus_space_tag_t tag; struct siba_pcib_softc *sc = device_get_softc(bus); struct rman *rmanp; struct resource *rv; tag = 0; rv = NULL; switch (type) { case SYS_RES_IRQ: rmanp = &sc->sc_irq_rman; break; case SYS_RES_MEMORY: rmanp = &sc->sc_mem_rman; tag = &sc->sc_pci_memt; break; default: return (rv); } rv = rman_reserve_resource(rmanp, start, end, count, flags, child); if (rv != NULL) { rman_set_rid(rv, *rid); if (type == SYS_RES_MEMORY) { #if 0 rman_set_bustag(rv, tag); rman_set_bushandle(rv, rman_get_bushandle(sc->sc_mem) + (rman_get_start(rv) - IXP425_PCI_MEM_HWBASE)); #endif } } return (rv); #endif } static int siba_pcib_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { device_printf(bus, "%s: not yet implemented\n", __func__); device_printf(bus, "%s called activate_resource\n", device_get_nameunit(child)); return (ENXIO); } static int siba_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { device_printf(bus, "%s: not yet implemented\n", __func__); device_printf(bus, "%s called deactivate_resource\n", device_get_nameunit(child)); return (ENXIO); } static int siba_pcib_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { device_printf(bus, "%s: not yet implemented\n", __func__); device_printf(bus, "%s called release_resource\n", device_get_nameunit(child)); return (ENXIO); } /* pcib interface functions */ static int siba_pcib_maxslots(device_t dev) { return (SBPCI_SLOTMAX); } /* * This needs hacking and fixery. It is currently broke and hangs. * Debugging it will be tricky; there seems to be no way to enable * a target abort which would cause a nice target abort. * Look at linux again? */ static u_int32_t siba_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes) { struct siba_pcib_softc *sc = device_get_softc(dev); bus_addr_t cfgaddr; uint32_t cfgtag; uint32_t val; /* XXX anything higher than slot 2 currently seems to hang the bus. * not sure why this is; look at linux again */ if (bus != 0 || slot > 2) { printf("%s: bad b/s/f %d/%d/%d\n", __func__, bus, slot, func); return 0xffffffff; // XXX } device_printf(dev, "requested %d bytes from b/s/f %d/%d/%d reg %d\n", bytes, bus, slot, func, reg); /* * The configuration tag on the broadcom is weird. */ SBPCI_WRITE_4(sc, SBPCI_SBTOPCI1, 2); /* XXX again??? */ cfgtag = ((1 << slot) << 16) | (func << 8); cfgaddr = SBPCI_CFGBASE | cfgtag | (reg & ~3); /* cfg space i/o is always 32 bits on this bridge */ printf("reading 4 bytes from %08x\n", cfgaddr); val = *(volatile uint32_t *)MIPS_PHYS_TO_KSEG1(cfgaddr); /* XXX MIPS */ val = bswap32(val); /* XXX seems to be needed for now */ /* swizzle and return what was asked for */ val &= 0xffffffff >> ((4 - bytes) * 8); return (val); } static void siba_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, u_int32_t val, int bytes) { /* write to pci configuration space */ //device_printf(dev, "%s: not yet implemented\n", __func__); } static int siba_pcib_route_interrupt(device_t bridge, device_t device, int pin) { //device_printf(bridge, "%s: not yet implemented\n", __func__); return (-1); } static device_method_t siba_pcib_methods[] = { /* Device interface */ DEVMETHOD(device_attach, siba_pcib_attach), DEVMETHOD(device_probe, siba_pcib_probe), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_read_ivar, siba_pcib_read_ivar), DEVMETHOD(bus_write_ivar, siba_pcib_write_ivar), DEVMETHOD(bus_setup_intr, siba_pcib_setup_intr), DEVMETHOD(bus_teardown_intr, siba_pcib_teardown_intr), DEVMETHOD(bus_alloc_resource, siba_pcib_alloc_resource), DEVMETHOD(bus_activate_resource, siba_pcib_activate_resource), DEVMETHOD(bus_deactivate_resource, siba_pcib_deactivate_resource), DEVMETHOD(bus_release_resource, siba_pcib_release_resource), /* pcib interface */ DEVMETHOD(pcib_maxslots, siba_pcib_maxslots), DEVMETHOD(pcib_read_config, siba_pcib_read_config), DEVMETHOD(pcib_write_config, siba_pcib_write_config), DEVMETHOD(pcib_route_interrupt, siba_pcib_route_interrupt), {0, 0}, }; static driver_t siba_pcib_driver = { "pcib", siba_pcib_methods, sizeof(struct siba_softc), }; static devclass_t siba_pcib_devclass; DRIVER_MODULE(siba_pcib, siba, siba_pcib_driver, siba_pcib_devclass, 0, 0);
[ "vaibhav123@gmail.com" ]
vaibhav123@gmail.com
5d93b30fd7dfe7127b17698784cae3c30f5a6bab
4ca4e6d6bf69dd0a0dc4d3317396d593446555bd
/event_selection.h
99f2cfb85dcb721b0d4f6bcc2b095ab0df568917
[]
no_license
tylern4/analysis
985949f4fc9aefc22c02073c43a465a82d759edb
aead716e49cbba70e3c5649ff02cdf3fd340c7eb
refs/heads/master
2021-01-22T06:18:25.927521
2017-02-09T22:17:40
2017-02-09T22:17:40
81,751,306
0
0
null
2017-02-12T19:34:49
2017-02-12T19:34:49
null
UTF-8
C
false
false
7,260
h
#ifndef EVENT_SELECTION_H #define EVENT_SELECTION_H #include "constants.h" #include "hid.h" #include "TVector3.h" #include <TLorentzVector.h> //Determine if multiple ids assigned to a single particle //These are the only particles I'm IDing so if it is something else it comes in as zero bool clean_id ( bool electron, bool proton, bool pi_plus, bool pi_minus) { bool clean = kFALSE; if((int)electron +(int)proton +(int)pi_plus +(int)pi_minus<=1) { clean = kTRUE; } return clean; } /* //Determine if kinematically clean //Only need to do when all particles are present //A momentum correction is all the more necessary after these bool clean_kin */ //Give proper particle ID number to the particle id varaible array you made int give_id( bool electron, bool proton, bool pi_plus, bool pi_minus) { //Check that the id is clean int id = 0; bool is_clean = clean_id(electron, proton, pi_plus, pi_minus); if( is_clean == kTRUE) { if( electron == kTRUE) { id = ELECTRON; } if( proton == kTRUE) { id = PROTON; } if( pi_plus == kTRUE) { id = PION; } if( pi_minus == kTRUE) { id = -PION; } } return id; } //Determine if there were only clean id's in an event //Not sure how this is useful, probably won't use. bool clean_event (Int_t gpart, int real_id[24]) { bool clean_event = kFALSE; int mult = 1; for( int a=0;a<gpart;a++) { mult = mult * real_id[a]; } if( mult != 0) { clean_event = kTRUE; } return clean_event; } // /* 1) Identify particles 2) Choose Topology 3) Pi-Missing mass 3.1 /* //pi- Missing Mass if(real_id[0]==ELECTRON) { int pidx = -1; int pipidx = -1; int event = 0; for(int k=1; k<gpart; k++) { if(is_proton(k) == kTRUE) { for(int l = 1; l<gpart; l++) { if(is_pip(l) == kTRUE && l!=k) { if(missing_mass(k,l) > (pim_center-3*pim_sigma) && missing_mass(k,l) < (pim_center+3*pim_sigma)) { event++; pidx = k; pipidx = l; } } } } } if(event == 1) { //Event found } } */ //proton, pi_plus measured // Looks for /* Takes in personal id: real_id bank momentum: p bank: gpart bank cosines: cx, cy, cz Energy of beam */ bool pi_m_miss (int real_id[24], Float_t p[23], Int_t gpart, bool clean_id, Float_t cx[23], Float_t cy[23], Float_t cz[23], double Energy) { bool pi_mi_found = kFALSE; int number_pi_mi = 0; TLorentzVector p_mu_prime, pi_mu_prime, k_mu_prime, k_mu(0.0,0.0,Energy,Energy),p_mu(0.0,0.0,0.0,mp),q_mu; TVector3 p_mu3_prime, pi_mu3_prime, k_mu_prime3; double missing_mass; //Need to recalculate four momentum of virtual exchange photon if(real_id[0]==ELECTRON) { k_mu_prime3.SetXYZ(p[0]*cx[0],p[0]*cy[0],p[0]*cz[0]); k_mu_prime.SetVectM(k_mu_prime3,me); q_mu = (k_mu - k_mu_prime); //Loop over particles twice to find a set of proton and pi_plus for(int w=0;w<gpart;w++) { for(int r=0;r<gpart;r++) { if( real_id[w]==PROTON && real_id[r]==PION) { p_mu3_prime.SetXYZ(p[w]*cx[w],p[w]*cy[w],p[w]*cz[w]); pi_mu3_prime.SetXYZ(p[r]*cx[r],p[r]*cy[r],p[r]*cz[r]); p_mu_prime.SetVectM(p_mu3_prime,mp); pi_mu_prime.SetVectM(pi_mu3_prime,mpi); missing_mass = (q_mu + p_mu - p_mu_prime - pi_mu_prime).Mag2(); if(missing_mass>=(pim_center - 3*pim_sig) && missing_mass<=(pim_center - 3*pim_sig)) { number_pi_mi++; } } } } } //Looking for just a single pi_minus paired with a proton, pi_plus if(number_pi_mi ==1) { pi_mi_found = kTRUE; } return pi_mi_found; } //Seen pi plus and minus bool proton_miss (int real_id[24], Float_t p[23], Int_t gpart, bool clean_id, Float_t cx[23], Float_t cy[23], Float_t cz[23], double Energy) { bool proton_found = kFALSE; int number_proton = 0; TLorentzVector p_mu_prime, pi_mu_prime, k_mu_prime, k_mu(0.0,0.0,Energy,Energy),p_mu(0.0,0.0,0.0,mp),q_mu; TVector3 p_mu3_prime, pi_mu3_prime, k_mu_prime3; double missing_mass; //Need to recalculate four momentum of virtual exchange photon if(real_id[0]==ELECTRON) { k_mu_prime3.SetXYZ(p[0]*cx[0],p[0]*cy[0],p[0]*cz[0]); k_mu_prime.SetVectM(k_mu_prime3,me); q_mu = (k_mu - k_mu_prime); //Loop over particles twice to find a set of pi_minus and pi_plus for(int w=0;w<gpart;w++) { for(int r=0;r<gpart;r++) { if( real_id[w]==PION && real_id[r]==-PION) { p_mu3_prime.SetXYZ(p[w]*cx[w],p[w]*cy[w],p[w]*cz[w]); pi_mu3_prime.SetXYZ(p[r]*cx[r],p[r]*cy[r],p[r]*cz[r]); p_mu_prime.SetVectM(p_mu3_prime,mpi); pi_mu_prime.SetVectM(pi_mu3_prime,mpi); missing_mass = (q_mu + p_mu - p_mu_prime - pi_mu_prime).Mag2(); if(missing_mass>=(p_center - 3*p_sig) && missing_mass<=(p_center - 3*p_sig)) { number_proton++; } } } } } //Looking for just a single proton paired with a pi minus, pi_plus if(number_proton ==1) { proton_found = kTRUE; } return proton_found; } //Seen proton and pi minus: missing mass on pi plus bool pi_p_miss (int real_id[24], Float_t p[23], Int_t gpart, bool clean_id, Float_t cx[23], Float_t cy[23], Float_t cz[23], double Energy) { bool pi_p_found = kFALSE; int number_pi_p = 0; TLorentzVector p_mu_prime, pi_mu_prime, k_mu_prime, k_mu(0.0,0.0,Energy,Energy),p_mu(0.0,0.0,0.0,mp),q_mu; TVector3 p_mu3_prime, pi_mu3_prime, k_mu_prime3; double missing_mass; //Need to recalculate four momentum of virtual exchange photon if(real_id[0]==ELECTRON) { k_mu_prime3.SetXYZ(p[0]*cx[0],p[0]*cy[0],p[0]*cz[0]); k_mu_prime.SetVectM(k_mu_prime3,me); q_mu = (k_mu - k_mu_prime); //Loop over particles twice to find a set of proton and pi_minus for( int w=0;w<gpart;w++) { for( int r=0;r<gpart;r++) { if( real_id[w]==PROTON && real_id[r]==-PION) { p_mu3_prime.SetXYZ(p[w]*cx[w],p[w]*cy[w],p[w]*cz[w]); pi_mu3_prime.SetXYZ(p[r]*cx[r],p[r]*cy[r],p[r]*cz[r]); p_mu_prime.SetVectM(p_mu3_prime,mp); pi_mu_prime.SetVectM(pi_mu3_prime,mpi); missing_mass = (q_mu + p_mu - p_mu_prime - pi_mu_prime).Mag2(); if(missing_mass>=(pip_center - 3*pip_sig) && missing_mass<=(pip_center - 3*pip_sig)) { number_pi_p++; } } } } } //Looking for just a single pi_minus paired with a proton, pi_minus if(number_pi_p ==1) { pi_p_found = kTRUE; } return pi_p_found; } //This just says whether or not all target particles are in the event bool all_present(int real_id[24], Int_t gpart) { bool all_present = kFALSE; for(int i=0;i<gpart;i++) { for(int j=0;j<gpart;j++) { for(int k=0;k<gpart;k++) { if( real_id[i]==PROTON && real_id[j]==PION && real_id[k]==-PION) { all_present = kTRUE; } } } } return all_present; } //To see if an event satisfies any of the four topologies bool topology_cross ( bool all_present, bool pi_mi_miss, bool pi_p_miss, bool proton_miss) { bool cross = kFALSE; if( ((int)all_present + (int)pi_mi_miss +(int)pi_p_miss +(int)proton_miss)>=1) { cross = kTRUE; } return cross; } //Actual event selection //Will cross reference through diffrent topologies to make sure that events are not double, or triple counted /* Says whether or not the event fits within - Taret Particles - Kinematic Agreement - no momentum corrections yet */ //bool event_selection() #endif /* EVENT_SELECTION_H */
[ "c.a.mclauchlin@gmail.com" ]
c.a.mclauchlin@gmail.com
c334b30f354d2fd11eb3cf7de70c6e160f30d843
4b8cc482b171a24b9e77b5baf2d44c57797140f2
/mod_sslhaf.c
4643de2a8ded2ed6ef2f43fdb84eaf816b24527d
[]
no_license
grimreaper/sslhaf
78aed96fc5b5bd7ed8f98f9602d7e352fcb52fee
cf4a7961df890e35c2ae8bf58822ad95343f3f87
refs/heads/master
2021-01-18T09:23:25.274953
2012-10-18T14:28:59
2012-10-18T14:28:59
null
0
0
null
null
null
null
UTF-8
C
false
false
36,718
c
/* mod_sslhaf: Apache module for passive SSL client fingerprinting | THIS PRODUCT IS NOT READY FOR PRODUCTION USE. DEPLOY AT YOUR OWN RISK. Copyright (c) 2009-2012, Qualys, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Qualys, Inc. 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. */ /* * This Apache module will extract the list of SSL cipher suites * offered by HTTP clients during the SSL negotiation phase. The idea * is that different clients use different SSL implementations and * configure them in different ways. By looking at the differences in * the cipher suites we should be able to identify clients, irrespective * of what they seem to be (looking at HTTP request headers). * * This way of fingerprinting is much more reliable than other approaches * (e.g. TCP/IP fingerprinting), for the following reasons: * * - HTTP proxies do not terminate SSL, which means that every client * creates a unique data stream that is sent directly to servers. * * - NAT will modify TCP/IP packets, but leave SSL data streams * untouched. * * * To compile and install the module, do this: * * # apxs -cia mod_sslhaf.c * * The above script will try to add a LoadModule statement to your * configuration file but it will fail if it can't find at least one * previous such statement. If that happens (you'll see the error * message) you'll need to add the following line manually: * * LoadModule sslhaf_module /path/to/modules/mod_sslhaf.so * * You will also need to add a custom log to record cipher suite information. * For example (add to the virtual host where you want the fingerprinting * to take place): * * CustomLog logs/sslhaf.log "%t %h \"%{SSLHAF_HANDSHAKE}e\" \ * \"%{SSLHAF_PROTOCOL}e\" \"%{SSLHAF_SUITES}e\" \"%{SSLHAF_BEAST}e\" \ * \"%{SSLHAF_COMPRESSION}e\" \"%{SSLHAF_EXTENSIONS_LEN}e\" \"%{SSLHAF_EXTENSIONS}e\" \ * \"%{User-Agent}i\"" * * As an example, these are the values you'd get from a visit by the Google * search engine: * * SSLHAF_HANDSHAKE 2 * SSLHAF_PROTOCOL 3.1 * SSLHAF_SUITES 04,010080,05,0a * * The tokens have the following meaning: * * - SSL_HANDSHAKE contains the handshake version used: 2 and 3 for an SSL v2 and SSL v3+ * handshake, respectively. You can see in the example that Google bot uses a SSLv2 handshake, * which means that it is ready to use SSL v2 or better. * * - SSL_PROTOCOL The second token contains the best SSL/TLS version supported by the client. For * example, SSLv3 is "3.0"; TLS 1.0 is "3.1"; TLS 1.1 is "3.2", etc. * * - SSLHAF_SUITES contains a list of the supported cipher suites. Each value, a hexadecimal number, * corresponds to one cipher suite. From the example, 0x04 stands for SSL_RSA_WITH_RC4_128_MD5, * 0x010080 stands for SSL_CK_RC4_128_WITH_MD5 (a SSLv2 suite) and 0x05 stands * for SSL_RSA_WITH_RC4_128_SHA. * * - SSLHAF_BEAST is 1 if the 1/n-1 BEAST mitigation was detected, 0 otherwise. * * - SSLHAF_COMPRESSION contains the list of compression methods offered by the * client (NULL 00, DEFLATE 01). The field can be NULL, in which case it will appear * in the logs as "-". This happens when SSLv2 handshake is used. * * - SSLHAF_LOG is defined (and contains "1") only on the first request in a connection. This * variable can be used to reduce the amount of logging (SSL parameters will typically not * change across requests on the same connection). Example: * * CustomLog logs/sslhaf.log "YOUR_LOG_STRING_HERE" env=SSLHAF_LOG * */ #include "ap_config.h" #include "apr_lib.h" #include "apr_hash.h" #include "apr_optional.h" #include "apr_sha1.h" #include "apr_strings.h" #define APR_WANT_STRFUNC #include "apr_want.h" #include "httpd.h" #include "http_core.h" #include "http_config.h" #include "http_connection.h" #include "http_log.h" #include "http_protocol.h" #include "mod_log_config.h" module AP_MODULE_DECLARE_DATA sslhaf_module; static const char sslhaf_in_filter_name[] = "SSLHAF_IN"; static const char sslhaf_out_filter_name[] = "SSLHAF_OUT"; struct sslhaf_cfg_t { /* Inspection state; see above for the constants. */ int state; /* The buffer we use to store the first SSL packet. * Allocated from the connection pool. */ int buf_protocol; unsigned char *buf; apr_size_t buf_len; apr_size_t buf_to_go; /* The client hello version used; 2 or 3. */ unsigned int hello_version; /* SSL version indicated in the handshake. */ unsigned int protocol_high; unsigned int protocol_low; /* How many suites are there? */ unsigned int slen; /* Pointer to the first suite. Do note that a v3 suites consumes * 2 bytes whereas a v2 suite consumes 3 bytes. You need to check * hello_version before you access the suites. */ const char *suites; /* Handkshake version as string. */ const char *thandshake; /* Protocol version number as string. */ const char *tprotocol; /* Suites as text. */ const char *tsuites; /* How many requests were there on this connection? */ unsigned int request_counter; /* SHA1 hash of the remote address. */ const char *ipaddress_hash; /* How many output buckets seen on a connection */ int out_bucket_count; /* How many input data fragments seen before first output data fragment. */ int in_data_fragments; /* How many output buckets sent before first input data fragment. */ int in_data_fragment_out_buckets; /* Indicates the connection has switched to encrypted handshake messages. */ int seen_cipher_change; /* How many compression methods are there. */ int compression_len; /* List of all compression methods as a comma-separated string. */ const char *compression_methods; /* How many extensions were there in the handshake? */ int extensions_len; /* A string that contains the list of all extensions seen in the handshake. */ const char *extensions; }; typedef struct sslhaf_cfg_t sslhaf_cfg_t; #define STATE_START 0 #define STATE_BUFFER 1 #define STATE_READING 2 #define STATE_GOAWAY 3 #define BUF_LIMIT 16384 #define PROTOCOL_CHANGE_CIPHER_SPEC 20 #define PROTOCOL_HANDSHAKE 22 #define PROTOCOL_APPLICATION 23 /** * Convert the bytes given on input into their hexadecimal representation. */ char *bytes2hex(apr_pool_t *pool, unsigned char *data, int len) { static unsigned char b2hex[] = "0123456789abcdef"; char *hex = NULL; int i, j; hex = apr_palloc(pool, (len * 2) + 1); if (hex == NULL) return NULL; j = 0; for(i = 0; i < len; i++) { hex[j++] = b2hex[data[i] >> 4]; hex[j++] = b2hex[data[i] & 0x0f]; } hex[j] = '\0'; return hex; } /** * Generate a SHA1 hash of the supplied data. */ char *generate_sha1(apr_pool_t *pool, char *data, int len) { unsigned char digest[APR_SHA1_DIGESTSIZE]; apr_sha1_ctx_t context; apr_sha1_init(&context); apr_sha1_update(&context, (const char *)data, len); apr_sha1_final(digest, &context); return bytes2hex(pool, digest, APR_SHA1_DIGESTSIZE); } /** * Convert one byte into its hexadecimal representation. */ unsigned char *c2x(unsigned what, unsigned char *where) { static const char c2x_table[] = "0123456789abcdef"; what = what & 0xff; *where++ = c2x_table[what >> 4]; *where++ = c2x_table[what & 0x0f]; return where; } /** * Decode SSLv2 packet. */ static int decode_packet_v2(ap_filter_t *f, sslhaf_cfg_t *cfg) { unsigned char *buf = cfg->buf; apr_size_t len = cfg->buf_len; int cslen; unsigned char *q; // There are 6 bytes before the list of cipher suites: // cipher suite length (2 bytes), session ID length (2 bytes) // and challenge length (2 bytes). if (len < 6) { return -1; } // How many bytes do the cipher suites consume? cslen = (buf[0] * 256) + buf[1]; // Skip over to the list. buf += 6; len -= 6; // Check that we have the suites in the buffer. if (len < (apr_size_t)cslen) { return -2; } // In SSLv2 each suite consumes 3 bytes. cslen = cslen / 3; // Keep the pointer to where the suites begin. The memory // was allocated from the connection pool, so it should // be around for as long as we need it. cfg->slen = cslen; cfg->suites = (const char *)buf; cfg->thandshake = apr_psprintf(f->c->pool, "%i", cfg->hello_version); cfg->tprotocol = apr_psprintf(f->c->pool, "%i.%i", cfg->protocol_high, cfg->protocol_low); // Create a list of suites as text, for logging. Each 3-byte // suite can consume up to 6 bytes (in hexadecimal form) with // an additional byte for a comma. We need 9 bytes at the // beginning (handshake and version), as well as a byte for // the terminating NUL byte. q = apr_pcalloc(f->c->pool, (cslen * 7) + 1); if (q == NULL) { return -3; } cfg->tsuites = (const char *)q; // Extract cipher suites; each suite consists of 3 bytes. while(cslen--) { if ((const char *)q != cfg->tsuites) { *q++ = ','; } if (*buf != 0) { c2x(*buf, q); q += 2; c2x(*(buf + 1), q); q += 2; } else { if (*(buf + 1) != 0) { c2x(*(buf + 1), q); q += 2; } } c2x(*(buf + 2), q); q += 2; buf += 3; } *q = '\0'; return 1; } /** * Decode SSLv3+ packet containing handshake data. */ static int decode_packet_v3_handshake(ap_filter_t *f, sslhaf_cfg_t *cfg) { unsigned char *buf = cfg->buf; apr_size_t len = cfg->buf_len; #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf [%s]: decode_packet_v3_handshake (len %" APR_SIZE_T_FMT ")", f->c->remote_ip, len); #endif // Loop while there's data in buffer while(len > 0) { apr_size_t ml; int mt; #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf [%s]: decode_packet_v3_handshake loop (len %" APR_SIZE_T_FMT, f->c->remote_ip, len); #endif // Check for size first if (len < 4) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Decoding packet v3 HANDSHAKE: Packet too small %" APR_SIZE_T_FMT, f->c->remote_ip, len); return -1; } // Message type mt = buf[0]; // Message length ml = (buf[1] * 65536) + (buf[2] * 256) + buf[3]; #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf [%s]: decode_packet_v3_handshake mt %d %" APR_SIZE_T_FMT, f->c->remote_ip, mt, ml); #endif if (mt != 1) { return 1; } // Does the message length correspond // to the size of our buffer? if (ml > len - 4) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Decoding packet v3 HANDSHAKE: Length mismatch. Expecting %" APR_SIZE_T_FMT " got %" APR_SIZE_T_FMT, f->c->remote_ip, ml, len - 4); return -2; } // Is this a Client Hello message? if (mt == 1) { unsigned char *p = buf + 4; // skip over the message type and length unsigned char *q; apr_size_t mylen = ml; int idlen; int cslen; if (mylen < 34) { // for the version number and random value return -3; } p += 2; // version number p += 32; // random value mylen -= 34; if (mylen < 1) { // for the ID length byte return -4; } idlen = *p; p += 1; // ID len mylen -= 1; if (mylen < (apr_size_t)idlen) { // for the ID return -5; } p += idlen; // ID mylen -= idlen; if (mylen < 2) { // for the CS length bytes return -6; } cslen = (*p * 256) + *(p + 1); cslen = cslen / 2; // each suite consumes 2 bytes p += 2; // Cipher Suites len mylen -= 2; if (mylen < (apr_size_t)cslen * 2) { // for the suites return -7; } // Keep the pointer to where the suites begin. The memory // was allocated from the connection pool, so it should // be around for as long as we need it. cfg->slen = cslen; cfg->suites = (const char *)p; cfg->thandshake = apr_psprintf(f->c->pool, "%d", cfg->hello_version); cfg->tprotocol = apr_psprintf(f->c->pool, "%d.%d", cfg->protocol_high, cfg->protocol_low); // Create a list of suites as text, for logging q = apr_pcalloc(f->c->pool, (cslen * 7) + 1); cfg->tsuites = (const char *)q; // Extract cipher suites; each suite consists of 2 bytes while(cslen--) { if ((const char *)q != cfg->tsuites) { *q++ = ','; } if (*p != 0) { c2x(*p, q); q += 2; } c2x(*(p + 1), q); q += 2; p += 2; } *q = '\0'; mylen -= cfg->slen * 2; // Compression if (mylen < 1) { // compression data length return -8; } int clen = *p++; mylen--; if (mylen < clen) { // compression data return -9; } cfg->compression_len = clen; q = apr_pcalloc(f->c->pool, (clen * 3) + 1); cfg->compression_methods = (const char *)q; while(clen--) { if ((const char *)q != cfg->compression_methods) { *q++ = ','; } c2x(*p, q); p++; q += 2; } *q = '\0'; mylen -= cfg->compression_len; if (mylen == 0) { // It's OK if there is no more data; that means // we're seeing a handshake without any extensions return 1; } // Extensions if (mylen < 2) { // extensions length return -10; } int elen = (*p * 256) + *(p + 1); mylen -= 2; p += 2; if (mylen < elen) { // extension data return -11; } cfg->extensions_len = 0; q = apr_pcalloc(f->c->pool, (elen * 5) + 1); cfg->extensions = (const char *)q; while(elen > 0) { cfg->extensions_len++; if ((const char *)q != cfg->extensions) { *q++ = ','; } // extension type, byte 1 c2x(*p, q); p++; elen--; q += 2; // extension type, byte 2 c2x(*p, q); p++; elen--; q += 2; // extension length int ext1len = (*p * 256) + *(p + 1); p += 2; elen -= 2; // skip over extension data p += ext1len; elen -= ext1len; } *q = '\0'; } // Skip over the message len -= 4; len -= ml; buf += 4; buf += ml; } return 1; } /** * Decode SSLv3+ packet data. */ static int decode_packet_v3(ap_filter_t *f, sslhaf_cfg_t *cfg) { /* Handshake */ if (cfg->buf_protocol == PROTOCOL_HANDSHAKE) { if (cfg->seen_cipher_change == 0) { return decode_packet_v3_handshake(f, cfg); } else { // Ignore encrypted handshake messages return 1; } } else /* Application data */ if (cfg->buf_protocol == PROTOCOL_APPLICATION) { // On first data fragment, remember how many // output buckets we have seen so far if (cfg->in_data_fragments == 0) { cfg->in_data_fragment_out_buckets = cfg->out_bucket_count; cfg->in_data_fragments++; } else { // Increment data fragement counter for as // long as the output bucket counter remains // the same if (cfg->out_bucket_count == cfg->in_data_fragment_out_buckets) { cfg->in_data_fragments++; } } return 1; } else /* Change cipher spec */ if (cfg->buf_protocol == PROTOCOL_CHANGE_CIPHER_SPEC) { cfg->seen_cipher_change = 1; return 1; } else { // Ignore unknown protocols return 1; } } /** * Deal with a single bucket. We look for a handshake SSL packet, buffer * it (possibly across several invocations), then invoke a function to analyse it. */ static int decode_bucket(ap_filter_t *f, sslhaf_cfg_t *cfg, const unsigned char *inputbuf, apr_size_t inputlen) { #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf [%s]: decode_bucket (inputlen %" APR_SIZE_T_FMT ")", f->c->remote_ip, inputlen); #endif // Loop while there's input to process while(inputlen > 0) { #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf [%s]: decode_bucket (inputlen %" APR_SIZE_T_FMT ", state %d)", f->c->remote_ip, inputlen, cfg->state); #endif // Are we looking for the next packet of data? if ((cfg->state == STATE_START)||(cfg->state == STATE_READING)) { apr_size_t len; // Are we expecting a handshake packet? if (cfg->state == STATE_START) { if ((inputbuf[0] != PROTOCOL_HANDSHAKE)&&(inputbuf[0] != 128)) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf: First byte (%d) of this connection does not indicate SSL; skipping", inputbuf[0]); return -1; } } // Check for SSLv3+ if ( (inputbuf[0] == PROTOCOL_HANDSHAKE) ||(inputbuf[0] == PROTOCOL_APPLICATION) ||(inputbuf[0] == PROTOCOL_CHANGE_CIPHER_SPEC)) { // Remember protocol cfg->buf_protocol = inputbuf[0]; // Go over the protocol byte inputbuf++; inputlen--; // Are there enough bytes to begin analysis? if (inputlen < 4) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Less than 5 bytes from the packet available in this bucket", f->c->remote_ip); return -1; } cfg->hello_version = 3; cfg->protocol_high = inputbuf[0]; cfg->protocol_low = inputbuf[1]; // Go over the version bytes inputbuf += 2; inputlen -= 2; // Calculate packet length len = (inputbuf[0] * 256) + inputbuf[1]; // Limit what we are willing to accept if ((len <= 0)||(len > BUF_LIMIT)) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: TLS record too long: %" APR_SIZE_T_FMT "; limit %d", f->c->remote_ip, len, BUF_LIMIT); return -1; } // Go over the packet length bytes inputbuf += 2; inputlen -= 2; // Allocate a buffer to hold the entire packet cfg->buf = malloc(len); if (cfg->buf == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Failed to allocate %" APR_SIZE_T_FMT " bytes", f->c->remote_ip, len); return -1; } // Go into buffering mode cfg->state = STATE_BUFFER; cfg->buf_len = 0; cfg->buf_to_go = len; #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->c->base_server, "mod_sslhaf [%s]: decode_bucket; buffering protocol %d high %d low %d len %" APR_SIZE_T_FMT, f->c->remote_ip, cfg->buf_protocol, cfg->protocol_high, cfg->protocol_low, len); #endif } else // Is it a SSLv2 ClientHello? if (inputbuf[0] == 128) { // Go over packet type inputbuf++; inputlen--; // Are there enough bytes to begin analysis? if (inputlen < 4) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Less than 5 bytes from the packet available in this bucket", f->c->remote_ip); return -1; } // Check that it is indeed ClientHello if (inputbuf[1] != 1) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Not SSLv2 ClientHello (%d)", f->c->remote_ip, inputbuf[1]); return -1; } cfg->hello_version = 2; if ((inputbuf[2] == 0x00)&&(inputbuf[3] == 0x02)) { // SSL v2 uses 0x0002 for the version number cfg->protocol_high = inputbuf[3]; cfg->protocol_low = inputbuf[2]; } else { // SSL v3 will use 0x0300, 0x0301, etc. cfg->protocol_high = inputbuf[2]; cfg->protocol_low = inputbuf[3]; } // We've already consumed 3 bytes from the packet len = inputbuf[0] - 3; // Limit what we are willing to accept if ((len <= 0)||(len > BUF_LIMIT)) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: TLS record too long: %" APR_SIZE_T_FMT "; limit %d", f->c->remote_ip, len, BUF_LIMIT); return -1; } // Go over the packet length (1 byte), message // type (1 byte) and version (2 bytes) inputbuf += 4; inputlen -= 4; // Allocate a buffer to hold the entire packet cfg->buf = apr_pcalloc(f->c->pool, len); if (cfg->buf == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Failed to allocate %" APR_SIZE_T_FMT " bytes", f->c->remote_ip, len); return -1; } // Go into buffering mode cfg->state = STATE_BUFFER; cfg->buf_len = 0; cfg->buf_to_go = len; } else { // Unknown protocol return -1; } } // Are we buffering? if (cfg->state == STATE_BUFFER) { // How much data is available? if (cfg->buf_to_go <= inputlen) { int rc; // We have enough data to complete this packet memcpy(cfg->buf + cfg->buf_len, inputbuf, cfg->buf_to_go); cfg->buf_len += cfg->buf_to_go; inputbuf += cfg->buf_to_go; inputlen -= cfg->buf_to_go; cfg->buf_to_go = 0; // Decode the packet now if (cfg->hello_version == 3) { rc = decode_packet_v3(f, cfg); } else { rc = decode_packet_v2(f, cfg); } // Free the packet buffer, which we no longer need free(cfg->buf); cfg->buf = NULL; if (rc < 0) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, f->c->base_server, "mod_sslhaf [%s]: Packet decoding error rc %d (hello %d)", f->c->remote_ip, rc, cfg->hello_version); return -1; } // Go back to looking at the next packet cfg->state = STATE_READING; return rc; } else { // There's not enough data; copy what we can and // we'll get the rest later memcpy(cfg->buf + cfg->buf_len, inputbuf, inputlen); cfg->buf_len += inputlen; cfg->buf_to_go -= inputlen; inputbuf += inputlen; inputlen = 0; } } } return 1; } /** * Monitor outbound data and count buckets. This will help us determine * if input data is fragmented (we see more than one inbound bucket before * we see one outbound bucket). */ static apr_status_t sslhaf_out_filter(ap_filter_t *f, apr_bucket_brigade *bb) { sslhaf_cfg_t *cfg = ap_get_module_config(f->c->conn_config, &sslhaf_module); apr_status_t status; apr_bucket *bucket; // Return straight away if there's no configuration if (cfg == NULL) { return ap_pass_brigade(f->next, bb); } // Loop through the buckets for (bucket = APR_BRIGADE_FIRST(bb); bucket != APR_BRIGADE_SENTINEL(bb); bucket = APR_BUCKET_NEXT(bucket)) { const char *buf = NULL; apr_size_t buflen = 0; if (!(APR_BUCKET_IS_METADATA(bucket))) { // Get bucket data status = apr_bucket_read(bucket, &buf, &buflen, APR_BLOCK_READ); if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, status, f->c->base_server, "mod_sslhaf [%s]: Error while reading output bucket", f->c->remote_ip); return status; } // Count output buckets cfg->out_bucket_count++; } } return ap_pass_brigade(f->next, bb); } /** * This input filter will basicall sniff on a connection and analyse * the packets when it detects SSL. */ static apr_status_t sslhaf_in_filter(ap_filter_t *f, apr_bucket_brigade *bb, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes) { sslhaf_cfg_t *cfg = ap_get_module_config(f->c->conn_config, &sslhaf_module); apr_status_t status; apr_bucket *bucket; // Return straight away if there's no configuration if (cfg == NULL) { return ap_get_brigade(f->next, bb, mode, block, readbytes); } // Sanity check first if (cfg->state == STATE_GOAWAY) { return ap_get_brigade(f->next, bb, mode, block, readbytes); } // Get brigade status = ap_get_brigade(f->next, bb, mode, block, readbytes); if (status != APR_SUCCESS) { // Do not log, since we're passing the status anyway cfg->state = STATE_GOAWAY; return status; } // Loop through the buckets for(bucket = APR_BRIGADE_FIRST(bb); bucket != APR_BRIGADE_SENTINEL(bb); bucket = APR_BUCKET_NEXT(bucket)) { const char *buf = NULL; apr_size_t buflen = 0; if (!(APR_BUCKET_IS_METADATA(bucket))) { // Get bucket data status = apr_bucket_read(bucket, &buf, &buflen, APR_BLOCK_READ); if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, status, f->c->base_server, "mod_sslhaf [%s]: Error while reading input bucket", f->c->remote_ip); return status; } // Look into the bucket if (decode_bucket(f, cfg, (const unsigned char *)buf, buflen) <= 0) { cfg->state = STATE_GOAWAY; } } } return APR_SUCCESS; } /** * Attach our filter to every incoming connection. */ static int sslhaf_pre_conn(conn_rec *c, void *csd) { sslhaf_cfg_t *cfg = NULL; // TODO Can we determine if SSL is enabled on this connection // and don't bother if it isn't? It is actually possible that // someone speaks SSL on a non-SSL connection, but we won't // be able to detect that. It wouldn't matter, though, because // Apache will not process such a request. cfg = apr_pcalloc(c->pool, sizeof(*cfg)); if (cfg == NULL) return OK; ap_set_module_config(c->conn_config, &sslhaf_module, cfg); ap_add_input_filter(sslhaf_in_filter_name, NULL, NULL, c); ap_add_output_filter(sslhaf_out_filter_name, NULL, NULL, c); #ifdef ENABLE_DEBUG ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c->base_server, "mod_sslhaf: Connection from %s", c->remote_ip); #endif return OK; } /** * Take the textual representation of the client's cipher suite * list and attach it to the request. */ static int sslhaf_post_request(request_rec *r) { sslhaf_cfg_t *cfg = ap_get_module_config(r->connection->conn_config, &sslhaf_module); if ((cfg != NULL)&&(cfg->tsuites != NULL)) { // Release the packet buffer if we're still holding it if (cfg->buf != NULL) { free(cfg->buf); cfg->buf = NULL; } // Make the handshake information available to other modules apr_table_setn(r->subprocess_env, "SSLHAF_HANDSHAKE", cfg->thandshake); apr_table_setn(r->subprocess_env, "SSLHAF_PROTOCOL", cfg->tprotocol); apr_table_setn(r->subprocess_env, "SSLHAF_SUITES", cfg->tsuites); // BEAST mitigation detection if (cfg->in_data_fragments > 1) { apr_table_setn(r->subprocess_env, "SSLHAF_BEAST", "1"); } else { apr_table_setn(r->subprocess_env, "SSLHAF_BEAST", "0"); } // Expose compression methods apr_table_setn(r->subprocess_env, "SSLHAF_COMPRESSION", cfg->compression_methods); // Expose extension data char *extensions_len = apr_psprintf(r->pool, "%d", cfg->extensions_len); apr_table_setn(r->subprocess_env, "SSLHAF_EXTENSIONS_LEN", extensions_len); apr_table_setn(r->subprocess_env, "SSLHAF_EXTENSIONS", cfg->extensions); // Keep track of how many requests there were cfg->request_counter++; // Help to log only once per connection if (cfg->request_counter == 1) { apr_table_setn(r->subprocess_env, "SSLHAF_LOG", "1"); } #if 0 // Generate a sha1 of the remote address on the first request if (cfg->ipaddress_hash == NULL) { cfg->ipaddress_hash = generate_sha1(r->connection->pool, r->connection->remote_ip, strlen(r->connection->remote_ip)); } apr_table_setn(r->subprocess_env, "SSLHAF_IP_HASH", cfg->ipaddress_hash); #endif } return DECLINED; } /** * Main entry point. */ static void register_hooks(apr_pool_t *p) { static const char * const afterme[] = { "mod_security2.c", NULL }; ap_hook_pre_connection(sslhaf_pre_conn, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_post_read_request(sslhaf_post_request, NULL, afterme, APR_HOOK_REALLY_FIRST); ap_register_input_filter(sslhaf_in_filter_name, sslhaf_in_filter, NULL, AP_FTYPE_NETWORK - 1); ap_register_output_filter(sslhaf_out_filter_name, sslhaf_out_filter, NULL, AP_FTYPE_NETWORK - 1); } module AP_MODULE_DECLARE_DATA sslhaf_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-dir config */ NULL, /* merge per-dir config */ NULL, /* server config */ NULL, /* merge server config */ NULL, /* command apr_table_t */ register_hooks /* register hooks */ };
[ "ivanr@webkreator.com" ]
ivanr@webkreator.com
84ef33ccd3ecf2c7a05d529f6b90ed952cccfa8b
bcbafb00a458e3e3f25bf8e07b8784351a498d92
/libs/stb/include/stb_image.h
5fbbf6445bb36650678436493040041ed60f027a
[ "Apache-2.0" ]
permissive
carsonclarke570/Metacraft
5b7bda08e7311a34f6827a26398666d82d1cad20
2647a48c7c04b80efe4041343b09d4c70e8927b5
refs/heads/master
2020-05-17T04:22:01.299965
2019-07-01T13:43:38
2019-07-01T13:43:38
183,505,903
3
0
Apache-2.0
2019-08-07T02:29:24
2019-04-25T20:33:52
C
UTF-8
C
false
false
263,264
h
/* stb_image - v2.22 - 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.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 Blazej Dariusz Roszkowski github:Michaelangel007 */ #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 // NOT 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); // 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 <vector.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 #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 // this is not threadsafe static const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } 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; } // 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); } // 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 // 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); } 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 = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load = flag_true_if_should_flip; } 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); #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; } 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; } 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; } 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; } static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #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 ////////////////////////////////////////////////////////////////////////////// // // 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); } 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; } static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } 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; } #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; 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; z >>= 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 >= 0 && 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; } 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; 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); // 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 - 14 - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - 14 - info.hsz) >> 2; } 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 - 14 - 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 - 14 - 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); // 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; // 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) { out = (stbi_uc*) STBI_REALLOC( out, layers * stride ); 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) *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. ------------------------------------------------------------------------------ */
[ "carsonclarke570@gmail.com" ]
carsonclarke570@gmail.com
ac706098b1414dde64d5440acb7e08e5352cb738
d4cd08313af2c124ca7ba3d6942f84ff85c4caaa
/binoclean/jondefs.h
4c90bdc86170fb3916c24a54ae940744e8bdc7ca
[]
no_license
alimoeeny/binoclean
5f268d6fa137b78f35ceefb11d61035181cef017
000ce229f15aef22de0cb06b9146426dfa65e663
refs/heads/master
2021-01-18T14:02:40.000976
2013-04-05T12:08:12
2013-04-05T12:08:12
1,907,605
0
2
null
2013-01-03T13:34:49
2011-06-16T19:57:01
C
UTF-8
C
false
false
345
h
#define X 0 #define Y 1 #define XY 2 #define RGB_BLACK 0x00000000 #define RGB_WHITE 0x00ffffff #define RGB_FULLRED 0x000000ff #define RGB_FULLGREEN 0x0000ff00 #define RGB_MIDGREY 0x008f8f8f #define RGB_LGREY 0x00afafaf #define RGB_REDBIT 0x00000001 #define RGB_GREENBIT 0x00000100 #define RGB_WHITEBITS 0x01010101 #define GAMMA_DEFAULT 1.7
[ "alimoeeny@gmail.com" ]
alimoeeny@gmail.com
e123f9d9687cf38061f412444e3d05f5823f32e9
df76be2b1cd04046270478db8b97c8e6c1bc32ce
/day05/ex03/ft_strcpy.c
929cc8b7b24a85144728845c3ab10af1f0c92615
[]
no_license
JLL32/piscine
6b625dfd7cce08dd09b66469836f245bc6989779
bc83308cc39ebfc1b47bcb8314dfdc46fe1c5798
refs/heads/master
2020-06-25T01:40:03.556080
2020-03-30T17:37:44
2020-03-30T17:37:44
199,158,712
1
0
null
null
null
null
UTF-8
C
false
false
1,045
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strcpy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ael-hach <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/25 09:55:06 by ael-hach #+# #+# */ /* Updated: 2019/07/25 09:55:09 by ael-hach ### ########.fr */ /* */ /* ************************************************************************** */ char *ft_strcpy(char *dest, char *src) { int i; i = 0; while (1) { dest[i] = src[i]; if (src[i] == '\0') break ; i++; } return (dest); }
[ "eabduljalil@outlook.com" ]
eabduljalil@outlook.com
914ecb925c08c9ad70bbcfaaf0b08564bfb89326
5184a318fee8340c2757a93a9345e570516de977
/patches/patch_zbit_flash_driver_and_low_voltage_detection/vendor/mesh/app_config_8278.h
6d17098906f8c5c622a05b874c1f548533ddb6e6
[]
no_license
danghaoRD/ble_mesh_sdk_edit_RD
589a70a7078eddd1a0cb5ee511575ae58db6ed92
9db084c50d751fff88f571ccec28cbb0f17bfc14
refs/heads/master
2023-06-13T01:40:35.177806
2021-07-10T03:26:31
2021-07-10T03:26:31
384,600,845
0
0
null
null
null
null
UTF-8
C
false
false
8,531
h
/******************************************************************************************************** * @file app_config_8258.h * * @brief for TLSR chips * * @author telink * @date Sep. 30, 2010 * * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. * All rights reserved. * * The information contained herein is confidential and proprietary property of Telink * Semiconductor (Shanghai) Co., Ltd. and is available under the terms * of Commercial License Agreement between Telink Semiconductor (Shanghai) * Co., Ltd. and the licensee in separate contract or the terms described here-in. * This heading MUST NOT be removed from this file. * * Licensees are granted free, non-transferable use of the information in this * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. * *******************************************************************************************************/ #pragma once /* Enable C linkage for C++ Compilers: */ #if defined(__cplusplus) extern "C" { #endif #include "vendor/common/version.h" // include mesh_config.h inside. //////////////////board sel///////////////////////////////////// #define PCBA_8278_DONGLE_48PIN 1 #define PCBA_8278_C1T197A30_V1_0 2 #define PCBA_SEL PCBA_8278_DONGLE_48PIN #define _USER_CONFIG_DEFINED_ 1 // must define this macro to make others known #define __LOG_RT_ENABLE__ 0 //#define __DEBUG_PRINT__ 0 #if DUAL_VENDOR_EN #define FLASH_1M_ENABLE 0 #else #define FLASH_1M_ENABLE 0 #endif #if FLASH_1M_ENABLE #define PINGPONG_OTA_DISABLE 0 // it can disable only when 1M flash. #if PINGPONG_OTA_DISABLE #define SWITCH_FW_ENABLE 0 // set to 0, just for particular customer #endif #endif //////////// product Information ////////////////////////////// #define ID_VENDOR 0x248a // for report #define ID_PRODUCT_BASE 0x880C #define STRING_VENDOR L"Telink" #define STRING_PRODUCT L"BLE Mesh" #define STRING_SERIAL L"TLSR825X" #define DEV_NAME "SigMesh" #define APPLICATION_DONGLE 0 // or else APPLICATION_DEVICE #define USB_PRINTER 1 #define FLOW_NO_OS 1 /////////////////////HCI ACCESS OPTIONS/////////////////////////////////////// #define HCI_USE_NONE 0 #define HCI_USE_UART 1 #define HCI_USE_USB 2 #if WIN32 #define HCI_ACCESS HCI_USE_USB #else #define HCI_ACCESS HCI_USE_NONE #endif #if (HCI_ACCESS==HCI_USE_UART) #define UART_TX_PIN UART_TX_PB1 #define UART_RX_PIN UART_RX_PB0 #endif #define HCI_LOG_FW_EN 0 #if HCI_LOG_FW_EN #define DEBUG_INFO_TX_PIN GPIO_PB2 #define PRINT_DEBUG_INFO 1 #endif #define BATT_CHECK_ENABLE 1 //must enable #if (BATT_CHECK_ENABLE) //telink device: you must choose one gpio with adc function to output high level(voltage will equal to vbat), then use adc to measure high level voltage //use PC5 output high level, then adc measure this high level voltage #define GPIO_VBAT_DETECT GPIO_PC5 #define PC5_FUNC AS_GPIO #define PC5_INPUT_ENABLE 0 #define ADC_INPUT_PCHN C5P //corresponding ADC_InputPchTypeDef in adc.h #endif #define ADC_ENABLE 0 #if ADC_ENABLE #define ADC_BASE_MODE 1 //GPIO voltage #define ADC_VBAT_MODE 2 //Battery Voltage #define ADC_MODE ADC_VBAT_MODE #define ADC_CHNM_ANA_INPUT GPIO_PB3 // one of ADC_GPIO_tab[] #define ADC_PRESCALER ADC_PRESCALER_1F8 #endif #define ONLINE_STATUS_EN 0 #define DUAL_MODE_ADAPT_EN 0 // dual mode as master with Zigbee #if (0 == DUAL_MODE_ADAPT_EN) #define DUAL_MODE_WITH_TLK_MESH_EN 0 // dual mode as slave with Telink mesh #endif /////////////////// mesh project config ///////////////////////////////// #if (MESH_RX_TEST || (!MD_DEF_TRANSIT_TIME_EN)) #define TRANSITION_TIME_DEFAULT_VAL (0) #else #if MI_API_ENABLE #define TRANSITION_TIME_DEFAULT_VAL 0 #else #define TRANSITION_TIME_DEFAULT_VAL (GET_TRANSITION_TIME_WITH_STEP(1, TRANSITION_STEP_RES_1S)) // (0x41) // 0x41: 1 second // 0x00: means no default transition time #endif #endif /////////////////// MODULE ///////////////////////////////// #define BLE_REMOTE_PM_ENABLE 0 #if BLE_REMOTE_PM_ENABLE #define PM_DEEPSLEEP_RETENTION_ENABLE 1 // must #else #define PM_DEEPSLEEP_RETENTION_ENABLE 0 #endif #define BLE_REMOTE_SECURITY_ENABLE 0 #define BLE_IR_ENABLE 0 #define BLE_SIG_MESH_CERTIFY_ENABLE 0 #ifndef BLT_SOFTWARE_TIMER_ENABLE #define BLT_SOFTWARE_TIMER_ENABLE 0 #endif //////////////////////////// KEYSCAN/MIC GPIO ////////////////////////////////// #define MATRIX_ROW_PULL PM_PIN_PULLDOWN_100K #define MATRIX_COL_PULL PM_PIN_PULLUP_10K #define KB_LINE_HIGH_VALID 0 //dirve pin output 0 when keyscan, scanpin read 0 is valid #define DEEPBACK_FAST_KEYSCAN_ENABLE 1 //proc fast scan when deepsleep back trigged by key press, in case key loss #define KEYSCAN_IRQ_TRIGGER_MODE 0 #define LONG_PRESS_KEY_POWER_OPTIMIZE 1 //lower power when pressing key without release //stuck key #define STUCK_KEY_PROCESS_ENABLE 0 #define STUCK_KEY_ENTERDEEP_TIME 60 //in s //repeat key #define KB_REPEAT_KEY_ENABLE 0 #define KB_REPEAT_KEY_INTERVAL_MS 200 #define KB_REPEAT_KEY_NUM 1 // //----------------------- GPIO for UI -------------------------------- //--------------- Button #if (PCBA_SEL == PCBA_8278_DONGLE_48PIN) #define PULL_WAKEUP_SRC_PD6 PM_PIN_PULLUP_1M //btn #define PULL_WAKEUP_SRC_PD5 PM_PIN_PULLUP_1M //btn #define PD6_INPUT_ENABLE 1 #define PD5_INPUT_ENABLE 1 #define SW1_GPIO GPIO_PD6 #define SW2_GPIO GPIO_PD5 #elif(PCBA_SEL == PCBA_8278_C1T197A30_V1_0) #define PULL_WAKEUP_SRC_PB2 PM_PIN_PULLUP_1M //btn #define PULL_WAKEUP_SRC_PB3 PM_PIN_PULLUP_1M //btn #define PB2_INPUT_ENABLE 1 #define PB3_INPUT_ENABLE 1 #define SW1_GPIO GPIO_PB2 // SW2 in board #define SW2_GPIO GPIO_PB3 // SW4 in board #if 1 // must output 0, because it is keyboard array. pull down is not enough to output low level. #define PB4_FUNC AS_GPIO #define PB4_OUTPUT_ENABLE 1 #define PB4_DATA_OUT 0 #endif #endif #define XIAOMI_MODULE_ENABLE MI_API_ENABLE #define XIAOMI_TEST_CODE_ENABLE 0 //--------------- LED / PWM #if(PCBA_SEL == PCBA_8278_DONGLE_48PIN) #define PWM_R GPIO_PWM1A3 //red #define PWM_G GPIO_PWM0A2 //green #define PWM_B GPIO_PWM3B0 //blue #define PWM_W GPIO_PWM4B1 //white #elif(PCBA_SEL == PCBA_8278_C1T197A30_V1_0) // PCBA_8258_DEVELOPMENT_BOARD #define PWM_R GPIO_PWM1ND3 //red #define PWM_G GPIO_PWM2ND4 //green #define PWM_B GPIO_PD5 //blue #define PWM_W GPIO_PWM3D2 //white #endif #define PWM_FUNC_R AS_PWM // AS_PWM_SECOND #define PWM_FUNC_G AS_PWM // AS_PWM_SECOND #define PWM_FUNC_B AS_PWM // AS_PWM_SECOND #define PWM_FUNC_W AS_PWM // AS_PWM_SECOND #define PWMID_R (GET_PWMID(PWM_R, PWM_FUNC_R)) #define PWMID_G (GET_PWMID(PWM_G, PWM_FUNC_G)) #define PWMID_B (GET_PWMID(PWM_B, PWM_FUNC_B)) #define PWMID_W (GET_PWMID(PWM_W, PWM_FUNC_W)) #define PWM_INV_R (GET_PWM_INVERT_VAL(PWM_R, PWM_FUNC_R)) #define PWM_INV_G (GET_PWM_INVERT_VAL(PWM_G, PWM_FUNC_G)) #define PWM_INV_B (GET_PWM_INVERT_VAL(PWM_B, PWM_FUNC_B)) #define PWM_INV_W (GET_PWM_INVERT_VAL(PWM_W, PWM_FUNC_W)) #define GPIO_LED PWM_R /////////////open SWS digital pullup to prevent MCU err, this is must //////////// #define PA7_DATA_OUT 1 //save suspend current //#define PA5_FUNC AS_GPIO // USB DM //#define PA6_FUNC AS_GPIO // USB DP /////////////////// Clock ///////////////////////////////// #define USE_SYS_TICK_PER_US #define CLOCK_SYS_TYPE CLOCK_TYPE_PLL // one of the following: CLOCK_TYPE_PLL, CLOCK_TYPE_OSC, CLOCK_TYPE_PAD, CLOCK_TYPE_ADC #if (MI_API_ENABLE) #define CLOCK_SYS_CLOCK_HZ 48000000 #else #define CLOCK_SYS_CLOCK_HZ 16000000 #endif //////////////////Extern Crystal Type/////////////////////// #define CRYSTAL_TYPE XTAL_12M // extern 12M crystal /////////////////// watchdog ////////////////////////////// #define MODULE_WATCHDOG_ENABLE 1 #if (MI_API_ENABLE) #define WATCHDOG_INIT_TIMEOUT 20000 //in mi mode the watchdog timeout is 20s #else #define WATCHDOG_INIT_TIMEOUT 2000 //in mi mode the watchdog timeout is 20s #endif /////////////////// set default //////////////// #include "../common/default_config.h" /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) } #endif
[ "danghao57utc@gmail.com" ]
danghao57utc@gmail.com
2d750d80d84942b99b970a86b55107adec411333
f54e190986325926de1f75cc45ceef71404896f5
/sim_function.c
e9c2b5c772599e4337c20e6746fc8e40d3242d3c
[]
no_license
tuliopereirab/pyConv
5245e81fc484b24dfde8b7b1e90a53bda5ab35cd
8bc36efdca028d151183ef6b44b1ca32d10c2b5e
refs/heads/master
2020-08-06T23:24:49.445471
2019-06-06T20:34:46
2019-06-06T20:34:46
213,196,984
3
0
null
null
null
null
UTF-8
C
false
false
2,081
c
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define MEMORY_SIZE 4096 #define DATA_WIDTH 8 #define ADDR_FUNC_WIDTH 8 #define ADDR_WIDTH 12 typedef struct _funcStack{ char *TOSreturn; char *PCreturn; }funcStack; int return_value(); int call_func(char pc[], char tos[]); int func_init(); int bin_to_dec(char bin[]); char *dec_to_bin(int n, int tam); int add_stack(char data[]); int read_stack(); int pilha_init(); void changeTos(int newTos); int verTos(); funcStack *func = NULL; int tosFunc=0; int func_init(){ int i; if((func = (funcStack*)malloc(sizeof(funcStack)*pow(2,ADDR_FUNC_WIDTH))) == NULL) return -97; for(i=0; i<pow(2, ADDR_FUNC_WIDTH); i++){ func[i].TOSreturn = (char*)malloc(sizeof(char)*ADDR_WIDTH); func[i].PCreturn = (char*)malloc(sizeof(char)*ADDR_WIDTH); strcpy(func[i].PCreturn, "000000000000"); stpcpy(func[i].TOSreturn, "000000000000"); } return 0; } int call_func(char pc[], char tos[]){ if((tosFunc+1) >= pow(2, ADDR_FUNC_WIDTH)) return -7; tosFunc++; strcpy(func[tosFunc].TOSreturn, tos); stpcpy(func[tosFunc].PCreturn, pc); return 0; } int return_value(){ // retorna o valor de PC int dataReturn; int status, statusReturn; char *TOSreturn, *PCreturn; if((tosFunc-1) < 0) return -8; TOSreturn = (char*)malloc(sizeof(char)*ADDR_WIDTH); PCreturn = (char*)malloc(sizeof(char)*ADDR_WIDTH); strcpy(TOSreturn, func[tosFunc].TOSreturn); strcpy(PCreturn, func[tosFunc].PCreturn); tosFunc--; if(atoi(TOSreturn) >= verTos()) statusReturn = -1; // não retorna dados else{ dataReturn = read_stack(); statusReturn = 0; // retorna dados } changeTos(bin_to_dec(TOSreturn)); // faz a pilha retornar seu TOS if(statusReturn >= 0) // retorna dados status = add_stack(dec_to_bin(dataReturn, DATA_WIDTH)); // so retorna dados se houver return bin_to_dec(PCreturn); // retorna novo valor de PC }
[ "tulio.pereirab@gmail.com" ]
tulio.pereirab@gmail.com
6b4b74ad0045a353db0b379ba833b3c9f3cdf75e
6d68d3aedd159f896e7bcd3e05eee58df8d2f259
/TBLogDemo/TBLogDemo/WBCLogMacros.h
c2d9935eda6060efc626a2a6daf7ced3cbe22e79
[]
no_license
ICloud0114/Demo
ed5482114ad611ef5ae36d7a93180933d642eeee
59e2e9b7677ae347a734fc5f0b36ccbdffb40b80
refs/heads/master
2021-07-01T06:02:20.726183
2020-08-20T16:31:24
2020-08-20T16:31:24
141,997,350
1
0
null
null
null
null
UTF-8
C
false
false
1,696
h
// // WBCLogMacros.h // KuaiChong // // Created by Onliu on 14-6-8. // Copyright (c) 2014年 Onliu. All rights reserved. // #ifndef KuaiChong_WBCLogMacros_h #define KuaiChong_WBCLogMacros_h typedef NS_ENUM(NSInteger, WBCLog_LEVEL) { WBCLog_LEVEL_DEBUG=1, WBCLog_LEVEL_INFO, WBCLog_LEVEL_WARN, WBCLog_LEVEL_ERROR, WBCLog_LEVEL_FATAL, WBCLog_LEVEL_NONE }; #define WBCLog_LEVEL_STRING_DEBUG @"1" #define WBCLog_LEVEL_STRING_INFO @"2" #define WBCLog_LEVEL_STRING_WARN @"3" #define WBCLog_LEVEL_STRING_ERROR @"4" #define WBCLog_LEVEL_STRING_FATAL @"5" #define WBCLog_LEVEL_STRING_NONE @"6" #define WBCLogDebug(format, ...) \ [[WBCLog sharedInstance] Log:WBCLog_LEVEL_DEBUG message:[NSString stringWithFormat:format, ##__VA_ARGS__]\ classObject:self file:__FILE__ function:__FUNCTION__ line:__LINE__] #define WBCLogInfo(format, ...) \ [[WBCLog sharedInstance] Log:WBCLog_LEVEL_INFO message:[NSString stringWithFormat:format, ##__VA_ARGS__]\ classObject:self file:__FILE__ function:__FUNCTION__ line:__LINE__] #define WBCLogWarn(format, ...) \ [[WBCLog sharedInstance] Log:WBCLog_LEVEL_WARN message:[NSString stringWithFormat:format, ##__VA_ARGS__]\ classObject:self file:__FILE__ function:__FUNCTION__ line:__LINE__] #define WBCLogError(format, ...) \ [[WBCLog sharedInstance] Log:WBCLog_LEVEL_ERROR message:[NSString stringWithFormat:format, ##__VA_ARGS__]\ classObject:self file:__FILE__ function:__FUNCTION__ line:__LINE__] #define WBCLogFatal(format, ...) \ [[WBCLog sharedInstance] Log:WBCLog_LEVEL_FATAL message:[NSString stringWithFormat:format, ##__VA_ARGS__]\ classObject:self file:__FILE__ function:__FUNCTION__ line:__LINE__] #endif
[ "zhengyun@yeah.net" ]
zhengyun@yeah.net
905aab4a8be275ddd0234377e66cc50d6ab6f720
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/xnnpack/src/src/x16-transposec/gen/x16-transposec-8x8-reuse-multi-sse2.c
190115bd50f25d560af5043138147e51efce6e80
[ "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-3-Clause", "LicenseRef-scancode-generic-cla" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
11,344
c
// Auto-generated file. Do not edit! // Template: src/x32-transposec/sse2.c.in // Generator: tools/xngen // // Copyright 2021 Google LLC // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. #include <immintrin.h> #include <assert.h> #include <xnnpack/common.h> #include <xnnpack/math.h> #include <xnnpack/transpose.h> #include <xnnpack/unaligned.h> void xnn_x16_transposec_ukernel__8x8_reuse_multi_sse2( const uint16_t* input, uint16_t* output, size_t input_stride, size_t output_stride, size_t block_width, size_t block_height, const union xnn_x16_transpose_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS { assert(output_stride >= block_height * sizeof(uint16_t)); assert(input_stride >= block_width * sizeof(uint16_t)); const size_t tile_height = 8; const size_t tile_width = 8; const size_t tile_hbytes = tile_height * sizeof(uint16_t); const size_t tile_wbytes = tile_width * sizeof(uint16_t); const size_t input_reset = tile_wbytes - round_down_po2(block_height, tile_height) * input_stride; const size_t output_reset = tile_width * output_stride - round_down_po2(block_height, 2) * sizeof(uint16_t); const uint16_t* i0 = input; uint16_t* o0 = (uint16_t*) output; uint16_t* o1 = (uint16_t*) ((uintptr_t) o0 + output_stride); uint16_t* o2 = (uint16_t*) ((uintptr_t) o1 + output_stride); uint16_t* o3 = (uint16_t*) ((uintptr_t) o2 + output_stride); uint16_t* o4 = (uint16_t*) ((uintptr_t) o3 + output_stride); uint16_t* o5 = (uint16_t*) ((uintptr_t) o4 + output_stride); uint16_t* o6 = (uint16_t*) ((uintptr_t) o5 + output_stride); uint16_t* o7 = (uint16_t*) ((uintptr_t) o6 + output_stride); do { if XNN_UNPREDICTABLE(block_width < 2) { o1 = o0; } if XNN_UNPREDICTABLE(block_width <= 2) { o2 = o0; } if XNN_UNPREDICTABLE(block_width < 4) { o3 = o0; } if XNN_UNPREDICTABLE(block_width <= 4) { o4 = o0; } if XNN_UNPREDICTABLE(block_width < 6) { o5 = o0; } if XNN_UNPREDICTABLE(block_width <= 6) { o6 = o0; } if XNN_UNPREDICTABLE(block_width < 8) { o7 = o0; } size_t bh = block_height; for (; bh >= 8; bh -= 8) { const __m128i v3_0 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_1 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_2 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_3 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_4 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_5 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_6 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v3_7 = _mm_loadu_si128((const __m128i*) i0); i0 = (uint16_t*) ((uintptr_t) i0 + input_stride); const __m128i v2_0 = _mm_unpacklo_epi16(v3_0, v3_1); const __m128i v2_1 = _mm_unpackhi_epi16(v3_0, v3_1); const __m128i v2_2 = _mm_unpacklo_epi16(v3_2, v3_3); const __m128i v2_3 = _mm_unpackhi_epi16(v3_2, v3_3); const __m128i v2_4 = _mm_unpacklo_epi16(v3_4, v3_5); const __m128i v2_5 = _mm_unpackhi_epi16(v3_4, v3_5); const __m128i v2_6 = _mm_unpacklo_epi16(v3_6, v3_7); const __m128i v2_7 = _mm_unpackhi_epi16(v3_6, v3_7); const __m128i v1_0 = _mm_unpacklo_epi32(v2_0, v2_2); const __m128i v1_1 = _mm_unpackhi_epi32(v2_0, v2_2); const __m128i v1_2 = _mm_unpacklo_epi32(v2_1, v2_3); const __m128i v1_3 = _mm_unpackhi_epi32(v2_1, v2_3); const __m128i v1_4 = _mm_unpacklo_epi32(v2_4, v2_6); const __m128i v1_5 = _mm_unpackhi_epi32(v2_4, v2_6); const __m128i v1_6 = _mm_unpacklo_epi32(v2_5, v2_7); const __m128i v1_7 = _mm_unpackhi_epi32(v2_5, v2_7); const __m128i v0_0 = _mm_unpacklo_epi64(v1_0, v1_4); const __m128i v0_1 = _mm_unpackhi_epi64(v1_0, v1_4); const __m128i v0_2 = _mm_unpacklo_epi64(v1_1, v1_5); const __m128i v0_3 = _mm_unpackhi_epi64(v1_1, v1_5); const __m128i v0_4 = _mm_unpacklo_epi64(v1_2, v1_6); const __m128i v0_5 = _mm_unpackhi_epi64(v1_2, v1_6); const __m128i v0_6 = _mm_unpacklo_epi64(v1_3, v1_7); const __m128i v0_7 = _mm_unpackhi_epi64(v1_3, v1_7); _mm_storeu_si128((__m128i*) o7, v0_7); o7 = (uint16_t*) ((uintptr_t) o7 + tile_hbytes); _mm_storeu_si128((__m128i*) o6, v0_6); o6 = (uint16_t*) ((uintptr_t) o6 + tile_hbytes); _mm_storeu_si128((__m128i*) o5, v0_5); o5 = (uint16_t*) ((uintptr_t) o5 + tile_hbytes); _mm_storeu_si128((__m128i*) o4, v0_4); o4 = (uint16_t*) ((uintptr_t) o4 + tile_hbytes); _mm_storeu_si128((__m128i*) o3, v0_3); o3 = (uint16_t*) ((uintptr_t) o3 + tile_hbytes); _mm_storeu_si128((__m128i*) o2, v0_2); o2 = (uint16_t*) ((uintptr_t) o2 + tile_hbytes); _mm_storeu_si128((__m128i*) o1, v0_1); o1 = (uint16_t*) ((uintptr_t) o1 + tile_hbytes); _mm_storeu_si128((__m128i*) o0, v0_0); o0 = (uint16_t*) ((uintptr_t) o0 + tile_hbytes); } if (bh != 0) { const __m128i v3_0 = _mm_loadu_si128((const __m128i*) i0); const uint16_t *i1 = (const uint16_t*) ((uintptr_t) i0 + input_stride); if XNN_UNPREDICTABLE(bh < 2) { i1 = i0; } const __m128i v3_1 = _mm_loadu_si128((const __m128i*) i1); const uint16_t *i2 = (const uint16_t*) ((uintptr_t) i1 + input_stride); if XNN_UNPREDICTABLE(bh <= 2) { i2 = i1; } const __m128i v3_2 = _mm_loadu_si128((const __m128i*) i2); const uint16_t *i3 = (const uint16_t*) ((uintptr_t) i2 + input_stride); if XNN_UNPREDICTABLE(bh < 4) { i3 = i2; } const __m128i v3_3 = _mm_loadu_si128((const __m128i*) i3); const uint16_t *i4 = (const uint16_t*) ((uintptr_t) i3 + input_stride); if XNN_UNPREDICTABLE(bh <= 4) { i4 = i3; } const __m128i v3_4 = _mm_loadu_si128((const __m128i*) i4); const uint16_t *i5 = (const uint16_t*) ((uintptr_t) i4 + input_stride); if XNN_UNPREDICTABLE(bh < 6) { i5 = i4; } const __m128i v3_5 = _mm_loadu_si128((const __m128i*) i5); const uint16_t *i6 = (const uint16_t*) ((uintptr_t) i5 + input_stride); if XNN_UNPREDICTABLE(bh <= 6) { i6 = i5; } const __m128i v3_6 = _mm_loadu_si128((const __m128i*) i6); const __m128i v3_7 = _mm_undefined_si128(); const __m128i v2_0 = _mm_unpacklo_epi16(v3_0, v3_1); const __m128i v2_1 = _mm_unpackhi_epi16(v3_0, v3_1); const __m128i v2_2 = _mm_unpacklo_epi16(v3_2, v3_3); const __m128i v2_3 = _mm_unpackhi_epi16(v3_2, v3_3); const __m128i v2_4 = _mm_unpacklo_epi16(v3_4, v3_5); const __m128i v2_5 = _mm_unpackhi_epi16(v3_4, v3_5); const __m128i v2_6 = _mm_unpacklo_epi16(v3_6, v3_7); const __m128i v2_7 = _mm_unpackhi_epi16(v3_6, v3_7); const __m128i v1_0 = _mm_unpacklo_epi32(v2_0, v2_2); const __m128i v1_1 = _mm_unpackhi_epi32(v2_0, v2_2); const __m128i v1_2 = _mm_unpacklo_epi32(v2_1, v2_3); const __m128i v1_3 = _mm_unpackhi_epi32(v2_1, v2_3); const __m128i v1_4 = _mm_unpacklo_epi32(v2_4, v2_6); const __m128i v1_5 = _mm_unpackhi_epi32(v2_4, v2_6); const __m128i v1_6 = _mm_unpacklo_epi32(v2_5, v2_7); const __m128i v1_7 = _mm_unpackhi_epi32(v2_5, v2_7); __m128i v0_0 = _mm_unpacklo_epi64(v1_0, v1_4); __m128i v0_1 = _mm_unpackhi_epi64(v1_0, v1_4); __m128i v0_2 = _mm_unpacklo_epi64(v1_1, v1_5); __m128i v0_3 = _mm_unpackhi_epi64(v1_1, v1_5); __m128i v0_4 = _mm_unpacklo_epi64(v1_2, v1_6); __m128i v0_5 = _mm_unpackhi_epi64(v1_2, v1_6); __m128i v0_6 = _mm_unpacklo_epi64(v1_3, v1_7); __m128i v0_7 = _mm_unpackhi_epi64(v1_3, v1_7); if (bh & 4) { _mm_storel_epi64((__m128i*) o7, v0_7); o7 += 4; _mm_storel_epi64((__m128i*) o6, v0_6); o6 += 4; _mm_storel_epi64((__m128i*) o5, v0_5); o5 += 4; _mm_storel_epi64((__m128i*) o4, v0_4); o4 += 4; _mm_storel_epi64((__m128i*) o3, v0_3); o3 += 4; _mm_storel_epi64((__m128i*) o2, v0_2); o2 += 4; _mm_storel_epi64((__m128i*) o1, v0_1); o1 += 4; _mm_storel_epi64((__m128i*) o0, v0_0); o0 += 4; v0_0 = _mm_unpackhi_epi64(v0_0, v0_0); v0_1 = _mm_unpackhi_epi64(v0_1, v0_1); v0_2 = _mm_unpackhi_epi64(v0_2, v0_2); v0_3 = _mm_unpackhi_epi64(v0_3, v0_3); v0_4 = _mm_unpackhi_epi64(v0_4, v0_4); v0_5 = _mm_unpackhi_epi64(v0_5, v0_5); v0_6 = _mm_unpackhi_epi64(v0_6, v0_6); v0_7 = _mm_unpackhi_epi64(v0_7, v0_7); } if (bh & 2) { unaligned_store_u32(o7, (uint32_t) _mm_cvtsi128_si32(v0_7)); o7 += 2; unaligned_store_u32(o6, (uint32_t) _mm_cvtsi128_si32(v0_6)); o6 += 2; unaligned_store_u32(o5, (uint32_t) _mm_cvtsi128_si32(v0_5)); o5 += 2; unaligned_store_u32(o4, (uint32_t) _mm_cvtsi128_si32(v0_4)); o4 += 2; unaligned_store_u32(o3, (uint32_t) _mm_cvtsi128_si32(v0_3)); o3 += 2; unaligned_store_u32(o2, (uint32_t) _mm_cvtsi128_si32(v0_2)); o2 += 2; unaligned_store_u32(o1, (uint32_t) _mm_cvtsi128_si32(v0_1)); o1 += 2; unaligned_store_u32(o0, (uint32_t) _mm_cvtsi128_si32(v0_0)); o0 += 2; v0_0 = _mm_srli_epi64(v0_0, 32); v0_1 = _mm_srli_epi64(v0_1, 32); v0_2 = _mm_srli_epi64(v0_2, 32); v0_3 = _mm_srli_epi64(v0_3, 32); v0_4 = _mm_srli_epi64(v0_4, 32); v0_5 = _mm_srli_epi64(v0_5, 32); v0_6 = _mm_srli_epi64(v0_6, 32); v0_7 = _mm_srli_epi64(v0_7, 32); } if (bh & 1) { unaligned_store_u16(o7, (uint16_t) _mm_cvtsi128_si32(v0_7)); unaligned_store_u16(o6, (uint16_t) _mm_cvtsi128_si32(v0_6)); unaligned_store_u16(o5, (uint16_t) _mm_cvtsi128_si32(v0_5)); unaligned_store_u16(o4, (uint16_t) _mm_cvtsi128_si32(v0_4)); unaligned_store_u16(o3, (uint16_t) _mm_cvtsi128_si32(v0_3)); unaligned_store_u16(o2, (uint16_t) _mm_cvtsi128_si32(v0_2)); unaligned_store_u16(o1, (uint16_t) _mm_cvtsi128_si32(v0_1)); unaligned_store_u16(o0, (uint16_t) _mm_cvtsi128_si32(v0_0)); } } i0 = (const uint16_t*) ((uintptr_t) i0 + input_reset); o0 = (uint16_t*) ((uintptr_t) o0 + output_reset); o1 = (uint16_t*) ((uintptr_t) o1 + output_reset); o2 = (uint16_t*) ((uintptr_t) o2 + output_reset); o3 = (uint16_t*) ((uintptr_t) o3 + output_reset); o4 = (uint16_t*) ((uintptr_t) o4 + output_reset); o5 = (uint16_t*) ((uintptr_t) o5 + output_reset); o6 = (uint16_t*) ((uintptr_t) o6 + output_reset); o7 = (uint16_t*) ((uintptr_t) o7 + output_reset); block_width = doz(block_width, tile_width); } while (block_width != 0); }
[ "jengelh@inai.de" ]
jengelh@inai.de
f054990638304a912f246f8a28133b4accf22ab9
ca7cec248138cd3415dd0d27a64edb6f1c4d84a1
/javaapi/app/src/main/jni/Interface.h
a6189eaae2f55d4cc8582df57a360cdb17477fcf
[]
no_license
lsczyp/AndroidFridaCheckdiff
44bfffaf9482018b2e357ae55ef3fe7d757e7b8b
49c35958f86d87f522d5fd0b298b966daf1db73e
refs/heads/master
2022-11-19T05:57:11.324557
2020-07-22T10:37:46
2020-07-22T10:37:46
281,641,741
2
1
null
null
null
null
UTF-8
C
false
false
489
h
// // Created by lishe on 2019/9/24. // #ifndef MOBILEPROTECT_INTERFACE_H #define MOBILEPROTECT_INTERFACE_H #include <jni.h> extern "C" { jlong JNICALL mapload(JNIEnv * env , jobject thiz,jstring libname); jlong JNICALL getImport(JNIEnv *env, jobject thiz,jlong base, jstring funcname); jlong JNICALL getExport(JNIEnv *env, jobject thiz,jlong base, jstring funcname); jlong JNICALL getCode(JNIEnv *env, jobject thiz,jlong base, jstring funcname); } #endif //MOBILEPROTECT_INTERFACE_H
[ "285765606@qq.com" ]
285765606@qq.com
cc1c0102de8032ea5a02324f3094071a84385064
447825339948e4ed008e5fa90dd587469f2d5440
/include/WBMatrix/inverse.h
c667d3fbee43824d45e09a3484424231b1b1a504
[ "Apache-2.0" ]
permissive
one30/CEJO-whitebox-AES
4e182ad4999a7431eec13690818a5b2699e56ed3
21653ae4f90fe981e788e71adb892126583f54d9
refs/heads/master
2022-11-11T21:54:42.452819
2020-06-29T12:31:41
2020-06-29T12:31:41
null
0
0
null
null
null
null
UTF-8
C
false
false
478
h
#ifndef _HINVERSE_H_ #define _HINVERSE_H_ //times generate from base matrix, define by user #define M8N 11 #define M16N 33 #define M32N 103 #define M64N 342 #define M128N 1172 //times of basis matrix's generation, select by user #define initM8_min 8 #define initM8_max 32 #define initM16_min 16 #define initM16_max 128 #define initM32_min 32 #define initM32_max 512 #define initM64_min 64 #define initM64_max 2048 #define initM128_min 128 #define initM128_max 8192 #endif
[ "tyfeng98@163.com" ]
tyfeng98@163.com
5a3e149662833399e39b4dccc1730547af8b0118
d8eab9a6c0bbdf6f8367ec1dce3bf80dbe1a9b5c
/KdG/includes/io/sapim_io.h
212f817f7959d43c34278f7bfe9d47555bda97df
[]
no_license
ajperalt/bpelo-STM-1112
0efc78f0f7fe8f9ef014ab10a12f8584a8b2b441
e4dd375231638de200de7145e8c270dffb49878c
refs/heads/master
2021-01-18T07:53:48.664719
2012-03-16T22:33:45
2012-03-16T22:33:45
null
0
0
null
null
null
null
UTF-8
C
false
false
144
h
#ifndef __SAPIM_IO__ #define __SAPIM_IO__ #include "sapim_io_errors.h" #include "sapim_io_functions.h" #include "sapim_io_constants.h" #endif
[ "akkermans.adriaan@gmail.com" ]
akkermans.adriaan@gmail.com
48cf0e239ad44039155d5a7fa5235f63d9ad0a12
0a277d853d50a61fc8219186bb2f3337ac4deec1
/Classes/MultiResolution.h
d25c5309cb79b5012fc6d8d9297a376355e8bc83
[ "MIT" ]
permissive
Crasader/yoshidagames
2bed114b4934cdaaae03ee8294ee87b6e3a60cee
a8de2fea3eb58dddaacaf846cc88726194c51658
refs/heads/master
2020-12-07T11:31:41.252182
2016-05-19T10:16:46
2016-05-19T10:16:46
null
0
0
null
null
null
null
UTF-8
C
false
false
380
h
// // MultiResolution.h // #ifndef CrossProject007_MultiResolution_h #define CrossProject007_MultiResolution_h #include "cocos2d.h" static cocos2d::Size designResolutionSize = cocos2d::Size(1200, 800); static cocos2d::Vec2 visibleCenter = cocos2d::Vec2(designResolutionSize.width/2, designResolutionSize.height/2); #endif
[ "nkc.kyousuke.kagihiro@gmail.com" ]
nkc.kyousuke.kagihiro@gmail.com