hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
9c1375b79418d15d3e6b1d4e4cc4b28af19a8a00
7,630
c
C
ConfProfile/jni/strongswan/src/libpts/pts/components/pts_component_manager.c
Infoss/conf-profile-4-android
619bd63095bb0f5a67616436d5510d24a233a339
[ "MIT" ]
2
2017-10-16T07:51:18.000Z
2019-06-16T12:07:52.000Z
strongswan/strongswan-5.3.2/src/libimcv/pts/components/pts_component_manager.c
SECURED-FP7/secured-mobility-ned
36fdbfee58a31d42f7047f7a7eaa1b2b70246151
[ "Apache-2.0" ]
5
2016-01-25T18:04:42.000Z
2016-02-25T08:54:56.000Z
strongswan/strongswan-5.3.2/src/libimcv/pts/components/pts_component_manager.c
SECURED-FP7/secured-mobility-ned
36fdbfee58a31d42f7047f7a7eaa1b2b70246151
[ "Apache-2.0" ]
2
2016-01-25T17:14:17.000Z
2016-02-13T20:14:09.000Z
/* * Copyright (C) 2011-2012 Andreas Steffen * HSR Hochschule fuer Technik Rapperswil * * 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. See <http://www.fsf.org/copyleft/gpl.txt>. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ #include "pts/components/pts_component_manager.h" #include <collections/linked_list.h> #include <utils/debug.h> typedef struct private_pts_component_manager_t private_pts_component_manager_t; typedef struct vendor_entry_t vendor_entry_t; typedef struct component_entry_t component_entry_t; #define PTS_QUALIFIER_SIZE 6 /** * Vendor-specific namespace information and list of registered components */ struct vendor_entry_t { /** * Vendor ID */ pen_t vendor_id; /** * Vendor-specific Component Functional names */ enum_name_t *comp_func_names; /** * Vendor-specific Qualifier Type names */ enum_name_t *qualifier_type_names; /** * Vendor-specific Qualifier Flag names */ char *qualifier_flag_names; /** * Vendor-specific size of Qualfiier Type field */ int qualifier_type_size; /** * List of vendor-specific registered Functional Components */ linked_list_t *components; }; /** * Destroy a vendor_entry_t object */ static void vendor_entry_destroy(vendor_entry_t *entry) { entry->components->destroy_function(entry->components, free); free(entry); } /** * Creation method for a vendor-specific Functional Component */ struct component_entry_t { /** * Vendor-Specific Component Functional Name */ u_int32_t name; /** * Functional Component creation method */ pts_component_create_t create; }; /** * Private data of a pts_component_manager_t object. * */ struct private_pts_component_manager_t { /** * Public pts_component_manager_t interface. */ pts_component_manager_t public; /** * List of vendor-specific namespaces and registered components */ linked_list_t *list; }; METHOD(pts_component_manager_t, add_vendor, void, private_pts_component_manager_t *this, pen_t vendor_id, enum_name_t *comp_func_names, int qualifier_type_size, char *qualifier_flag_names, enum_name_t *qualifier_type_names) { vendor_entry_t *entry; entry = malloc_thing(vendor_entry_t); entry->vendor_id = vendor_id; entry->comp_func_names = comp_func_names; entry->qualifier_type_size = qualifier_type_size; entry->qualifier_flag_names = qualifier_flag_names; entry->qualifier_type_names = qualifier_type_names; entry->components = linked_list_create(); this->list->insert_last(this->list, entry); DBG2(DBG_PTS, "added %N functional component namespace", pen_names, vendor_id); } METHOD(pts_component_manager_t, get_comp_func_names, enum_name_t*, private_pts_component_manager_t *this, pen_t vendor_id) { enumerator_t *enumerator; vendor_entry_t *entry; enum_name_t *names = NULL; enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &entry)) { if (entry->vendor_id == vendor_id) { names = entry->comp_func_names; break; } } enumerator->destroy(enumerator); return names; } METHOD(pts_component_manager_t, get_qualifier_type_names, enum_name_t*, private_pts_component_manager_t *this, pen_t vendor_id) { enumerator_t *enumerator; vendor_entry_t *entry; enum_name_t *names = NULL; enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &entry)) { if (entry->vendor_id == vendor_id) { names = entry->qualifier_type_names; break; } } enumerator->destroy(enumerator); return names; } METHOD(pts_component_manager_t, add_component, void, private_pts_component_manager_t *this, pen_t vendor_id, u_int32_t name, pts_component_create_t create) { enumerator_t *enumerator; vendor_entry_t *entry; component_entry_t *component; enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &entry)) { if (entry->vendor_id == vendor_id) { component = malloc_thing(component_entry_t); component->name = name; component->create = create; entry->components->insert_last(entry->components, component); DBG2(DBG_PTS, "added %N functional component '%N'", pen_names, vendor_id, get_comp_func_names(this, vendor_id), name); } } enumerator->destroy(enumerator); } METHOD(pts_component_manager_t, remove_vendor, void, private_pts_component_manager_t *this, pen_t vendor_id) { enumerator_t *enumerator; vendor_entry_t *entry; enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &entry)) { if (entry->vendor_id == vendor_id) { this->list->remove_at(this->list, enumerator); vendor_entry_destroy(entry); DBG2(DBG_PTS, "removed %N functional component namespace", pen_names, vendor_id); } } enumerator->destroy(enumerator); } METHOD(pts_component_manager_t, get_qualifier, u_int8_t, private_pts_component_manager_t *this, pts_comp_func_name_t *name, char *flags) { enumerator_t *enumerator; vendor_entry_t *entry; u_int8_t qualifier, size, flag, type = 0; int i; enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &entry)) { if (entry->vendor_id == name->get_vendor_id(name)) { qualifier = name->get_qualifier(name); size = entry->qualifier_type_size; /* mask qualifier type field */ type = qualifier & ((1 << size) - 1); /* determine flags */ size = PTS_QUALIFIER_SIZE - size; flag = (1 << (PTS_QUALIFIER_SIZE - 1)); if (flags) { for (i = 0 ; i < size; i++) { flags[i] = (qualifier & flag) ? entry->qualifier_flag_names[i] : '.'; flag >>= 1; } flags[size] = '\0'; } } } enumerator->destroy(enumerator); return type; } METHOD(pts_component_manager_t, create, pts_component_t*, private_pts_component_manager_t *this, pts_comp_func_name_t *name, u_int32_t depth, pts_database_t *pts_db) { enumerator_t *enumerator, *e2; vendor_entry_t *entry; component_entry_t *entry2; pts_component_t *component = NULL; enumerator = this->list->create_enumerator(this->list); while (enumerator->enumerate(enumerator, &entry)) { if (entry->vendor_id == name->get_vendor_id(name)) { e2 = entry->components->create_enumerator(entry->components); while (e2->enumerate(e2, &entry2)) { if (entry2->name == name->get_name(name) && entry2->create) { component = entry2->create(depth, pts_db); break; } } e2->destroy(e2); break; } } enumerator->destroy(enumerator); return component; } METHOD(pts_component_manager_t, destroy, void, private_pts_component_manager_t *this) { this->list->destroy_function(this->list, (void *)vendor_entry_destroy); free(this); } /** * See header */ pts_component_manager_t *pts_component_manager_create(void) { private_pts_component_manager_t *this; INIT(this, .public = { .add_vendor = _add_vendor, .add_component = _add_component, .remove_vendor = _remove_vendor, .get_comp_func_names = _get_comp_func_names, .get_qualifier_type_names = _get_qualifier_type_names, .get_qualifier = _get_qualifier, .create = _create, .destroy = _destroy, }, .list = linked_list_create(), ); return &this->public; }
24.14557
79
0.732503
a7f2dba622e028558f462527da4ab0ad3af11d49
359
h
C
tableauaffichage.h
HatemTemimi/Smart-Garden-Qt-Arduino
791da871548647bbac975096d739a7bc95083d9e
[ "MIT" ]
null
null
null
tableauaffichage.h
HatemTemimi/Smart-Garden-Qt-Arduino
791da871548647bbac975096d739a7bc95083d9e
[ "MIT" ]
null
null
null
tableauaffichage.h
HatemTemimi/Smart-Garden-Qt-Arduino
791da871548647bbac975096d739a7bc95083d9e
[ "MIT" ]
null
null
null
#ifndef TABLEAUAFFICHAGE_H #define TABLEAUAFFICHAGE_H #include <QWidget> namespace Ui { class TableauAffichage; } class TableauAffichage : public QWidget { Q_OBJECT public: explicit TableauAffichage(QWidget *parent = nullptr); ~TableauAffichage(); private: Ui::TableauAffichage *ui; }; #endif // TABLEAUAFFICHAGE_H
15.608696
58
0.70195
cb667ee2b6ed822685dc0624b75bf3e8cc50cd1d
1,253
h
C
Sources/Controllers/Map/OADestinationsHelper.h
Zahnstocher/OsmAnd-ios
d67009024c5ebb0084c83e3a9c305455b5db3397
[ "MIT" ]
null
null
null
Sources/Controllers/Map/OADestinationsHelper.h
Zahnstocher/OsmAnd-ios
d67009024c5ebb0084c83e3a9c305455b5db3397
[ "MIT" ]
null
null
null
Sources/Controllers/Map/OADestinationsHelper.h
Zahnstocher/OsmAnd-ios
d67009024c5ebb0084c83e3a9c305455b5db3397
[ "MIT" ]
null
null
null
// // OADestinationsHelper.h // OsmAnd // // Created by Alexey Kulish on 14/07/15. // Copyright (c) 2015 OsmAnd. All rights reserved. // #import <Foundation/Foundation.h> #define kMinDistanceFor2ndRowAutoSelection 100.0 @class OADestination; @interface OADestinationsHelper : NSObject @property (nonatomic, readonly) NSMutableArray *sortedDestinations; @property (nonatomic, readonly) OADestination *dynamic2ndRowDestination; + (OADestinationsHelper *) instance; - (void) updateRoutePointsWithinDestinations:(NSArray *)routePoints rebuildPointsOrder:(BOOL)rebuildPointsOrder; - (void) addDestination:(OADestination *)destination; - (void) removeDestination:(OADestination *)destination; - (void) moveDestinationOnTop:(OADestination *)destination wasSelected:(BOOL)wasSelected; - (void) moveRoutePointOnTop:(NSInteger)pointIndex; - (void) apply2ndRowAutoSelection; - (NSInteger) pureDestinationsCount; - (OADestination *) getParkingPoint; - (void) showOnMap:(OADestination *)destination; - (void) hideOnMap:(OADestination *)destination; - (void) addHistoryItem:(OADestination *)destination; + (void) addParkingReminderToCalendar:(OADestination *)destination; + (void) removeParkingReminderFromCalendar:(OADestination *)destination; @end
29.833333
112
0.788508
fe0c9ac45b7b5e4ea9e9f2f13b4def8d499c63ae
319
h
C
docs/sample_code/MYINST/MYINST.h
jwmatthys/RTcmix
c9ba0c5bee2cd5e091c81333cf819d267008635b
[ "Apache-2.0" ]
40
2015-01-14T20:52:42.000Z
2022-03-09T00:50:45.000Z
docs/sample_code/MYINST/MYINST.h
jwmatthys/RTcmix
c9ba0c5bee2cd5e091c81333cf819d267008635b
[ "Apache-2.0" ]
20
2015-01-26T19:02:59.000Z
2022-01-30T18:00:39.000Z
docs/sample_code/MYINST/MYINST.h
jwmatthys/RTcmix
c9ba0c5bee2cd5e091c81333cf819d267008635b
[ "Apache-2.0" ]
14
2015-01-14T20:52:43.000Z
2021-09-24T02:24:32.000Z
#include <Instrument.h> // the base class for this instrument class MYINST : public Instrument { public: MYINST(); virtual ~MYINST(); virtual int init(double *, int); virtual int configure(); virtual int run(); private: void doupdate(); float *_in; int _nargs, _inchan, _branch; float _amp, _pan; };
15.95
66
0.680251
7e941dc4b69dcedf7dfdb160c23c512cb8fbfc80
3,606
h
C
bin/yadifa/yadifa-config.h
cosgrove39264/yadifa
aa7d1c66ecf6dc3ce0f8ce37876578e80a7b931a
[ "BSD-3-Clause" ]
1
2019-01-12T18:46:48.000Z
2019-01-12T18:46:48.000Z
bin/yadifa/yadifa-config.h
cosgrove39264/yadifa
aa7d1c66ecf6dc3ce0f8ce37876578e80a7b931a
[ "BSD-3-Clause" ]
null
null
null
bin/yadifa/yadifa-config.h
cosgrove39264/yadifa
aa7d1c66ecf6dc3ce0f8ce37876578e80a7b931a
[ "BSD-3-Clause" ]
null
null
null
/*------------------------------------------------------------------------------ * * Copyright (c) 2011-2018, EURid vzw. All rights reserved. * The YADIFA TM software product is provided under the BSD 3-clause license: * * 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 EURid 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. * *------------------------------------------------------------------------------ * */ #pragma once /** @defgroup yadifa * @ingroup ### * @brief yadifa */ #include <dnscore/sys_error.h> typedef struct config_main_settings_s config_main_settings_s; struct config_main_settings_s { host_address *server; u8 *qname; u8 *tsig_key_name; // u8 *file; char *config_file; u8 log_level; /* ------------------------------------------------------------ */ int16_t qclass; int16_t qtype; bool clean; /** @todo 20150219 gve -- #if HAS_TCL must be set, before release */ //#if HAS_TCL bool interactive; //#endif // HAS_TCL bool verbose; bool enable; }; /*----------------------------------------------------------------------------*/ #pragma mark PROTOTYPES ya_result yadifa_config_init(); ya_result yadifa_config_cmdline(int argc, char **argv); ya_result yadifa_config_finalise(); char *yadifa_config_file_get(); void yadifa_print_usage(void); bool yadifa_is_interactive(void); void yadifa_print_version(int level); /* ------------------------------------------------------------ */
41.448276
80
0.514143
2499bee193873e66aa52437dc5c04ebaca6b7703
554
h
C
ek-m-oas2-rev1/dsp/demo_1/src/periph/link.h
mcjtag/eval-kits
4c7e4568ac5cace05f3d50f9462ad3ecf76383b5
[ "MIT" ]
null
null
null
ek-m-oas2-rev1/dsp/demo_1/src/periph/link.h
mcjtag/eval-kits
4c7e4568ac5cace05f3d50f9462ad3ecf76383b5
[ "MIT" ]
null
null
null
ek-m-oas2-rev1/dsp/demo_1/src/periph/link.h
mcjtag/eval-kits
4c7e4568ac5cace05f3d50f9462ad3ecf76383b5
[ "MIT" ]
null
null
null
/** * @file link.h * @brief * @author matyunin.d * @date 28.07.2017 */ #ifndef LINK_H_ #define LINK_H_ #include <stdint.h> #define LINK_PATTERN0 0x0F0F0F0F #define LINK_PATTERN1 0xF0F0F0F0 #define LINK_PATTERN2 0xA5A5A5A5 #define LINK_PATTERN3 0x5A5A5A5A typedef void (*link_callback)(void *callback_ref); void link_init(void); void link_send(uint32_t *buf, uint16_t len); void link_send_callback(uint32_t *buf, uint16_t len, link_callback cb, void *cb_ref); void link_send_pattern(uint32_t length, uint32_t pattern); #endif /* LINK_H_ */
21.307692
85
0.758123
f1c710b1449a736fa18d9657713c6fe9aff10da6
47,969
c
C
lsp_shiloh/common/network/apps/ipp/src/ipp_main.c
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/common/network/apps/ipp/src/ipp_main.c
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/common/network/apps/ipp/src/ipp_main.c
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
/****************************************************************************** * Copyright (c) 2011 Marvell International, Ltd. All Rights Reserved * * Marvell Confidential ******************************************************************************/ #include <string.h> #include <stdio.h> #include "posix_ostools.h" #include "pthread.h" #include "memAPI.h" #include "platform.h" #include "platform_api.h" #include "debug.h" #include "logger.h" #include "error_types.h" #include "http_api.h" #include "net_logger.h" #include "map_api.h" #include "oid_sm_api.h" // module local includes #include "ipp_api.h" #include "ipp_const.h" #include "ipp.h" #include "ipp_cntxt.h" #include "ipp_printer_requested_attr.h" #include "ipp_job_requested_attr.h" #include "ipp_request.h" #include "oid_api.h" //======================================================================================= // Debug configuration //======================================================================================= #define DBG_PRFX "IPP: " #define LOGGER_MODULE_MASK DEBUG_LOGGER_MODULE_NETWORK | NET_LOGGER_SUBMOD_IPP #define DBG_ENTER(fmt,...) dbg_printf(DBG_PRFX "==>%s "fmt"\n", __func__ ,##__VA_ARGS__ ) #define DBG_RETURN(fmt,...) dbg_printf(DBG_PRFX "<==%s "fmt"\n", __func__ ,##__VA_ARGS__ ) #define DBG_ERR(...) DBG_PRINTF(LOG_ERR, DBG_PRFX __VA_ARGS__) #define DBG_MSG(...) DBG_PRINTF(LOG_NOTICE, DBG_PRFX __VA_ARGS__) #define DBG_VERBOSE(...) DBG_PRINTF(LOG_DEBUG, DBG_PRFX __VA_ARGS__) //#define DBG_VERBOSE(...) DBG_PRINTF(LOG_NOTICE, DBG_PRFX __VA_ARGS__) #define DBG_CMD(...) DBG_PRINTF(LOG_ERR, __VA_ARGS__) #ifndef DBG_ENTER #define DBG_ENTER(...) #endif #ifndef DBG_RETURN #define DBG_RETURN(...) #endif //======================================================================================= // Data types //======================================================================================= #define MS_PER_TICK ( 1000 / SYS_TICK_FREQ ) // thread stack size #define IPP_STACK_SIZE POSIX_MIN_STACK_SIZE // IPP instance context signature #define IPP_INST_CTXT_SIGNATURE 0x49505069 // ascii "IPPi" // IPP request context signature #define IPP_REQ_CTXT_SIGNATURE 0x49505072 // ascii "IPPr" #ifdef ENABLE_SINDOH_MOBILE_APP extern bool isSprintBusy; extern pthread_mutex_t _ipp_mutex; #endif /* * Message queue */ // IMPORTANT: after modifying this table, must also modify g_ipp_msg_strs typedef enum { IPP_MSG_PROCESS_HTTP_HEADER, IPP_MSG_PROCESS_REQUEST, IPP_MSG_SEND_RESPONSE, IPP_MSG_CLEANUP, // add new msgs above this line IPP_NUM_MSGS } ipp_msg_type_t; static const char *g_ipp_msg_strs[IPP_NUM_MSGS] = { "IPP_MSG_PROCESS_HTTP_HEADER", "IPP_MSG_PROCESS_REQUEST", "IPP_MSG_SEND_RESPONSE", "IPP_MSG_CLEANUP", }; static const char *g_ipp_state_strs[IPP_NUM_STATES] = { "IPP_STATE_PROCESS_HTTP_HEADER", "IPP_STATE_PROCESS_REQUEST", "IPP_STATE_SEND_RESPONSE", "IPP_STATE_CLEANUP", }; #define IPP_MQ_NUM_MSG_BUFS 20 /* message format */ #define IPP_MQ_MSG_BUF_SIZE 2 // TX_2_ULONG // buff byte size must be >= sizeof(ipp_msg_t) typedef struct { ipp_msg_type_t type; void *data; // message-specific opaque data } ipp_msg_t; /* message queue buffer */ #define IPP_MQ_MSG_BUF_BYTES (IPP_MQ_MSG_BUF_SIZE*sizeof(uint32_t)) typedef union { ipp_msg_t msg; uint8_t buf[IPP_MQ_MSG_BUF_BYTES]; // Forces ipp_msg_buf_t size into valid // threadx queue size option. } ipp_msg_buf_t; static pthread_t ipp_thread; static ALIGN(8) uint8_t ipp_stack[IPP_STACK_SIZE]; static mqd_t ipp_msg_queue; // msg queue control block bool g_ipp_initialized = false; // internal translation functions // returns binary data ready for insertion into IPP stream, e.g. cannot assume strings will be NULL-terminated. static int32_t ipp_features_supported_func(ipp_req_hndl_t request_hndl, oid_t oid, uint32_t index, char *buf, uint32_t *len); static ipp_attribute_t g_ipp_grp_names[] = { {"job-template", OID_INVALID, IPP_TAG_CHARSET, NULL, IPP_GRP_JOB_TEMPLATE}, {"printer-description", OID_INVALID, IPP_TAG_CHARSET, NULL, IPP_GRP_DESCRIPTION}, {"all", OID_INVALID, IPP_TAG_CHARSET, NULL, IPP_GRP_MASK}, }; static uint32_t g_ipp_grp_name_cnt = sizeof(g_ipp_grp_names)/sizeof(ipp_attribute_t); static ipp_attribute_t g_ipp_printer_attrs[] = { {"charset-configured", OID_SM_CHARSET_CONFIGURED, IPP_TAG_CHARSET, NULL, IPP_GRP_DESCRIPTION}, {"ipp-features-supported", OID_INVALID, IPP_TAG_KEYWORD, ipp_features_supported_func, IPP_GRP_DESCRIPTION}, }; static uint32_t g_ipp_printer_attr_cnt = sizeof(g_ipp_printer_attrs)/sizeof(ipp_attribute_t); //======================================================================================= // Local function prototypes //======================================================================================= // Thread Entry Point and State Loop static void *ipp_state_loop(void *entry_input); // Helper Routines static ipp_rcode_t ipp_send_msg_wait_opt(ipp_msg_type_t type, void *data, uint32_t posix_wait_opt); static ipp_request_t *ipp_create_request(ipp_instance_t *ipp_instance, http_request_t http_hndl); static void ipp_free_request(ipp_request_t *ipp_req); // Callback Routines static void ipp_http_event( http_request_t http_hndl, http_resource_event_flag_t event, void *usr_ctxt ); //======================================================================================= // Parameterized Macros //======================================================================================= #define IPP_LOCK_CONTEXT(ipp_mutex) \ do \ { \ int32_t posix_rcode; \ posix_rcode = pthread_mutex_lock( &ipp_mutex ); \ XASSERT(posix_rcode == 0, posix_rcode); \ } while(0) #define IPP_UNLOCK_CONTEXT(ipp_mutex) \ do \ { \ int32_t posix_rcode; \ posix_rcode = pthread_mutex_unlock(&ipp_mutex); \ XASSERT(posix_rcode == 0, posix_rcode); \ } while(0) #define IPP_STATE_TRANSITION(ipp_request, next_state) \ do{ \ ASSERT(ipp_request->ipp_instance); \ DBG_VERBOSE("%s %08x from %s to %s\n", ipp_request->ipp_instance->name, \ ipp_request, \ g_ipp_state_strs[ipp_request->state], \ g_ipp_state_strs[next_state]); \ ipp_request->state = next_state; \ } while(0) // send a message // WARNING: do not call from a non-thread (e.g. timer) // NOTE: ensures no messages are sent while in state IPP_STATE_CLEANUP #define ipp_send_msg(type, ipp_request) \ ((ipp_request->state != IPP_STATE_CLEANUP)? \ ipp_send_msg_wait_opt(type, (void *)ipp_request, POSIX_WAIT_FOREVER): \ IPP_OK); // send a message from a threadx non-thread (e.g. timer) // NOTE: ensures no messages are sent while in state IPP_STATE_CLEANUP #define ipp_send_msg_no_wait(type, ipp_request) \ ((ipp_request->state != IPP_STATE_CLEANUP)? \ ipp_send_msg_wait_opt(type, (void *)ipp_request, 0): \ IPP_OK); //======================================================================================= // Public API //======================================================================================= void ipp_init(void) { DBG_ENTER(); int32_t posix_rcode; int32_t map_rcode; // TODO move to main.c map_rcode = map_init(); XASSERT(map_rcode == SYS_OK, map_rcode); #ifdef ENABLE_SINDOH_MOBILE_APP isSprintBusy=false; posix_mutex_init(&_ipp_mutex); #endif /* * create message queue */ ASSERT(sizeof(ipp_msg_buf_t) == IPP_MQ_MSG_BUF_BYTES); // validation of msg buf size posix_create_message_queue(&ipp_msg_queue, "/ipp", IPP_MQ_NUM_MSG_BUFS, sizeof(ipp_msg_buf_t)); /* * create threads */ posix_rcode = posix_create_thread(&ipp_thread, ipp_state_loop, (void *)0, "ipp", &ipp_stack, IPP_STACK_SIZE, POSIX_THR_PRI_NORMAL); if(posix_rcode) { DBG_ERR("error creating thread (posix_rcode=%d)\n", posix_rcode); goto error; } g_ipp_initialized = true; // rdj TODO TEMP: this should be called from outside module, e.g. at network init time // Update: with VPI support enabled, ipp_open is called outside module. #ifndef HAVE_VPI_SUPPORT #ifdef HAVE_AIRPRINT void airprint_init(void); airprint_init(); #endif #endif // Generate the printer and job attributes tables. generate_req_printer_attr_tbl(); generate_req_job_attr_tbl(); // success DBG_RETURN(); return; error: DBG_ERR("init failed!\n"); DBG_RETURN(); return; } ipp_inst_hndl_t ipp_open(const char *instance_name, const char *resource_str, int32_t port) { ipp_instance_t *ipp_instance = NULL; map_handle_t attr_map = MAP_INVALID_HANDLE; int32_t ipp_rcode; DBG_VERBOSE("opening %s\n", instance_name); if(!g_ipp_initialized) { DBG_ERR("not initialized!\n"); goto error; } attr_map = map_create(0); if(attr_map == MAP_INVALID_HANDLE) { DBG_ERR("create attr_map failed!\n"); goto error; } ipp_instance = (ipp_instance_t *)IPP_MALLOC(sizeof(ipp_instance_t)); if(!ipp_instance) { DBG_ERR("low mem!\n"); goto error; } memset(ipp_instance, 0, sizeof(ipp_instance_t)); #ifdef DEBUG ipp_instance->signature = IPP_INST_CTXT_SIGNATURE; #endif ipp_instance->name = instance_name; ipp_instance->resource_str = resource_str; ipp_instance->port = port; ipp_instance->ipp_requests = NULL; ipp_instance->attr_map = attr_map; int i; for(i = 0; i < IPP_MAX_FEATURES; i++) { ipp_instance->features[i] = NULL; } // add group names ipp_rcode = ipp_insert_attr_list(ipp_instance, g_ipp_grp_names, g_ipp_grp_name_cnt, IPP_CAT_GRP_NAME); if(ipp_rcode != SYS_OK) { DBG_ERR("add attr grps failed (ipp_rcode=%d)!\n", ipp_rcode); goto error; } // add our internal set of supported IPP attributes ipp_rcode = ipp_insert_attr_list(ipp_instance, g_ipp_printer_attrs, g_ipp_printer_attr_cnt, IPP_CAT_ATTR); if(ipp_rcode != SYS_OK) { DBG_ERR("add attrs failed (ipp_rcode=%d)!\n", ipp_rcode); goto error; } error_type_t rcode; rcode = http_resource_register_event((char *)ipp_instance->resource_str, ipp_instance->port, 0 /*flags*/, ipp_http_event, (void *)ipp_instance); if(rcode != OK) { DBG_ERR("http error!\n"); goto error; } return (ipp_inst_hndl_t)ipp_instance; error: // cleanup if(ipp_instance) { IPP_FREE(ipp_instance); } if(attr_map != MAP_INVALID_HANDLE) { map_destroy(attr_map); } DBG_ERR("open %s failed!\n", instance_name); return IPP_INVALID_HANDLE; } void ipp_close(ipp_inst_hndl_t instance_hndl) { ipp_instance_t *ipp_instance; error_type_t status; ipp_instance = (ipp_instance_t *)instance_hndl; #ifdef DEBUG XASSERT(ipp_instance->signature == IPP_INST_CTXT_SIGNATURE, (int)ipp_instance); #endif status = http_resource_deregister( (char *)ipp_instance->resource_str, ipp_instance->port ); XASSERT(status == OK, status); #ifdef DEBUG ipp_instance->signature = 0; #endif IPP_FREE(ipp_instance); return; } int32_t ipp_add_attributes(ipp_inst_hndl_t instance_hndl, ipp_attribute_t *attr_list, uint32_t attr_cnt) { ipp_instance_t *ipp_instance = (ipp_instance_t *)instance_hndl; #ifdef DEBUG XASSERT(ipp_instance->signature == IPP_INST_CTXT_SIGNATURE, (int)ipp_instance); #endif int32_t map_rcode; map_rcode = ipp_insert_attr_list(ipp_instance, attr_list, attr_cnt, IPP_CAT_ATTR); return map_rcode; } int32_t ipp_replace_attributes(ipp_inst_hndl_t instance_hndl, ipp_attribute_t *attr_list, uint32_t attr_cnt) { ipp_instance_t *ipp_instance = (ipp_instance_t *)instance_hndl; #ifdef DEBUG XASSERT(ipp_instance->signature == IPP_INST_CTXT_SIGNATURE, (int)ipp_instance); #endif int32_t map_rcode; map_rcode = ipp_insert_attr_list(ipp_instance, attr_list, attr_cnt, IPP_CAT_ATTR|IPP_MAP_OVERRIDE); return map_rcode; } int32_t ipp_add_feature(ipp_inst_hndl_t instance_hndl, const char *feature_name) { ipp_instance_t *ipp_instance = (ipp_instance_t *)instance_hndl; #ifdef DEBUG XASSERT(ipp_instance->signature == IPP_INST_CTXT_SIGNATURE, (int)ipp_instance); #endif int i; for(i = 0; i < IPP_MAX_FEATURES; i++) { if(ipp_instance->features[i] == NULL) { ipp_instance->features[i] = feature_name; break; } } if(i == IPP_MAX_FEATURES) { // no free slots XASSERT(0, i); return SYS_FAIL; } return SYS_OK; } int32_t ipp_get_response_hostname(ipp_req_hndl_t request_hndl, char *buf, uint32_t len) { ipp_request_t *ipp_req = (ipp_request_t *)request_hndl; #ifdef DEBUG XASSERT(ipp_req->signature == IPP_REQ_CTXT_SIGNATURE, (int)ipp_req); #endif XASSERT(ipp_req->ipp_instance, (int)ipp_req); _get_correct_host_address(buf, len, ipp_req); return SYS_OK; } //========================================================================================================================= // Private API - local to IPP module (declared in ipp.h) //========================================================================================================================= #define IPP_READER_TIMESLICE 500 int http_resource_read_friendly(ipp_request_t *ipp_req, char *buf, int len, uint32_t *timeout) { ASSERT(timeout); int bytes_read = 0; uint32_t start_time, timeslice; int32_t timeleft; int cur_bytes_read; DBG_VERBOSE("%s - %x: (buf=%08x, len=%d, timeout=%d)\n", __func__, ipp_req->http_hndl, buf, len, *timeout); // Save off current time at start of function to determine timeout later start_time = posix_gettime_ticks(); timeleft = MAX( 0, (int32_t)(*timeout - ( (posix_gettime_ticks() - start_time) * MS_PER_TICK)) ); while (bytes_read < len) { if (timeleft <= 0) { timeleft = 0; break; } timeslice = (uint32_t)MIN(IPP_READER_TIMESLICE, timeleft); DBG_VERBOSE("%s - %x: http_resource_read timeleft=%d, timeslice=%d\n", __func__, ipp_req->http_hndl, timeleft, timeslice); cur_bytes_read = http_resource_read(ipp_req->http_hndl, buf + bytes_read, len - bytes_read, &timeslice); if (cur_bytes_read > 0) { bytes_read += cur_bytes_read; } else if (cur_bytes_read == 0) { // zero bytes read, not a timeout (EOF?) break; } else { if (timeslice == 0) { // timed out, just continue } else { if (bytes_read == 0) { DBG_ERR("%s - %x: http resource read error! (timeout=%d)\n", __func__, ipp_req->http_hndl, timeslice); bytes_read = -1; } // no timeout, done reading break; } } timeleft = MAX( 0, (int32_t)(*timeout - ( (posix_gettime_ticks() - start_time) * MS_PER_TICK)) ); } *timeout = (uint32_t)timeleft; // return error on timeout if( (*timeout == 0) && (bytes_read == 0) ) { DBG_ERR("%s - %x: http resource read timeout! (timeout=%d)\n", __func__, ipp_req->http_hndl, *timeout); bytes_read = -1; } DBG_VERBOSE("%s - %x: bytes read=%d, timeout=%d\n", __func__, ipp_req->http_hndl, bytes_read, *timeout); return bytes_read; } // temp hook int ipp_reader(void *data, void *buf, int len) { ASSERT(data); ipp_request_t *ipp_req = (ipp_request_t *)data; uint32_t timeout = ipp_req->io_timeout; int32_t num_bytes = http_resource_read_friendly(ipp_req, (char *)buf, len, &timeout); return num_bytes; } int32_t ipp_smjob_reader(char *buf, uint32_t len, uint32_t *timeout_ms, void *user_data) { ASSERT(user_data); ipp_request_t *ipp_req = (ipp_request_t *)user_data; DBG_VERBOSE("%s mutex lock ipp request %08x\n", __func__, ipp_req); IPP_LOCK_CONTEXT(ipp_req->access_mtx); DBG_VERBOSE("%s - %x: (timeout_ms=%d, buf=%08x, len=%d, tmp_req_len=%d)\n", __func__, ipp_req->http_hndl, *timeout_ms, buf, len, ipp_req->tmp_data_len); int32_t num_bytes = 0; ASSERT(ipp_req->ipp_ctxt); //XASSERT(ipp_req->tmp_data_len >= 0, ipp_req->tmp_data_len); if (ipp_req->tmp_data_len > 0) { size_t to_copy = (ipp_req->tmp_data_len < len) ? ipp_req->tmp_data_len : len; memcpy(buf, ipp_req->tmp_data + ipp_req->tmp_data_read, to_copy); ipp_req->tmp_data_read += to_copy; ipp_req->tmp_data_len -= to_copy; char *tmp_buf = buf + to_copy; XASSERT(len >= to_copy, to_copy); uint32_t tmp_len = len - to_copy; DBG_VERBOSE("%s - %x: (to_copy=%d, tmp_req_read=%d, tmp_req_len=%d, tmp_buf=%08x,"\ " tmp_len=%d)\n", __func__, ipp_req->http_hndl, to_copy, ipp_req->tmp_data_read, ipp_req->tmp_data_len, tmp_buf, tmp_len); num_bytes = to_copy; if (tmp_len) { int32_t tmp_num_bytes; tmp_num_bytes = http_resource_read_friendly(ipp_req, tmp_buf, tmp_len, timeout_ms); if (tmp_num_bytes >= 0) { num_bytes += tmp_num_bytes; } } } else if (ipp_req->tmp_data_len == 0) { num_bytes = http_resource_read_friendly(ipp_req, buf, len, timeout_ms); } else { // should not get here DBG_ERR("req %d: print job timeout!\n", ipp_req->http_hndl); ipp_req->job_http_error = true; num_bytes = 0; } DBG_VERBOSE("%x: job reader num_bytes=%d, timeout=%d\n", ipp_req->http_hndl, num_bytes, *timeout_ms); if (num_bytes <= 0) { if (num_bytes == 0) { ipp_req->job_http_eof = true; } else if (*timeout_ms != 0) // ignore timeout errors - these are recoverable { ipp_req->job_http_error = true; } } DBG_VERBOSE("%s mutex unlock ipp request %08x\n", __func__, ipp_req); IPP_UNLOCK_CONTEXT(ipp_req->access_mtx); return num_bytes; } ipp_u16bit_t ipp_get_status_from_smjob_reason(smjob_status_t *job_status) { ipp_u16bit_t status = IPP_STAT_OK; int i = 0; ASSERT(job_status); while (status == IPP_STAT_OK && i < job_status->num_reasons) { switch (job_status->reasons[i]) { case SMJOB_STATE_REASON_JOB_CANCELED_BY_USER: case SMJOB_STATE_REASON_JOB_CANCELED_BY_OPERATOR: case SMJOB_STATE_REASON_JOB_CANCELED_AT_DEVICE: status = IPP_STAT_SRV_JOB_CANCELED; break; case SMJOB_STATE_REASON_UNSUPPORTED_DOC_FORMAT: status = IPP_STAT_CLI_DOCUMENT_FORMAT_NOT_SUPPORTED; break; case SMJOB_STATE_REASON_DOC_FORMAT_ERROR: status = IPP_STAT_CLI_DOCUMENT_FORMAT_ERROR; break; /* TODO: expand cases here */ default: break; } i++; } return status; } void ipp_smjob_status_event(uint32_t job_id, smjob_status_events_t job_events, void *user_data) { smjob_rcode_t smjob_rcode; smjob_status_t job_status; ASSERT(user_data); ipp_request_t *ipp_req = (ipp_request_t *)user_data; smjob_rcode = smjob_get_status(job_id, &job_status); XASSERT(smjob_rcode == SMJOB_OK, smjob_rcode); DBG_VERBOSE("req %d: ipp_smjob_status_event (job_events=0x%x, smjob_state=%d)\n", ipp_req->http_hndl, job_events, job_status.state); if (job_events & SMJOB_STATUS_EVENT_STATE_REASONS) { DBG_VERBOSE("req %d: change in job event state reason\n", ipp_req->http_hndl); if (job_status.num_reasons) { ipp_u16bit_t status = ipp_get_status_from_smjob_reason(&job_status); DBG_VERBOSE("req %d: updating status=%d\n", ipp_req->http_hndl, status); ipp_req->ipp_status = status; } } if (job_events & SMJOB_STATUS_EVENT_STATE) { DBG_VERBOSE("req %d: change in job event state(smjob_state=%d)\n", ipp_req->http_hndl, job_status.state); switch (job_status.state) { case SMJOB_STATE_CANCELED: case SMJOB_STATE_ABORTED: case SMJOB_STATE_COMPLETED: DBG_VERBOSE("req %d: got job done (smjob_state=%d)\n", ipp_req->http_hndl, job_status.state); ipp_request_processing_complete(ipp_req); break; default: // do nothing break; } } } void ipp_request_processing_complete(ipp_request_t *ipp_req) { ASSERT(ipp_req); ipp_rcode_t ipp_rcode = ipp_send_msg(IPP_MSG_SEND_RESPONSE, ipp_req); UNUSED_VAR(ipp_rcode); XASSERT(ipp_rcode == IPP_OK, ipp_rcode); return; } //rdj added feb-2014 int32_t ipp_insert_attr_list(ipp_instance_t *ipp_inst, ipp_attribute_t *attr_list, uint32_t attr_cnt, ipp_flags_t flags) { ASSERT(ipp_inst); int32_t ipp_rcode = SYS_OK; int32_t map_rcode; int i; for(i = 0; i < attr_cnt; i++) { // only public group flags (defined in ipp_api.h) may be set directly from initializer list XASSERT(!(attr_list[i].flags & ~IPP_GRP_MASK), (int)attr_list[i].flags); attr_list[i].flags &= IPP_GRP_MASK; // apply any internal flags attr_list[i].flags |= flags; // verify IPP_CAT_ATTR entries are assigned to one and only one group and that all entries // have one and only one category -- note that at most one bit is set if (x&(x-1))==0 XASSERT((attr_list[i].flags & IPP_GRP_MASK) && (!(attr_list[i].flags & IPP_CAT_ATTR) || !((attr_list[i].flags & IPP_GRP_MASK) & ((attr_list[i].flags & IPP_GRP_MASK)-1))), i); XASSERT((attr_list[i].flags & IPP_CAT_MASK) && !((attr_list[i].flags & IPP_CAT_MASK) & ((attr_list[i].flags & IPP_CAT_MASK)-1)), i); if(flags & IPP_MAP_OVERRIDE) { // first remove any pre-existing IPP attribute of same name void *val; val = map_remove(ipp_inst->attr_map, attr_list[i].name, strlen(attr_list[i].name)); if(!val) { // there was no pre-existing IPP attribute with this name so clear the flag attr_list[i].flags &= ~IPP_MAP_OVERRIDE; } } map_rcode = map_insert(ipp_inst->attr_map, attr_list[i].name, strlen(attr_list[i].name), (void *)&attr_list[i]); XASSERT(map_rcode == SYS_OK || map_rcode == MAP_DUP_KEY, map_rcode); if(map_rcode == MAP_DUP_KEY) { // note this is not necessarily a fatal error ipp_rcode = IPP_DUP_ATTR; } } return ipp_rcode; } //======================================================================================= // Thread Entry Point and State Loop //======================================================================================= /* * IMPORTANT NOTE: Correct operation of this state machine depends on the following: * * 1) The value of the state variable MUST NOT be directly modified outside of the state * machine. * * 2) Adding a message to the queue MUST NOT be conditional on the current value of the * state variable. * * These conditions are required because the current value of the state variable does not * account for messages pending in the message queue and therefore does not reflect * actual state. The value of the state variable is only accurate relative to the last * message processed, whereas actual state is a function of the current state variable * value plus any messages still pending in the message queue. Once a message is sent it * cannot be taken back, and its effect on the state variable is determined the moment it * enters the message queue. * * When reading the state variable from outside the state machine, be aware that the * the state variable value lags behind actual state. */ static void *ipp_state_loop(void *entry_input) { int32_t posix_rcode; ipp_msg_buf_t msg_buf; ipp_msg_t *msg; ipp_request_t *ipp_req; ipp_instance_t *ipp_inst; DBG_VERBOSE("starting state loop\n"); while(1) { ipp_req = NULL; ipp_inst = NULL; posix_rcode = posix_wait_for_message(ipp_msg_queue, (char *)&msg_buf, sizeof(ipp_msg_t), POSIX_WAIT_FOREVER); if(posix_rcode != 0) { DBG_ERR("error reading ipp_msg_queue (posix_rcode=%d)\n", posix_rcode); break; } msg = &msg_buf.msg; ASSERT(msg->type < IPP_NUM_MSGS); ipp_req = (ipp_request_t *)msg->data; if(ipp_req) { DBG_VERBOSE("%s %08x got msg %s in state %s\n", ipp_req->ipp_instance->name, ipp_req, g_ipp_msg_strs[msg->type], g_ipp_state_strs[ipp_req->state]); } else { DBG_VERBOSE("got stateless msg %s\n", g_ipp_msg_strs[msg->type]); } /* * process stateful messages */ if(!ipp_req) { // message is not stateful - ignore continue; } ipp_inst = ipp_req->ipp_instance; ASSERT(ipp_inst); ASSERT(ipp_req->state < IPP_NUM_STATES); switch(ipp_req->state) { /*************************************************** * IPP_STATE_PROCESS_HTTP_HEADER ***************************************************/ case IPP_STATE_PROCESS_HTTP_HEADER: switch(msg->type) { case IPP_MSG_PROCESS_HTTP_HEADER: { // received a new HTTP request IPP_STATE_TRANSITION(ipp_req, IPP_STATE_PROCESS_REQUEST); ipp_rcode_t ipp_rcode = ipp_send_msg(IPP_MSG_PROCESS_REQUEST, ipp_req); UNUSED_VAR(ipp_rcode); XASSERT(ipp_rcode == IPP_OK, ipp_rcode); break; } default: // ignore other messages DBG_VERBOSE("%s %08x ignoring msg %s!\n", ipp_inst->name, ipp_req, g_ipp_msg_strs[msg->type]); break; } break; /*************************************************** * IPP_STATE_PROCESS_REQUEST ***************************************************/ case IPP_STATE_PROCESS_REQUEST: switch(msg->type) { case IPP_MSG_PROCESS_REQUEST: { #ifdef HAVE_IPV6 char network_address[INET6_ADDRSTRLEN]; #else char network_address[INET_ADDRSTRLEN]; #endif uint32_t error; error = ipp_get_network_ip_address_from_connection( ipp_req->http_hndl, &network_address[0], sizeof(network_address)); UNUSED_VAR(error); ASSERT(error == OK); ipp_req->ipp_ctxt = ipp_create_context("ipp", &network_address[0], ipp_req->ipp_instance->port, "ipp"); if(ipp_req->ipp_ctxt) { ipp_req->ipp_ctxt->ipp_req = ipp_req; int r = ipp_handle_request(ipp_req->ipp_ctxt, "dummy_uri", ipp_reader); UNUSED_VAR(r); } else { DBG_VERBOSE("req %d: no response data\n", ipp_req->http_hndl); } IPP_STATE_TRANSITION(ipp_req, IPP_STATE_SEND_RESPONSE); break; } default: // ignore other messages DBG_VERBOSE("%s %08x ignoring msg %s!\n", ipp_inst->name, ipp_req, g_ipp_msg_strs[msg->type]); break; } break; /*************************************************** * IPP_STATE_SEND_RESPONSE ***************************************************/ case IPP_STATE_SEND_RESPONSE: switch(msg->type) { case IPP_MSG_SEND_RESPONSE: { char tmp_buf[512]; int bytes_read; uint32_t timeout; uint32_t tout; // skip if EOF or HTTP ERROR detected if (!ipp_req->job_http_eof && !ipp_req->job_http_error) { DBG_VERBOSE("req %d: checking for any remaining http data to dump...\n", ipp_req->http_hndl); // Reset if repsonse drain timeout is zero - this indicates its the // first time or it's been reset if (ipp_req->job_resp_drain_timeout == 0) { DBG_VERBOSE("req %d: resetting timeout\n", ipp_req->http_hndl); ipp_req->job_resp_drain_timeout = ipp_req->io_timeout; } // determine timeout - should not be more than 500ms timeout = (ipp_req->job_resp_drain_timeout) < 500 ? ipp_req->job_resp_drain_timeout : 500; tout = timeout; // get start time - only want to drain data from pipe for appox 500ms at a time uint32_t start_time = posix_gettime_ticks(); // loop while timeout has not expired, not EOF and no HTTP error while (tout && !ipp_req->job_http_eof && !ipp_req->job_http_error) { // attempt to drain 32 bytes from pipe bytes_read = ipp_smjob_reader(tmp_buf, 512, &tout, (void *)ipp_req); // determine if there was a read error or not if (bytes_read < 0) { // check for read timeout if (tout == 0) { // decrement the drain timeout ipp_req->job_resp_drain_timeout -= timeout; // check to see if the drain timeout has expired (no data) if (ipp_req->job_resp_drain_timeout == 0) { DBG_MSG("req %d: timed out waiting to drain pipe, indicate HTTP error\n", ipp_req->http_hndl); // When draining the pipe, if we hit a full IO timeout that's really // an error. ipp_req->job_http_error = true; } else { DBG_VERBOSE("req %d: timed out, IO time left = %d\n", ipp_req->http_hndl, ipp_req->job_resp_drain_timeout); } } else { // something went wonky with the read DBG_MSG("req %d: HTTP error reading pipe\n", ipp_req->http_hndl); ipp_req->job_http_error = true; } } else { // determine elapse time in ms uint32_t elapse_time = (posix_gettime_ticks() - start_time)*10; // decrement tout or set to 0 if greater than time left if (elapse_time > tout) tout = 0; else tout -= elapse_time; DBG_VERBOSE("req %d: drained %d bytes from pipe, time left %d\n", ipp_req->http_hndl, bytes_read, tout); // since we have read data, reset drain timeout ipp_req->job_resp_drain_timeout = ipp_req->io_timeout; } } } // check for EOF or HTTP error if (ipp_req->job_http_eof || ipp_req->job_http_error) { DBG_VERBOSE("req %d: sending http reponse\n", ipp_req->http_hndl); // if no HTTP error (then EOF), send reponse if (!ipp_req->job_http_error) { // build the response ipp_build_response(ipp_req); http_resource_set_status_code(ipp_req->http_hndl, HTTP_200_OK); http_resource_set_content_length(ipp_req->http_hndl, ipp_req->response_len); http_resource_set_content_type(ipp_req->http_hndl, HTTP_TYPE_IPP); http_resource_header_complete(ipp_req->http_hndl); DBG_VERBOSE("req %d: sending %d bytes of response data\n", ipp_req->http_hndl, ipp_req->response_len); if(ipp_req->response_len) { int32_t num_sent = http_resource_write(ipp_req->http_hndl, ipp_req->response_data, ipp_req->response_len ); // Note that if http_resource_write returns -1, then something // has gone wonky with the connection (probably aborted). Not // really assert worthy, just let folks know what happened. if (num_sent == -1) { DBG_ERR("req %d: response http_resource_write failed\n", ipp_req->http_hndl); } else { XASSERT(num_sent == ipp_req->response_len, num_sent); //UNUSED_VAR(num_sent); // indicate we passed the buffer off to HTTP ipp_req->response_data = NULL; ipp_req->response_len = 0; } } http_resource_send_complete(ipp_req->http_hndl); } else { // if HTTP error, reset connection DBG_ERR("req %d: HTTP error, reset connection\n", ipp_req->http_hndl); http_resource_reset_connection(ipp_req->http_hndl); } /* * Must send cleanup msg BEFORE transition to cleanup state. * * No messages are allowed to be sent while in the cleanup state, * * because the ipp request context is in process of being freed. * * NOTE: This must be done from within state loop to guarantee msg is * processed after transition to cleanup state. Msg must be sent before * transition but processed after transition. */ ipp_rcode_t ipp_rcode = ipp_send_msg(IPP_MSG_CLEANUP, ipp_req); UNUSED_VAR(ipp_rcode); XASSERT(ipp_rcode == IPP_OK, ipp_rcode); // NOTE: any messages for this ipp_req sent after the transition to // IPP_STATE_CLEANUP will be ignored. IPP_STATE_TRANSITION(ipp_req, IPP_STATE_CLEANUP); } else { // if not EOF or HTTP error, then we are still trying to drain the pipe. ipp_rcode_t ipp_rcode = ipp_send_msg(IPP_STATE_SEND_RESPONSE, ipp_req); UNUSED_VAR(ipp_rcode); XASSERT(ipp_rcode == IPP_OK, ipp_rcode); } break; } default: // ignore other messages DBG_VERBOSE("%s %08x ignoring msg %s!\n", ipp_inst->name, ipp_req, g_ipp_msg_strs[msg->type]); break; } break; /*************************************************** * IPP_STATE_CLEANUP ***************************************************/ case IPP_STATE_CLEANUP: switch(msg->type) { case IPP_MSG_CLEANUP: DBG_VERBOSE("%s free ipp request %08x\n", ipp_inst->name, ipp_req); ASSERT(ipp_req); ASSERT(ipp_req->ipp_ctxt); // must destroy map before cntxt since ipp group structs contain the map keys if(ipp_req->req_attrs.map != MAP_INVALID_HANDLE) { map_destroy(ipp_req->req_attrs.map); } ipp_destroy_context(ipp_req->ipp_ctxt); ipp_free_request(ipp_req); // must not receive any futher messages referencing this ipp request context break; default: // ignore other messages DBG_VERBOSE("%s %08x ignoring msg %s!\n", ipp_inst->name, ipp_req, g_ipp_msg_strs[msg->type]); break; } break; default: // unknown state - ignore XASSERT(0, ipp_req->state); break; } } DBG_VERBOSE("exiting\n"); return 0; } //======================================================================================= // State Loop Helper Routines // NOTE: these routines must only be called directly from state machine //======================================================================================= //======================================================================================= // Helper Routines //======================================================================================= static ipp_rcode_t ipp_send_msg_wait_opt(ipp_msg_type_t type, void *data, uint32_t posix_wait_opt) { ipp_msg_buf_t buf; buf.msg.type = type; buf.msg.data = data; int32_t posix_rcode = posix_message_send(ipp_msg_queue, (char *)&buf, sizeof(buf), MQ_DEFAULT_PRIORITY, posix_wait_opt); if(posix_rcode == ETIMEDOUT) { /* * msg queue full * * NOTE: should only get here when caller is a non-thread (e.g. timer) and * threadx_wait_opt must therefore be set to TX_NO_WAIT. */ return IPP_WOULDBLOCK; } else if(posix_rcode) { // any other errors are unexpected and unhandled XASSERT(0, posix_rcode); return IPP_FAIL; } return IPP_OK; } // WARNING: called from context of HTTP callback static ipp_request_t *ipp_create_request(ipp_instance_t *ipp_instance, http_request_t http_hndl) { ipp_rcode_t ipp_rcode = IPP_OK; error_type_t rcode; ipp_request_t *ipp_req = (ipp_request_t *)IPP_MALLOC(sizeof(ipp_request_t)); ASSERT(ipp_req); memset(ipp_req, 0, sizeof(ipp_request_t)); #ifdef DEBUG ipp_req->signature = IPP_REQ_CTXT_SIGNATURE; #endif ipp_req->ipp_instance = ipp_instance; ipp_req->http_hndl = http_hndl; ipp_req->state = IPP_STATE_PROCESS_HTTP_HEADER; ipp_req->job_http_eof = false; ipp_req->job_http_error = false; ipp_req->job_done_event = false; ipp_req->job_resp_drain_timeout = 0; ipp_req->job_id = SMJOB_INVALID_JOB_ID; ipp_req->req_attrs.grp_mask = 0; ipp_req->req_attrs.map = MAP_INVALID_HANDLE; ipp_req->oid_buf = (char *)IPP_MALLOC(OID_BUF_MAX_LEN); ASSERT(ipp_req->oid_buf); int32_t posix_rcode; posix_rcode = posix_mutex_init(&ipp_req->access_mtx); XASSERT(posix_rcode == 0, posix_rcode); #ifdef IPP_TIME_LOG ipp_req->start_ticks = posix_gettime_ticks(); #endif //IPP_TIME_LOG uint16_t io_timeout_sec; platvars_get_io_timeout(&io_timeout_sec); ipp_req->io_timeout = (io_timeout_sec * 1000); rcode = http_resource_get_header_length( http_hndl, &ipp_req->http_hdr_len ); if(rcode != OK) { ipp_rcode = FAIL; goto done; } ipp_req->http_hdr = (char *)IPP_MALLOC( ipp_req->http_hdr_len ); ASSERT(ipp_req->http_hdr); rcode = http_resource_get_header( http_hndl, ipp_req->http_hdr, ipp_req->http_hdr_len ); if(rcode != OK) { ipp_rcode = FAIL; goto done; } done: if(ipp_rcode != IPP_OK) { // free resources if(ipp_req) { ipp_free_request(ipp_req); ipp_req = NULL; } } return ipp_req; } static void ipp_free_request(ipp_request_t *ipp_req) { ASSERT(ipp_req); MEM_FREE_AND_NULL(ipp_req->oid_buf); pthread_mutex_destroy(&ipp_req->access_mtx); // free response data if not passed to HTTP for some reason if (ipp_req->response_data) MEM_FREE_AND_NULL(ipp_req->response_data); IPP_FREE(ipp_req->http_hdr); #ifdef DEBUG ipp_req->signature = 0; #endif IPP_FREE(ipp_req); return; } //======================================================================================= // Callback Routines //======================================================================================= static void ipp_http_event( http_request_t http_hndl, http_resource_event_flag_t event, void *usr_ctxt ) { ASSERT(usr_ctxt); ipp_rcode_t ipp_rcode; ipp_instance_t *ipp_instance = (ipp_instance_t *)usr_ctxt; DBG_VERBOSE("req %d: ipp_http_event - %d\n", http_hndl, event); switch (event) { case HTTP_RESOURCE_HEADER_DATA_AVAILABLE: { ipp_request_t *ipp_req = ipp_create_request(ipp_instance, http_hndl); if(ipp_req) { ipp_rcode = ipp_send_msg(IPP_MSG_PROCESS_HTTP_HEADER, ipp_req); XASSERT(ipp_rcode == IPP_OK, ipp_rcode); } else { // at this point all we can do is reset the TCP connection http_resource_reset_connection(http_hndl); } break; } case HTTP_RESOURCE_CONNECTION_ABORTED: DBG_VERBOSE( "http_test: CONNECTION ABORTED\n" ); break; } } //rdj added feb-2014 // translation function callback // buf [out] // len [in/out] static int32_t ipp_features_supported_func(ipp_req_hndl_t request_hndl, oid_t oid, uint32_t index, char *buf, uint32_t *len) { int32_t ret = SYS_OK; uint32_t out_len = 0; ipp_request_t *ipp_req = (ipp_request_t *)request_hndl; #ifdef DEBUG XASSERT(ipp_req->signature == IPP_REQ_CTXT_SIGNATURE, (int)ipp_req); #endif XASSERT(ipp_req->ipp_instance, (int)ipp_req); // confirm no OID defined ASSERT(oid == OID_INVALID); if(index >= IPP_MAX_FEATURES || ipp_req->ipp_instance->features[index] == NULL) { ret = OID_ERROR_INDEX_INVALID; goto done; } out_len = strlen(ipp_req->ipp_instance->features[index]); if(out_len > *len) { out_len = 0; ret = OID_ERROR_BUFFER_TOO_SMALL; goto done; } memcpy(buf, ipp_req->ipp_instance->features[index], out_len); done: *len = out_len; return ret; }
35.19369
125
0.518397
00bd64e7a85e4ea8b3b48e41ca809c14d0349011
3,290
h
C
IotHttpServer/MultipartParser.h
saarbastler/IotHttpServer
f55896950510e7a6403d19ce2f425adae4761b2d
[ "BSD-2-Clause" ]
1
2018-08-26T11:37:31.000Z
2018-08-26T11:37:31.000Z
IotHttpServer/MultipartParser.h
saarbastler/IotHttpServer
f55896950510e7a6403d19ce2f425adae4761b2d
[ "BSD-2-Clause" ]
null
null
null
IotHttpServer/MultipartParser.h
saarbastler/IotHttpServer
f55896950510e7a6403d19ce2f425adae4761b2d
[ "BSD-2-Clause" ]
null
null
null
#ifndef _INCLUDE_MULTI_PART_PARSER_ #define _INCLUDE_MULTI_PART_PARSER_ #include <boost/utility/string_view.hpp> #include <boost/algorithm/string.hpp> #include "SabaException.h" namespace saba { namespace web { using namespace boost; class MultipartParser { public: MultipartParser(string_view body) { string_view::iterator it = body.begin(); string_view separator = readToEndOfLine(it, body.end()); while (it != body.end()) { string_view line = readToEndOfLine(it, body.end()); if (line.starts_with(ContentDisposition)) readFilename(line); else if (line.starts_with(ContentType)) readContenttype(line); else if (line.empty()) { fileStart = it; break; } } if (fileStart) { size_t end = body.find(separator, fileStart - body.begin()); fileSize = end - (fileStart - body.begin()); if (fileStart[fileSize - 1] == '\n') fileSize--; if (fileStart[fileSize - 1] == '\r') fileSize--; } else throw saba::Exception("unable to parse Multipart Body"); } const std::string& getFilename() { return filename; } const std::string& getContentType() { return contentType; } const char *getFileStart() { return fileStart; } size_t getFilesize() { return fileSize; } protected: static constexpr const char *ContentDisposition= "Content-Disposition:" ; static constexpr const char *FileName = "filename=\""; static constexpr const char *ContentType = "Content-Type:"; std::string filename; std::string contentType; const char *fileStart= nullptr; size_t fileSize = 0; void readContenttype(string_view line) { contentType = std::string(line.begin() + strlen(ContentType), line.end()); boost::trim(contentType); } void readFilename(string_view line) { size_t filenamePos = line.find(FileName); if (filenamePos != string_view::npos) { filenamePos += strlen(FileName); size_t filenameEnd = line.find('\"', filenamePos); if (filenameEnd != string_view::npos) filename = std::string(line.begin() + filenamePos, filenameEnd - filenamePos); } } string_view readToEndOfLine(string_view::iterator& it, string_view::iterator end) { string_view::iterator from = it; for(;it != end;it++) { if (*it == '\r') { string_view::iterator to = it; it++; if (*it == '\n') it++; return string_view(from, to-from); } else if(*it == '\n') { string_view::iterator to = it; it++; return string_view(from, to - from); } } return string_view(); } }; } } #endif // _INCLUDE_MULTI_PART_PARSER_
24.736842
91
0.519149
283fc9b6104a80e6a7fbf53227be83fa69cdd0a4
334
h
C
cpuminer-2.4.5/compat.h
digital50/gcmtestFebruary
d4800f0f078a09c7abfe15025861ea41c62a656a
[ "MIT" ]
5
2020-01-03T13:16:51.000Z
2021-02-13T12:49:22.000Z
assets/cpuminer-2.5.0/compat.h
zeus16/DAPS
4736048d3bcb1656584ee01e497002c006b8e1ef
[ "MIT" ]
7
2020-01-03T13:46:27.000Z
2020-02-24T05:59:59.000Z
assets/cpuminer-2.5.0/compat.h
zeus16/DAPS
4736048d3bcb1656584ee01e497002c006b8e1ef
[ "MIT" ]
3
2020-03-26T02:35:13.000Z
2021-09-11T00:15:20.000Z
#ifndef __COMPAT_H__ #define __COMPAT_H__ #ifdef WIN32 #include <windows.h> #define sleep(secs) Sleep((secs) * 1000) enum { PRIO_PROCESS = 0, }; static inline int setpriority(int which, int who, int prio) { return -!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); } #endif /* WIN32 */ #endif /* __COMPAT_H__ */
15.181818
70
0.715569
ffc9c4bf663255119cd9331bd6be28e961c13ac3
317
h
C
Battle Ship Strategy Game/Game_Header_Files_Part_One.h
Limitless-Rasul-Power/BattleShip-Game
558d58d96bf7d404e825e9d1e7f2483252e586f5
[ "MIT" ]
null
null
null
Battle Ship Strategy Game/Game_Header_Files_Part_One.h
Limitless-Rasul-Power/BattleShip-Game
558d58d96bf7d404e825e9d1e7f2483252e586f5
[ "MIT" ]
2
2020-11-25T17:11:50.000Z
2020-11-25T17:17:30.000Z
Battle Ship Strategy Game/Game_Header_Files_Part_One.h
Limitless-Rasul-Power/BattleShip-Game
558d58d96bf7d404e825e9d1e7f2483252e586f5
[ "MIT" ]
null
null
null
#pragma once #include "Player_Structure.h" #include "About_Entry.h" #include "About_Console.h" #include "About_Button.h" #include "About_Rules.h" #include "About_Computer.h" #include "About_Name.h" #include "About_Board.h" #include "About_Define.h" #include "About_Hit.h" #include "About_Target_and_Swap.h"
26.416667
34
0.750789
152e928c8fbd559ec1c7e1719d5dd96020f11bce
1,999
c
C
BlockMatching/src/libbasic/test-rot.c
Xqua/standalone-Mouse
1655a2cf15563155a13d6094638c5d440a383005
[ "BSD-3-Clause" ]
2
2018-10-16T01:52:14.000Z
2021-03-16T11:53:46.000Z
BlockMatching/src/libbasic/test-rot.c
Xqua/standalone-Mouse
1655a2cf15563155a13d6094638c5d440a383005
[ "BSD-3-Clause" ]
2
2018-11-24T00:16:44.000Z
2019-11-11T09:01:26.000Z
BlockMatching/src/libbasic/test-rot.c
Xqua/standalone-Mouse
1655a2cf15563155a13d6094638c5d440a383005
[ "BSD-3-Clause" ]
2
2018-11-21T23:55:04.000Z
2020-12-10T16:52:54.000Z
/************************************************************************* * test-quater.c - Rigid transformation with least squares * * $Id: test-quater.c,v 1.1 2000/10/09 09:02:10 greg Exp $ * * Copyright INRIA * * AUTHOR: * Gregoire Malandain (greg@sophia.inria.fr) * * CREATION DATE: * Fri Oct 6 21:51:48 MEST 2000 * * ADDITIONS, CHANGES * * */ #include <stdio.h> #include <transfo.h> #include <time.h> #include <math.h> #include <stdlib.h> int main (int argc, char *argv[] ) { int i, imax=10; double vec[3], n; double t, theta; double mat[9]; double rot[3]; double max = 2147483647; /* (2^31)-1 */ (void)srandom(time(0)); t = ( random() / max ) * 3.1415927; for ( i=0; i<imax; i++, t /= 10 ) { vec[0] = 2.0*random() / max - 1.0; vec[1] = 2.0*random() / max - 1.0; vec[2] = 2.0*random() / max - 1.0; n = sqrt( vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2] ); vec[0] /= n; vec[1] /= n; vec[2] /= n; /* t = ( random() / max ) * 3.1415927; */ fprintf( stderr, "trial #%2d\n", i ); fprintf( stderr, " random vector = [%f %f %f], angle = %g degrees\n", vec[0], vec[1], vec[2], t * 180.0/3.1415927 ); vec[0] *= t; vec[1] *= t; vec[2] *= t; RotationMatrixFromRotationVector( mat, vec ); fprintf( stderr, " matrix = [ %f %f %f ]\n", mat[0], mat[1], mat[2] ); fprintf( stderr, " [ %f %f %f ]\n", mat[3], mat[4], mat[5] ); fprintf( stderr, " [ %f %f %f ]\n", mat[6], mat[7], mat[8] ); RotationVectorFromRotationMatrix( rot, mat ); theta = sqrt( rot[0]*rot[0] + rot[1]*rot[1] + rot[2]*rot[2] ); fprintf( stderr, " vector = [%f %f %f], angle = %f degrees\n", rot[0]/theta, rot[1]/theta, vec[2]/theta, theta * 180.0/3.1415927 ); fprintf( stderr, " error on angle = %f (%f %%)\n", theta - t, (theta-t)/theta * 100.0 ); } return( 1 ); }
27.763889
141
0.476738
9ef132b356dc8ef57828173514a811111021bdc6
1,318
h
C
lammps-master/tools/lmp2arc/src/lmp2.h
rajkubp020/helloword
4bd22691de24b30a0f5b73821c35a7ac0666b034
[ "MIT" ]
null
null
null
lammps-master/tools/lmp2arc/src/lmp2.h
rajkubp020/helloword
4bd22691de24b30a0f5b73821c35a7ac0666b034
[ "MIT" ]
null
null
null
lammps-master/tools/lmp2arc/src/lmp2.h
rajkubp020/helloword
4bd22691de24b30a0f5b73821c35a7ac0666b034
[ "MIT" ]
null
null
null
# include <stdio.h> # include <stdlib.h> # include <string.h> # include <stddef.h> # include <math.h> #define MAX_LINE_LENGTH 200 #define MAX_POS_FILES 50 #ifdef MAIN #define _EX #else #define _EX extern #endif struct Sys { int periodic; int ntypes; int natoms; int no_molecules; int nbonds; float celldim[3]; float *masses; struct Mol *molinfo; struct Atom *atoms; int *bondindex; }; struct Mol { int start; int end; }; struct Atom /* atom information in .car file */ { int molecule; /* molecule id */ float q; /* charge */ double xyz[3]; /* position vector */ char potential[5]; /* atom potential type */ char element[2]; /* atom element */ char res_name[8]; /* residue name */ char res_num[8]; /* residue numer */ char name[10]; /* atom name */ }; struct Boundary { double low[3]; double hi[3]; double size[3]; }; struct NewAtomCoordinates { int type; double fract[3]; int truef[3]; }; struct Colors { float rgb[3]; }; _EX int trueflag; /* 0=no_true_flags; 1=true_flags */ _EX int move_molecules; /* 0=don't move; 1=move */ _EX int nskip; /* number of steps to skip in pos file */ _EX int npico; /* number of steps per picosecond */
18.054795
75
0.594082
7f2fcb52b404c174152cf3fb64fafddbdf625867
101,839
h
C
test/aarch32/traces/assembler-cond-rd-operand-rn-shift-amount-1to32-a32-cmn.h
Componolit/android_external_vixl
0cc1043fc66e89d6f0d538a10668a7b3bb1a372b
[ "BSD-3-Clause" ]
null
null
null
test/aarch32/traces/assembler-cond-rd-operand-rn-shift-amount-1to32-a32-cmn.h
Componolit/android_external_vixl
0cc1043fc66e89d6f0d538a10668a7b3bb1a372b
[ "BSD-3-Clause" ]
null
null
null
test/aarch32/traces/assembler-cond-rd-operand-rn-shift-amount-1to32-a32-cmn.h
Componolit/android_external_vixl
0cc1043fc66e89d6f0d538a10668a7b3bb1a372b
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2015, VIXL authors // 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 ARM Limited 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 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. // --------------------------------------------------------------------- // This file is auto generated using tools/generate_simulator_traces.py. // // PLEASE DO NOT EDIT. // --------------------------------------------------------------------- #ifndef VIXL_ASSEMBLER_COND_RD_OPERAND_RN_SHIFT_AMOUNT_1TO32_A32_CMN_H_ #define VIXL_ASSEMBLER_COND_RD_OPERAND_RN_SHIFT_AMOUNT_1TO32_A32_CMN_H_ const byte kInstruction_cmn_eq_r10_r13_LSR_23[] = { 0xad, 0x0b, 0x7a, 0x01 // cmn eq r10 r13 LSR 23 }; const byte kInstruction_cmn_eq_r12_r13_LSR_13[] = { 0xad, 0x06, 0x7c, 0x01 // cmn eq r12 r13 LSR 13 }; const byte kInstruction_cmn_pl_r13_r5_LSR_12[] = { 0x25, 0x06, 0x7d, 0x51 // cmn pl r13 r5 LSR 12 }; const byte kInstruction_cmn_vc_r8_r11_ASR_13[] = { 0xcb, 0x06, 0x78, 0x71 // cmn vc r8 r11 ASR 13 }; const byte kInstruction_cmn_al_r9_r12_ASR_1[] = { 0xcc, 0x00, 0x79, 0xe1 // cmn al r9 r12 ASR 1 }; const byte kInstruction_cmn_vs_r10_r3_ASR_31[] = { 0xc3, 0x0f, 0x7a, 0x61 // cmn vs r10 r3 ASR 31 }; const byte kInstruction_cmn_pl_r2_r11_ASR_14[] = { 0x4b, 0x07, 0x72, 0x51 // cmn pl r2 r11 ASR 14 }; const byte kInstruction_cmn_al_r11_r10_LSR_27[] = { 0xaa, 0x0d, 0x7b, 0xe1 // cmn al r11 r10 LSR 27 }; const byte kInstruction_cmn_le_r10_r8_LSR_19[] = { 0xa8, 0x09, 0x7a, 0xd1 // cmn le r10 r8 LSR 19 }; const byte kInstruction_cmn_vc_r6_r2_ASR_9[] = { 0xc2, 0x04, 0x76, 0x71 // cmn vc r6 r2 ASR 9 }; const byte kInstruction_cmn_al_r10_r10_ASR_7[] = { 0xca, 0x03, 0x7a, 0xe1 // cmn al r10 r10 ASR 7 }; const byte kInstruction_cmn_pl_r4_r6_LSR_3[] = { 0xa6, 0x01, 0x74, 0x51 // cmn pl r4 r6 LSR 3 }; const byte kInstruction_cmn_vs_r0_r6_ASR_19[] = { 0xc6, 0x09, 0x70, 0x61 // cmn vs r0 r6 ASR 19 }; const byte kInstruction_cmn_vc_r5_r8_LSR_5[] = { 0xa8, 0x02, 0x75, 0x71 // cmn vc r5 r8 LSR 5 }; const byte kInstruction_cmn_ne_r2_r9_LSR_26[] = { 0x29, 0x0d, 0x72, 0x11 // cmn ne r2 r9 LSR 26 }; const byte kInstruction_cmn_lt_r14_r0_LSR_12[] = { 0x20, 0x06, 0x7e, 0xb1 // cmn lt r14 r0 LSR 12 }; const byte kInstruction_cmn_hi_r8_r1_ASR_15[] = { 0xc1, 0x07, 0x78, 0x81 // cmn hi r8 r1 ASR 15 }; const byte kInstruction_cmn_vc_r9_r13_LSR_16[] = { 0x2d, 0x08, 0x79, 0x71 // cmn vc r9 r13 LSR 16 }; const byte kInstruction_cmn_lt_r4_r11_LSR_26[] = { 0x2b, 0x0d, 0x74, 0xb1 // cmn lt r4 r11 LSR 26 }; const byte kInstruction_cmn_vs_r2_r2_ASR_7[] = { 0xc2, 0x03, 0x72, 0x61 // cmn vs r2 r2 ASR 7 }; const byte kInstruction_cmn_pl_r8_r8_ASR_4[] = { 0x48, 0x02, 0x78, 0x51 // cmn pl r8 r8 ASR 4 }; const byte kInstruction_cmn_al_r10_r11_ASR_31[] = { 0xcb, 0x0f, 0x7a, 0xe1 // cmn al r10 r11 ASR 31 }; const byte kInstruction_cmn_cs_r14_r11_ASR_3[] = { 0xcb, 0x01, 0x7e, 0x21 // cmn cs r14 r11 ASR 3 }; const byte kInstruction_cmn_vs_r0_r11_LSR_30[] = { 0x2b, 0x0f, 0x70, 0x61 // cmn vs r0 r11 LSR 30 }; const byte kInstruction_cmn_pl_r6_r13_LSR_18[] = { 0x2d, 0x09, 0x76, 0x51 // cmn pl r6 r13 LSR 18 }; const byte kInstruction_cmn_pl_r14_r2_ASR_32[] = { 0x42, 0x00, 0x7e, 0x51 // cmn pl r14 r2 ASR 32 }; const byte kInstruction_cmn_ls_r11_r6_ASR_23[] = { 0xc6, 0x0b, 0x7b, 0x91 // cmn ls r11 r6 ASR 23 }; const byte kInstruction_cmn_cc_r11_r2_ASR_2[] = { 0x42, 0x01, 0x7b, 0x31 // cmn cc r11 r2 ASR 2 }; const byte kInstruction_cmn_le_r12_r5_ASR_27[] = { 0xc5, 0x0d, 0x7c, 0xd1 // cmn le r12 r5 ASR 27 }; const byte kInstruction_cmn_ge_r2_r5_ASR_31[] = { 0xc5, 0x0f, 0x72, 0xa1 // cmn ge r2 r5 ASR 31 }; const byte kInstruction_cmn_le_r0_r5_ASR_7[] = { 0xc5, 0x03, 0x70, 0xd1 // cmn le r0 r5 ASR 7 }; const byte kInstruction_cmn_ge_r1_r10_ASR_28[] = { 0x4a, 0x0e, 0x71, 0xa1 // cmn ge r1 r10 ASR 28 }; const byte kInstruction_cmn_vc_r6_r0_LSR_13[] = { 0xa0, 0x06, 0x76, 0x71 // cmn vc r6 r0 LSR 13 }; const byte kInstruction_cmn_eq_r13_r2_ASR_4[] = { 0x42, 0x02, 0x7d, 0x01 // cmn eq r13 r2 ASR 4 }; const byte kInstruction_cmn_pl_r10_r12_ASR_20[] = { 0x4c, 0x0a, 0x7a, 0x51 // cmn pl r10 r12 ASR 20 }; const byte kInstruction_cmn_gt_r2_r0_ASR_32[] = { 0x40, 0x00, 0x72, 0xc1 // cmn gt r2 r0 ASR 32 }; const byte kInstruction_cmn_hi_r10_r5_LSR_9[] = { 0xa5, 0x04, 0x7a, 0x81 // cmn hi r10 r5 LSR 9 }; const byte kInstruction_cmn_ge_r12_r1_ASR_27[] = { 0xc1, 0x0d, 0x7c, 0xa1 // cmn ge r12 r1 ASR 27 }; const byte kInstruction_cmn_eq_r5_r5_LSR_17[] = { 0xa5, 0x08, 0x75, 0x01 // cmn eq r5 r5 LSR 17 }; const byte kInstruction_cmn_pl_r10_r0_LSR_2[] = { 0x20, 0x01, 0x7a, 0x51 // cmn pl r10 r0 LSR 2 }; const byte kInstruction_cmn_mi_r6_r3_ASR_24[] = { 0x43, 0x0c, 0x76, 0x41 // cmn mi r6 r3 ASR 24 }; const byte kInstruction_cmn_eq_r1_r7_LSR_1[] = { 0xa7, 0x00, 0x71, 0x01 // cmn eq r1 r7 LSR 1 }; const byte kInstruction_cmn_eq_r13_r14_ASR_24[] = { 0x4e, 0x0c, 0x7d, 0x01 // cmn eq r13 r14 ASR 24 }; const byte kInstruction_cmn_pl_r0_r5_ASR_12[] = { 0x45, 0x06, 0x70, 0x51 // cmn pl r0 r5 ASR 12 }; const byte kInstruction_cmn_gt_r2_r14_ASR_17[] = { 0xce, 0x08, 0x72, 0xc1 // cmn gt r2 r14 ASR 17 }; const byte kInstruction_cmn_cs_r14_r0_LSR_15[] = { 0xa0, 0x07, 0x7e, 0x21 // cmn cs r14 r0 LSR 15 }; const byte kInstruction_cmn_ls_r14_r3_LSR_18[] = { 0x23, 0x09, 0x7e, 0x91 // cmn ls r14 r3 LSR 18 }; const byte kInstruction_cmn_le_r0_r13_ASR_29[] = { 0xcd, 0x0e, 0x70, 0xd1 // cmn le r0 r13 ASR 29 }; const byte kInstruction_cmn_ge_r5_r14_ASR_17[] = { 0xce, 0x08, 0x75, 0xa1 // cmn ge r5 r14 ASR 17 }; const byte kInstruction_cmn_vc_r7_r1_ASR_12[] = { 0x41, 0x06, 0x77, 0x71 // cmn vc r7 r1 ASR 12 }; const byte kInstruction_cmn_ne_r1_r5_ASR_23[] = { 0xc5, 0x0b, 0x71, 0x11 // cmn ne r1 r5 ASR 23 }; const byte kInstruction_cmn_ls_r5_r2_LSR_15[] = { 0xa2, 0x07, 0x75, 0x91 // cmn ls r5 r2 LSR 15 }; const byte kInstruction_cmn_le_r12_r7_ASR_18[] = { 0x47, 0x09, 0x7c, 0xd1 // cmn le r12 r7 ASR 18 }; const byte kInstruction_cmn_hi_r11_r8_ASR_8[] = { 0x48, 0x04, 0x7b, 0x81 // cmn hi r11 r8 ASR 8 }; const byte kInstruction_cmn_pl_r9_r0_LSR_16[] = { 0x20, 0x08, 0x79, 0x51 // cmn pl r9 r0 LSR 16 }; const byte kInstruction_cmn_ls_r13_r4_LSR_18[] = { 0x24, 0x09, 0x7d, 0x91 // cmn ls r13 r4 LSR 18 }; const byte kInstruction_cmn_ls_r4_r6_ASR_7[] = { 0xc6, 0x03, 0x74, 0x91 // cmn ls r4 r6 ASR 7 }; const byte kInstruction_cmn_gt_r1_r7_LSR_1[] = { 0xa7, 0x00, 0x71, 0xc1 // cmn gt r1 r7 LSR 1 }; const byte kInstruction_cmn_eq_r7_r11_LSR_24[] = { 0x2b, 0x0c, 0x77, 0x01 // cmn eq r7 r11 LSR 24 }; const byte kInstruction_cmn_al_r8_r10_LSR_7[] = { 0xaa, 0x03, 0x78, 0xe1 // cmn al r8 r10 LSR 7 }; const byte kInstruction_cmn_pl_r8_r14_LSR_32[] = { 0x2e, 0x00, 0x78, 0x51 // cmn pl r8 r14 LSR 32 }; const byte kInstruction_cmn_ne_r12_r10_LSR_9[] = { 0xaa, 0x04, 0x7c, 0x11 // cmn ne r12 r10 LSR 9 }; const byte kInstruction_cmn_vc_r2_r4_LSR_23[] = { 0xa4, 0x0b, 0x72, 0x71 // cmn vc r2 r4 LSR 23 }; const byte kInstruction_cmn_ne_r1_r3_ASR_22[] = { 0x43, 0x0b, 0x71, 0x11 // cmn ne r1 r3 ASR 22 }; const byte kInstruction_cmn_eq_r7_r1_ASR_32[] = { 0x41, 0x00, 0x77, 0x01 // cmn eq r7 r1 ASR 32 }; const byte kInstruction_cmn_ge_r7_r12_LSR_29[] = { 0xac, 0x0e, 0x77, 0xa1 // cmn ge r7 r12 LSR 29 }; const byte kInstruction_cmn_hi_r4_r6_LSR_2[] = { 0x26, 0x01, 0x74, 0x81 // cmn hi r4 r6 LSR 2 }; const byte kInstruction_cmn_hi_r12_r8_LSR_3[] = { 0xa8, 0x01, 0x7c, 0x81 // cmn hi r12 r8 LSR 3 }; const byte kInstruction_cmn_vs_r3_r9_ASR_11[] = { 0xc9, 0x05, 0x73, 0x61 // cmn vs r3 r9 ASR 11 }; const byte kInstruction_cmn_cs_r4_r9_ASR_2[] = { 0x49, 0x01, 0x74, 0x21 // cmn cs r4 r9 ASR 2 }; const byte kInstruction_cmn_cs_r7_r6_ASR_23[] = { 0xc6, 0x0b, 0x77, 0x21 // cmn cs r7 r6 ASR 23 }; const byte kInstruction_cmn_lt_r5_r8_LSR_17[] = { 0xa8, 0x08, 0x75, 0xb1 // cmn lt r5 r8 LSR 17 }; const byte kInstruction_cmn_eq_r8_r2_LSR_11[] = { 0xa2, 0x05, 0x78, 0x01 // cmn eq r8 r2 LSR 11 }; const byte kInstruction_cmn_ls_r12_r9_LSR_5[] = { 0xa9, 0x02, 0x7c, 0x91 // cmn ls r12 r9 LSR 5 }; const byte kInstruction_cmn_cc_r14_r14_ASR_15[] = { 0xce, 0x07, 0x7e, 0x31 // cmn cc r14 r14 ASR 15 }; const byte kInstruction_cmn_mi_r2_r14_LSR_10[] = { 0x2e, 0x05, 0x72, 0x41 // cmn mi r2 r14 LSR 10 }; const byte kInstruction_cmn_vs_r5_r11_ASR_29[] = { 0xcb, 0x0e, 0x75, 0x61 // cmn vs r5 r11 ASR 29 }; const byte kInstruction_cmn_gt_r12_r9_LSR_27[] = { 0xa9, 0x0d, 0x7c, 0xc1 // cmn gt r12 r9 LSR 27 }; const byte kInstruction_cmn_hi_r12_r5_LSR_11[] = { 0xa5, 0x05, 0x7c, 0x81 // cmn hi r12 r5 LSR 11 }; const byte kInstruction_cmn_cc_r12_r10_ASR_10[] = { 0x4a, 0x05, 0x7c, 0x31 // cmn cc r12 r10 ASR 10 }; const byte kInstruction_cmn_lt_r11_r1_LSR_20[] = { 0x21, 0x0a, 0x7b, 0xb1 // cmn lt r11 r1 LSR 20 }; const byte kInstruction_cmn_lt_r0_r0_ASR_25[] = { 0xc0, 0x0c, 0x70, 0xb1 // cmn lt r0 r0 ASR 25 }; const byte kInstruction_cmn_le_r10_r1_LSR_19[] = { 0xa1, 0x09, 0x7a, 0xd1 // cmn le r10 r1 LSR 19 }; const byte kInstruction_cmn_le_r5_r1_LSR_28[] = { 0x21, 0x0e, 0x75, 0xd1 // cmn le r5 r1 LSR 28 }; const byte kInstruction_cmn_cs_r6_r11_LSR_32[] = { 0x2b, 0x00, 0x76, 0x21 // cmn cs r6 r11 LSR 32 }; const byte kInstruction_cmn_vs_r10_r13_LSR_8[] = { 0x2d, 0x04, 0x7a, 0x61 // cmn vs r10 r13 LSR 8 }; const byte kInstruction_cmn_eq_r3_r4_ASR_5[] = { 0xc4, 0x02, 0x73, 0x01 // cmn eq r3 r4 ASR 5 }; const byte kInstruction_cmn_pl_r3_r13_LSR_17[] = { 0xad, 0x08, 0x73, 0x51 // cmn pl r3 r13 LSR 17 }; const byte kInstruction_cmn_vs_r3_r6_ASR_5[] = { 0xc6, 0x02, 0x73, 0x61 // cmn vs r3 r6 ASR 5 }; const byte kInstruction_cmn_al_r7_r8_ASR_3[] = { 0xc8, 0x01, 0x77, 0xe1 // cmn al r7 r8 ASR 3 }; const byte kInstruction_cmn_hi_r9_r8_ASR_16[] = { 0x48, 0x08, 0x79, 0x81 // cmn hi r9 r8 ASR 16 }; const byte kInstruction_cmn_le_r12_r5_ASR_16[] = { 0x45, 0x08, 0x7c, 0xd1 // cmn le r12 r5 ASR 16 }; const byte kInstruction_cmn_al_r12_r10_ASR_8[] = { 0x4a, 0x04, 0x7c, 0xe1 // cmn al r12 r10 ASR 8 }; const byte kInstruction_cmn_lt_r9_r9_LSR_3[] = { 0xa9, 0x01, 0x79, 0xb1 // cmn lt r9 r9 LSR 3 }; const byte kInstruction_cmn_ge_r2_r11_ASR_26[] = { 0x4b, 0x0d, 0x72, 0xa1 // cmn ge r2 r11 ASR 26 }; const byte kInstruction_cmn_cs_r13_r12_ASR_12[] = { 0x4c, 0x06, 0x7d, 0x21 // cmn cs r13 r12 ASR 12 }; const byte kInstruction_cmn_hi_r14_r2_ASR_9[] = { 0xc2, 0x04, 0x7e, 0x81 // cmn hi r14 r2 ASR 9 }; const byte kInstruction_cmn_lt_r0_r3_ASR_23[] = { 0xc3, 0x0b, 0x70, 0xb1 // cmn lt r0 r3 ASR 23 }; const byte kInstruction_cmn_eq_r6_r4_LSR_16[] = { 0x24, 0x08, 0x76, 0x01 // cmn eq r6 r4 LSR 16 }; const byte kInstruction_cmn_mi_r11_r8_LSR_20[] = { 0x28, 0x0a, 0x7b, 0x41 // cmn mi r11 r8 LSR 20 }; const byte kInstruction_cmn_vc_r0_r9_ASR_23[] = { 0xc9, 0x0b, 0x70, 0x71 // cmn vc r0 r9 ASR 23 }; const byte kInstruction_cmn_pl_r11_r0_LSR_8[] = { 0x20, 0x04, 0x7b, 0x51 // cmn pl r11 r0 LSR 8 }; const byte kInstruction_cmn_pl_r14_r9_LSR_11[] = { 0xa9, 0x05, 0x7e, 0x51 // cmn pl r14 r9 LSR 11 }; const byte kInstruction_cmn_pl_r10_r12_LSR_2[] = { 0x2c, 0x01, 0x7a, 0x51 // cmn pl r10 r12 LSR 2 }; const byte kInstruction_cmn_mi_r0_r9_ASR_23[] = { 0xc9, 0x0b, 0x70, 0x41 // cmn mi r0 r9 ASR 23 }; const byte kInstruction_cmn_ge_r12_r0_ASR_9[] = { 0xc0, 0x04, 0x7c, 0xa1 // cmn ge r12 r0 ASR 9 }; const byte kInstruction_cmn_eq_r4_r9_LSR_1[] = { 0xa9, 0x00, 0x74, 0x01 // cmn eq r4 r9 LSR 1 }; const byte kInstruction_cmn_eq_r14_r11_ASR_4[] = { 0x4b, 0x02, 0x7e, 0x01 // cmn eq r14 r11 ASR 4 }; const byte kInstruction_cmn_ge_r1_r1_ASR_23[] = { 0xc1, 0x0b, 0x71, 0xa1 // cmn ge r1 r1 ASR 23 }; const byte kInstruction_cmn_ge_r14_r2_LSR_3[] = { 0xa2, 0x01, 0x7e, 0xa1 // cmn ge r14 r2 LSR 3 }; const byte kInstruction_cmn_pl_r1_r5_ASR_16[] = { 0x45, 0x08, 0x71, 0x51 // cmn pl r1 r5 ASR 16 }; const byte kInstruction_cmn_vc_r9_r14_ASR_28[] = { 0x4e, 0x0e, 0x79, 0x71 // cmn vc r9 r14 ASR 28 }; const byte kInstruction_cmn_cs_r6_r3_LSR_9[] = { 0xa3, 0x04, 0x76, 0x21 // cmn cs r6 r3 LSR 9 }; const byte kInstruction_cmn_pl_r6_r12_ASR_32[] = { 0x4c, 0x00, 0x76, 0x51 // cmn pl r6 r12 ASR 32 }; const byte kInstruction_cmn_ne_r4_r4_ASR_32[] = { 0x44, 0x00, 0x74, 0x11 // cmn ne r4 r4 ASR 32 }; const byte kInstruction_cmn_cs_r14_r6_ASR_14[] = { 0x46, 0x07, 0x7e, 0x21 // cmn cs r14 r6 ASR 14 }; const byte kInstruction_cmn_al_r2_r5_LSR_1[] = { 0xa5, 0x00, 0x72, 0xe1 // cmn al r2 r5 LSR 1 }; const byte kInstruction_cmn_ge_r0_r1_LSR_20[] = { 0x21, 0x0a, 0x70, 0xa1 // cmn ge r0 r1 LSR 20 }; const byte kInstruction_cmn_vs_r2_r5_LSR_11[] = { 0xa5, 0x05, 0x72, 0x61 // cmn vs r2 r5 LSR 11 }; const byte kInstruction_cmn_vs_r1_r10_LSR_17[] = { 0xaa, 0x08, 0x71, 0x61 // cmn vs r1 r10 LSR 17 }; const byte kInstruction_cmn_hi_r0_r2_LSR_13[] = { 0xa2, 0x06, 0x70, 0x81 // cmn hi r0 r2 LSR 13 }; const byte kInstruction_cmn_hi_r11_r14_LSR_9[] = { 0xae, 0x04, 0x7b, 0x81 // cmn hi r11 r14 LSR 9 }; const byte kInstruction_cmn_le_r11_r9_ASR_3[] = { 0xc9, 0x01, 0x7b, 0xd1 // cmn le r11 r9 ASR 3 }; const byte kInstruction_cmn_le_r14_r13_LSR_9[] = { 0xad, 0x04, 0x7e, 0xd1 // cmn le r14 r13 LSR 9 }; const byte kInstruction_cmn_cc_r7_r4_ASR_24[] = { 0x44, 0x0c, 0x77, 0x31 // cmn cc r7 r4 ASR 24 }; const byte kInstruction_cmn_lt_r1_r3_LSR_17[] = { 0xa3, 0x08, 0x71, 0xb1 // cmn lt r1 r3 LSR 17 }; const byte kInstruction_cmn_mi_r10_r12_LSR_16[] = { 0x2c, 0x08, 0x7a, 0x41 // cmn mi r10 r12 LSR 16 }; const byte kInstruction_cmn_vc_r7_r14_LSR_11[] = { 0xae, 0x05, 0x77, 0x71 // cmn vc r7 r14 LSR 11 }; const byte kInstruction_cmn_gt_r7_r3_ASR_29[] = { 0xc3, 0x0e, 0x77, 0xc1 // cmn gt r7 r3 ASR 29 }; const byte kInstruction_cmn_mi_r7_r13_ASR_27[] = { 0xcd, 0x0d, 0x77, 0x41 // cmn mi r7 r13 ASR 27 }; const byte kInstruction_cmn_cs_r4_r10_ASR_21[] = { 0xca, 0x0a, 0x74, 0x21 // cmn cs r4 r10 ASR 21 }; const byte kInstruction_cmn_cc_r8_r9_ASR_16[] = { 0x49, 0x08, 0x78, 0x31 // cmn cc r8 r9 ASR 16 }; const byte kInstruction_cmn_gt_r1_r1_LSR_29[] = { 0xa1, 0x0e, 0x71, 0xc1 // cmn gt r1 r1 LSR 29 }; const byte kInstruction_cmn_lt_r11_r8_LSR_8[] = { 0x28, 0x04, 0x7b, 0xb1 // cmn lt r11 r8 LSR 8 }; const byte kInstruction_cmn_eq_r9_r3_ASR_24[] = { 0x43, 0x0c, 0x79, 0x01 // cmn eq r9 r3 ASR 24 }; const byte kInstruction_cmn_mi_r0_r14_LSR_13[] = { 0xae, 0x06, 0x70, 0x41 // cmn mi r0 r14 LSR 13 }; const byte kInstruction_cmn_hi_r5_r9_LSR_31[] = { 0xa9, 0x0f, 0x75, 0x81 // cmn hi r5 r9 LSR 31 }; const byte kInstruction_cmn_vc_r8_r3_LSR_25[] = { 0xa3, 0x0c, 0x78, 0x71 // cmn vc r8 r3 LSR 25 }; const byte kInstruction_cmn_le_r6_r5_ASR_28[] = { 0x45, 0x0e, 0x76, 0xd1 // cmn le r6 r5 ASR 28 }; const byte kInstruction_cmn_ne_r11_r6_ASR_24[] = { 0x46, 0x0c, 0x7b, 0x11 // cmn ne r11 r6 ASR 24 }; const byte kInstruction_cmn_vc_r11_r10_LSR_9[] = { 0xaa, 0x04, 0x7b, 0x71 // cmn vc r11 r10 LSR 9 }; const byte kInstruction_cmn_cc_r9_r4_LSR_31[] = { 0xa4, 0x0f, 0x79, 0x31 // cmn cc r9 r4 LSR 31 }; const byte kInstruction_cmn_vs_r14_r3_ASR_32[] = { 0x43, 0x00, 0x7e, 0x61 // cmn vs r14 r3 ASR 32 }; const byte kInstruction_cmn_cs_r5_r3_ASR_27[] = { 0xc3, 0x0d, 0x75, 0x21 // cmn cs r5 r3 ASR 27 }; const byte kInstruction_cmn_gt_r2_r8_ASR_18[] = { 0x48, 0x09, 0x72, 0xc1 // cmn gt r2 r8 ASR 18 }; const byte kInstruction_cmn_lt_r11_r7_LSR_4[] = { 0x27, 0x02, 0x7b, 0xb1 // cmn lt r11 r7 LSR 4 }; const byte kInstruction_cmn_eq_r11_r3_LSR_17[] = { 0xa3, 0x08, 0x7b, 0x01 // cmn eq r11 r3 LSR 17 }; const byte kInstruction_cmn_cc_r2_r12_LSR_10[] = { 0x2c, 0x05, 0x72, 0x31 // cmn cc r2 r12 LSR 10 }; const byte kInstruction_cmn_ne_r10_r12_ASR_31[] = { 0xcc, 0x0f, 0x7a, 0x11 // cmn ne r10 r12 ASR 31 }; const byte kInstruction_cmn_lt_r11_r5_LSR_4[] = { 0x25, 0x02, 0x7b, 0xb1 // cmn lt r11 r5 LSR 4 }; const byte kInstruction_cmn_gt_r3_r10_ASR_3[] = { 0xca, 0x01, 0x73, 0xc1 // cmn gt r3 r10 ASR 3 }; const byte kInstruction_cmn_ge_r7_r0_ASR_17[] = { 0xc0, 0x08, 0x77, 0xa1 // cmn ge r7 r0 ASR 17 }; const byte kInstruction_cmn_hi_r7_r14_ASR_23[] = { 0xce, 0x0b, 0x77, 0x81 // cmn hi r7 r14 ASR 23 }; const byte kInstruction_cmn_mi_r10_r14_LSR_28[] = { 0x2e, 0x0e, 0x7a, 0x41 // cmn mi r10 r14 LSR 28 }; const byte kInstruction_cmn_al_r14_r11_LSR_12[] = { 0x2b, 0x06, 0x7e, 0xe1 // cmn al r14 r11 LSR 12 }; const byte kInstruction_cmn_cc_r13_r6_ASR_23[] = { 0xc6, 0x0b, 0x7d, 0x31 // cmn cc r13 r6 ASR 23 }; const byte kInstruction_cmn_ge_r4_r0_ASR_3[] = { 0xc0, 0x01, 0x74, 0xa1 // cmn ge r4 r0 ASR 3 }; const byte kInstruction_cmn_vc_r8_r2_LSR_16[] = { 0x22, 0x08, 0x78, 0x71 // cmn vc r8 r2 LSR 16 }; const byte kInstruction_cmn_vc_r9_r8_ASR_26[] = { 0x48, 0x0d, 0x79, 0x71 // cmn vc r9 r8 ASR 26 }; const byte kInstruction_cmn_pl_r3_r4_ASR_16[] = { 0x44, 0x08, 0x73, 0x51 // cmn pl r3 r4 ASR 16 }; const byte kInstruction_cmn_vc_r12_r13_ASR_29[] = { 0xcd, 0x0e, 0x7c, 0x71 // cmn vc r12 r13 ASR 29 }; const byte kInstruction_cmn_hi_r0_r7_LSR_13[] = { 0xa7, 0x06, 0x70, 0x81 // cmn hi r0 r7 LSR 13 }; const byte kInstruction_cmn_vc_r2_r2_ASR_1[] = { 0xc2, 0x00, 0x72, 0x71 // cmn vc r2 r2 ASR 1 }; const byte kInstruction_cmn_eq_r13_r6_ASR_2[] = { 0x46, 0x01, 0x7d, 0x01 // cmn eq r13 r6 ASR 2 }; const byte kInstruction_cmn_ge_r14_r3_LSR_5[] = { 0xa3, 0x02, 0x7e, 0xa1 // cmn ge r14 r3 LSR 5 }; const byte kInstruction_cmn_cc_r2_r11_ASR_19[] = { 0xcb, 0x09, 0x72, 0x31 // cmn cc r2 r11 ASR 19 }; const byte kInstruction_cmn_eq_r14_r6_LSR_17[] = { 0xa6, 0x08, 0x7e, 0x01 // cmn eq r14 r6 LSR 17 }; const byte kInstruction_cmn_mi_r11_r2_LSR_1[] = { 0xa2, 0x00, 0x7b, 0x41 // cmn mi r11 r2 LSR 1 }; const byte kInstruction_cmn_pl_r6_r14_ASR_31[] = { 0xce, 0x0f, 0x76, 0x51 // cmn pl r6 r14 ASR 31 }; const byte kInstruction_cmn_le_r10_r11_LSR_30[] = { 0x2b, 0x0f, 0x7a, 0xd1 // cmn le r10 r11 LSR 30 }; const byte kInstruction_cmn_lt_r4_r5_ASR_30[] = { 0x45, 0x0f, 0x74, 0xb1 // cmn lt r4 r5 ASR 30 }; const byte kInstruction_cmn_ge_r11_r0_LSR_15[] = { 0xa0, 0x07, 0x7b, 0xa1 // cmn ge r11 r0 LSR 15 }; const byte kInstruction_cmn_cc_r0_r1_ASR_14[] = { 0x41, 0x07, 0x70, 0x31 // cmn cc r0 r1 ASR 14 }; const byte kInstruction_cmn_le_r10_r12_LSR_30[] = { 0x2c, 0x0f, 0x7a, 0xd1 // cmn le r10 r12 LSR 30 }; const byte kInstruction_cmn_le_r8_r2_ASR_11[] = { 0xc2, 0x05, 0x78, 0xd1 // cmn le r8 r2 ASR 11 }; const byte kInstruction_cmn_ls_r12_r7_ASR_23[] = { 0xc7, 0x0b, 0x7c, 0x91 // cmn ls r12 r7 ASR 23 }; const byte kInstruction_cmn_hi_r14_r9_ASR_31[] = { 0xc9, 0x0f, 0x7e, 0x81 // cmn hi r14 r9 ASR 31 }; const byte kInstruction_cmn_lt_r12_r4_LSR_20[] = { 0x24, 0x0a, 0x7c, 0xb1 // cmn lt r12 r4 LSR 20 }; const byte kInstruction_cmn_lt_r6_r4_ASR_12[] = { 0x44, 0x06, 0x76, 0xb1 // cmn lt r6 r4 ASR 12 }; const byte kInstruction_cmn_pl_r0_r0_ASR_21[] = { 0xc0, 0x0a, 0x70, 0x51 // cmn pl r0 r0 ASR 21 }; const byte kInstruction_cmn_ls_r2_r3_LSR_9[] = { 0xa3, 0x04, 0x72, 0x91 // cmn ls r2 r3 LSR 9 }; const byte kInstruction_cmn_le_r4_r11_LSR_22[] = { 0x2b, 0x0b, 0x74, 0xd1 // cmn le r4 r11 LSR 22 }; const byte kInstruction_cmn_gt_r9_r6_LSR_28[] = { 0x26, 0x0e, 0x79, 0xc1 // cmn gt r9 r6 LSR 28 }; const byte kInstruction_cmn_lt_r7_r6_ASR_25[] = { 0xc6, 0x0c, 0x77, 0xb1 // cmn lt r7 r6 ASR 25 }; const byte kInstruction_cmn_ne_r10_r3_LSR_25[] = { 0xa3, 0x0c, 0x7a, 0x11 // cmn ne r10 r3 LSR 25 }; const byte kInstruction_cmn_hi_r14_r11_ASR_16[] = { 0x4b, 0x08, 0x7e, 0x81 // cmn hi r14 r11 ASR 16 }; const byte kInstruction_cmn_cc_r0_r8_ASR_26[] = { 0x48, 0x0d, 0x70, 0x31 // cmn cc r0 r8 ASR 26 }; const byte kInstruction_cmn_pl_r5_r0_LSR_29[] = { 0xa0, 0x0e, 0x75, 0x51 // cmn pl r5 r0 LSR 29 }; const byte kInstruction_cmn_lt_r5_r6_ASR_9[] = { 0xc6, 0x04, 0x75, 0xb1 // cmn lt r5 r6 ASR 9 }; const byte kInstruction_cmn_vc_r11_r7_ASR_20[] = { 0x47, 0x0a, 0x7b, 0x71 // cmn vc r11 r7 ASR 20 }; const byte kInstruction_cmn_vc_r14_r13_ASR_20[] = { 0x4d, 0x0a, 0x7e, 0x71 // cmn vc r14 r13 ASR 20 }; const byte kInstruction_cmn_le_r3_r0_ASR_31[] = { 0xc0, 0x0f, 0x73, 0xd1 // cmn le r3 r0 ASR 31 }; const byte kInstruction_cmn_eq_r5_r12_LSR_18[] = { 0x2c, 0x09, 0x75, 0x01 // cmn eq r5 r12 LSR 18 }; const byte kInstruction_cmn_cs_r2_r14_ASR_3[] = { 0xce, 0x01, 0x72, 0x21 // cmn cs r2 r14 ASR 3 }; const byte kInstruction_cmn_ge_r1_r4_ASR_15[] = { 0xc4, 0x07, 0x71, 0xa1 // cmn ge r1 r4 ASR 15 }; const byte kInstruction_cmn_mi_r8_r5_ASR_9[] = { 0xc5, 0x04, 0x78, 0x41 // cmn mi r8 r5 ASR 9 }; const byte kInstruction_cmn_vc_r7_r11_LSR_9[] = { 0xab, 0x04, 0x77, 0x71 // cmn vc r7 r11 LSR 9 }; const byte kInstruction_cmn_pl_r4_r7_ASR_10[] = { 0x47, 0x05, 0x74, 0x51 // cmn pl r4 r7 ASR 10 }; const byte kInstruction_cmn_hi_r4_r13_ASR_32[] = { 0x4d, 0x00, 0x74, 0x81 // cmn hi r4 r13 ASR 32 }; const byte kInstruction_cmn_lt_r4_r10_ASR_22[] = { 0x4a, 0x0b, 0x74, 0xb1 // cmn lt r4 r10 ASR 22 }; const byte kInstruction_cmn_ne_r2_r4_LSR_23[] = { 0xa4, 0x0b, 0x72, 0x11 // cmn ne r2 r4 LSR 23 }; const byte kInstruction_cmn_lt_r12_r12_ASR_18[] = { 0x4c, 0x09, 0x7c, 0xb1 // cmn lt r12 r12 ASR 18 }; const byte kInstruction_cmn_lt_r6_r13_LSR_28[] = { 0x2d, 0x0e, 0x76, 0xb1 // cmn lt r6 r13 LSR 28 }; const byte kInstruction_cmn_vc_r8_r8_ASR_32[] = { 0x48, 0x00, 0x78, 0x71 // cmn vc r8 r8 ASR 32 }; const byte kInstruction_cmn_vs_r4_r1_LSR_24[] = { 0x21, 0x0c, 0x74, 0x61 // cmn vs r4 r1 LSR 24 }; const byte kInstruction_cmn_al_r7_r7_ASR_24[] = { 0x47, 0x0c, 0x77, 0xe1 // cmn al r7 r7 ASR 24 }; const byte kInstruction_cmn_mi_r9_r2_LSR_2[] = { 0x22, 0x01, 0x79, 0x41 // cmn mi r9 r2 LSR 2 }; const byte kInstruction_cmn_lt_r4_r6_ASR_5[] = { 0xc6, 0x02, 0x74, 0xb1 // cmn lt r4 r6 ASR 5 }; const byte kInstruction_cmn_vs_r14_r11_LSR_18[] = { 0x2b, 0x09, 0x7e, 0x61 // cmn vs r14 r11 LSR 18 }; const byte kInstruction_cmn_cc_r9_r7_LSR_12[] = { 0x27, 0x06, 0x79, 0x31 // cmn cc r9 r7 LSR 12 }; const byte kInstruction_cmn_mi_r0_r6_LSR_12[] = { 0x26, 0x06, 0x70, 0x41 // cmn mi r0 r6 LSR 12 }; const byte kInstruction_cmn_vs_r5_r0_LSR_11[] = { 0xa0, 0x05, 0x75, 0x61 // cmn vs r5 r0 LSR 11 }; const byte kInstruction_cmn_hi_r0_r14_LSR_13[] = { 0xae, 0x06, 0x70, 0x81 // cmn hi r0 r14 LSR 13 }; const byte kInstruction_cmn_vc_r1_r5_LSR_30[] = { 0x25, 0x0f, 0x71, 0x71 // cmn vc r1 r5 LSR 30 }; const byte kInstruction_cmn_vc_r14_r7_LSR_19[] = { 0xa7, 0x09, 0x7e, 0x71 // cmn vc r14 r7 LSR 19 }; const byte kInstruction_cmn_eq_r2_r14_LSR_28[] = { 0x2e, 0x0e, 0x72, 0x01 // cmn eq r2 r14 LSR 28 }; const byte kInstruction_cmn_ls_r5_r1_LSR_14[] = { 0x21, 0x07, 0x75, 0x91 // cmn ls r5 r1 LSR 14 }; const byte kInstruction_cmn_mi_r6_r12_LSR_14[] = { 0x2c, 0x07, 0x76, 0x41 // cmn mi r6 r12 LSR 14 }; const byte kInstruction_cmn_ne_r1_r0_LSR_11[] = { 0xa0, 0x05, 0x71, 0x11 // cmn ne r1 r0 LSR 11 }; const byte kInstruction_cmn_al_r14_r12_LSR_2[] = { 0x2c, 0x01, 0x7e, 0xe1 // cmn al r14 r12 LSR 2 }; const byte kInstruction_cmn_eq_r10_r10_LSR_20[] = { 0x2a, 0x0a, 0x7a, 0x01 // cmn eq r10 r10 LSR 20 }; const byte kInstruction_cmn_vc_r2_r14_ASR_29[] = { 0xce, 0x0e, 0x72, 0x71 // cmn vc r2 r14 ASR 29 }; const byte kInstruction_cmn_vc_r3_r1_ASR_22[] = { 0x41, 0x0b, 0x73, 0x71 // cmn vc r3 r1 ASR 22 }; const byte kInstruction_cmn_vs_r6_r5_ASR_2[] = { 0x45, 0x01, 0x76, 0x61 // cmn vs r6 r5 ASR 2 }; const byte kInstruction_cmn_gt_r2_r5_ASR_19[] = { 0xc5, 0x09, 0x72, 0xc1 // cmn gt r2 r5 ASR 19 }; const byte kInstruction_cmn_eq_r12_r13_LSR_16[] = { 0x2d, 0x08, 0x7c, 0x01 // cmn eq r12 r13 LSR 16 }; const byte kInstruction_cmn_ls_r7_r7_ASR_14[] = { 0x47, 0x07, 0x77, 0x91 // cmn ls r7 r7 ASR 14 }; const byte kInstruction_cmn_ge_r5_r7_ASR_15[] = { 0xc7, 0x07, 0x75, 0xa1 // cmn ge r5 r7 ASR 15 }; const byte kInstruction_cmn_al_r10_r1_ASR_29[] = { 0xc1, 0x0e, 0x7a, 0xe1 // cmn al r10 r1 ASR 29 }; const byte kInstruction_cmn_pl_r4_r11_LSR_14[] = { 0x2b, 0x07, 0x74, 0x51 // cmn pl r4 r11 LSR 14 }; const byte kInstruction_cmn_cc_r9_r13_LSR_5[] = { 0xad, 0x02, 0x79, 0x31 // cmn cc r9 r13 LSR 5 }; const byte kInstruction_cmn_ls_r10_r12_ASR_13[] = { 0xcc, 0x06, 0x7a, 0x91 // cmn ls r10 r12 ASR 13 }; const byte kInstruction_cmn_gt_r5_r11_LSR_25[] = { 0xab, 0x0c, 0x75, 0xc1 // cmn gt r5 r11 LSR 25 }; const byte kInstruction_cmn_vc_r1_r13_ASR_18[] = { 0x4d, 0x09, 0x71, 0x71 // cmn vc r1 r13 ASR 18 }; const byte kInstruction_cmn_le_r0_r4_LSR_30[] = { 0x24, 0x0f, 0x70, 0xd1 // cmn le r0 r4 LSR 30 }; const byte kInstruction_cmn_eq_r6_r1_ASR_15[] = { 0xc1, 0x07, 0x76, 0x01 // cmn eq r6 r1 ASR 15 }; const byte kInstruction_cmn_eq_r11_r6_LSR_19[] = { 0xa6, 0x09, 0x7b, 0x01 // cmn eq r11 r6 LSR 19 }; const byte kInstruction_cmn_vc_r3_r7_ASR_2[] = { 0x47, 0x01, 0x73, 0x71 // cmn vc r3 r7 ASR 2 }; const byte kInstruction_cmn_cs_r9_r13_ASR_11[] = { 0xcd, 0x05, 0x79, 0x21 // cmn cs r9 r13 ASR 11 }; const byte kInstruction_cmn_lt_r12_r3_ASR_1[] = { 0xc3, 0x00, 0x7c, 0xb1 // cmn lt r12 r3 ASR 1 }; const byte kInstruction_cmn_le_r0_r11_LSR_26[] = { 0x2b, 0x0d, 0x70, 0xd1 // cmn le r0 r11 LSR 26 }; const byte kInstruction_cmn_lt_r9_r10_LSR_23[] = { 0xaa, 0x0b, 0x79, 0xb1 // cmn lt r9 r10 LSR 23 }; const byte kInstruction_cmn_ls_r10_r13_LSR_25[] = { 0xad, 0x0c, 0x7a, 0x91 // cmn ls r10 r13 LSR 25 }; const byte kInstruction_cmn_eq_r5_r9_ASR_32[] = { 0x49, 0x00, 0x75, 0x01 // cmn eq r5 r9 ASR 32 }; const byte kInstruction_cmn_vc_r9_r12_LSR_11[] = { 0xac, 0x05, 0x79, 0x71 // cmn vc r9 r12 LSR 11 }; const byte kInstruction_cmn_lt_r12_r0_LSR_5[] = { 0xa0, 0x02, 0x7c, 0xb1 // cmn lt r12 r0 LSR 5 }; const byte kInstruction_cmn_mi_r13_r5_LSR_23[] = { 0xa5, 0x0b, 0x7d, 0x41 // cmn mi r13 r5 LSR 23 }; const byte kInstruction_cmn_ge_r13_r14_ASR_3[] = { 0xce, 0x01, 0x7d, 0xa1 // cmn ge r13 r14 ASR 3 }; const byte kInstruction_cmn_cc_r7_r6_LSR_2[] = { 0x26, 0x01, 0x77, 0x31 // cmn cc r7 r6 LSR 2 }; const byte kInstruction_cmn_ge_r11_r7_LSR_26[] = { 0x27, 0x0d, 0x7b, 0xa1 // cmn ge r11 r7 LSR 26 }; const byte kInstruction_cmn_vs_r7_r5_LSR_3[] = { 0xa5, 0x01, 0x77, 0x61 // cmn vs r7 r5 LSR 3 }; const byte kInstruction_cmn_cs_r2_r2_ASR_23[] = { 0xc2, 0x0b, 0x72, 0x21 // cmn cs r2 r2 ASR 23 }; const byte kInstruction_cmn_hi_r11_r11_ASR_15[] = { 0xcb, 0x07, 0x7b, 0x81 // cmn hi r11 r11 ASR 15 }; const byte kInstruction_cmn_ge_r14_r13_LSR_1[] = { 0xad, 0x00, 0x7e, 0xa1 // cmn ge r14 r13 LSR 1 }; const byte kInstruction_cmn_vs_r6_r13_ASR_29[] = { 0xcd, 0x0e, 0x76, 0x61 // cmn vs r6 r13 ASR 29 }; const byte kInstruction_cmn_lt_r1_r9_LSR_3[] = { 0xa9, 0x01, 0x71, 0xb1 // cmn lt r1 r9 LSR 3 }; const byte kInstruction_cmn_vs_r8_r7_ASR_4[] = { 0x47, 0x02, 0x78, 0x61 // cmn vs r8 r7 ASR 4 }; const byte kInstruction_cmn_ls_r14_r14_ASR_31[] = { 0xce, 0x0f, 0x7e, 0x91 // cmn ls r14 r14 ASR 31 }; const byte kInstruction_cmn_pl_r2_r7_ASR_2[] = { 0x47, 0x01, 0x72, 0x51 // cmn pl r2 r7 ASR 2 }; const byte kInstruction_cmn_al_r1_r2_LSR_14[] = { 0x22, 0x07, 0x71, 0xe1 // cmn al r1 r2 LSR 14 }; const byte kInstruction_cmn_ge_r7_r9_ASR_17[] = { 0xc9, 0x08, 0x77, 0xa1 // cmn ge r7 r9 ASR 17 }; const byte kInstruction_cmn_le_r2_r9_ASR_1[] = { 0xc9, 0x00, 0x72, 0xd1 // cmn le r2 r9 ASR 1 }; const byte kInstruction_cmn_cs_r7_r2_ASR_26[] = { 0x42, 0x0d, 0x77, 0x21 // cmn cs r7 r2 ASR 26 }; const byte kInstruction_cmn_eq_r6_r0_LSR_26[] = { 0x20, 0x0d, 0x76, 0x01 // cmn eq r6 r0 LSR 26 }; const byte kInstruction_cmn_gt_r10_r12_ASR_10[] = { 0x4c, 0x05, 0x7a, 0xc1 // cmn gt r10 r12 ASR 10 }; const byte kInstruction_cmn_ge_r2_r2_ASR_7[] = { 0xc2, 0x03, 0x72, 0xa1 // cmn ge r2 r2 ASR 7 }; const byte kInstruction_cmn_vc_r1_r1_ASR_5[] = { 0xc1, 0x02, 0x71, 0x71 // cmn vc r1 r1 ASR 5 }; const byte kInstruction_cmn_cs_r1_r7_ASR_7[] = { 0xc7, 0x03, 0x71, 0x21 // cmn cs r1 r7 ASR 7 }; const byte kInstruction_cmn_eq_r0_r5_LSR_21[] = { 0xa5, 0x0a, 0x70, 0x01 // cmn eq r0 r5 LSR 21 }; const byte kInstruction_cmn_lt_r13_r1_LSR_22[] = { 0x21, 0x0b, 0x7d, 0xb1 // cmn lt r13 r1 LSR 22 }; const byte kInstruction_cmn_cs_r11_r3_ASR_26[] = { 0x43, 0x0d, 0x7b, 0x21 // cmn cs r11 r3 ASR 26 }; const byte kInstruction_cmn_cs_r2_r14_LSR_13[] = { 0xae, 0x06, 0x72, 0x21 // cmn cs r2 r14 LSR 13 }; const byte kInstruction_cmn_cs_r11_r0_LSR_9[] = { 0xa0, 0x04, 0x7b, 0x21 // cmn cs r11 r0 LSR 9 }; const byte kInstruction_cmn_lt_r11_r12_LSR_29[] = { 0xac, 0x0e, 0x7b, 0xb1 // cmn lt r11 r12 LSR 29 }; const byte kInstruction_cmn_vc_r9_r0_ASR_7[] = { 0xc0, 0x03, 0x79, 0x71 // cmn vc r9 r0 ASR 7 }; const byte kInstruction_cmn_eq_r8_r12_ASR_13[] = { 0xcc, 0x06, 0x78, 0x01 // cmn eq r8 r12 ASR 13 }; const byte kInstruction_cmn_vc_r0_r8_ASR_22[] = { 0x48, 0x0b, 0x70, 0x71 // cmn vc r0 r8 ASR 22 }; const byte kInstruction_cmn_lt_r6_r4_ASR_25[] = { 0xc4, 0x0c, 0x76, 0xb1 // cmn lt r6 r4 ASR 25 }; const byte kInstruction_cmn_cs_r11_r9_ASR_2[] = { 0x49, 0x01, 0x7b, 0x21 // cmn cs r11 r9 ASR 2 }; const byte kInstruction_cmn_cs_r8_r1_ASR_1[] = { 0xc1, 0x00, 0x78, 0x21 // cmn cs r8 r1 ASR 1 }; const byte kInstruction_cmn_hi_r9_r7_ASR_26[] = { 0x47, 0x0d, 0x79, 0x81 // cmn hi r9 r7 ASR 26 }; const byte kInstruction_cmn_pl_r8_r10_ASR_6[] = { 0x4a, 0x03, 0x78, 0x51 // cmn pl r8 r10 ASR 6 }; const byte kInstruction_cmn_al_r6_r11_ASR_1[] = { 0xcb, 0x00, 0x76, 0xe1 // cmn al r6 r11 ASR 1 }; const byte kInstruction_cmn_al_r2_r8_ASR_28[] = { 0x48, 0x0e, 0x72, 0xe1 // cmn al r2 r8 ASR 28 }; const byte kInstruction_cmn_eq_r6_r10_LSR_8[] = { 0x2a, 0x04, 0x76, 0x01 // cmn eq r6 r10 LSR 8 }; const byte kInstruction_cmn_pl_r6_r6_ASR_10[] = { 0x46, 0x05, 0x76, 0x51 // cmn pl r6 r6 ASR 10 }; const byte kInstruction_cmn_ls_r10_r6_LSR_8[] = { 0x26, 0x04, 0x7a, 0x91 // cmn ls r10 r6 LSR 8 }; const byte kInstruction_cmn_ge_r7_r4_LSR_10[] = { 0x24, 0x05, 0x77, 0xa1 // cmn ge r7 r4 LSR 10 }; const byte kInstruction_cmn_pl_r3_r2_ASR_29[] = { 0xc2, 0x0e, 0x73, 0x51 // cmn pl r3 r2 ASR 29 }; const byte kInstruction_cmn_vc_r12_r4_LSR_1[] = { 0xa4, 0x00, 0x7c, 0x71 // cmn vc r12 r4 LSR 1 }; const byte kInstruction_cmn_hi_r8_r8_ASR_24[] = { 0x48, 0x0c, 0x78, 0x81 // cmn hi r8 r8 ASR 24 }; const byte kInstruction_cmn_vs_r0_r12_ASR_8[] = { 0x4c, 0x04, 0x70, 0x61 // cmn vs r0 r12 ASR 8 }; const byte kInstruction_cmn_ge_r1_r0_ASR_6[] = { 0x40, 0x03, 0x71, 0xa1 // cmn ge r1 r0 ASR 6 }; const byte kInstruction_cmn_gt_r13_r3_ASR_3[] = { 0xc3, 0x01, 0x7d, 0xc1 // cmn gt r13 r3 ASR 3 }; const byte kInstruction_cmn_cc_r0_r8_LSR_26[] = { 0x28, 0x0d, 0x70, 0x31 // cmn cc r0 r8 LSR 26 }; const byte kInstruction_cmn_eq_r8_r9_ASR_19[] = { 0xc9, 0x09, 0x78, 0x01 // cmn eq r8 r9 ASR 19 }; const byte kInstruction_cmn_eq_r3_r6_LSR_10[] = { 0x26, 0x05, 0x73, 0x01 // cmn eq r3 r6 LSR 10 }; const byte kInstruction_cmn_gt_r4_r3_ASR_24[] = { 0x43, 0x0c, 0x74, 0xc1 // cmn gt r4 r3 ASR 24 }; const byte kInstruction_cmn_pl_r12_r14_ASR_5[] = { 0xce, 0x02, 0x7c, 0x51 // cmn pl r12 r14 ASR 5 }; const byte kInstruction_cmn_cs_r7_r5_ASR_8[] = { 0x45, 0x04, 0x77, 0x21 // cmn cs r7 r5 ASR 8 }; const byte kInstruction_cmn_cc_r3_r8_LSR_21[] = { 0xa8, 0x0a, 0x73, 0x31 // cmn cc r3 r8 LSR 21 }; const byte kInstruction_cmn_ge_r5_r12_ASR_9[] = { 0xcc, 0x04, 0x75, 0xa1 // cmn ge r5 r12 ASR 9 }; const byte kInstruction_cmn_lt_r2_r4_ASR_21[] = { 0xc4, 0x0a, 0x72, 0xb1 // cmn lt r2 r4 ASR 21 }; const byte kInstruction_cmn_ne_r5_r10_LSR_24[] = { 0x2a, 0x0c, 0x75, 0x11 // cmn ne r5 r10 LSR 24 }; const byte kInstruction_cmn_eq_r10_r13_LSR_6[] = { 0x2d, 0x03, 0x7a, 0x01 // cmn eq r10 r13 LSR 6 }; const byte kInstruction_cmn_le_r2_r12_ASR_25[] = { 0xcc, 0x0c, 0x72, 0xd1 // cmn le r2 r12 ASR 25 }; const byte kInstruction_cmn_lt_r6_r1_ASR_7[] = { 0xc1, 0x03, 0x76, 0xb1 // cmn lt r6 r1 ASR 7 }; const byte kInstruction_cmn_vs_r12_r10_ASR_28[] = { 0x4a, 0x0e, 0x7c, 0x61 // cmn vs r12 r10 ASR 28 }; const byte kInstruction_cmn_ls_r10_r4_ASR_17[] = { 0xc4, 0x08, 0x7a, 0x91 // cmn ls r10 r4 ASR 17 }; const byte kInstruction_cmn_le_r3_r4_ASR_8[] = { 0x44, 0x04, 0x73, 0xd1 // cmn le r3 r4 ASR 8 }; const byte kInstruction_cmn_hi_r14_r0_LSR_31[] = { 0xa0, 0x0f, 0x7e, 0x81 // cmn hi r14 r0 LSR 31 }; const byte kInstruction_cmn_ge_r13_r2_ASR_19[] = { 0xc2, 0x09, 0x7d, 0xa1 // cmn ge r13 r2 ASR 19 }; const byte kInstruction_cmn_pl_r13_r3_ASR_10[] = { 0x43, 0x05, 0x7d, 0x51 // cmn pl r13 r3 ASR 10 }; const byte kInstruction_cmn_cc_r7_r8_ASR_32[] = { 0x48, 0x00, 0x77, 0x31 // cmn cc r7 r8 ASR 32 }; const byte kInstruction_cmn_cc_r8_r3_ASR_20[] = { 0x43, 0x0a, 0x78, 0x31 // cmn cc r8 r3 ASR 20 }; const byte kInstruction_cmn_vc_r5_r10_LSR_25[] = { 0xaa, 0x0c, 0x75, 0x71 // cmn vc r5 r10 LSR 25 }; const byte kInstruction_cmn_le_r3_r14_ASR_24[] = { 0x4e, 0x0c, 0x73, 0xd1 // cmn le r3 r14 ASR 24 }; const byte kInstruction_cmn_pl_r1_r12_LSR_12[] = { 0x2c, 0x06, 0x71, 0x51 // cmn pl r1 r12 LSR 12 }; const byte kInstruction_cmn_vs_r11_r0_ASR_11[] = { 0xc0, 0x05, 0x7b, 0x61 // cmn vs r11 r0 ASR 11 }; const byte kInstruction_cmn_eq_r14_r1_LSR_2[] = { 0x21, 0x01, 0x7e, 0x01 // cmn eq r14 r1 LSR 2 }; const byte kInstruction_cmn_ne_r2_r1_LSR_18[] = { 0x21, 0x09, 0x72, 0x11 // cmn ne r2 r1 LSR 18 }; const byte kInstruction_cmn_al_r7_r13_LSR_2[] = { 0x2d, 0x01, 0x77, 0xe1 // cmn al r7 r13 LSR 2 }; const byte kInstruction_cmn_vc_r5_r8_LSR_18[] = { 0x28, 0x09, 0x75, 0x71 // cmn vc r5 r8 LSR 18 }; const byte kInstruction_cmn_le_r1_r12_ASR_5[] = { 0xcc, 0x02, 0x71, 0xd1 // cmn le r1 r12 ASR 5 }; const byte kInstruction_cmn_pl_r6_r2_LSR_11[] = { 0xa2, 0x05, 0x76, 0x51 // cmn pl r6 r2 LSR 11 }; const byte kInstruction_cmn_cc_r7_r12_LSR_3[] = { 0xac, 0x01, 0x77, 0x31 // cmn cc r7 r12 LSR 3 }; const byte kInstruction_cmn_al_r10_r0_LSR_9[] = { 0xa0, 0x04, 0x7a, 0xe1 // cmn al r10 r0 LSR 9 }; const byte kInstruction_cmn_hi_r2_r1_LSR_29[] = { 0xa1, 0x0e, 0x72, 0x81 // cmn hi r2 r1 LSR 29 }; const byte kInstruction_cmn_lt_r3_r13_LSR_13[] = { 0xad, 0x06, 0x73, 0xb1 // cmn lt r3 r13 LSR 13 }; const byte kInstruction_cmn_mi_r13_r14_ASR_23[] = { 0xce, 0x0b, 0x7d, 0x41 // cmn mi r13 r14 ASR 23 }; const byte kInstruction_cmn_lt_r14_r14_LSR_16[] = { 0x2e, 0x08, 0x7e, 0xb1 // cmn lt r14 r14 LSR 16 }; const byte kInstruction_cmn_hi_r11_r14_ASR_8[] = { 0x4e, 0x04, 0x7b, 0x81 // cmn hi r11 r14 ASR 8 }; const byte kInstruction_cmn_eq_r4_r1_LSR_1[] = { 0xa1, 0x00, 0x74, 0x01 // cmn eq r4 r1 LSR 1 }; const byte kInstruction_cmn_ls_r14_r0_LSR_30[] = { 0x20, 0x0f, 0x7e, 0x91 // cmn ls r14 r0 LSR 30 }; const byte kInstruction_cmn_le_r1_r9_LSR_29[] = { 0xa9, 0x0e, 0x71, 0xd1 // cmn le r1 r9 LSR 29 }; const byte kInstruction_cmn_vc_r4_r2_ASR_27[] = { 0xc2, 0x0d, 0x74, 0x71 // cmn vc r4 r2 ASR 27 }; const byte kInstruction_cmn_cc_r11_r2_LSR_27[] = { 0xa2, 0x0d, 0x7b, 0x31 // cmn cc r11 r2 LSR 27 }; const byte kInstruction_cmn_lt_r13_r7_ASR_3[] = { 0xc7, 0x01, 0x7d, 0xb1 // cmn lt r13 r7 ASR 3 }; const byte kInstruction_cmn_hi_r12_r12_ASR_1[] = { 0xcc, 0x00, 0x7c, 0x81 // cmn hi r12 r12 ASR 1 }; const byte kInstruction_cmn_ne_r14_r13_LSR_25[] = { 0xad, 0x0c, 0x7e, 0x11 // cmn ne r14 r13 LSR 25 }; const byte kInstruction_cmn_mi_r8_r11_ASR_6[] = { 0x4b, 0x03, 0x78, 0x41 // cmn mi r8 r11 ASR 6 }; const byte kInstruction_cmn_pl_r7_r5_ASR_31[] = { 0xc5, 0x0f, 0x77, 0x51 // cmn pl r7 r5 ASR 31 }; const byte kInstruction_cmn_gt_r14_r6_LSR_9[] = { 0xa6, 0x04, 0x7e, 0xc1 // cmn gt r14 r6 LSR 9 }; const byte kInstruction_cmn_cc_r1_r9_LSR_7[] = { 0xa9, 0x03, 0x71, 0x31 // cmn cc r1 r9 LSR 7 }; const byte kInstruction_cmn_ge_r11_r14_LSR_10[] = { 0x2e, 0x05, 0x7b, 0xa1 // cmn ge r11 r14 LSR 10 }; const byte kInstruction_cmn_le_r7_r9_ASR_25[] = { 0xc9, 0x0c, 0x77, 0xd1 // cmn le r7 r9 ASR 25 }; const byte kInstruction_cmn_gt_r0_r14_LSR_14[] = { 0x2e, 0x07, 0x70, 0xc1 // cmn gt r0 r14 LSR 14 }; const byte kInstruction_cmn_ne_r11_r4_ASR_6[] = { 0x44, 0x03, 0x7b, 0x11 // cmn ne r11 r4 ASR 6 }; const byte kInstruction_cmn_ls_r10_r9_LSR_12[] = { 0x29, 0x06, 0x7a, 0x91 // cmn ls r10 r9 LSR 12 }; const byte kInstruction_cmn_al_r8_r0_ASR_27[] = { 0xc0, 0x0d, 0x78, 0xe1 // cmn al r8 r0 ASR 27 }; const byte kInstruction_cmn_le_r4_r7_ASR_21[] = { 0xc7, 0x0a, 0x74, 0xd1 // cmn le r4 r7 ASR 21 }; const byte kInstruction_cmn_cc_r8_r5_ASR_18[] = { 0x45, 0x09, 0x78, 0x31 // cmn cc r8 r5 ASR 18 }; const byte kInstruction_cmn_al_r4_r10_LSR_21[] = { 0xaa, 0x0a, 0x74, 0xe1 // cmn al r4 r10 LSR 21 }; const byte kInstruction_cmn_hi_r8_r5_LSR_25[] = { 0xa5, 0x0c, 0x78, 0x81 // cmn hi r8 r5 LSR 25 }; const byte kInstruction_cmn_gt_r4_r2_LSR_29[] = { 0xa2, 0x0e, 0x74, 0xc1 // cmn gt r4 r2 LSR 29 }; const byte kInstruction_cmn_al_r10_r0_ASR_1[] = { 0xc0, 0x00, 0x7a, 0xe1 // cmn al r10 r0 ASR 1 }; const byte kInstruction_cmn_ls_r1_r12_LSR_26[] = { 0x2c, 0x0d, 0x71, 0x91 // cmn ls r1 r12 LSR 26 }; const byte kInstruction_cmn_vs_r13_r6_ASR_8[] = { 0x46, 0x04, 0x7d, 0x61 // cmn vs r13 r6 ASR 8 }; const byte kInstruction_cmn_eq_r13_r12_ASR_1[] = { 0xcc, 0x00, 0x7d, 0x01 // cmn eq r13 r12 ASR 1 }; const byte kInstruction_cmn_eq_r9_r11_ASR_5[] = { 0xcb, 0x02, 0x79, 0x01 // cmn eq r9 r11 ASR 5 }; const byte kInstruction_cmn_le_r11_r2_LSR_18[] = { 0x22, 0x09, 0x7b, 0xd1 // cmn le r11 r2 LSR 18 }; const byte kInstruction_cmn_hi_r11_r0_LSR_32[] = { 0x20, 0x00, 0x7b, 0x81 // cmn hi r11 r0 LSR 32 }; const byte kInstruction_cmn_eq_r8_r5_LSR_31[] = { 0xa5, 0x0f, 0x78, 0x01 // cmn eq r8 r5 LSR 31 }; const byte kInstruction_cmn_ne_r7_r13_ASR_4[] = { 0x4d, 0x02, 0x77, 0x11 // cmn ne r7 r13 ASR 4 }; const byte kInstruction_cmn_cs_r7_r7_LSR_32[] = { 0x27, 0x00, 0x77, 0x21 // cmn cs r7 r7 LSR 32 }; const byte kInstruction_cmn_pl_r13_r5_ASR_2[] = { 0x45, 0x01, 0x7d, 0x51 // cmn pl r13 r5 ASR 2 }; const byte kInstruction_cmn_vc_r9_r2_ASR_11[] = { 0xc2, 0x05, 0x79, 0x71 // cmn vc r9 r2 ASR 11 }; const byte kInstruction_cmn_mi_r7_r7_ASR_16[] = { 0x47, 0x08, 0x77, 0x41 // cmn mi r7 r7 ASR 16 }; const byte kInstruction_cmn_vs_r2_r3_ASR_8[] = { 0x43, 0x04, 0x72, 0x61 // cmn vs r2 r3 ASR 8 }; const byte kInstruction_cmn_lt_r5_r3_LSR_19[] = { 0xa3, 0x09, 0x75, 0xb1 // cmn lt r5 r3 LSR 19 }; const byte kInstruction_cmn_al_r3_r14_ASR_20[] = { 0x4e, 0x0a, 0x73, 0xe1 // cmn al r3 r14 ASR 20 }; const byte kInstruction_cmn_ge_r10_r11_LSR_7[] = { 0xab, 0x03, 0x7a, 0xa1 // cmn ge r10 r11 LSR 7 }; const byte kInstruction_cmn_mi_r2_r14_LSR_11[] = { 0xae, 0x05, 0x72, 0x41 // cmn mi r2 r14 LSR 11 }; const byte kInstruction_cmn_mi_r3_r1_ASR_24[] = { 0x41, 0x0c, 0x73, 0x41 // cmn mi r3 r1 ASR 24 }; const byte kInstruction_cmn_lt_r7_r14_ASR_23[] = { 0xce, 0x0b, 0x77, 0xb1 // cmn lt r7 r14 ASR 23 }; const byte kInstruction_cmn_ge_r14_r3_LSR_8[] = { 0x23, 0x04, 0x7e, 0xa1 // cmn ge r14 r3 LSR 8 }; const byte kInstruction_cmn_al_r3_r3_ASR_16[] = { 0x43, 0x08, 0x73, 0xe1 // cmn al r3 r3 ASR 16 }; const byte kInstruction_cmn_cs_r12_r6_LSR_8[] = { 0x26, 0x04, 0x7c, 0x21 // cmn cs r12 r6 LSR 8 }; const byte kInstruction_cmn_ge_r9_r1_LSR_1[] = { 0xa1, 0x00, 0x79, 0xa1 // cmn ge r9 r1 LSR 1 }; const byte kInstruction_cmn_hi_r0_r2_LSR_15[] = { 0xa2, 0x07, 0x70, 0x81 // cmn hi r0 r2 LSR 15 }; const byte kInstruction_cmn_pl_r4_r3_LSR_22[] = { 0x23, 0x0b, 0x74, 0x51 // cmn pl r4 r3 LSR 22 }; const byte kInstruction_cmn_mi_r14_r1_ASR_3[] = { 0xc1, 0x01, 0x7e, 0x41 // cmn mi r14 r1 ASR 3 }; const byte kInstruction_cmn_vc_r7_r6_LSR_5[] = { 0xa6, 0x02, 0x77, 0x71 // cmn vc r7 r6 LSR 5 }; const byte kInstruction_cmn_lt_r7_r3_LSR_19[] = { 0xa3, 0x09, 0x77, 0xb1 // cmn lt r7 r3 LSR 19 }; const byte kInstruction_cmn_vc_r9_r3_LSR_4[] = { 0x23, 0x02, 0x79, 0x71 // cmn vc r9 r3 LSR 4 }; const byte kInstruction_cmn_ls_r2_r1_ASR_15[] = { 0xc1, 0x07, 0x72, 0x91 // cmn ls r2 r1 ASR 15 }; const byte kInstruction_cmn_ls_r1_r10_ASR_31[] = { 0xca, 0x0f, 0x71, 0x91 // cmn ls r1 r10 ASR 31 }; const byte kInstruction_cmn_mi_r5_r9_ASR_7[] = { 0xc9, 0x03, 0x75, 0x41 // cmn mi r5 r9 ASR 7 }; const byte kInstruction_cmn_ne_r7_r2_ASR_31[] = { 0xc2, 0x0f, 0x77, 0x11 // cmn ne r7 r2 ASR 31 }; const byte kInstruction_cmn_vc_r0_r1_LSR_20[] = { 0x21, 0x0a, 0x70, 0x71 // cmn vc r0 r1 LSR 20 }; const byte kInstruction_cmn_ge_r7_r11_ASR_9[] = { 0xcb, 0x04, 0x77, 0xa1 // cmn ge r7 r11 ASR 9 }; const byte kInstruction_cmn_vc_r8_r13_ASR_19[] = { 0xcd, 0x09, 0x78, 0x71 // cmn vc r8 r13 ASR 19 }; const byte kInstruction_cmn_hi_r7_r5_LSR_17[] = { 0xa5, 0x08, 0x77, 0x81 // cmn hi r7 r5 LSR 17 }; const byte kInstruction_cmn_mi_r11_r2_LSR_23[] = { 0xa2, 0x0b, 0x7b, 0x41 // cmn mi r11 r2 LSR 23 }; const byte kInstruction_cmn_pl_r13_r13_LSR_5[] = { 0xad, 0x02, 0x7d, 0x51 // cmn pl r13 r13 LSR 5 }; const byte kInstruction_cmn_ls_r1_r3_LSR_17[] = { 0xa3, 0x08, 0x71, 0x91 // cmn ls r1 r3 LSR 17 }; const byte kInstruction_cmn_vc_r6_r5_LSR_10[] = { 0x25, 0x05, 0x76, 0x71 // cmn vc r6 r5 LSR 10 }; const byte kInstruction_cmn_cs_r6_r6_ASR_9[] = { 0xc6, 0x04, 0x76, 0x21 // cmn cs r6 r6 ASR 9 }; const byte kInstruction_cmn_ls_r3_r8_LSR_21[] = { 0xa8, 0x0a, 0x73, 0x91 // cmn ls r3 r8 LSR 21 }; const byte kInstruction_cmn_cs_r2_r0_ASR_23[] = { 0xc0, 0x0b, 0x72, 0x21 // cmn cs r2 r0 ASR 23 }; const byte kInstruction_cmn_ge_r0_r13_LSR_29[] = { 0xad, 0x0e, 0x70, 0xa1 // cmn ge r0 r13 LSR 29 }; const byte kInstruction_cmn_lt_r13_r12_ASR_10[] = { 0x4c, 0x05, 0x7d, 0xb1 // cmn lt r13 r12 ASR 10 }; const byte kInstruction_cmn_vs_r4_r2_ASR_15[] = { 0xc2, 0x07, 0x74, 0x61 // cmn vs r4 r2 ASR 15 }; const byte kInstruction_cmn_mi_r6_r14_ASR_6[] = { 0x4e, 0x03, 0x76, 0x41 // cmn mi r6 r14 ASR 6 }; const byte kInstruction_cmn_ge_r10_r12_ASR_22[] = { 0x4c, 0x0b, 0x7a, 0xa1 // cmn ge r10 r12 ASR 22 }; const byte kInstruction_cmn_cs_r4_r5_ASR_2[] = { 0x45, 0x01, 0x74, 0x21 // cmn cs r4 r5 ASR 2 }; const byte kInstruction_cmn_cc_r5_r4_ASR_4[] = { 0x44, 0x02, 0x75, 0x31 // cmn cc r5 r4 ASR 4 }; const byte kInstruction_cmn_ge_r13_r13_LSR_30[] = { 0x2d, 0x0f, 0x7d, 0xa1 // cmn ge r13 r13 LSR 30 }; const byte kInstruction_cmn_gt_r1_r11_ASR_20[] = { 0x4b, 0x0a, 0x71, 0xc1 // cmn gt r1 r11 ASR 20 }; const byte kInstruction_cmn_cs_r2_r12_ASR_15[] = { 0xcc, 0x07, 0x72, 0x21 // cmn cs r2 r12 ASR 15 }; const byte kInstruction_cmn_le_r11_r0_ASR_32[] = { 0x40, 0x00, 0x7b, 0xd1 // cmn le r11 r0 ASR 32 }; const byte kInstruction_cmn_hi_r0_r3_ASR_9[] = { 0xc3, 0x04, 0x70, 0x81 // cmn hi r0 r3 ASR 9 }; const byte kInstruction_cmn_mi_r9_r8_LSR_10[] = { 0x28, 0x05, 0x79, 0x41 // cmn mi r9 r8 LSR 10 }; const byte kInstruction_cmn_lt_r12_r3_ASR_2[] = { 0x43, 0x01, 0x7c, 0xb1 // cmn lt r12 r3 ASR 2 }; const byte kInstruction_cmn_ne_r11_r2_LSR_32[] = { 0x22, 0x00, 0x7b, 0x11 // cmn ne r11 r2 LSR 32 }; const byte kInstruction_cmn_al_r1_r5_ASR_6[] = { 0x45, 0x03, 0x71, 0xe1 // cmn al r1 r5 ASR 6 }; const byte kInstruction_cmn_eq_r0_r3_LSR_21[] = { 0xa3, 0x0a, 0x70, 0x01 // cmn eq r0 r3 LSR 21 }; const byte kInstruction_cmn_lt_r7_r11_ASR_23[] = { 0xcb, 0x0b, 0x77, 0xb1 // cmn lt r7 r11 ASR 23 }; const byte kInstruction_cmn_hi_r8_r13_LSR_19[] = { 0xad, 0x09, 0x78, 0x81 // cmn hi r8 r13 LSR 19 }; const byte kInstruction_cmn_ne_r9_r10_LSR_18[] = { 0x2a, 0x09, 0x79, 0x11 // cmn ne r9 r10 LSR 18 }; const byte kInstruction_cmn_hi_r9_r8_ASR_24[] = { 0x48, 0x0c, 0x79, 0x81 // cmn hi r9 r8 ASR 24 }; const byte kInstruction_cmn_ls_r14_r8_ASR_9[] = { 0xc8, 0x04, 0x7e, 0x91 // cmn ls r14 r8 ASR 9 }; const byte kInstruction_cmn_al_r0_r6_LSR_1[] = { 0xa6, 0x00, 0x70, 0xe1 // cmn al r0 r6 LSR 1 }; const byte kInstruction_cmn_al_r9_r12_ASR_32[] = { 0x4c, 0x00, 0x79, 0xe1 // cmn al r9 r12 ASR 32 }; const byte kInstruction_cmn_gt_r8_r14_ASR_5[] = { 0xce, 0x02, 0x78, 0xc1 // cmn gt r8 r14 ASR 5 }; const byte kInstruction_cmn_cc_r6_r13_ASR_31[] = { 0xcd, 0x0f, 0x76, 0x31 // cmn cc r6 r13 ASR 31 }; const byte kInstruction_cmn_ne_r2_r14_ASR_10[] = { 0x4e, 0x05, 0x72, 0x11 // cmn ne r2 r14 ASR 10 }; const byte kInstruction_cmn_mi_r0_r11_ASR_22[] = { 0x4b, 0x0b, 0x70, 0x41 // cmn mi r0 r11 ASR 22 }; const byte kInstruction_cmn_mi_r1_r5_LSR_22[] = { 0x25, 0x0b, 0x71, 0x41 // cmn mi r1 r5 LSR 22 }; const byte kInstruction_cmn_pl_r5_r1_ASR_2[] = { 0x41, 0x01, 0x75, 0x51 // cmn pl r5 r1 ASR 2 }; const byte kInstruction_cmn_cs_r6_r13_LSR_9[] = { 0xad, 0x04, 0x76, 0x21 // cmn cs r6 r13 LSR 9 }; const byte kInstruction_cmn_al_r12_r5_LSR_12[] = { 0x25, 0x06, 0x7c, 0xe1 // cmn al r12 r5 LSR 12 }; const byte kInstruction_cmn_gt_r6_r12_ASR_2[] = { 0x4c, 0x01, 0x76, 0xc1 // cmn gt r6 r12 ASR 2 }; const byte kInstruction_cmn_eq_r4_r0_LSR_24[] = { 0x20, 0x0c, 0x74, 0x01 // cmn eq r4 r0 LSR 24 }; const byte kInstruction_cmn_ls_r5_r6_LSR_32[] = { 0x26, 0x00, 0x75, 0x91 // cmn ls r5 r6 LSR 32 }; const byte kInstruction_cmn_mi_r13_r7_ASR_24[] = { 0x47, 0x0c, 0x7d, 0x41 // cmn mi r13 r7 ASR 24 }; const byte kInstruction_cmn_ge_r8_r6_ASR_26[] = { 0x46, 0x0d, 0x78, 0xa1 // cmn ge r8 r6 ASR 26 }; const byte kInstruction_cmn_eq_r5_r1_ASR_24[] = { 0x41, 0x0c, 0x75, 0x01 // cmn eq r5 r1 ASR 24 }; const byte kInstruction_cmn_al_r13_r2_ASR_6[] = { 0x42, 0x03, 0x7d, 0xe1 // cmn al r13 r2 ASR 6 }; const byte kInstruction_cmn_mi_r0_r2_ASR_15[] = { 0xc2, 0x07, 0x70, 0x41 // cmn mi r0 r2 ASR 15 }; const byte kInstruction_cmn_lt_r7_r13_ASR_8[] = { 0x4d, 0x04, 0x77, 0xb1 // cmn lt r7 r13 ASR 8 }; const byte kInstruction_cmn_cs_r7_r12_ASR_27[] = { 0xcc, 0x0d, 0x77, 0x21 // cmn cs r7 r12 ASR 27 }; const byte kInstruction_cmn_ls_r9_r1_ASR_27[] = { 0xc1, 0x0d, 0x79, 0x91 // cmn ls r9 r1 ASR 27 }; const byte kInstruction_cmn_ne_r14_r7_ASR_18[] = { 0x47, 0x09, 0x7e, 0x11 // cmn ne r14 r7 ASR 18 }; const byte kInstruction_cmn_cc_r5_r14_LSR_28[] = { 0x2e, 0x0e, 0x75, 0x31 // cmn cc r5 r14 LSR 28 }; const byte kInstruction_cmn_vs_r0_r8_ASR_14[] = { 0x48, 0x07, 0x70, 0x61 // cmn vs r0 r8 ASR 14 }; const byte kInstruction_cmn_gt_r3_r7_ASR_1[] = { 0xc7, 0x00, 0x73, 0xc1 // cmn gt r3 r7 ASR 1 }; const byte kInstruction_cmn_pl_r8_r6_ASR_18[] = { 0x46, 0x09, 0x78, 0x51 // cmn pl r8 r6 ASR 18 }; const byte kInstruction_cmn_vc_r14_r5_ASR_4[] = { 0x45, 0x02, 0x7e, 0x71 // cmn vc r14 r5 ASR 4 }; const byte kInstruction_cmn_vc_r7_r5_LSR_9[] = { 0xa5, 0x04, 0x77, 0x71 // cmn vc r7 r5 LSR 9 }; const byte kInstruction_cmn_vs_r8_r1_LSR_15[] = { 0xa1, 0x07, 0x78, 0x61 // cmn vs r8 r1 LSR 15 }; const byte kInstruction_cmn_ge_r12_r13_ASR_21[] = { 0xcd, 0x0a, 0x7c, 0xa1 // cmn ge r12 r13 ASR 21 }; const byte kInstruction_cmn_vs_r8_r3_ASR_8[] = { 0x43, 0x04, 0x78, 0x61 // cmn vs r8 r3 ASR 8 }; const byte kInstruction_cmn_al_r0_r3_ASR_8[] = { 0x43, 0x04, 0x70, 0xe1 // cmn al r0 r3 ASR 8 }; const byte kInstruction_cmn_vs_r9_r7_LSR_13[] = { 0xa7, 0x06, 0x79, 0x61 // cmn vs r9 r7 LSR 13 }; const byte kInstruction_cmn_al_r7_r6_LSR_31[] = { 0xa6, 0x0f, 0x77, 0xe1 // cmn al r7 r6 LSR 31 }; const byte kInstruction_cmn_lt_r8_r1_ASR_14[] = { 0x41, 0x07, 0x78, 0xb1 // cmn lt r8 r1 ASR 14 }; const byte kInstruction_cmn_ne_r10_r13_ASR_10[] = { 0x4d, 0x05, 0x7a, 0x11 // cmn ne r10 r13 ASR 10 }; const byte kInstruction_cmn_ls_r7_r14_ASR_22[] = { 0x4e, 0x0b, 0x77, 0x91 // cmn ls r7 r14 ASR 22 }; const byte kInstruction_cmn_vs_r10_r4_LSR_9[] = { 0xa4, 0x04, 0x7a, 0x61 // cmn vs r10 r4 LSR 9 }; const byte kInstruction_cmn_eq_r0_r5_ASR_6[] = { 0x45, 0x03, 0x70, 0x01 // cmn eq r0 r5 ASR 6 }; const byte kInstruction_cmn_vc_r1_r13_LSR_27[] = { 0xad, 0x0d, 0x71, 0x71 // cmn vc r1 r13 LSR 27 }; const byte kInstruction_cmn_vc_r1_r13_ASR_19[] = { 0xcd, 0x09, 0x71, 0x71 // cmn vc r1 r13 ASR 19 }; const byte kInstruction_cmn_mi_r11_r7_ASR_27[] = { 0xc7, 0x0d, 0x7b, 0x41 // cmn mi r11 r7 ASR 27 }; const byte kInstruction_cmn_hi_r6_r0_ASR_18[] = { 0x40, 0x09, 0x76, 0x81 // cmn hi r6 r0 ASR 18 }; const byte kInstruction_cmn_vs_r12_r13_ASR_22[] = { 0x4d, 0x0b, 0x7c, 0x61 // cmn vs r12 r13 ASR 22 }; const byte kInstruction_cmn_vc_r0_r14_LSR_23[] = { 0xae, 0x0b, 0x70, 0x71 // cmn vc r0 r14 LSR 23 }; const byte kInstruction_cmn_mi_r14_r8_LSR_24[] = { 0x28, 0x0c, 0x7e, 0x41 // cmn mi r14 r8 LSR 24 }; const byte kInstruction_cmn_mi_r2_r10_LSR_13[] = { 0xaa, 0x06, 0x72, 0x41 // cmn mi r2 r10 LSR 13 }; const byte kInstruction_cmn_ne_r13_r9_LSR_17[] = { 0xa9, 0x08, 0x7d, 0x11 // cmn ne r13 r9 LSR 17 }; const byte kInstruction_cmn_cs_r1_r1_ASR_28[] = { 0x41, 0x0e, 0x71, 0x21 // cmn cs r1 r1 ASR 28 }; const byte kInstruction_cmn_eq_r14_r1_LSR_9[] = { 0xa1, 0x04, 0x7e, 0x01 // cmn eq r14 r1 LSR 9 }; const byte kInstruction_cmn_gt_r7_r11_LSR_5[] = { 0xab, 0x02, 0x77, 0xc1 // cmn gt r7 r11 LSR 5 }; const byte kInstruction_cmn_le_r4_r13_ASR_25[] = { 0xcd, 0x0c, 0x74, 0xd1 // cmn le r4 r13 ASR 25 }; const byte kInstruction_cmn_eq_r5_r11_LSR_15[] = { 0xab, 0x07, 0x75, 0x01 // cmn eq r5 r11 LSR 15 }; const byte kInstruction_cmn_mi_r10_r13_ASR_13[] = { 0xcd, 0x06, 0x7a, 0x41 // cmn mi r10 r13 ASR 13 }; const byte kInstruction_cmn_gt_r10_r7_ASR_32[] = { 0x47, 0x00, 0x7a, 0xc1 // cmn gt r10 r7 ASR 32 }; const byte kInstruction_cmn_mi_r2_r12_ASR_31[] = { 0xcc, 0x0f, 0x72, 0x41 // cmn mi r2 r12 ASR 31 }; const byte kInstruction_cmn_gt_r8_r14_ASR_31[] = { 0xce, 0x0f, 0x78, 0xc1 // cmn gt r8 r14 ASR 31 }; const byte kInstruction_cmn_hi_r6_r8_ASR_4[] = { 0x48, 0x02, 0x76, 0x81 // cmn hi r6 r8 ASR 4 }; const byte kInstruction_cmn_ne_r5_r12_ASR_23[] = { 0xcc, 0x0b, 0x75, 0x11 // cmn ne r5 r12 ASR 23 }; const byte kInstruction_cmn_eq_r4_r10_ASR_13[] = { 0xca, 0x06, 0x74, 0x01 // cmn eq r4 r10 ASR 13 }; const byte kInstruction_cmn_ls_r11_r12_LSR_21[] = { 0xac, 0x0a, 0x7b, 0x91 // cmn ls r11 r12 LSR 21 }; const byte kInstruction_cmn_mi_r8_r3_ASR_29[] = { 0xc3, 0x0e, 0x78, 0x41 // cmn mi r8 r3 ASR 29 }; const byte kInstruction_cmn_ls_r0_r13_LSR_16[] = { 0x2d, 0x08, 0x70, 0x91 // cmn ls r0 r13 LSR 16 }; const byte kInstruction_cmn_mi_r12_r7_LSR_22[] = { 0x27, 0x0b, 0x7c, 0x41 // cmn mi r12 r7 LSR 22 }; const byte kInstruction_cmn_eq_r4_r14_LSR_19[] = { 0xae, 0x09, 0x74, 0x01 // cmn eq r4 r14 LSR 19 }; const byte kInstruction_cmn_ge_r3_r7_LSR_4[] = { 0x27, 0x02, 0x73, 0xa1 // cmn ge r3 r7 LSR 4 }; const byte kInstruction_cmn_ge_r10_r10_LSR_5[] = { 0xaa, 0x02, 0x7a, 0xa1 // cmn ge r10 r10 LSR 5 }; const byte kInstruction_cmn_vc_r13_r8_LSR_30[] = { 0x28, 0x0f, 0x7d, 0x71 // cmn vc r13 r8 LSR 30 }; const byte kInstruction_cmn_mi_r2_r14_LSR_8[] = { 0x2e, 0x04, 0x72, 0x41 // cmn mi r2 r14 LSR 8 }; const byte kInstruction_cmn_hi_r14_r11_ASR_20[] = { 0x4b, 0x0a, 0x7e, 0x81 // cmn hi r14 r11 ASR 20 }; const byte kInstruction_cmn_ge_r13_r6_LSR_16[] = { 0x26, 0x08, 0x7d, 0xa1 // cmn ge r13 r6 LSR 16 }; const byte kInstruction_cmn_vs_r5_r0_LSR_16[] = { 0x20, 0x08, 0x75, 0x61 // cmn vs r5 r0 LSR 16 }; const byte kInstruction_cmn_cc_r6_r1_LSR_23[] = { 0xa1, 0x0b, 0x76, 0x31 // cmn cc r6 r1 LSR 23 }; const byte kInstruction_cmn_mi_r14_r12_LSR_16[] = { 0x2c, 0x08, 0x7e, 0x41 // cmn mi r14 r12 LSR 16 }; const byte kInstruction_cmn_vs_r1_r9_ASR_24[] = { 0x49, 0x0c, 0x71, 0x61 // cmn vs r1 r9 ASR 24 }; const byte kInstruction_cmn_vs_r9_r4_LSR_28[] = { 0x24, 0x0e, 0x79, 0x61 // cmn vs r9 r4 LSR 28 }; const byte kInstruction_cmn_cc_r12_r10_ASR_25[] = { 0xca, 0x0c, 0x7c, 0x31 // cmn cc r12 r10 ASR 25 }; const byte kInstruction_cmn_lt_r8_r7_LSR_1[] = { 0xa7, 0x00, 0x78, 0xb1 // cmn lt r8 r7 LSR 1 }; const TestResult kReferencecmn[] = { { ARRAY_SIZE(kInstruction_cmn_eq_r10_r13_LSR_23), kInstruction_cmn_eq_r10_r13_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_eq_r12_r13_LSR_13), kInstruction_cmn_eq_r12_r13_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_pl_r13_r5_LSR_12), kInstruction_cmn_pl_r13_r5_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_vc_r8_r11_ASR_13), kInstruction_cmn_vc_r8_r11_ASR_13, }, { ARRAY_SIZE(kInstruction_cmn_al_r9_r12_ASR_1), kInstruction_cmn_al_r9_r12_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_vs_r10_r3_ASR_31), kInstruction_cmn_vs_r10_r3_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_pl_r2_r11_ASR_14), kInstruction_cmn_pl_r2_r11_ASR_14, }, { ARRAY_SIZE(kInstruction_cmn_al_r11_r10_LSR_27), kInstruction_cmn_al_r11_r10_LSR_27, }, { ARRAY_SIZE(kInstruction_cmn_le_r10_r8_LSR_19), kInstruction_cmn_le_r10_r8_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_vc_r6_r2_ASR_9), kInstruction_cmn_vc_r6_r2_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_al_r10_r10_ASR_7), kInstruction_cmn_al_r10_r10_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_pl_r4_r6_LSR_3), kInstruction_cmn_pl_r4_r6_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_vs_r0_r6_ASR_19), kInstruction_cmn_vs_r0_r6_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_vc_r5_r8_LSR_5), kInstruction_cmn_vc_r5_r8_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_ne_r2_r9_LSR_26), kInstruction_cmn_ne_r2_r9_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_lt_r14_r0_LSR_12), kInstruction_cmn_lt_r14_r0_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_hi_r8_r1_ASR_15), kInstruction_cmn_hi_r8_r1_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r13_LSR_16), kInstruction_cmn_vc_r9_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_lt_r4_r11_LSR_26), kInstruction_cmn_lt_r4_r11_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_vs_r2_r2_ASR_7), kInstruction_cmn_vs_r2_r2_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_pl_r8_r8_ASR_4), kInstruction_cmn_pl_r8_r8_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_al_r10_r11_ASR_31), kInstruction_cmn_al_r10_r11_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_cs_r14_r11_ASR_3), kInstruction_cmn_cs_r14_r11_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_vs_r0_r11_LSR_30), kInstruction_cmn_vs_r0_r11_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_pl_r6_r13_LSR_18), kInstruction_cmn_pl_r6_r13_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_pl_r14_r2_ASR_32), kInstruction_cmn_pl_r14_r2_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_ls_r11_r6_ASR_23), kInstruction_cmn_ls_r11_r6_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_cc_r11_r2_ASR_2), kInstruction_cmn_cc_r11_r2_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_le_r12_r5_ASR_27), kInstruction_cmn_le_r12_r5_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_ge_r2_r5_ASR_31), kInstruction_cmn_ge_r2_r5_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_le_r0_r5_ASR_7), kInstruction_cmn_le_r0_r5_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_ge_r1_r10_ASR_28), kInstruction_cmn_ge_r1_r10_ASR_28, }, { ARRAY_SIZE(kInstruction_cmn_vc_r6_r0_LSR_13), kInstruction_cmn_vc_r6_r0_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_eq_r13_r2_ASR_4), kInstruction_cmn_eq_r13_r2_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_pl_r10_r12_ASR_20), kInstruction_cmn_pl_r10_r12_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_gt_r2_r0_ASR_32), kInstruction_cmn_gt_r2_r0_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_hi_r10_r5_LSR_9), kInstruction_cmn_hi_r10_r5_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_ge_r12_r1_ASR_27), kInstruction_cmn_ge_r12_r1_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_eq_r5_r5_LSR_17), kInstruction_cmn_eq_r5_r5_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_pl_r10_r0_LSR_2), kInstruction_cmn_pl_r10_r0_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_mi_r6_r3_ASR_24), kInstruction_cmn_mi_r6_r3_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_eq_r1_r7_LSR_1), kInstruction_cmn_eq_r1_r7_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_eq_r13_r14_ASR_24), kInstruction_cmn_eq_r13_r14_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_pl_r0_r5_ASR_12), kInstruction_cmn_pl_r0_r5_ASR_12, }, { ARRAY_SIZE(kInstruction_cmn_gt_r2_r14_ASR_17), kInstruction_cmn_gt_r2_r14_ASR_17, }, { ARRAY_SIZE(kInstruction_cmn_cs_r14_r0_LSR_15), kInstruction_cmn_cs_r14_r0_LSR_15, }, { ARRAY_SIZE(kInstruction_cmn_ls_r14_r3_LSR_18), kInstruction_cmn_ls_r14_r3_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_le_r0_r13_ASR_29), kInstruction_cmn_le_r0_r13_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_ge_r5_r14_ASR_17), kInstruction_cmn_ge_r5_r14_ASR_17, }, { ARRAY_SIZE(kInstruction_cmn_vc_r7_r1_ASR_12), kInstruction_cmn_vc_r7_r1_ASR_12, }, { ARRAY_SIZE(kInstruction_cmn_ne_r1_r5_ASR_23), kInstruction_cmn_ne_r1_r5_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_ls_r5_r2_LSR_15), kInstruction_cmn_ls_r5_r2_LSR_15, }, { ARRAY_SIZE(kInstruction_cmn_le_r12_r7_ASR_18), kInstruction_cmn_le_r12_r7_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_hi_r11_r8_ASR_8), kInstruction_cmn_hi_r11_r8_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_pl_r9_r0_LSR_16), kInstruction_cmn_pl_r9_r0_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_ls_r13_r4_LSR_18), kInstruction_cmn_ls_r13_r4_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_ls_r4_r6_ASR_7), kInstruction_cmn_ls_r4_r6_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_gt_r1_r7_LSR_1), kInstruction_cmn_gt_r1_r7_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_eq_r7_r11_LSR_24), kInstruction_cmn_eq_r7_r11_LSR_24, }, { ARRAY_SIZE(kInstruction_cmn_al_r8_r10_LSR_7), kInstruction_cmn_al_r8_r10_LSR_7, }, { ARRAY_SIZE(kInstruction_cmn_pl_r8_r14_LSR_32), kInstruction_cmn_pl_r8_r14_LSR_32, }, { ARRAY_SIZE(kInstruction_cmn_ne_r12_r10_LSR_9), kInstruction_cmn_ne_r12_r10_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_vc_r2_r4_LSR_23), kInstruction_cmn_vc_r2_r4_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_ne_r1_r3_ASR_22), kInstruction_cmn_ne_r1_r3_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_eq_r7_r1_ASR_32), kInstruction_cmn_eq_r7_r1_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_ge_r7_r12_LSR_29), kInstruction_cmn_ge_r7_r12_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_hi_r4_r6_LSR_2), kInstruction_cmn_hi_r4_r6_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_hi_r12_r8_LSR_3), kInstruction_cmn_hi_r12_r8_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_vs_r3_r9_ASR_11), kInstruction_cmn_vs_r3_r9_ASR_11, }, { ARRAY_SIZE(kInstruction_cmn_cs_r4_r9_ASR_2), kInstruction_cmn_cs_r4_r9_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_cs_r7_r6_ASR_23), kInstruction_cmn_cs_r7_r6_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_lt_r5_r8_LSR_17), kInstruction_cmn_lt_r5_r8_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_eq_r8_r2_LSR_11), kInstruction_cmn_eq_r8_r2_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_ls_r12_r9_LSR_5), kInstruction_cmn_ls_r12_r9_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_cc_r14_r14_ASR_15), kInstruction_cmn_cc_r14_r14_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_mi_r2_r14_LSR_10), kInstruction_cmn_mi_r2_r14_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_vs_r5_r11_ASR_29), kInstruction_cmn_vs_r5_r11_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_gt_r12_r9_LSR_27), kInstruction_cmn_gt_r12_r9_LSR_27, }, { ARRAY_SIZE(kInstruction_cmn_hi_r12_r5_LSR_11), kInstruction_cmn_hi_r12_r5_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_cc_r12_r10_ASR_10), kInstruction_cmn_cc_r12_r10_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_lt_r11_r1_LSR_20), kInstruction_cmn_lt_r11_r1_LSR_20, }, { ARRAY_SIZE(kInstruction_cmn_lt_r0_r0_ASR_25), kInstruction_cmn_lt_r0_r0_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_le_r10_r1_LSR_19), kInstruction_cmn_le_r10_r1_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_le_r5_r1_LSR_28), kInstruction_cmn_le_r5_r1_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_cs_r6_r11_LSR_32), kInstruction_cmn_cs_r6_r11_LSR_32, }, { ARRAY_SIZE(kInstruction_cmn_vs_r10_r13_LSR_8), kInstruction_cmn_vs_r10_r13_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_eq_r3_r4_ASR_5), kInstruction_cmn_eq_r3_r4_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_pl_r3_r13_LSR_17), kInstruction_cmn_pl_r3_r13_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_vs_r3_r6_ASR_5), kInstruction_cmn_vs_r3_r6_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_al_r7_r8_ASR_3), kInstruction_cmn_al_r7_r8_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_hi_r9_r8_ASR_16), kInstruction_cmn_hi_r9_r8_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_le_r12_r5_ASR_16), kInstruction_cmn_le_r12_r5_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_al_r12_r10_ASR_8), kInstruction_cmn_al_r12_r10_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_lt_r9_r9_LSR_3), kInstruction_cmn_lt_r9_r9_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_ge_r2_r11_ASR_26), kInstruction_cmn_ge_r2_r11_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_cs_r13_r12_ASR_12), kInstruction_cmn_cs_r13_r12_ASR_12, }, { ARRAY_SIZE(kInstruction_cmn_hi_r14_r2_ASR_9), kInstruction_cmn_hi_r14_r2_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_lt_r0_r3_ASR_23), kInstruction_cmn_lt_r0_r3_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_eq_r6_r4_LSR_16), kInstruction_cmn_eq_r6_r4_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_mi_r11_r8_LSR_20), kInstruction_cmn_mi_r11_r8_LSR_20, }, { ARRAY_SIZE(kInstruction_cmn_vc_r0_r9_ASR_23), kInstruction_cmn_vc_r0_r9_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_pl_r11_r0_LSR_8), kInstruction_cmn_pl_r11_r0_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_pl_r14_r9_LSR_11), kInstruction_cmn_pl_r14_r9_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_pl_r10_r12_LSR_2), kInstruction_cmn_pl_r10_r12_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_mi_r0_r9_ASR_23), kInstruction_cmn_mi_r0_r9_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_ge_r12_r0_ASR_9), kInstruction_cmn_ge_r12_r0_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_eq_r4_r9_LSR_1), kInstruction_cmn_eq_r4_r9_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_eq_r14_r11_ASR_4), kInstruction_cmn_eq_r14_r11_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_ge_r1_r1_ASR_23), kInstruction_cmn_ge_r1_r1_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_ge_r14_r2_LSR_3), kInstruction_cmn_ge_r14_r2_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_pl_r1_r5_ASR_16), kInstruction_cmn_pl_r1_r5_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r14_ASR_28), kInstruction_cmn_vc_r9_r14_ASR_28, }, { ARRAY_SIZE(kInstruction_cmn_cs_r6_r3_LSR_9), kInstruction_cmn_cs_r6_r3_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_pl_r6_r12_ASR_32), kInstruction_cmn_pl_r6_r12_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_ne_r4_r4_ASR_32), kInstruction_cmn_ne_r4_r4_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_cs_r14_r6_ASR_14), kInstruction_cmn_cs_r14_r6_ASR_14, }, { ARRAY_SIZE(kInstruction_cmn_al_r2_r5_LSR_1), kInstruction_cmn_al_r2_r5_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_ge_r0_r1_LSR_20), kInstruction_cmn_ge_r0_r1_LSR_20, }, { ARRAY_SIZE(kInstruction_cmn_vs_r2_r5_LSR_11), kInstruction_cmn_vs_r2_r5_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_vs_r1_r10_LSR_17), kInstruction_cmn_vs_r1_r10_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_hi_r0_r2_LSR_13), kInstruction_cmn_hi_r0_r2_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_hi_r11_r14_LSR_9), kInstruction_cmn_hi_r11_r14_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_le_r11_r9_ASR_3), kInstruction_cmn_le_r11_r9_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_le_r14_r13_LSR_9), kInstruction_cmn_le_r14_r13_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_cc_r7_r4_ASR_24), kInstruction_cmn_cc_r7_r4_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_lt_r1_r3_LSR_17), kInstruction_cmn_lt_r1_r3_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_mi_r10_r12_LSR_16), kInstruction_cmn_mi_r10_r12_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_vc_r7_r14_LSR_11), kInstruction_cmn_vc_r7_r14_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_gt_r7_r3_ASR_29), kInstruction_cmn_gt_r7_r3_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_mi_r7_r13_ASR_27), kInstruction_cmn_mi_r7_r13_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_cs_r4_r10_ASR_21), kInstruction_cmn_cs_r4_r10_ASR_21, }, { ARRAY_SIZE(kInstruction_cmn_cc_r8_r9_ASR_16), kInstruction_cmn_cc_r8_r9_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_gt_r1_r1_LSR_29), kInstruction_cmn_gt_r1_r1_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_lt_r11_r8_LSR_8), kInstruction_cmn_lt_r11_r8_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_eq_r9_r3_ASR_24), kInstruction_cmn_eq_r9_r3_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_mi_r0_r14_LSR_13), kInstruction_cmn_mi_r0_r14_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_hi_r5_r9_LSR_31), kInstruction_cmn_hi_r5_r9_LSR_31, }, { ARRAY_SIZE(kInstruction_cmn_vc_r8_r3_LSR_25), kInstruction_cmn_vc_r8_r3_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_le_r6_r5_ASR_28), kInstruction_cmn_le_r6_r5_ASR_28, }, { ARRAY_SIZE(kInstruction_cmn_ne_r11_r6_ASR_24), kInstruction_cmn_ne_r11_r6_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_vc_r11_r10_LSR_9), kInstruction_cmn_vc_r11_r10_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_cc_r9_r4_LSR_31), kInstruction_cmn_cc_r9_r4_LSR_31, }, { ARRAY_SIZE(kInstruction_cmn_vs_r14_r3_ASR_32), kInstruction_cmn_vs_r14_r3_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_cs_r5_r3_ASR_27), kInstruction_cmn_cs_r5_r3_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_gt_r2_r8_ASR_18), kInstruction_cmn_gt_r2_r8_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_lt_r11_r7_LSR_4), kInstruction_cmn_lt_r11_r7_LSR_4, }, { ARRAY_SIZE(kInstruction_cmn_eq_r11_r3_LSR_17), kInstruction_cmn_eq_r11_r3_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_cc_r2_r12_LSR_10), kInstruction_cmn_cc_r2_r12_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_ne_r10_r12_ASR_31), kInstruction_cmn_ne_r10_r12_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_lt_r11_r5_LSR_4), kInstruction_cmn_lt_r11_r5_LSR_4, }, { ARRAY_SIZE(kInstruction_cmn_gt_r3_r10_ASR_3), kInstruction_cmn_gt_r3_r10_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_ge_r7_r0_ASR_17), kInstruction_cmn_ge_r7_r0_ASR_17, }, { ARRAY_SIZE(kInstruction_cmn_hi_r7_r14_ASR_23), kInstruction_cmn_hi_r7_r14_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_mi_r10_r14_LSR_28), kInstruction_cmn_mi_r10_r14_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_al_r14_r11_LSR_12), kInstruction_cmn_al_r14_r11_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_cc_r13_r6_ASR_23), kInstruction_cmn_cc_r13_r6_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_ge_r4_r0_ASR_3), kInstruction_cmn_ge_r4_r0_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_vc_r8_r2_LSR_16), kInstruction_cmn_vc_r8_r2_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r8_ASR_26), kInstruction_cmn_vc_r9_r8_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_pl_r3_r4_ASR_16), kInstruction_cmn_pl_r3_r4_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_vc_r12_r13_ASR_29), kInstruction_cmn_vc_r12_r13_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_hi_r0_r7_LSR_13), kInstruction_cmn_hi_r0_r7_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_vc_r2_r2_ASR_1), kInstruction_cmn_vc_r2_r2_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_eq_r13_r6_ASR_2), kInstruction_cmn_eq_r13_r6_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_ge_r14_r3_LSR_5), kInstruction_cmn_ge_r14_r3_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_cc_r2_r11_ASR_19), kInstruction_cmn_cc_r2_r11_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_eq_r14_r6_LSR_17), kInstruction_cmn_eq_r14_r6_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_mi_r11_r2_LSR_1), kInstruction_cmn_mi_r11_r2_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_pl_r6_r14_ASR_31), kInstruction_cmn_pl_r6_r14_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_le_r10_r11_LSR_30), kInstruction_cmn_le_r10_r11_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_lt_r4_r5_ASR_30), kInstruction_cmn_lt_r4_r5_ASR_30, }, { ARRAY_SIZE(kInstruction_cmn_ge_r11_r0_LSR_15), kInstruction_cmn_ge_r11_r0_LSR_15, }, { ARRAY_SIZE(kInstruction_cmn_cc_r0_r1_ASR_14), kInstruction_cmn_cc_r0_r1_ASR_14, }, { ARRAY_SIZE(kInstruction_cmn_le_r10_r12_LSR_30), kInstruction_cmn_le_r10_r12_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_le_r8_r2_ASR_11), kInstruction_cmn_le_r8_r2_ASR_11, }, { ARRAY_SIZE(kInstruction_cmn_ls_r12_r7_ASR_23), kInstruction_cmn_ls_r12_r7_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_hi_r14_r9_ASR_31), kInstruction_cmn_hi_r14_r9_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_lt_r12_r4_LSR_20), kInstruction_cmn_lt_r12_r4_LSR_20, }, { ARRAY_SIZE(kInstruction_cmn_lt_r6_r4_ASR_12), kInstruction_cmn_lt_r6_r4_ASR_12, }, { ARRAY_SIZE(kInstruction_cmn_pl_r0_r0_ASR_21), kInstruction_cmn_pl_r0_r0_ASR_21, }, { ARRAY_SIZE(kInstruction_cmn_ls_r2_r3_LSR_9), kInstruction_cmn_ls_r2_r3_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_le_r4_r11_LSR_22), kInstruction_cmn_le_r4_r11_LSR_22, }, { ARRAY_SIZE(kInstruction_cmn_gt_r9_r6_LSR_28), kInstruction_cmn_gt_r9_r6_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_lt_r7_r6_ASR_25), kInstruction_cmn_lt_r7_r6_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_ne_r10_r3_LSR_25), kInstruction_cmn_ne_r10_r3_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_hi_r14_r11_ASR_16), kInstruction_cmn_hi_r14_r11_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_cc_r0_r8_ASR_26), kInstruction_cmn_cc_r0_r8_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_pl_r5_r0_LSR_29), kInstruction_cmn_pl_r5_r0_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_lt_r5_r6_ASR_9), kInstruction_cmn_lt_r5_r6_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_vc_r11_r7_ASR_20), kInstruction_cmn_vc_r11_r7_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_vc_r14_r13_ASR_20), kInstruction_cmn_vc_r14_r13_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_le_r3_r0_ASR_31), kInstruction_cmn_le_r3_r0_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_eq_r5_r12_LSR_18), kInstruction_cmn_eq_r5_r12_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_cs_r2_r14_ASR_3), kInstruction_cmn_cs_r2_r14_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_ge_r1_r4_ASR_15), kInstruction_cmn_ge_r1_r4_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_mi_r8_r5_ASR_9), kInstruction_cmn_mi_r8_r5_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_vc_r7_r11_LSR_9), kInstruction_cmn_vc_r7_r11_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_pl_r4_r7_ASR_10), kInstruction_cmn_pl_r4_r7_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_hi_r4_r13_ASR_32), kInstruction_cmn_hi_r4_r13_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_lt_r4_r10_ASR_22), kInstruction_cmn_lt_r4_r10_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_ne_r2_r4_LSR_23), kInstruction_cmn_ne_r2_r4_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_lt_r12_r12_ASR_18), kInstruction_cmn_lt_r12_r12_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_lt_r6_r13_LSR_28), kInstruction_cmn_lt_r6_r13_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_vc_r8_r8_ASR_32), kInstruction_cmn_vc_r8_r8_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_vs_r4_r1_LSR_24), kInstruction_cmn_vs_r4_r1_LSR_24, }, { ARRAY_SIZE(kInstruction_cmn_al_r7_r7_ASR_24), kInstruction_cmn_al_r7_r7_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_mi_r9_r2_LSR_2), kInstruction_cmn_mi_r9_r2_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_lt_r4_r6_ASR_5), kInstruction_cmn_lt_r4_r6_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_vs_r14_r11_LSR_18), kInstruction_cmn_vs_r14_r11_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_cc_r9_r7_LSR_12), kInstruction_cmn_cc_r9_r7_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_mi_r0_r6_LSR_12), kInstruction_cmn_mi_r0_r6_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_vs_r5_r0_LSR_11), kInstruction_cmn_vs_r5_r0_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_hi_r0_r14_LSR_13), kInstruction_cmn_hi_r0_r14_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_vc_r1_r5_LSR_30), kInstruction_cmn_vc_r1_r5_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_vc_r14_r7_LSR_19), kInstruction_cmn_vc_r14_r7_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_eq_r2_r14_LSR_28), kInstruction_cmn_eq_r2_r14_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_ls_r5_r1_LSR_14), kInstruction_cmn_ls_r5_r1_LSR_14, }, { ARRAY_SIZE(kInstruction_cmn_mi_r6_r12_LSR_14), kInstruction_cmn_mi_r6_r12_LSR_14, }, { ARRAY_SIZE(kInstruction_cmn_ne_r1_r0_LSR_11), kInstruction_cmn_ne_r1_r0_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_al_r14_r12_LSR_2), kInstruction_cmn_al_r14_r12_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_eq_r10_r10_LSR_20), kInstruction_cmn_eq_r10_r10_LSR_20, }, { ARRAY_SIZE(kInstruction_cmn_vc_r2_r14_ASR_29), kInstruction_cmn_vc_r2_r14_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_vc_r3_r1_ASR_22), kInstruction_cmn_vc_r3_r1_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_vs_r6_r5_ASR_2), kInstruction_cmn_vs_r6_r5_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_gt_r2_r5_ASR_19), kInstruction_cmn_gt_r2_r5_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_eq_r12_r13_LSR_16), kInstruction_cmn_eq_r12_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_ls_r7_r7_ASR_14), kInstruction_cmn_ls_r7_r7_ASR_14, }, { ARRAY_SIZE(kInstruction_cmn_ge_r5_r7_ASR_15), kInstruction_cmn_ge_r5_r7_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_al_r10_r1_ASR_29), kInstruction_cmn_al_r10_r1_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_pl_r4_r11_LSR_14), kInstruction_cmn_pl_r4_r11_LSR_14, }, { ARRAY_SIZE(kInstruction_cmn_cc_r9_r13_LSR_5), kInstruction_cmn_cc_r9_r13_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_ls_r10_r12_ASR_13), kInstruction_cmn_ls_r10_r12_ASR_13, }, { ARRAY_SIZE(kInstruction_cmn_gt_r5_r11_LSR_25), kInstruction_cmn_gt_r5_r11_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_vc_r1_r13_ASR_18), kInstruction_cmn_vc_r1_r13_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_le_r0_r4_LSR_30), kInstruction_cmn_le_r0_r4_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_eq_r6_r1_ASR_15), kInstruction_cmn_eq_r6_r1_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_eq_r11_r6_LSR_19), kInstruction_cmn_eq_r11_r6_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_vc_r3_r7_ASR_2), kInstruction_cmn_vc_r3_r7_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_cs_r9_r13_ASR_11), kInstruction_cmn_cs_r9_r13_ASR_11, }, { ARRAY_SIZE(kInstruction_cmn_lt_r12_r3_ASR_1), kInstruction_cmn_lt_r12_r3_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_le_r0_r11_LSR_26), kInstruction_cmn_le_r0_r11_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_lt_r9_r10_LSR_23), kInstruction_cmn_lt_r9_r10_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_ls_r10_r13_LSR_25), kInstruction_cmn_ls_r10_r13_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_eq_r5_r9_ASR_32), kInstruction_cmn_eq_r5_r9_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r12_LSR_11), kInstruction_cmn_vc_r9_r12_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_lt_r12_r0_LSR_5), kInstruction_cmn_lt_r12_r0_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_mi_r13_r5_LSR_23), kInstruction_cmn_mi_r13_r5_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_ge_r13_r14_ASR_3), kInstruction_cmn_ge_r13_r14_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_cc_r7_r6_LSR_2), kInstruction_cmn_cc_r7_r6_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_ge_r11_r7_LSR_26), kInstruction_cmn_ge_r11_r7_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_vs_r7_r5_LSR_3), kInstruction_cmn_vs_r7_r5_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_cs_r2_r2_ASR_23), kInstruction_cmn_cs_r2_r2_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_hi_r11_r11_ASR_15), kInstruction_cmn_hi_r11_r11_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_ge_r14_r13_LSR_1), kInstruction_cmn_ge_r14_r13_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_vs_r6_r13_ASR_29), kInstruction_cmn_vs_r6_r13_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_lt_r1_r9_LSR_3), kInstruction_cmn_lt_r1_r9_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_vs_r8_r7_ASR_4), kInstruction_cmn_vs_r8_r7_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_ls_r14_r14_ASR_31), kInstruction_cmn_ls_r14_r14_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_pl_r2_r7_ASR_2), kInstruction_cmn_pl_r2_r7_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_al_r1_r2_LSR_14), kInstruction_cmn_al_r1_r2_LSR_14, }, { ARRAY_SIZE(kInstruction_cmn_ge_r7_r9_ASR_17), kInstruction_cmn_ge_r7_r9_ASR_17, }, { ARRAY_SIZE(kInstruction_cmn_le_r2_r9_ASR_1), kInstruction_cmn_le_r2_r9_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_cs_r7_r2_ASR_26), kInstruction_cmn_cs_r7_r2_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_eq_r6_r0_LSR_26), kInstruction_cmn_eq_r6_r0_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_gt_r10_r12_ASR_10), kInstruction_cmn_gt_r10_r12_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_ge_r2_r2_ASR_7), kInstruction_cmn_ge_r2_r2_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_vc_r1_r1_ASR_5), kInstruction_cmn_vc_r1_r1_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_cs_r1_r7_ASR_7), kInstruction_cmn_cs_r1_r7_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_eq_r0_r5_LSR_21), kInstruction_cmn_eq_r0_r5_LSR_21, }, { ARRAY_SIZE(kInstruction_cmn_lt_r13_r1_LSR_22), kInstruction_cmn_lt_r13_r1_LSR_22, }, { ARRAY_SIZE(kInstruction_cmn_cs_r11_r3_ASR_26), kInstruction_cmn_cs_r11_r3_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_cs_r2_r14_LSR_13), kInstruction_cmn_cs_r2_r14_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_cs_r11_r0_LSR_9), kInstruction_cmn_cs_r11_r0_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_lt_r11_r12_LSR_29), kInstruction_cmn_lt_r11_r12_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r0_ASR_7), kInstruction_cmn_vc_r9_r0_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_eq_r8_r12_ASR_13), kInstruction_cmn_eq_r8_r12_ASR_13, }, { ARRAY_SIZE(kInstruction_cmn_vc_r0_r8_ASR_22), kInstruction_cmn_vc_r0_r8_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_lt_r6_r4_ASR_25), kInstruction_cmn_lt_r6_r4_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_cs_r11_r9_ASR_2), kInstruction_cmn_cs_r11_r9_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_cs_r8_r1_ASR_1), kInstruction_cmn_cs_r8_r1_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_hi_r9_r7_ASR_26), kInstruction_cmn_hi_r9_r7_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_pl_r8_r10_ASR_6), kInstruction_cmn_pl_r8_r10_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_al_r6_r11_ASR_1), kInstruction_cmn_al_r6_r11_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_al_r2_r8_ASR_28), kInstruction_cmn_al_r2_r8_ASR_28, }, { ARRAY_SIZE(kInstruction_cmn_eq_r6_r10_LSR_8), kInstruction_cmn_eq_r6_r10_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_pl_r6_r6_ASR_10), kInstruction_cmn_pl_r6_r6_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_ls_r10_r6_LSR_8), kInstruction_cmn_ls_r10_r6_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_ge_r7_r4_LSR_10), kInstruction_cmn_ge_r7_r4_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_pl_r3_r2_ASR_29), kInstruction_cmn_pl_r3_r2_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_vc_r12_r4_LSR_1), kInstruction_cmn_vc_r12_r4_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_hi_r8_r8_ASR_24), kInstruction_cmn_hi_r8_r8_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_vs_r0_r12_ASR_8), kInstruction_cmn_vs_r0_r12_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_ge_r1_r0_ASR_6), kInstruction_cmn_ge_r1_r0_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_gt_r13_r3_ASR_3), kInstruction_cmn_gt_r13_r3_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_cc_r0_r8_LSR_26), kInstruction_cmn_cc_r0_r8_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_eq_r8_r9_ASR_19), kInstruction_cmn_eq_r8_r9_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_eq_r3_r6_LSR_10), kInstruction_cmn_eq_r3_r6_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_gt_r4_r3_ASR_24), kInstruction_cmn_gt_r4_r3_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_pl_r12_r14_ASR_5), kInstruction_cmn_pl_r12_r14_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_cs_r7_r5_ASR_8), kInstruction_cmn_cs_r7_r5_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_cc_r3_r8_LSR_21), kInstruction_cmn_cc_r3_r8_LSR_21, }, { ARRAY_SIZE(kInstruction_cmn_ge_r5_r12_ASR_9), kInstruction_cmn_ge_r5_r12_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_lt_r2_r4_ASR_21), kInstruction_cmn_lt_r2_r4_ASR_21, }, { ARRAY_SIZE(kInstruction_cmn_ne_r5_r10_LSR_24), kInstruction_cmn_ne_r5_r10_LSR_24, }, { ARRAY_SIZE(kInstruction_cmn_eq_r10_r13_LSR_6), kInstruction_cmn_eq_r10_r13_LSR_6, }, { ARRAY_SIZE(kInstruction_cmn_le_r2_r12_ASR_25), kInstruction_cmn_le_r2_r12_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_lt_r6_r1_ASR_7), kInstruction_cmn_lt_r6_r1_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_vs_r12_r10_ASR_28), kInstruction_cmn_vs_r12_r10_ASR_28, }, { ARRAY_SIZE(kInstruction_cmn_ls_r10_r4_ASR_17), kInstruction_cmn_ls_r10_r4_ASR_17, }, { ARRAY_SIZE(kInstruction_cmn_le_r3_r4_ASR_8), kInstruction_cmn_le_r3_r4_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_hi_r14_r0_LSR_31), kInstruction_cmn_hi_r14_r0_LSR_31, }, { ARRAY_SIZE(kInstruction_cmn_ge_r13_r2_ASR_19), kInstruction_cmn_ge_r13_r2_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_pl_r13_r3_ASR_10), kInstruction_cmn_pl_r13_r3_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_cc_r7_r8_ASR_32), kInstruction_cmn_cc_r7_r8_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_cc_r8_r3_ASR_20), kInstruction_cmn_cc_r8_r3_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_vc_r5_r10_LSR_25), kInstruction_cmn_vc_r5_r10_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_le_r3_r14_ASR_24), kInstruction_cmn_le_r3_r14_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_pl_r1_r12_LSR_12), kInstruction_cmn_pl_r1_r12_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_vs_r11_r0_ASR_11), kInstruction_cmn_vs_r11_r0_ASR_11, }, { ARRAY_SIZE(kInstruction_cmn_eq_r14_r1_LSR_2), kInstruction_cmn_eq_r14_r1_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_ne_r2_r1_LSR_18), kInstruction_cmn_ne_r2_r1_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_al_r7_r13_LSR_2), kInstruction_cmn_al_r7_r13_LSR_2, }, { ARRAY_SIZE(kInstruction_cmn_vc_r5_r8_LSR_18), kInstruction_cmn_vc_r5_r8_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_le_r1_r12_ASR_5), kInstruction_cmn_le_r1_r12_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_pl_r6_r2_LSR_11), kInstruction_cmn_pl_r6_r2_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_cc_r7_r12_LSR_3), kInstruction_cmn_cc_r7_r12_LSR_3, }, { ARRAY_SIZE(kInstruction_cmn_al_r10_r0_LSR_9), kInstruction_cmn_al_r10_r0_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_hi_r2_r1_LSR_29), kInstruction_cmn_hi_r2_r1_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_lt_r3_r13_LSR_13), kInstruction_cmn_lt_r3_r13_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_mi_r13_r14_ASR_23), kInstruction_cmn_mi_r13_r14_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_lt_r14_r14_LSR_16), kInstruction_cmn_lt_r14_r14_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_hi_r11_r14_ASR_8), kInstruction_cmn_hi_r11_r14_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_eq_r4_r1_LSR_1), kInstruction_cmn_eq_r4_r1_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_ls_r14_r0_LSR_30), kInstruction_cmn_ls_r14_r0_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_le_r1_r9_LSR_29), kInstruction_cmn_le_r1_r9_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_vc_r4_r2_ASR_27), kInstruction_cmn_vc_r4_r2_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_cc_r11_r2_LSR_27), kInstruction_cmn_cc_r11_r2_LSR_27, }, { ARRAY_SIZE(kInstruction_cmn_lt_r13_r7_ASR_3), kInstruction_cmn_lt_r13_r7_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_hi_r12_r12_ASR_1), kInstruction_cmn_hi_r12_r12_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_ne_r14_r13_LSR_25), kInstruction_cmn_ne_r14_r13_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_mi_r8_r11_ASR_6), kInstruction_cmn_mi_r8_r11_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_pl_r7_r5_ASR_31), kInstruction_cmn_pl_r7_r5_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_gt_r14_r6_LSR_9), kInstruction_cmn_gt_r14_r6_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_cc_r1_r9_LSR_7), kInstruction_cmn_cc_r1_r9_LSR_7, }, { ARRAY_SIZE(kInstruction_cmn_ge_r11_r14_LSR_10), kInstruction_cmn_ge_r11_r14_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_le_r7_r9_ASR_25), kInstruction_cmn_le_r7_r9_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_gt_r0_r14_LSR_14), kInstruction_cmn_gt_r0_r14_LSR_14, }, { ARRAY_SIZE(kInstruction_cmn_ne_r11_r4_ASR_6), kInstruction_cmn_ne_r11_r4_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_ls_r10_r9_LSR_12), kInstruction_cmn_ls_r10_r9_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_al_r8_r0_ASR_27), kInstruction_cmn_al_r8_r0_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_le_r4_r7_ASR_21), kInstruction_cmn_le_r4_r7_ASR_21, }, { ARRAY_SIZE(kInstruction_cmn_cc_r8_r5_ASR_18), kInstruction_cmn_cc_r8_r5_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_al_r4_r10_LSR_21), kInstruction_cmn_al_r4_r10_LSR_21, }, { ARRAY_SIZE(kInstruction_cmn_hi_r8_r5_LSR_25), kInstruction_cmn_hi_r8_r5_LSR_25, }, { ARRAY_SIZE(kInstruction_cmn_gt_r4_r2_LSR_29), kInstruction_cmn_gt_r4_r2_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_al_r10_r0_ASR_1), kInstruction_cmn_al_r10_r0_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_ls_r1_r12_LSR_26), kInstruction_cmn_ls_r1_r12_LSR_26, }, { ARRAY_SIZE(kInstruction_cmn_vs_r13_r6_ASR_8), kInstruction_cmn_vs_r13_r6_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_eq_r13_r12_ASR_1), kInstruction_cmn_eq_r13_r12_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_eq_r9_r11_ASR_5), kInstruction_cmn_eq_r9_r11_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_le_r11_r2_LSR_18), kInstruction_cmn_le_r11_r2_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_hi_r11_r0_LSR_32), kInstruction_cmn_hi_r11_r0_LSR_32, }, { ARRAY_SIZE(kInstruction_cmn_eq_r8_r5_LSR_31), kInstruction_cmn_eq_r8_r5_LSR_31, }, { ARRAY_SIZE(kInstruction_cmn_ne_r7_r13_ASR_4), kInstruction_cmn_ne_r7_r13_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_cs_r7_r7_LSR_32), kInstruction_cmn_cs_r7_r7_LSR_32, }, { ARRAY_SIZE(kInstruction_cmn_pl_r13_r5_ASR_2), kInstruction_cmn_pl_r13_r5_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r2_ASR_11), kInstruction_cmn_vc_r9_r2_ASR_11, }, { ARRAY_SIZE(kInstruction_cmn_mi_r7_r7_ASR_16), kInstruction_cmn_mi_r7_r7_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_vs_r2_r3_ASR_8), kInstruction_cmn_vs_r2_r3_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_lt_r5_r3_LSR_19), kInstruction_cmn_lt_r5_r3_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_al_r3_r14_ASR_20), kInstruction_cmn_al_r3_r14_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_ge_r10_r11_LSR_7), kInstruction_cmn_ge_r10_r11_LSR_7, }, { ARRAY_SIZE(kInstruction_cmn_mi_r2_r14_LSR_11), kInstruction_cmn_mi_r2_r14_LSR_11, }, { ARRAY_SIZE(kInstruction_cmn_mi_r3_r1_ASR_24), kInstruction_cmn_mi_r3_r1_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_lt_r7_r14_ASR_23), kInstruction_cmn_lt_r7_r14_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_ge_r14_r3_LSR_8), kInstruction_cmn_ge_r14_r3_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_al_r3_r3_ASR_16), kInstruction_cmn_al_r3_r3_ASR_16, }, { ARRAY_SIZE(kInstruction_cmn_cs_r12_r6_LSR_8), kInstruction_cmn_cs_r12_r6_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_ge_r9_r1_LSR_1), kInstruction_cmn_ge_r9_r1_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_hi_r0_r2_LSR_15), kInstruction_cmn_hi_r0_r2_LSR_15, }, { ARRAY_SIZE(kInstruction_cmn_pl_r4_r3_LSR_22), kInstruction_cmn_pl_r4_r3_LSR_22, }, { ARRAY_SIZE(kInstruction_cmn_mi_r14_r1_ASR_3), kInstruction_cmn_mi_r14_r1_ASR_3, }, { ARRAY_SIZE(kInstruction_cmn_vc_r7_r6_LSR_5), kInstruction_cmn_vc_r7_r6_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_lt_r7_r3_LSR_19), kInstruction_cmn_lt_r7_r3_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_vc_r9_r3_LSR_4), kInstruction_cmn_vc_r9_r3_LSR_4, }, { ARRAY_SIZE(kInstruction_cmn_ls_r2_r1_ASR_15), kInstruction_cmn_ls_r2_r1_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_ls_r1_r10_ASR_31), kInstruction_cmn_ls_r1_r10_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_mi_r5_r9_ASR_7), kInstruction_cmn_mi_r5_r9_ASR_7, }, { ARRAY_SIZE(kInstruction_cmn_ne_r7_r2_ASR_31), kInstruction_cmn_ne_r7_r2_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_vc_r0_r1_LSR_20), kInstruction_cmn_vc_r0_r1_LSR_20, }, { ARRAY_SIZE(kInstruction_cmn_ge_r7_r11_ASR_9), kInstruction_cmn_ge_r7_r11_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_vc_r8_r13_ASR_19), kInstruction_cmn_vc_r8_r13_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_hi_r7_r5_LSR_17), kInstruction_cmn_hi_r7_r5_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_mi_r11_r2_LSR_23), kInstruction_cmn_mi_r11_r2_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_pl_r13_r13_LSR_5), kInstruction_cmn_pl_r13_r13_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_ls_r1_r3_LSR_17), kInstruction_cmn_ls_r1_r3_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_vc_r6_r5_LSR_10), kInstruction_cmn_vc_r6_r5_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_cs_r6_r6_ASR_9), kInstruction_cmn_cs_r6_r6_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_ls_r3_r8_LSR_21), kInstruction_cmn_ls_r3_r8_LSR_21, }, { ARRAY_SIZE(kInstruction_cmn_cs_r2_r0_ASR_23), kInstruction_cmn_cs_r2_r0_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_ge_r0_r13_LSR_29), kInstruction_cmn_ge_r0_r13_LSR_29, }, { ARRAY_SIZE(kInstruction_cmn_lt_r13_r12_ASR_10), kInstruction_cmn_lt_r13_r12_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_vs_r4_r2_ASR_15), kInstruction_cmn_vs_r4_r2_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_mi_r6_r14_ASR_6), kInstruction_cmn_mi_r6_r14_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_ge_r10_r12_ASR_22), kInstruction_cmn_ge_r10_r12_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_cs_r4_r5_ASR_2), kInstruction_cmn_cs_r4_r5_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_cc_r5_r4_ASR_4), kInstruction_cmn_cc_r5_r4_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_ge_r13_r13_LSR_30), kInstruction_cmn_ge_r13_r13_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_gt_r1_r11_ASR_20), kInstruction_cmn_gt_r1_r11_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_cs_r2_r12_ASR_15), kInstruction_cmn_cs_r2_r12_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_le_r11_r0_ASR_32), kInstruction_cmn_le_r11_r0_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_hi_r0_r3_ASR_9), kInstruction_cmn_hi_r0_r3_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_mi_r9_r8_LSR_10), kInstruction_cmn_mi_r9_r8_LSR_10, }, { ARRAY_SIZE(kInstruction_cmn_lt_r12_r3_ASR_2), kInstruction_cmn_lt_r12_r3_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_ne_r11_r2_LSR_32), kInstruction_cmn_ne_r11_r2_LSR_32, }, { ARRAY_SIZE(kInstruction_cmn_al_r1_r5_ASR_6), kInstruction_cmn_al_r1_r5_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_eq_r0_r3_LSR_21), kInstruction_cmn_eq_r0_r3_LSR_21, }, { ARRAY_SIZE(kInstruction_cmn_lt_r7_r11_ASR_23), kInstruction_cmn_lt_r7_r11_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_hi_r8_r13_LSR_19), kInstruction_cmn_hi_r8_r13_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_ne_r9_r10_LSR_18), kInstruction_cmn_ne_r9_r10_LSR_18, }, { ARRAY_SIZE(kInstruction_cmn_hi_r9_r8_ASR_24), kInstruction_cmn_hi_r9_r8_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_ls_r14_r8_ASR_9), kInstruction_cmn_ls_r14_r8_ASR_9, }, { ARRAY_SIZE(kInstruction_cmn_al_r0_r6_LSR_1), kInstruction_cmn_al_r0_r6_LSR_1, }, { ARRAY_SIZE(kInstruction_cmn_al_r9_r12_ASR_32), kInstruction_cmn_al_r9_r12_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_gt_r8_r14_ASR_5), kInstruction_cmn_gt_r8_r14_ASR_5, }, { ARRAY_SIZE(kInstruction_cmn_cc_r6_r13_ASR_31), kInstruction_cmn_cc_r6_r13_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_ne_r2_r14_ASR_10), kInstruction_cmn_ne_r2_r14_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_mi_r0_r11_ASR_22), kInstruction_cmn_mi_r0_r11_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_mi_r1_r5_LSR_22), kInstruction_cmn_mi_r1_r5_LSR_22, }, { ARRAY_SIZE(kInstruction_cmn_pl_r5_r1_ASR_2), kInstruction_cmn_pl_r5_r1_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_cs_r6_r13_LSR_9), kInstruction_cmn_cs_r6_r13_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_al_r12_r5_LSR_12), kInstruction_cmn_al_r12_r5_LSR_12, }, { ARRAY_SIZE(kInstruction_cmn_gt_r6_r12_ASR_2), kInstruction_cmn_gt_r6_r12_ASR_2, }, { ARRAY_SIZE(kInstruction_cmn_eq_r4_r0_LSR_24), kInstruction_cmn_eq_r4_r0_LSR_24, }, { ARRAY_SIZE(kInstruction_cmn_ls_r5_r6_LSR_32), kInstruction_cmn_ls_r5_r6_LSR_32, }, { ARRAY_SIZE(kInstruction_cmn_mi_r13_r7_ASR_24), kInstruction_cmn_mi_r13_r7_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_ge_r8_r6_ASR_26), kInstruction_cmn_ge_r8_r6_ASR_26, }, { ARRAY_SIZE(kInstruction_cmn_eq_r5_r1_ASR_24), kInstruction_cmn_eq_r5_r1_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_al_r13_r2_ASR_6), kInstruction_cmn_al_r13_r2_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_mi_r0_r2_ASR_15), kInstruction_cmn_mi_r0_r2_ASR_15, }, { ARRAY_SIZE(kInstruction_cmn_lt_r7_r13_ASR_8), kInstruction_cmn_lt_r7_r13_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_cs_r7_r12_ASR_27), kInstruction_cmn_cs_r7_r12_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_ls_r9_r1_ASR_27), kInstruction_cmn_ls_r9_r1_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_ne_r14_r7_ASR_18), kInstruction_cmn_ne_r14_r7_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_cc_r5_r14_LSR_28), kInstruction_cmn_cc_r5_r14_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_vs_r0_r8_ASR_14), kInstruction_cmn_vs_r0_r8_ASR_14, }, { ARRAY_SIZE(kInstruction_cmn_gt_r3_r7_ASR_1), kInstruction_cmn_gt_r3_r7_ASR_1, }, { ARRAY_SIZE(kInstruction_cmn_pl_r8_r6_ASR_18), kInstruction_cmn_pl_r8_r6_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_vc_r14_r5_ASR_4), kInstruction_cmn_vc_r14_r5_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_vc_r7_r5_LSR_9), kInstruction_cmn_vc_r7_r5_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_vs_r8_r1_LSR_15), kInstruction_cmn_vs_r8_r1_LSR_15, }, { ARRAY_SIZE(kInstruction_cmn_ge_r12_r13_ASR_21), kInstruction_cmn_ge_r12_r13_ASR_21, }, { ARRAY_SIZE(kInstruction_cmn_vs_r8_r3_ASR_8), kInstruction_cmn_vs_r8_r3_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_al_r0_r3_ASR_8), kInstruction_cmn_al_r0_r3_ASR_8, }, { ARRAY_SIZE(kInstruction_cmn_vs_r9_r7_LSR_13), kInstruction_cmn_vs_r9_r7_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_al_r7_r6_LSR_31), kInstruction_cmn_al_r7_r6_LSR_31, }, { ARRAY_SIZE(kInstruction_cmn_lt_r8_r1_ASR_14), kInstruction_cmn_lt_r8_r1_ASR_14, }, { ARRAY_SIZE(kInstruction_cmn_ne_r10_r13_ASR_10), kInstruction_cmn_ne_r10_r13_ASR_10, }, { ARRAY_SIZE(kInstruction_cmn_ls_r7_r14_ASR_22), kInstruction_cmn_ls_r7_r14_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_vs_r10_r4_LSR_9), kInstruction_cmn_vs_r10_r4_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_eq_r0_r5_ASR_6), kInstruction_cmn_eq_r0_r5_ASR_6, }, { ARRAY_SIZE(kInstruction_cmn_vc_r1_r13_LSR_27), kInstruction_cmn_vc_r1_r13_LSR_27, }, { ARRAY_SIZE(kInstruction_cmn_vc_r1_r13_ASR_19), kInstruction_cmn_vc_r1_r13_ASR_19, }, { ARRAY_SIZE(kInstruction_cmn_mi_r11_r7_ASR_27), kInstruction_cmn_mi_r11_r7_ASR_27, }, { ARRAY_SIZE(kInstruction_cmn_hi_r6_r0_ASR_18), kInstruction_cmn_hi_r6_r0_ASR_18, }, { ARRAY_SIZE(kInstruction_cmn_vs_r12_r13_ASR_22), kInstruction_cmn_vs_r12_r13_ASR_22, }, { ARRAY_SIZE(kInstruction_cmn_vc_r0_r14_LSR_23), kInstruction_cmn_vc_r0_r14_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_mi_r14_r8_LSR_24), kInstruction_cmn_mi_r14_r8_LSR_24, }, { ARRAY_SIZE(kInstruction_cmn_mi_r2_r10_LSR_13), kInstruction_cmn_mi_r2_r10_LSR_13, }, { ARRAY_SIZE(kInstruction_cmn_ne_r13_r9_LSR_17), kInstruction_cmn_ne_r13_r9_LSR_17, }, { ARRAY_SIZE(kInstruction_cmn_cs_r1_r1_ASR_28), kInstruction_cmn_cs_r1_r1_ASR_28, }, { ARRAY_SIZE(kInstruction_cmn_eq_r14_r1_LSR_9), kInstruction_cmn_eq_r14_r1_LSR_9, }, { ARRAY_SIZE(kInstruction_cmn_gt_r7_r11_LSR_5), kInstruction_cmn_gt_r7_r11_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_le_r4_r13_ASR_25), kInstruction_cmn_le_r4_r13_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_eq_r5_r11_LSR_15), kInstruction_cmn_eq_r5_r11_LSR_15, }, { ARRAY_SIZE(kInstruction_cmn_mi_r10_r13_ASR_13), kInstruction_cmn_mi_r10_r13_ASR_13, }, { ARRAY_SIZE(kInstruction_cmn_gt_r10_r7_ASR_32), kInstruction_cmn_gt_r10_r7_ASR_32, }, { ARRAY_SIZE(kInstruction_cmn_mi_r2_r12_ASR_31), kInstruction_cmn_mi_r2_r12_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_gt_r8_r14_ASR_31), kInstruction_cmn_gt_r8_r14_ASR_31, }, { ARRAY_SIZE(kInstruction_cmn_hi_r6_r8_ASR_4), kInstruction_cmn_hi_r6_r8_ASR_4, }, { ARRAY_SIZE(kInstruction_cmn_ne_r5_r12_ASR_23), kInstruction_cmn_ne_r5_r12_ASR_23, }, { ARRAY_SIZE(kInstruction_cmn_eq_r4_r10_ASR_13), kInstruction_cmn_eq_r4_r10_ASR_13, }, { ARRAY_SIZE(kInstruction_cmn_ls_r11_r12_LSR_21), kInstruction_cmn_ls_r11_r12_LSR_21, }, { ARRAY_SIZE(kInstruction_cmn_mi_r8_r3_ASR_29), kInstruction_cmn_mi_r8_r3_ASR_29, }, { ARRAY_SIZE(kInstruction_cmn_ls_r0_r13_LSR_16), kInstruction_cmn_ls_r0_r13_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_mi_r12_r7_LSR_22), kInstruction_cmn_mi_r12_r7_LSR_22, }, { ARRAY_SIZE(kInstruction_cmn_eq_r4_r14_LSR_19), kInstruction_cmn_eq_r4_r14_LSR_19, }, { ARRAY_SIZE(kInstruction_cmn_ge_r3_r7_LSR_4), kInstruction_cmn_ge_r3_r7_LSR_4, }, { ARRAY_SIZE(kInstruction_cmn_ge_r10_r10_LSR_5), kInstruction_cmn_ge_r10_r10_LSR_5, }, { ARRAY_SIZE(kInstruction_cmn_vc_r13_r8_LSR_30), kInstruction_cmn_vc_r13_r8_LSR_30, }, { ARRAY_SIZE(kInstruction_cmn_mi_r2_r14_LSR_8), kInstruction_cmn_mi_r2_r14_LSR_8, }, { ARRAY_SIZE(kInstruction_cmn_hi_r14_r11_ASR_20), kInstruction_cmn_hi_r14_r11_ASR_20, }, { ARRAY_SIZE(kInstruction_cmn_ge_r13_r6_LSR_16), kInstruction_cmn_ge_r13_r6_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_vs_r5_r0_LSR_16), kInstruction_cmn_vs_r5_r0_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_cc_r6_r1_LSR_23), kInstruction_cmn_cc_r6_r1_LSR_23, }, { ARRAY_SIZE(kInstruction_cmn_mi_r14_r12_LSR_16), kInstruction_cmn_mi_r14_r12_LSR_16, }, { ARRAY_SIZE(kInstruction_cmn_vs_r1_r9_ASR_24), kInstruction_cmn_vs_r1_r9_ASR_24, }, { ARRAY_SIZE(kInstruction_cmn_vs_r9_r4_LSR_28), kInstruction_cmn_vs_r9_r4_LSR_28, }, { ARRAY_SIZE(kInstruction_cmn_cc_r12_r10_ASR_25), kInstruction_cmn_cc_r12_r10_ASR_25, }, { ARRAY_SIZE(kInstruction_cmn_lt_r8_r7_LSR_1), kInstruction_cmn_lt_r8_r7_LSR_1, }, }; #endif // VIXL_ASSEMBLER_COND_RD_OPERAND_RN_SHIFT_AMOUNT_1TO32_A32_CMN_H_
28.759955
80
0.734267
9a4ae7c33431a2329677063db022ccde36617239
7,057
c
C
src/apdu/messages/sign_transaction.c
pscott/app-symbol
3b50caaf8368d7b43e032a44579be7a36e648512
[ "Apache-2.0" ]
null
null
null
src/apdu/messages/sign_transaction.c
pscott/app-symbol
3b50caaf8368d7b43e032a44579be7a36e648512
[ "Apache-2.0" ]
null
null
null
src/apdu/messages/sign_transaction.c
pscott/app-symbol
3b50caaf8368d7b43e032a44579be7a36e648512
[ "Apache-2.0" ]
null
null
null
/******************************************************************************* * XYM Wallet * (c) 2020 Ledger * (c) 2020 FDS * * 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 "sign_transaction.h" #include <os.h> #include "global.h" #include "xym/xym_helpers.h" #include "ui/main/idle_menu.h" #include "transaction/transaction.h" #include "printers.h" #define PREFIX_LENGTH 4 parse_context_t parseContext; void sign_transaction() { uint8_t privateKeyData[64]; cx_ecfp_private_key_t privateKey; uint32_t tx = 0; if (signState != PENDING_REVIEW) { reset_transaction_context(); display_idle_menu(); return; } // Abort if we accidentally end up here again after the transaction has already been signed if (parseContext.data == NULL) { display_idle_menu(); return; } BEGIN_TRY { TRY { io_seproxyhal_io_heartbeat(); os_perso_derive_node_bip32( CX_CURVE_256K1, transactionContext.bip32Path, transactionContext.pathLength, privateKeyData, NULL); cx_ecfp_init_private_key(transactionContext.curve, privateKeyData, XYM_PRIVATE_KEY_LENGTH, &privateKey); explicit_bzero(privateKeyData, sizeof(privateKeyData)); io_seproxyhal_io_heartbeat(); tx = (uint32_t) cx_eddsa_sign(&privateKey, CX_LAST, CX_SHA512, transactionContext.rawTx, transactionContext.rawTxLength, NULL, 0, G_io_apdu_buffer, IO_APDU_BUFFER_SIZE, NULL); } CATCH_OTHER(e) { THROW(e); } FINALLY { explicit_bzero(privateKeyData, sizeof(privateKeyData)); explicit_bzero(&privateKey, sizeof(privateKey)); // Always reset transaction context after a transaction has been signed reset_transaction_context(); } } END_TRY G_io_apdu_buffer[tx++] = 0x90; G_io_apdu_buffer[tx++] = 0x00; // Send back the response, do not restart the event loop io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); // Display back the original UX display_idle_menu(); } void reject_transaction() { if (signState != PENDING_REVIEW) { reset_transaction_context(); display_idle_menu(); return; } G_io_apdu_buffer[0] = 0x69; G_io_apdu_buffer[1] = 0x85; // Send back the response, do not restart the event loop io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, 2); // Reset transaction context and display back the original UX reset_transaction_context(); display_idle_menu(); } bool isFirst(uint8_t p1) { //return (p1 & P1_CONFIRM) == 0; return (p1 & P1_MASK_ORDER) == 0; } bool hasMore(uint8_t p1) { // return (p1 & P1_MORE) != 0; return (p1 & P1_MASK_MORE) != 0; } void handle_first_packet(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint8_t dataLength, volatile unsigned int *flags) { uint32_t i; if (!isFirst(p1)) { THROW(0x6A80); } // Reset old transaction data that might still remain reset_transaction_context(); parseContext.data = transactionContext.rawTx; transactionContext.pathLength = workBuffer[0]; if ((transactionContext.pathLength < 0x01) || (transactionContext.pathLength > MAX_BIP32_PATH)) { THROW(0x6a81); } workBuffer++; dataLength--; for (i = 0; i < transactionContext.pathLength; i++) { transactionContext.bip32Path[i] = (workBuffer[0] << 24u) | (workBuffer[1] << 16u) | (workBuffer[2] << 8u) | (workBuffer[3]); workBuffer += 4; dataLength -= 4; } if (((p2 & P2_SECP256K1) == 0) && ((p2 & P2_ED25519) == 0)) { THROW(0x6B00); } if (((p2 & P2_SECP256K1) != 0) && ((p2 & P2_ED25519) != 0)) { THROW(0x6B00); } transactionContext.curve = (((p2 & P2_ED25519) != 0) ? CX_CURVE_Ed25519 : CX_CURVE_256K1); handle_packet_content(p1, p2, workBuffer, dataLength, flags); } void handle_subsequent_packet(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint8_t dataLength, volatile unsigned int *flags) { if (isFirst(p1)) { THROW(0x6A80); } handle_packet_content(p1, p2, workBuffer, dataLength, flags); } void handle_packet_content(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint8_t dataLength, volatile unsigned int *flags) { uint16_t totalLength = PREFIX_LENGTH + parseContext.length + dataLength; if (totalLength > MAX_RAW_TX) { // Abort if the user is trying to sign a too large transaction THROW(0x6700); } // Append received data to stored transaction data memcpy(parseContext.data + parseContext.length, workBuffer, dataLength); parseContext.length += dataLength; if (hasMore(p1)) { // Reply to sender with status OK signState = WAITING_FOR_MORE; THROW(0x9000); } else { // No more data to receive, finish up and present transaction to user signState = PENDING_REVIEW; transactionContext.rawTxLength = parseContext.length; // Try to parse the transaction. If the parsing fails, throw an exception // to cause the processing to abort and the transaction context to be reset. switch (parse_txn_context(&parseContext)) { case E_TOO_MANY_FIELDS: // Abort if there are too many fields to show on Ledger device THROW(0x6700); break; case E_NOT_ENOUGH_DATA: case E_INVALID_DATA: // Mask real cause behind generic error (INCORRECT_DATA) THROW(0x6a80); break; default: break; } review_transaction(&parseContext.result, sign_transaction, reject_transaction); *flags |= IO_ASYNCH_REPLY; } } void handle_sign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint8_t dataLength, volatile unsigned int *flags) { switch (signState) { case IDLE: handle_first_packet(p1, p2, workBuffer, dataLength, flags); break; case WAITING_FOR_MORE: handle_subsequent_packet(p1, p2, workBuffer, dataLength, flags); break; default: THROW(0x6A80); } }
33.131455
116
0.615701
5cbeaaff49f32f58eca043390465c4aef3c2b31e
1,538
c
C
build/glibc-1.09/sysdeps/stub/sleep.c
VivekMaran27/How-to-install-SimpleScalar-on-Ubuntu
2c0d4f4d41087508b304664fe1a6da6f86fb830b
[ "MIT" ]
null
null
null
build/glibc-1.09/sysdeps/stub/sleep.c
VivekMaran27/How-to-install-SimpleScalar-on-Ubuntu
2c0d4f4d41087508b304664fe1a6da6f86fb830b
[ "MIT" ]
null
null
null
build/glibc-1.09/sysdeps/stub/sleep.c
VivekMaran27/How-to-install-SimpleScalar-on-Ubuntu
2c0d4f4d41087508b304664fe1a6da6f86fb830b
[ "MIT" ]
null
null
null
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <ansidecl.h> #include <signal.h> #include <time.h> #include <unistd.h> #include <errno.h> /* Make the process sleep for SECONDS seconds, or until a signal arrives and is not ignored. The function returns the number of seconds less than SECONDS which it actually slept (zero if it slept the full time). If a signal handler does a `longjmp' or modifies the handling of the SIGALRM signal while inside `sleep' call, the handling of the SIGALRM signal afterwards is undefined. There is no return value to indicate error, but if `sleep' returns SECONDS, it probably didn't work. */ unsigned int DEFUN(sleep, (seconds), unsigned int seconds) { errno = ENOSYS; return seconds; }
40.473684
73
0.760728
a920ca41dbf44269dec734dfedc2a1b59f3ad536
7,093
c
C
Pods/BoringSSL/crypto/fipsmodule/bn/montgomery_inv.c
agalan33/TutorsApp
19060b2689a5dc1a203d49381a0ae686857144e8
[ "Apache-2.0" ]
1,699
2017-05-06T02:22:00.000Z
2022-03-30T07:51:03.000Z
Pods/BoringSSL/crypto/fipsmodule/bn/montgomery_inv.c
agalan33/TutorsApp
19060b2689a5dc1a203d49381a0ae686857144e8
[ "Apache-2.0" ]
85
2017-05-08T18:48:44.000Z
2022-03-07T05:30:01.000Z
Pods/BoringSSL/crypto/fipsmodule/bn/montgomery_inv.c
agalan33/TutorsApp
19060b2689a5dc1a203d49381a0ae686857144e8
[ "Apache-2.0" ]
228
2020-10-07T17:15:26.000Z
2022-03-25T18:09:28.000Z
/* Copyright 2016 Brian Smith. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <openssl/bn.h> #include <assert.h> #include "internal.h" #include "../../internal.h" static uint64_t bn_neg_inv_mod_r_u64(uint64_t n); OPENSSL_COMPILE_ASSERT(BN_MONT_CTX_N0_LIMBS == 1 || BN_MONT_CTX_N0_LIMBS == 2, BN_MONT_CTX_N0_LIMBS_VALUE_INVALID_2); OPENSSL_COMPILE_ASSERT(sizeof(uint64_t) == BN_MONT_CTX_N0_LIMBS * sizeof(BN_ULONG), BN_MONT_CTX_N0_LIMBS_DOES_NOT_MATCH_UINT64_T); // LG_LITTLE_R is log_2(r). #define LG_LITTLE_R (BN_MONT_CTX_N0_LIMBS * BN_BITS2) uint64_t bn_mont_n0(const BIGNUM *n) { // These conditions are checked by the caller, |BN_MONT_CTX_set|. assert(!BN_is_zero(n)); assert(!BN_is_negative(n)); assert(BN_is_odd(n)); // r == 2**(BN_MONT_CTX_N0_LIMBS * BN_BITS2) and LG_LITTLE_R == lg(r). This // ensures that we can do integer division by |r| by simply ignoring // |BN_MONT_CTX_N0_LIMBS| limbs. Similarly, we can calculate values modulo // |r| by just looking at the lowest |BN_MONT_CTX_N0_LIMBS| limbs. This is // what makes Montgomery multiplication efficient. // // As shown in Algorithm 1 of "Fast Prime Field Elliptic Curve Cryptography // with 256 Bit Primes" by Shay Gueron and Vlad Krasnov, in the loop of a // multi-limb Montgomery multiplication of |a * b (mod n)|, given the // unreduced product |t == a * b|, we repeatedly calculate: // // t1 := t % r |t1| is |t|'s lowest limb (see previous paragraph). // t2 := t1*n0*n // t3 := t + t2 // t := t3 / r copy all limbs of |t3| except the lowest to |t|. // // In the last step, it would only make sense to ignore the lowest limb of // |t3| if it were zero. The middle steps ensure that this is the case: // // t3 == 0 (mod r) // t + t2 == 0 (mod r) // t + t1*n0*n == 0 (mod r) // t1*n0*n == -t (mod r) // t*n0*n == -t (mod r) // n0*n == -1 (mod r) // n0 == -1/n (mod r) // // Thus, in each iteration of the loop, we multiply by the constant factor // |n0|, the negative inverse of n (mod r). // n_mod_r = n % r. As explained above, this is done by taking the lowest // |BN_MONT_CTX_N0_LIMBS| limbs of |n|. uint64_t n_mod_r = n->d[0]; #if BN_MONT_CTX_N0_LIMBS == 2 if (n->width > 1) { n_mod_r |= (uint64_t)n->d[1] << BN_BITS2; } #endif return bn_neg_inv_mod_r_u64(n_mod_r); } // bn_neg_inv_r_mod_n_u64 calculates the -1/n mod r; i.e. it calculates |v| // such that u*r - v*n == 1. |r| is the constant defined in |bn_mont_n0|. |n| // must be odd. // // This is derived from |xbinGCD| in Henry S. Warren, Jr.'s "Montgomery // Multiplication" (http://www.hackersdelight.org/MontgomeryMultiplication.pdf). // It is very similar to the MODULAR-INVERSE function in Stephen R. Dussé's and // Burton S. Kaliski Jr.'s "A Cryptographic Library for the Motorola DSP56000" // (http://link.springer.com/chapter/10.1007%2F3-540-46877-3_21). // // This is inspired by Joppe W. Bos's "Constant Time Modular Inversion" // (http://www.joppebos.com/files/CTInversion.pdf) so that the inversion is // constant-time with respect to |n|. We assume uint64_t additions, // subtractions, shifts, and bitwise operations are all constant time, which // may be a large leap of faith on 32-bit targets. We avoid division and // multiplication, which tend to be the most problematic in terms of timing // leaks. // // Most GCD implementations return values such that |u*r + v*n == 1|, so the // caller would have to negate the resultant |v| for the purpose of Montgomery // multiplication. This implementation does the negation implicitly by doing // the computations as a difference instead of a sum. static uint64_t bn_neg_inv_mod_r_u64(uint64_t n) { assert(n % 2 == 1); // alpha == 2**(lg r - 1) == r / 2. static const uint64_t alpha = UINT64_C(1) << (LG_LITTLE_R - 1); const uint64_t beta = n; uint64_t u = 1; uint64_t v = 0; // The invariant maintained from here on is: // 2**(lg r - i) == u*2*alpha - v*beta. for (size_t i = 0; i < LG_LITTLE_R; ++i) { #if BN_BITS2 == 64 && defined(BN_ULLONG) assert((BN_ULLONG)(1) << (LG_LITTLE_R - i) == ((BN_ULLONG)u * 2 * alpha) - ((BN_ULLONG)v * beta)); #endif // Delete a common factor of 2 in u and v if |u| is even. Otherwise, set // |u = (u + beta) / 2| and |v = (v / 2) + alpha|. uint64_t u_is_odd = UINT64_C(0) - (u & 1); // Either 0xff..ff or 0. // The addition can overflow, so use Dietz's method for it. // // Dietz calculates (x+y)/2 by (x⊕y)>>1 + x&y. This is valid for all // (unsigned) x and y, even when x+y overflows. Evidence for 32-bit values // (embedded in 64 bits to so that overflow can be ignored): // // (declare-fun x () (_ BitVec 64)) // (declare-fun y () (_ BitVec 64)) // (assert (let ( // (one (_ bv1 64)) // (thirtyTwo (_ bv32 64))) // (and // (bvult x (bvshl one thirtyTwo)) // (bvult y (bvshl one thirtyTwo)) // (not (= // (bvadd (bvlshr (bvxor x y) one) (bvand x y)) // (bvlshr (bvadd x y) one))) // ))) // (check-sat) uint64_t beta_if_u_is_odd = beta & u_is_odd; // Either |beta| or 0. u = ((u ^ beta_if_u_is_odd) >> 1) + (u & beta_if_u_is_odd); uint64_t alpha_if_u_is_odd = alpha & u_is_odd; // Either |alpha| or 0. v = (v >> 1) + alpha_if_u_is_odd; } // The invariant now shows that u*r - v*n == 1 since r == 2 * alpha. #if BN_BITS2 == 64 && defined(BN_ULLONG) assert(1 == ((BN_ULLONG)u * 2 * alpha) - ((BN_ULLONG)v * beta)); #endif return v; } int bn_mod_exp_base_2_consttime(BIGNUM *r, unsigned p, const BIGNUM *n, BN_CTX *ctx) { assert(!BN_is_zero(n)); assert(!BN_is_negative(n)); assert(BN_is_odd(n)); BN_zero(r); unsigned n_bits = BN_num_bits(n); assert(n_bits != 0); assert(p > n_bits); if (n_bits == 1) { return 1; } // Set |r| to the larger power of two smaller than |n|, then shift with // reductions the rest of the way. if (!BN_set_bit(r, n_bits - 1) || !bn_mod_lshift_consttime(r, r, p - (n_bits - 1), n, ctx)) { return 0; } return 1; }
38.134409
80
0.630058
b77b836603d04cfc8740754e3476405d191803c2
13,169
h
C
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/openldap/2.4.47-r0/openldap-2.4.47/libraries/librewrite/rewrite-int.h
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/openldap/2.4.47-r0/openldap-2.4.47/libraries/librewrite/rewrite-int.h
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/openldap/2.4.47-r0/openldap-2.4.47/libraries/librewrite/rewrite-int.h
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
/* $OpenLDAP$ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * * Copyright 2000-2018 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in the file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ /* ACKNOWLEDGEMENT: * This work was initially developed by Pierangelo Masarati for * inclusion in OpenLDAP Software. */ #ifndef REWRITE_INT_H #define REWRITE_INT_H /* * These are required by every file of the library, so they're included here */ #include <ac/ctype.h> #include <ac/regex.h> #include <ac/socket.h> #include <ac/stdlib.h> #include <ac/string.h> #include <ac/syslog.h> #include <ac/unistd.h> #include <lber.h> #include <ldap.h> #define LDAP_DEFINE_LDAP_DEBUG #include <avl.h> #include <ldap_log.h> #include <lutil.h> #include <rewrite.h> #define malloc(x) ber_memalloc(x) #define calloc(x, y) ber_memcalloc(x, y) #define realloc(x, y) ber_memrealloc(x, y) #define free(x) ber_memfree(x) #undef strdup #define strdup(x) ber_strdup(x) /* Uncomment to use ldap pvt threads */ #define USE_REWRITE_LDAP_PVT_THREADS #include <ldap_pvt_thread.h> /* * For details, see RATIONALE. */ #define REWRITE_MAX_MATCH 11 /* 0: overall string; 1-9: submatches */ #define REWRITE_MAX_PASSES 100 /* * Submatch escape char */ /* the '\' conflicts with slapd.conf parsing */ /* #define REWRITE_SUBMATCH_ESCAPE '\\' */ #define REWRITE_SUBMATCH_ESCAPE_ORIG '%' #define REWRITE_SUBMATCH_ESCAPE '$' #define IS_REWRITE_SUBMATCH_ESCAPE(c) \ ((c) == REWRITE_SUBMATCH_ESCAPE || (c) == REWRITE_SUBMATCH_ESCAPE_ORIG) /* * REGEX flags */ #define REWRITE_FLAG_HONORCASE 'C' #define REWRITE_FLAG_BASICREGEX 'R' /* * Action flags */ #define REWRITE_FLAG_EXECONCE ':' #define REWRITE_FLAG_STOP '@' #define REWRITE_FLAG_UNWILLING '#' #define REWRITE_FLAG_GOTO 'G' /* requires an arg */ #define REWRITE_FLAG_USER 'U' /* requires an arg */ #define REWRITE_FLAG_MAX_PASSES 'M' /* requires an arg */ #define REWRITE_FLAG_IGNORE_ERR 'I' /* * Map operators */ #define REWRITE_OPERATOR_SUBCONTEXT '>' #define REWRITE_OPERATOR_COMMAND '|' #define REWRITE_OPERATOR_VARIABLE_SET '&' #define REWRITE_OPERATOR_VARIABLE_GET '*' #define REWRITE_OPERATOR_PARAM_GET '$' /*********** * PRIVATE * ***********/ /* * Action */ struct rewrite_action { struct rewrite_action* la_next; #define REWRITE_ACTION_STOP 0x0001 #define REWRITE_ACTION_UNWILLING 0x0002 #define REWRITE_ACTION_GOTO 0x0003 #define REWRITE_ACTION_IGNORE_ERR 0x0004 #define REWRITE_ACTION_USER 0x0005 int la_type; void* la_args; }; /* * Map */ struct rewrite_map { /* * Legacy stuff */ #define REWRITE_MAP_XFILEMAP 0x0001 /* Rough implementation! */ #define REWRITE_MAP_XPWDMAP 0x0002 /* uid -> gecos */ #define REWRITE_MAP_XLDAPMAP 0x0003 /* Not implemented yet! */ /* * Maps with args */ #define REWRITE_MAP_SUBCONTEXT 0x0101 #define REWRITE_MAP_SET_OP_VAR 0x0102 #define REWRITE_MAP_SETW_OP_VAR 0x0103 #define REWRITE_MAP_GET_OP_VAR 0x0104 #define REWRITE_MAP_SET_SESN_VAR 0x0105 #define REWRITE_MAP_SETW_SESN_VAR 0x0106 #define REWRITE_MAP_GET_SESN_VAR 0x0107 #define REWRITE_MAP_GET_PARAM 0x0108 #define REWRITE_MAP_BUILTIN 0x0109 int lm_type; char* lm_name; void* lm_data; /* * Old maps store private data in _lm_args; * new maps store the substitution pattern in _lm_subst */ union { void* _lm_args; struct rewrite_subst* _lm_subst; } lm_union; #define lm_args lm_union._lm_args #define lm_subst lm_union._lm_subst #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_mutex_t lm_mutex; #endif /* USE_REWRITE_LDAP_PVT_THREADS */ }; /* * Builtin maps */ struct rewrite_builtin_map { #define REWRITE_BUILTIN_MAP 0x0200 int lb_type; char* lb_name; void* lb_private; const rewrite_mapper* lb_mapper; #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_mutex_t lb_mutex; #endif /* USE_REWRITE_LDAP_PVT_THREADS */ }; /* * Submatch substitution */ struct rewrite_submatch { #define REWRITE_SUBMATCH_ASIS 0x0000 #define REWRITE_SUBMATCH_XMAP 0x0001 #define REWRITE_SUBMATCH_MAP_W_ARG 0x0002 int ls_type; struct rewrite_map* ls_map; int ls_submatch; /* * The first one represents the index of the submatch in case * the map has single submatch as argument; * the latter represents the map argument scheme in case * the map has substitution string argument form */ }; /* * Pattern substitution */ struct rewrite_subst { size_t lt_subs_len; struct berval* lt_subs; int lt_num_submatch; struct rewrite_submatch* lt_submatch; }; /* * Rule */ struct rewrite_rule { struct rewrite_rule* lr_next; struct rewrite_rule* lr_prev; char* lr_pattern; char* lr_subststring; char* lr_flagstring; regex_t lr_regex; /* * I was thinking about some kind of per-rule mutex, but there's * probably no need, because rules after compilation are only read; * however, I need to check whether regexec is reentrant ... */ struct rewrite_subst* lr_subst; #define REWRITE_REGEX_ICASE REG_ICASE #define REWRITE_REGEX_EXTENDED REG_EXTENDED int lr_flags; #define REWRITE_RECURSE 0x0001 #define REWRITE_EXEC_ONCE 0x0002 int lr_mode; int lr_max_passes; struct rewrite_action* lr_action; }; /* * Rewrite Context (set of rules) */ struct rewrite_context { char* lc_name; struct rewrite_context* lc_alias; struct rewrite_rule* lc_rule; }; /* * Session */ struct rewrite_session { void* ls_cookie; Avlnode* ls_vars; #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_rdwr_t ls_vars_mutex; ldap_pvt_thread_mutex_t ls_mutex; #endif /* USE_REWRITE_LDAP_PVT_THREADS */ int ls_count; }; /* * Variable */ struct rewrite_var { char* lv_name; int lv_flags; struct berval lv_value; }; /* * Operation */ struct rewrite_op { int lo_num_passes; int lo_depth; #if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */ char *lo_string; #endif char* lo_result; Avlnode* lo_vars; const void* lo_cookie; }; /********** * PUBLIC * **********/ /* * Rewrite info */ struct rewrite_info { Avlnode* li_context; Avlnode* li_maps; /* * No global mutex because maps are read only at * config time */ Avlnode* li_params; Avlnode* li_cookies; int li_num_cookies; #ifdef USE_REWRITE_LDAP_PVT_THREADS ldap_pvt_thread_rdwr_t li_params_mutex; ldap_pvt_thread_rdwr_t li_cookies_mutex; #endif /* USE_REWRITE_LDAP_PVT_THREADS */ /* * Default to `off'; * use `rewriteEngine {on|off}' directive to alter */ int li_state; /* * Defaults to REWRITE_MAXPASSES; * use `rewriteMaxPasses numPasses' directive to alter */ #define REWRITE_MAXPASSES 100 int li_max_passes; int li_max_passes_per_rule; /* * Behavior in case a NULL or non-existent context is required */ int li_rewrite_mode; }; /*********** * PRIVATE * ***********/ LDAP_REWRITE_V(struct rewrite_context*) rewrite_int_curr_context; /* * Maps */ /* * Parses a map (also in legacy 'x' version) */ LDAP_REWRITE_F(struct rewrite_map*) rewrite_map_parse(struct rewrite_info* info, const char* s, const char** end); LDAP_REWRITE_F(struct rewrite_map*) rewrite_xmap_parse(struct rewrite_info* info, const char* s, const char** end); /* * Resolves key in val by means of map (also in legacy 'x' version) */ LDAP_REWRITE_F(int) rewrite_map_apply(struct rewrite_info* info, struct rewrite_op* op, struct rewrite_map* map, struct berval* key, struct berval* val); LDAP_REWRITE_F(int) rewrite_xmap_apply(struct rewrite_info* info, struct rewrite_op* op, struct rewrite_map* map, struct berval* key, struct berval* val); LDAP_REWRITE_F(int) rewrite_map_destroy(struct rewrite_map** map); LDAP_REWRITE_F(int) rewrite_xmap_destroy(struct rewrite_map** map); LDAP_REWRITE_F(void) rewrite_builtin_map_free(void* map); /* * Submatch substitution */ /* * Compiles a substitution pattern */ LDAP_REWRITE_F(struct rewrite_subst*) rewrite_subst_compile(struct rewrite_info* info, const char* result); /* * Substitutes a portion of rewritten string according to substitution * pattern using submatches */ LDAP_REWRITE_F(int) rewrite_subst_apply(struct rewrite_info* info, struct rewrite_op* op, struct rewrite_subst* subst, const char* string, const regmatch_t* match, struct berval* val); LDAP_REWRITE_F(int) rewrite_subst_destroy(struct rewrite_subst** subst); /* * Rules */ /* * Compiles the rule and appends it at the running context */ LDAP_REWRITE_F(int) rewrite_rule_compile(struct rewrite_info* info, struct rewrite_context* context, const char* pattern, const char* result, const char* flagstring); /* * Rewrites string according to rule; may return: * REWRITE_REGEXEC_OK: fine; if *result != NULL rule matched * and rewrite succeeded. * REWRITE_REGEXEC_STOP: fine, rule matched; stop processing * following rules * REWRITE_REGEXEC_UNWILL: rule matched; force 'unwilling to perform' * REWRITE_REGEXEC_ERR: an error occurred */ LDAP_REWRITE_F(int) rewrite_rule_apply(struct rewrite_info* info, struct rewrite_op* op, struct rewrite_rule* rule, const char* string, char** result); LDAP_REWRITE_F(int) rewrite_rule_destroy(struct rewrite_rule** rule); /* * Sessions */ /* * Fetches a struct rewrite_session */ LDAP_REWRITE_F(struct rewrite_session*) rewrite_session_find(struct rewrite_info* info, const void* cookie); /* * Defines and inits a variable with session scope */ LDAP_REWRITE_F(int) rewrite_session_var_set_f(struct rewrite_info* info, const void* cookie, const char* name, const char* value, int flags); /* * Gets a var with session scope */ LDAP_REWRITE_F(int) rewrite_session_var_get(struct rewrite_info* info, const void* cookie, const char* name, struct berval* val); /* * Deletes a session */ LDAP_REWRITE_F(int) rewrite_session_delete(struct rewrite_info* info, const void* cookie); /* * Destroys the cookie tree */ LDAP_REWRITE_F(int) rewrite_session_destroy(struct rewrite_info* info); /* * Vars */ /* * Finds a var */ LDAP_REWRITE_F(struct rewrite_var*) rewrite_var_find(Avlnode* tree, const char* name); /* * Replaces the value of a variable */ LDAP_REWRITE_F(int) rewrite_var_replace(struct rewrite_var* var, const char* value, int flags); /* * Inserts a newly created var */ LDAP_REWRITE_F(struct rewrite_var*) rewrite_var_insert_f(Avlnode** tree, const char* name, const char* value, int flags); #define rewrite_var_insert(tree, name, value) \ rewrite_var_insert_f((tree), (name), (value), \ REWRITE_VAR_UPDATE | REWRITE_VAR_COPY_NAME | \ REWRITE_VAR_COPY_VALUE) /* * Sets/inserts a var */ LDAP_REWRITE_F(struct rewrite_var*) rewrite_var_set_f(Avlnode** tree, const char* name, const char* value, int flags); #define rewrite_var_set(tree, name, value, insert) \ rewrite_var_set_f((tree), (name), (value), \ REWRITE_VAR_UPDATE | REWRITE_VAR_COPY_NAME | \ REWRITE_VAR_COPY_VALUE | \ ((insert) ? REWRITE_VAR_INSERT : 0)) /* * Deletes a var tree */ LDAP_REWRITE_F(int) rewrite_var_delete(Avlnode* tree); /* * Contexts */ /* * Finds the context named rewriteContext in the context tree */ LDAP_REWRITE_F(struct rewrite_context*) rewrite_context_find(struct rewrite_info* info, const char* rewriteContext); /* * Creates a new context called rewriteContext and stores in into the tree */ LDAP_REWRITE_F(struct rewrite_context*) rewrite_context_create(struct rewrite_info* info, const char* rewriteContext); /* * Rewrites string according to context; may return: * OK: fine; if *result != NULL rule matched and rewrite succeeded. * STOP: fine, rule matched; stop processing following rules * UNWILL: rule matched; force 'unwilling to perform' */ LDAP_REWRITE_F(int) rewrite_context_apply(struct rewrite_info* info, struct rewrite_op* op, struct rewrite_context* context, const char* string, char** result); LDAP_REWRITE_F(int) rewrite_context_destroy(struct rewrite_context** context); LDAP_REWRITE_F(void) rewrite_context_free(void* tmp); #endif /* REWRITE_INT_H */
24.163303
80
0.690561
a27504bf3e2bf5e5152a8a6bfea3c2ef25c41e7d
2,371
c
C
tests/tests_records/tests-records_trips.c
4rterius/cgtfs
fb47716fcb6f23db27ade3b3d136a118eb621102
[ "MIT" ]
3
2020-09-16T05:14:19.000Z
2021-04-20T09:06:18.000Z
tests/tests_records/tests-records_trips.c
rakhack/cgtfs
fb47716fcb6f23db27ade3b3d136a118eb621102
[ "MIT" ]
null
null
null
tests/tests_records/tests-records_trips.c
rakhack/cgtfs
fb47716fcb6f23db27ade3b3d136a118eb621102
[ "MIT" ]
1
2020-09-16T05:14:29.000Z
2020-09-16T05:14:29.000Z
#ifndef CGTFS_TESTS_RECORDS_TRIPS_C #define CGTFS_TESTS_RECORDS_TRIPS_C #include "greatest/greatest.h" #include "records/trip.h" TEST trip_read(void) { #define FIELDS_NUM_13 10 char *field_names[FIELDS_NUM_13] = { "route_id", "service_id", "trip_id", "trip_headsign", "trip_short_name", "direction_id", "block_id", "shape_id", "wheelchair_accessible", "bikes_allowed" }; char *field_values[FIELDS_NUM_13] = { "A", "WE", "AWE1", "Downtown", "Some short name", "", "11", "8", "1", "2" }; trip_t tr_1; read_trip(&tr_1, FIELDS_NUM_13, (const char **)field_names, (const char **)field_values); ASSERT_STR_EQ("A", tr_1.route_id); ASSERT_STR_EQ("WE", tr_1.service_id); ASSERT_STR_EQ("AWE1", tr_1.id); ASSERT_STR_EQ("Downtown", tr_1.headsign); ASSERT_STR_EQ("Some short name", tr_1.short_name); ASSERT_STR_EQ("11", tr_1.block_id); ASSERT_STR_EQ("8", tr_1.shape_id); ASSERT_EQ(0, tr_1.direction_id); ASSERT_EQ(WA_POSSIBLE, tr_1.wheelchair_accessible); ASSERT_EQ(BA_NOT_POSSIBLE, tr_1.bikes_allowed); PASS(); } TEST trip_compare(void) { trip_t a = { .route_id = "RT1", .service_id = "123", .id = "RT1_888", .headsign = "The Grand Tour", .short_name = "TGT", .direction_id = 1, .block_id = "lbkc", .shape_id = "shpe", .wheelchair_accessible = WA_UNKNOWN, .bikes_allowed = BA_POSSIBLE }; trip_t b = { .route_id = "RT1", .service_id = "123", .id = "RT1_888", .headsign = "The Grand Tour", .short_name = "TGT", .direction_id = 1, .block_id = "lbkc", .shape_id = "shpe", .wheelchair_accessible = WA_UNKNOWN, .bikes_allowed = BA_POSSIBLE }; trip_t c = { .route_id = "RT2", .service_id = "123", .id = "RT2_888", .headsign = "The Grand Tour", .short_name = "TGT", .direction_id = 0, .block_id = "lbskc", .shape_id = "shpe", .wheelchair_accessible = WA_UNKNOWN, .bikes_allowed = BA_POSSIBLE }; ASSERT_EQ(1, equal_trip(&a, &b)); ASSERT_EQ(0, equal_trip(&a, &c)); ASSERT_EQ(0, equal_trip(&b, &c)); PASS(); } SUITE(CGTFS_RecordTrip) { RUN_TEST(trip_read); RUN_TEST(trip_compare); } #endif
26.943182
93
0.589625
0850554c651a2f385a74093590ac3258d66babee
2,607
h
C
src/include/globlbin.h
Pointer2VoidStar/CLIPS
f70ef28aca7f1d993071724276d83797998c720a
[ "MIT" ]
1
2018-05-18T07:39:56.000Z
2018-05-18T07:39:56.000Z
src/include/globlbin.h
Pointer2VoidStar/CLIPS
f70ef28aca7f1d993071724276d83797998c720a
[ "MIT" ]
4
2017-03-15T23:28:14.000Z
2017-10-29T22:48:28.000Z
src/include/globlbin.h
Pointer2VoidStar/CLIPS
f70ef28aca7f1d993071724276d83797998c720a
[ "MIT" ]
null
null
null
/*******************************************************/ /* "C" Language Integrated Production System */ /* */ /* CLIPS Version 6.40 07/30/16 */ /* */ /* DEFGLOBAL BINARY HEADER FILE */ /*******************************************************/ /*************************************************************/ /* Purpose: */ /* */ /* Principal Programmer(s): */ /* Gary D. Riley */ /* */ /* Contributing Programmer(s): */ /* Brian L. Dantes */ /* */ /* Revision History: */ /* */ /* 6.30: Changed integer type/precision. */ /* */ /* Moved WatchGlobals global to defglobalData. */ /* */ /* 6.40: Removed LOCALE definition. */ /* */ /* Pragma once and other inclusion changes. */ /* */ /*************************************************************/ #ifndef _H_globlbin #pragma once #define _H_globlbin #include "modulbin.h" #include "cstrcbin.h" #include "globldef.h" struct bsaveDefglobal { struct bsaveConstructHeader header; unsigned long initial; }; struct bsaveDefglobalModule { struct bsaveDefmoduleItemHeader header; }; #define GLOBLBIN_DATA 60 struct defglobalBinaryData { Defglobal *DefglobalArray; unsigned long NumberOfDefglobals; struct defglobalModule *ModuleArray; unsigned long NumberOfDefglobalModules; }; #define DefglobalBinaryData(theEnv) ((struct defglobalBinaryData *) GetEnvironmentData(theEnv,GLOBLBIN_DATA)) #define DefglobalPointer(i) (&DefglobalBinaryData(theEnv)->DefglobalArray[i]) void DefglobalBinarySetup(Environment *); void *BloadDefglobalModuleReference(Environment *,unsigned long); #endif /* _H_globlbin */
36.208333
109
0.364787
ecbc9e2eab19ac61ba70d8483db31ea76fea69db
5,566
c
C
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libblkid/src/partitions/mac.c
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libblkid/src/partitions/mac.c
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libblkid/src/partitions/mac.c
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
/* * mac partitions parsing code * * Copyright (C) 2009 Karel Zak <kzak@redhat.com> * * This file may be redistributed under the terms of the * GNU Lesser General Public License. * */ #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "partitions.h" #define MAC_PARTITION_MAGIC 0x504d #define MAC_PARTITION_MAGIC_OLD 0x5453 /* * Mac partition entry * http://developer.apple.com/legacy/mac/library/documentation/mac/Devices/Devices-126.html */ struct mac_partition { uint16_t signature; /* expected to be MAC_PARTITION_MAGIC */ uint16_t reserved; /* reserved */ uint32_t map_count; /* # blocks in partition map */ uint32_t start_block; /* absolute starting block # of partition */ uint32_t block_count; /* number of blocks in partition */ char name[32]; /* partition name */ char type[32]; /* string type description */ uint32_t data_start; /* rel block # of first data block */ uint32_t data_count; /* number of data blocks */ uint32_t status; /* partition status bits */ uint32_t boot_start; /* first logical block of boot code */ uint32_t boot_size; /* size of boot code, in bytes */ uint32_t boot_load; /* boot code load address */ uint32_t boot_load2; /* reserved */ uint32_t boot_entry; /* boot code entry point */ uint32_t boot_entry2; /* reserved */ uint32_t boot_cksum; /* boot code checksum */ char processor[16]; /* identifies ISA of boot */ /* there is more stuff after this that we don't need */ } __attribute__((packed)); /* * Driver descriptor structure, in block 0 * http://developer.apple.com/legacy/mac/library/documentation/mac/Devices/Devices-121.html */ struct mac_driver_desc { uint16_t signature; /* expected to be MAC_DRIVER_MAGIC */ uint16_t block_size; /* block size of the device */ uint32_t block_count; /* number of blocks on the device */ /* there is more stuff after this that we don't need */ } __attribute__((packed)); static inline unsigned char* get_mac_block(blkid_probe pr, uint16_t block_size, uint32_t num) { return blkid_probe_get_buffer(pr, (uint64_t)num * block_size, block_size); } static inline int has_part_signature(struct mac_partition* p) { return be16_to_cpu(p->signature) == MAC_PARTITION_MAGIC || be16_to_cpu(p->signature) == MAC_PARTITION_MAGIC_OLD; } static int probe_mac_pt(blkid_probe pr, const struct blkid_idmag* mag __attribute__((__unused__))) { struct mac_driver_desc* md; struct mac_partition* p; blkid_parttable tab = NULL; blkid_partlist ls; uint16_t block_size; uint16_t ssf; /* sector size fragment */ uint32_t nblks, i; /* The driver descriptor record is always located at physical block 0, * the first block on the disk. */ md = (struct mac_driver_desc*)blkid_probe_get_sector(pr, 0); if (!md) { if (errno) return -errno; goto nothing; } block_size = be16_to_cpu(md->block_size); /* The partition map always begins at physical block 1, * the second block on the disk. */ p = (struct mac_partition*)get_mac_block(pr, block_size, 1); if (!p) { if (errno) return -errno; goto nothing; } /* check the first partition signature */ if (!has_part_signature(p)) goto nothing; if (blkid_partitions_need_typeonly(pr)) /* caller does not ask for details about partitions */ return 0; ls = blkid_probe_get_partlist(pr); if (!ls) goto nothing; tab = blkid_partlist_new_parttable(ls, "mac", 0); if (!tab) goto err; ssf = block_size / 512; nblks = be32_to_cpu(p->map_count); for (i = 1; i <= nblks; ++i) { blkid_partition par; uint32_t start; uint32_t size; p = (struct mac_partition*)get_mac_block(pr, block_size, i); if (!p) { if (errno) return -errno; goto nothing; } if (!has_part_signature(p)) goto nothing; if (be32_to_cpu(p->map_count) != nblks) { DBG(LOWPROBE, ul_debug("mac: inconsistent map_count in partition map, " "entry[0]: %d, entry[%d]: %d", nblks, i - 1, be32_to_cpu(p->map_count))); } /* * note that libparted ignores some mac partitions according to * the partition name (e.g. "Apple_Free" or "Apple_Void"). We * follows Linux kernel and all partitions are visible */ start = be32_to_cpu(p->start_block) * ssf; size = be32_to_cpu(p->block_count) * ssf; par = blkid_partlist_add_partition(ls, tab, start, size); if (!par) goto err; blkid_partition_set_name(par, (unsigned char*)p->name, sizeof(p->name)); blkid_partition_set_type_string(par, (unsigned char*)p->type, sizeof(p->type)); } return BLKID_PROBE_OK; nothing: return BLKID_PROBE_NONE; err: return -ENOMEM; } /* * Mac disk always begin with "Driver Descriptor Record" * (struct mac_driver_desc) and magic 0x4552. */ const struct blkid_idinfo mac_pt_idinfo = { .name = "mac", .probefunc = probe_mac_pt, .magics = {/* big-endian magic string */ {.magic = "\x45\x52", .len = 2}, {NULL}}};
29.606383
91
0.617319
0c349d3e06af0b42c7702841d2ca25f29df3e8b8
159,744
h
C
joycon-driver/full/wxWidgets-3.0.3/interface/wx/grid.h
pokemonmegaman/JoyCon-Driver
049352827aa3d98b9bee8d5ce1838e12473aa484
[ "MIT" ]
471
2019-06-26T09:59:09.000Z
2022-03-30T04:59:42.000Z
joycon-driver/full/wxWidgets-3.0.4/interface/wx/grid.h
frekkanzer2/JoyCon-Driver
bab3821b70aa336f20acb821db214ebba34270a5
[ "MIT" ]
39
2019-07-06T02:51:39.000Z
2022-02-18T11:48:33.000Z
joycon-driver/full/wxWidgets-3.0.4/interface/wx/grid.h
frekkanzer2/JoyCon-Driver
bab3821b70aa336f20acb821db214ebba34270a5
[ "MIT" ]
151
2019-06-26T14:21:49.000Z
2022-03-24T10:10:18.000Z
///////////////////////////////////////////////////////////////////////////// // Name: grid.h // Purpose: interface of wxGrid and related classes // Author: wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /// Magic constant which tells (to some functions) to automatically calculate /// the appropriate size #define wxGRID_AUTOSIZE (-1) /// Many wxGrid methods work either with columns or rows, this enum is used for /// the parameter indicating which one should it be enum wxGridDirection { wxGRID_COLUMN, wxGRID_ROW }; /** @class wxGridCellRenderer This class is responsible for actually drawing the cell in the grid. You may pass it to the wxGridCellAttr (below) to change the format of one given cell or to wxGrid::SetDefaultRenderer() to change the view of all cells. This is an abstract class, and you will normally use one of the predefined derived classes or derive your own class from it. @library{wxadv} @category{grid} @see wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer */ class wxGridCellRenderer : public wxClientDataContainer, public wxRefCounter { public: wxGridCellRenderer(); /** This function must be implemented in derived classes to return a copy of itself. */ virtual wxGridCellRenderer* Clone() const = 0; /** Draw the given cell on the provided DC inside the given rectangle using the style specified by the attribute and the default or selected state corresponding to the isSelected value. This pure virtual function has a default implementation which will prepare the DC using the given attribute: it will draw the rectangle with the background colour from attr and set the text colour and font. */ virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) = 0; /** Get the preferred size of the cell for its contents. */ virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col) = 0; protected: /** The destructor is private because only DecRef() can delete us. */ virtual ~wxGridCellRenderer(); }; /** @class wxGridCellAutoWrapStringRenderer This class may be used to format string data in a cell. The too long lines are wrapped to be shown entirely at word boundaries. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer */ class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer { public: /** Default constructor. */ wxGridCellAutoWrapStringRenderer(); }; /** @class wxGridCellBoolRenderer This class may be used to format boolean data in a cell. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer */ class wxGridCellBoolRenderer : public wxGridCellRenderer { public: /** Default constructor. */ wxGridCellBoolRenderer(); }; /** @class wxGridCellDateTimeRenderer This class may be used to format a date/time data in a cell. The class wxDateTime is used internally to display the local date/time or to parse the string date entered in the cell thanks to the defined format. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, wxGridCellEnumRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer */ class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer { public: /** Date/time renderer constructor. @param outformat strptime()-like format string used the parse the output date/time. @param informat strptime()-like format string used to parse the string entered in the cell. */ wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat, const wxString& informat = wxDefaultDateTimeFormat); /** Sets the strptime()-like format string which will be used to parse the date/time. @param params strptime()-like format string used to parse the date/time. */ virtual void SetParameters(const wxString& params); }; /** @class wxGridCellEnumRenderer This class may be used to render in a cell a number as a textual equivalent. The corresponding text strings are specified as comma-separated items in the string passed to this renderer ctor or SetParameters() method. For example, if this string is @c "John,Fred,Bob" the cell will be rendered as "John", "Fred" or "Bob" if its contents is 0, 1 or 2 respectively. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer */ class wxGridCellEnumRenderer : public wxGridCellStringRenderer { public: /** Enum renderer ctor. @param choices Comma separated string parameters "item1[,item2[...,itemN]]". */ wxGridCellEnumRenderer( const wxString& choices = wxEmptyString ); /** Sets the comma separated string content of the enum. @param params Comma separated string parameters "item1[,item2[...,itemN]]". */ virtual void SetParameters(const wxString& params); }; /** Specifier used to format the data to string for the numbers handled by wxGridCellFloatRenderer and wxGridCellFloatEditor. @since 2.9.3 */ enum wxGridCellFloatFormat { /// Decimal floating point (%f). wxGRID_FLOAT_FORMAT_FIXED = 0x0010, /// Scientific notation (mantissa/exponent) using e character (%e). wxGRID_FLOAT_FORMAT_SCIENTIFIC = 0x0020, /// Use the shorter of %e or %f (%g). wxGRID_FLOAT_FORMAT_COMPACT = 0x0040, /// To use in combination with one of the above formats for the upper /// case version (%F/%E/%G) wxGRID_FLOAT_FORMAT_UPPER = 0x0080, /// The format used by default (wxGRID_FLOAT_FORMAT_FIXED). wxGRID_FLOAT_FORMAT_DEFAULT = wxGRID_FLOAT_FORMAT_FIXED }; /** @class wxGridCellFloatRenderer This class may be used to format floating point data in a cell. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer */ class wxGridCellFloatRenderer : public wxGridCellStringRenderer { public: /** Float cell renderer ctor. @param width Minimum number of characters to be shown. @param precision Number of digits after the decimal dot. @param format The format used to display the string, must be a combination of ::wxGridCellFloatFormat enum elements. This parameter is only available since wxWidgets 2.9.3. */ wxGridCellFloatRenderer(int width = -1, int precision = -1, int format = wxGRID_FLOAT_FORMAT_DEFAULT); /** Returns the specifier used to format the data to string. The returned value is a combination of ::wxGridCellFloatFormat elements. @since 2.9.3 */ int GetFormat() const; /** Returns the precision. */ int GetPrecision() const; /** Returns the width. */ int GetWidth() const; /** Set the format to use for display the number. @param format Must be a combination of ::wxGridCellFloatFormat enum elements. @since 2.9.3 */ void SetFormat(int format); /** The parameters string format is "width[,precision[,format]]" where @c format should be chosen between f|e|g|E|G (f is used by default) */ virtual void SetParameters(const wxString& params); /** Sets the precision. */ void SetPrecision(int precision); /** Sets the width. */ void SetWidth(int width); }; /** @class wxGridCellNumberRenderer This class may be used to format integer data in a cell. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, wxGridCellFloatRenderer, wxGridCellStringRenderer */ class wxGridCellNumberRenderer : public wxGridCellStringRenderer { public: /** Default constructor. */ wxGridCellNumberRenderer(); }; /** @class wxGridCellStringRenderer This class may be used to format string data in a cell; it is the default for string cells. @library{wxadv} @category{grid} @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer */ class wxGridCellStringRenderer : public wxGridCellRenderer { public: /** Default constructor. */ wxGridCellStringRenderer(); }; /** @class wxGridCellEditor This class is responsible for providing and manipulating the in-place edit controls for the grid. Instances of wxGridCellEditor (actually, instances of derived classes since it is an abstract class) can be associated with the cell attributes for individual cells, rows, columns, or even for the entire grid. @library{wxadv} @category{grid} @see wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor, wxGridCellFloatEditor, wxGridCellNumberEditor, wxGridCellTextEditor */ class wxGridCellEditor : public wxClientDataContainer, public wxRefCounter { public: /** Default constructor. */ wxGridCellEditor(); /** Fetch the value from the table and prepare the edit control to begin editing. This function should save the original value of the grid cell at the given @a row and @a col and show the control allowing the user to change it. @see EndEdit() */ virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; /** Create a new object which is the copy of this one. */ virtual wxGridCellEditor* Clone() const = 0; /** Creates the actual edit control. */ virtual void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) = 0; /** Final cleanup. */ virtual void Destroy(); /** End editing the cell. This function must check if the current value of the editing control is valid and different from the original value (available as @a oldval in its string form and possibly saved internally using its real type by BeginEdit()). If it isn't, it just returns @false, otherwise it must do the following: - Save the new value internally so that ApplyEdit() could apply it. - Fill @a newval (which is never @NULL) with the string representation of the new value. - Return @true Notice that it must @em not modify the grid as the change could still be vetoed. If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto this change, ApplyEdit() will be called next. */ virtual bool EndEdit(int row, int col, const wxGrid* grid, const wxString& oldval, wxString* newval) = 0; /** Effectively save the changes in the grid. This function should save the value of the control in the grid. It is called only after EndEdit() returns @true. */ virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0; /** Some types of controls on some platforms may need some help with the Return key. */ virtual void HandleReturn(wxKeyEvent& event); /** Returns @true if the edit control has been created. */ bool IsCreated(); /** Draws the part of the cell not occupied by the control: the base class version just fills it with background colour from the attribute. */ virtual void PaintBackground(wxDC& dc, const wxRect& rectCell, wxGridCellAttr& attr); /** Reset the value in the control back to its starting value. */ virtual void Reset() = 0; /** Size and position the edit control. */ virtual void SetSize(const wxRect& rect); /** Show or hide the edit control, use the specified attributes to set colours/fonts for it. */ virtual void Show(bool show, wxGridCellAttr* attr = NULL); /** If the editor is enabled by clicking on the cell, this method will be called. */ virtual void StartingClick(); /** If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired. */ virtual void StartingKey(wxKeyEvent& event); /** Returns the value currently in the editor control. */ virtual wxString GetValue() const = 0; /** Get the wxControl used by this editor. */ wxControl* GetControl() const; /** Set the wxControl that will be used by this cell editor for editing the value. */ void SetControl(wxControl* control); protected: /** The destructor is private because only DecRef() can delete us. */ virtual ~wxGridCellEditor(); }; /** @class wxGridCellAutoWrapStringEditor Grid cell editor for wrappable string/text data. @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor, wxGridCellFloatEditor, wxGridCellNumberEditor, wxGridCellTextEditor */ class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor { public: wxGridCellAutoWrapStringEditor(); }; /** @class wxGridCellBoolEditor Grid cell editor for boolean data. @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor, wxGridCellFloatEditor, wxGridCellNumberEditor, wxGridCellTextEditor */ class wxGridCellBoolEditor : public wxGridCellEditor { public: /** Default constructor. */ wxGridCellBoolEditor(); /** Returns @true if the given @a value is equal to the string representation of the truth value we currently use (see UseStringValues()). */ static bool IsTrueValue(const wxString& value); /** This method allows you to customize the values returned by GetValue() for the cell using this editor. By default, the default values of the arguments are used, i.e. @c "1" is returned if the cell is checked and an empty string otherwise. */ static void UseStringValues(const wxString& valueTrue = "1", const wxString& valueFalse = wxEmptyString); }; /** @class wxGridCellChoiceEditor Grid cell editor for string data providing the user a choice from a list of strings. @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, wxGridCellEnumEditor, wxGridCellFloatEditor, wxGridCellNumberEditor, wxGridCellTextEditor */ class wxGridCellChoiceEditor : public wxGridCellEditor { public: /** Choice cell renderer ctor. @param count Number of strings from which the user can choose. @param choices An array of strings from which the user can choose. @param allowOthers If allowOthers is @true, the user can type a string not in choices array. */ wxGridCellChoiceEditor(size_t count = 0, const wxString choices[] = NULL, bool allowOthers = false); /** Choice cell renderer ctor. @param choices An array of strings from which the user can choose. @param allowOthers If allowOthers is @true, the user can type a string not in choices array. */ wxGridCellChoiceEditor(const wxArrayString& choices, bool allowOthers = false); /** Parameters string format is "item1[,item2[...,itemN]]" */ virtual void SetParameters(const wxString& params); }; /** @class wxGridCellEnumEditor Grid cell editor which displays an enum number as a textual equivalent (eg. data in cell is 0,1,2 ... n the cell could be displayed as "John","Fred"..."Bob" in the combo choice box). @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellNumberEditor */ class wxGridCellEnumEditor : public wxGridCellChoiceEditor { public: /** Enum cell editor ctor. @param choices Comma separated choice parameters "item1[,item2[...,itemN]]". */ wxGridCellEnumEditor( const wxString& choices = wxEmptyString ); }; /** @class wxGridCellTextEditor Grid cell editor for string/text data. @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor, wxGridCellFloatEditor, wxGridCellNumberEditor */ class wxGridCellTextEditor : public wxGridCellEditor { public: /** Text cell editor constructor. @param maxChars Maximum width of text (this parameter is supported starting since wxWidgets 2.9.5). */ explicit wxGridCellTextEditor(size_t maxChars = 0); /** The parameters string format is "n" where n is a number representing the maximum width. */ virtual void SetParameters(const wxString& params); /** Set validator to validate user input. @since 2.9.5 */ virtual void SetValidator(const wxValidator& validator); }; /** @class wxGridCellFloatEditor The editor for floating point numbers data. @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor, wxGridCellNumberEditor, wxGridCellTextEditor */ class wxGridCellFloatEditor : public wxGridCellTextEditor { public: /** Float cell editor ctor. @param width Minimum number of characters to be shown. @param precision Number of digits after the decimal dot. @param format The format to use for displaying the number, a combination of ::wxGridCellFloatFormat enum elements. This parameter is only available since wxWidgets 2.9.3. */ wxGridCellFloatEditor(int width = -1, int precision = -1, int format = wxGRID_FLOAT_FORMAT_DEFAULT); /** The parameters string format is "width[,precision[,format]]" where @c format should be chosen between f|e|g|E|G (f is used by default) */ virtual void SetParameters(const wxString& params); }; /** @class wxGridCellNumberEditor Grid cell editor for numeric integer data. @library{wxadv} @category{grid} @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor, wxGridCellFloatEditor, wxGridCellTextEditor */ class wxGridCellNumberEditor : public wxGridCellTextEditor { public: /** Allows you to specify the range for acceptable data. Values equal to -1 for both @a min and @a max indicate that no range checking should be done. */ wxGridCellNumberEditor(int min = -1, int max = -1); /** Parameters string format is "min,max". */ virtual void SetParameters(const wxString& params); protected: /** If the return value is @true, the editor uses a wxSpinCtrl to get user input, otherwise it uses a wxTextCtrl. */ bool HasRange() const; /** String representation of the value. */ wxString GetString() const; }; /** @class wxGridCellAttr This class can be used to alter the cells' appearance in the grid by changing their attributes from the defaults. An object of this class may be returned by wxGridTableBase::GetAttr(). @library{wxadv} @category{grid} */ class wxGridCellAttr : public wxClientDataContainer, public wxRefCounter { public: /** Kind of the attribute to retrieve. @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr() */ enum wxAttrKind { /// Return the combined effective attribute for the cell. Any, /// Return the attribute explicitly set for this cell. Cell, /// Return the attribute set for this cells row. Row, /// Return the attribute set for this cells column. Col, Default, Merged }; /** Default constructor. */ wxGridCellAttr(wxGridCellAttr* attrDefault = NULL); /** Constructor specifying some of the often used attributes. */ wxGridCellAttr(const wxColour& colText, const wxColour& colBack, const wxFont& font, int hAlign, int vAlign); /** Creates a new copy of this object. */ wxGridCellAttr* Clone() const; /** This class is reference counted: it is created with ref count of 1, so calling DecRef() once will delete it. Calling IncRef() allows to lock it until the matching DecRef() is called. */ void DecRef(); /** Get the alignment to use for the cell with the given attribute. If this attribute doesn't specify any alignment, the default attribute alignment is used (which can be changed using wxGrid::SetDefaultCellAlignment() but is left and top by default). Notice that @a hAlign and @a vAlign values are always overwritten by this function, use GetNonDefaultAlignment() if this is not desirable. @param hAlign Horizontal alignment is returned here if this argument is non-@NULL. It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. @param vAlign Vertical alignment is returned here if this argument is non-@NULL. It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM. */ void GetAlignment(int* hAlign, int* vAlign) const; /** Returns the background colour. */ const wxColour& GetBackgroundColour() const; /** Returns the cell editor. */ wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const; /** Returns the font. */ const wxFont& GetFont() const; /** Get the alignment defined by this attribute. Unlike GetAlignment() this function only modifies @a hAlign and @a vAlign if this attribute does define a non-default alignment. This means that they must be initialized before calling this function and that their values will be preserved unchanged if they are different from wxALIGN_INVALID. For example, the following fragment can be used to use the cell alignment if one is defined but right-align its contents by default (instead of left-aligning it by default) while still using the default vertical alignment: @code int hAlign = wxALIGN_RIGHT, vAlign = wxALIGN_INVALID; attr.GetNonDefaultAlignment(&hAlign, &vAlign); @endcode @since 2.9.1 */ void GetNonDefaultAlignment(int *hAlign, int *vAlign) const; /** Returns the cell renderer. */ wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const; /** Returns the text colour. */ const wxColour& GetTextColour() const; /** Returns @true if this attribute has a valid alignment set. */ bool HasAlignment() const; /** Returns @true if this attribute has a valid background colour set. */ bool HasBackgroundColour() const; /** Returns @true if this attribute has a valid cell editor set. */ bool HasEditor() const; /** Returns @true if this attribute has a valid font set. */ bool HasFont() const; /** Returns @true if this attribute has a valid cell renderer set. */ bool HasRenderer() const; /** Returns @true if this attribute has a valid text colour set. */ bool HasTextColour() const; /** This class is reference counted: it is created with ref count of 1, so calling DecRef() once will delete it. Calling IncRef() allows to lock it until the matching DecRef() is called. */ void IncRef(); /** Returns @true if this cell is set as read-only. */ bool IsReadOnly() const; /** Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void SetAlignment(int hAlign, int vAlign); /** Sets the background colour. */ void SetBackgroundColour(const wxColour& colBack); /** @todo Needs documentation. */ void SetDefAttr(wxGridCellAttr* defAttr); /** Sets the editor to be used with the cells with this attribute. */ void SetEditor(wxGridCellEditor* editor); /** Sets the font. */ void SetFont(const wxFont& font); /** Sets the cell as read-only. */ void SetReadOnly(bool isReadOnly = true); /** Sets the renderer to be used for cells with this attribute. Takes ownership of the pointer. */ void SetRenderer(wxGridCellRenderer* renderer); /** Sets the text colour. */ void SetTextColour(const wxColour& colText); void MergeWith(wxGridCellAttr *mergefrom); void SetSize(int num_rows, int num_cols); void SetOverflow(bool allow = true); void SetKind(wxAttrKind kind); bool HasReadWriteMode() const; bool HasOverflowMode() const; bool HasSize() const; void GetSize(int *num_rows, int *num_cols) const; bool GetOverflow() const; wxAttrKind GetKind(); protected: /** The destructor is private because only DecRef() can delete us. */ virtual ~wxGridCellAttr(); }; /** Base class for corner window renderer. This is the simplest of all header renderers and only has a single function. @see wxGridCellAttrProvider::GetCornerRenderer() @since 2.9.1 */ class wxGridCornerHeaderRenderer { public: /** Called by the grid to draw the corner window border. This method is responsible for drawing the border inside the given @a rect and adjusting the rectangle size to correspond to the area inside the border, i.e. usually call wxRect::Deflate() to account for the border width. @param grid The grid whose corner window is being drawn. @param dc The device context to use for drawing. @param rect Input/output parameter which contains the border rectangle on input and should be updated to contain the area inside the border on function return. */ virtual void DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const = 0; }; /** Common base class for row and column headers renderers. @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer @since 2.9.1 */ class wxGridHeaderLabelsRenderer : public wxGridCornerHeaderRenderer { public: /** Called by the grid to draw the specified label. Notice that the base class DrawBorder() method is called before this one. The default implementation uses wxGrid::GetLabelTextColour() and wxGrid::GetLabelFont() to draw the label. */ virtual void DrawLabel(const wxGrid& grid, wxDC& dc, const wxString& value, const wxRect& rect, int horizAlign, int vertAlign, int textOrientation) const; }; /** Base class for row headers renderer. This is the same as wxGridHeaderLabelsRenderer currently but we still use a separate class for it to distinguish it from wxGridColumnHeaderRenderer. @see wxGridRowHeaderRendererDefault @see wxGridCellAttrProvider::GetRowHeaderRenderer() @since 2.9.1 */ class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer { }; /** Base class for column headers renderer. This is the same as wxGridHeaderLabelsRenderer currently but we still use a separate class for it to distinguish it from wxGridRowHeaderRenderer. @see wxGridColumnHeaderRendererDefault @see wxGridCellAttrProvider::GetColumnHeaderRenderer() @since 2.9.1 */ class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer { }; /** Default row header renderer. You may derive from this class if you need to only override one of its methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the default implementation for the other one. @see wxGridColumnHeaderRendererDefault @since 2.9.1 */ class wxGridRowHeaderRendererDefault : public wxGridRowHeaderRenderer { public: /// Implement border drawing for the row labels. virtual void DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const; }; /** Default column header renderer. @see wxGridRowHeaderRendererDefault @since 2.9.1 */ class wxGridColumnHeaderRendererDefault : public wxGridColumnHeaderRenderer { public: /// Implement border drawing for the column labels. virtual void DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const; }; /** Default corner window renderer. @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault @since 2.9.1 */ class wxGridCornerHeaderRendererDefault : public wxGridCornerHeaderRenderer { public: /// Implement border drawing for the corner window. virtual void DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const; }; /** Class providing attributes to be used for the grid cells. This class both defines an interface which grid cell attributes providers should implement -- and which can be implemented differently in derived classes -- and a default implementation of this interface which is often good enough to be used without modification, especially with not very large grids for which the efficiency of attributes storage hardly matters (see the discussion below). An object of this class can be associated with a wxGrid using wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you intend to use the default provider as it is used by wxGridTableBase by default anyhow. Notice that while attributes provided by this class can be set for individual cells using SetAttr() or the entire rows or columns using SetRowAttr() and SetColAttr() they are always retrieved using GetAttr() function. The default implementation of this class stores the attributes passed to its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A derived class may use its knowledge about how the attributes are used in your program to implement it much more efficiently: for example, using a special background colour for all even-numbered rows can be implemented by simply returning the same attribute from GetAttr() if the row number is even instead of having to store N/2 row attributes where N is the total number of rows in the grid. Notice that objects of this class can't be copied. */ class wxGridCellAttrProvider : public wxClientDataContainer { public: /// Trivial default constructor. wxGridCellAttrProvider(); /// Destructor releases any attributes held by this class. virtual ~wxGridCellAttrProvider(); /** Get the attribute to use for the specified cell. If wxGridCellAttr::Any is used as @a kind value, this function combines the attributes set for this cell using SetAttr() and those for its row or column (set with SetRowAttr() or SetColAttr() respectively), with the cell attribute having the highest precedence. Notice that the caller must call DecRef() on the returned pointer if it is non-@NULL. @param row The row of the cell. @param col The column of the cell. @param kind The kind of the attribute to return. @return The attribute to use which should be DecRef()'d by caller or @NULL if no attributes are defined for this cell. */ virtual wxGridCellAttr *GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) const; /*! @name Setting attributes. All these functions take ownership of the attribute passed to them, i.e. will call DecRef() on it themselves later and so it should not be destroyed by the caller. The attribute can be @NULL to reset a previously set value. */ //@{ /// Set attribute for the specified cell. virtual void SetAttr(wxGridCellAttr *attr, int row, int col); /// Set attribute for the specified row. virtual void SetRowAttr(wxGridCellAttr *attr, int row); /// Set attribute for the specified column. virtual void SetColAttr(wxGridCellAttr *attr, int col); //@} /** @name Getting header renderers. These functions return the renderers for the given row or column header label and the corner window. Unlike cell attributes, these objects are not reference counted and are never @NULL so they are returned by reference and not pointer and DecRef() shouldn't (and can't) be called for them. All these functions were added in wxWidgets 2.9.1. */ //@{ /** Return the renderer used for drawing column headers. By default wxGridColumnHeaderRendererDefault is returned. @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader() @since 2.9.1 */ virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col); /** Return the renderer used for drawing row headers. By default wxGridRowHeaderRendererDefault is returned. @since 2.9.1 */ virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row); /** Return the renderer used for drawing the corner window. By default wxGridCornerHeaderRendererDefault is returned. @since 2.9.1 */ virtual const wxGridCornerHeaderRenderer& GetCornerRenderer(); //@} }; /** Represents coordinates of a grid cell. An object of this class is simply a (row, column) pair. */ class wxGridCellCoords { public: /** Default constructor initializes the object to invalid state. Initially the row and column are both invalid (-1) and so operator!() for an uninitialized wxGridCellCoords returns false. */ wxGridCellCoords(); /** Constructor taking a row and a column. */ wxGridCellCoords(int row, int col); /** Return the row of the coordinate. */ int GetRow() const; /** Set the row of the coordinate. */ void SetRow(int n); /** Return the column of the coordinate. */ int GetCol() const; /** Set the column of the coordinate. */ void SetCol(int n); /** Set the row and column of the coordinate. */ void Set(int row, int col); /** Assignment operator for coordinate types. */ wxGridCellCoords& operator=(const wxGridCellCoords& other); /** Equality operator. */ bool operator==(const wxGridCellCoords& other) const; /** Inequality operator. */ bool operator!=(const wxGridCellCoords& other) const; /** Checks whether the coordinates are invalid. Returns false only if both row and column are -1. Notice that if either row or column (but not both) are -1, this method returns true even if the object is invalid. This is done because objects in such state should actually never exist, i.e. either both coordinates should be -1 or none of them should be -1. */ bool operator!() const; }; /** @class wxGridTableBase The almost abstract base class for grid tables. A grid table is responsible for storing the grid data and, indirectly, grid cell attributes. The data can be stored in the way most convenient for the application but has to be provided in string form to wxGrid. It is also possible to provide cells values in other formats if appropriate, e.g. as numbers. This base class is not quite abstract as it implements a trivial strategy for storing the attributes by forwarding it to wxGridCellAttrProvider and also provides stubs for some other functions. However it does have a number of pure virtual methods which must be implemented in the derived classes. @see wxGridStringTable @library{wxadv} @category{grid} */ class wxGridTableBase : public wxObject { public: /** Default constructor. */ wxGridTableBase(); /** Destructor frees the attribute provider if it was created. */ virtual ~wxGridTableBase(); /** Must be overridden to return the number of rows in the table. For backwards compatibility reasons, this method is not const. Use GetRowsCount() instead of it in const methods of derived table classes. */ virtual int GetNumberRows() = 0; /** Must be overridden to return the number of columns in the table. For backwards compatibility reasons, this method is not const. Use GetColsCount() instead of it in const methods of derived table classes, */ virtual int GetNumberCols() = 0; /** Return the number of rows in the table. This method is not virtual and is only provided as a convenience for the derived classes which can't call GetNumberRows() without a @c const_cast from their const methods. */ int GetRowsCount() const; /** Return the number of columns in the table. This method is not virtual and is only provided as a convenience for the derived classes which can't call GetNumberCols() without a @c const_cast from their const methods. */ int GetColsCount() const; /** @name Table Cell Accessors */ //@{ /** May be overridden to implement testing for empty cells. This method is used by the grid to test if the given cell is not used and so whether a neighbouring cell may overflow into it. By default it only returns true if the value of the given cell, as returned by GetValue(), is empty. */ virtual bool IsEmptyCell(int row, int col); /** Same as IsEmptyCell() but taking wxGridCellCoords. Notice that this method is not virtual, only IsEmptyCell() should be overridden. */ bool IsEmpty(const wxGridCellCoords& coords); /** Must be overridden to implement accessing the table values as text. */ virtual wxString GetValue(int row, int col) = 0; /** Must be overridden to implement setting the table values as text. */ virtual void SetValue(int row, int col, const wxString& value) = 0; /** Returns the type of the value in the given cell. By default all cells are strings and this method returns @c wxGRID_VALUE_STRING. */ virtual wxString GetTypeName(int row, int col); /** Returns true if the value of the given cell can be accessed as if it were of the specified type. By default the cells can only be accessed as strings. Note that a cell could be accessible in different ways, e.g. a numeric cell may return @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING indicating that the value can be coerced to a string form. */ virtual bool CanGetValueAs(int row, int col, const wxString& typeName); /** Returns true if the value of the given cell can be set as if it were of the specified type. @see CanGetValueAs() */ virtual bool CanSetValueAs(int row, int col, const wxString& typeName); /** Returns the value of the given cell as a long. This should only be called if CanGetValueAs() returns @true when called with @c wxGRID_VALUE_NUMBER argument. Default implementation always return 0. */ virtual long GetValueAsLong(int row, int col); /** Returns the value of the given cell as a double. This should only be called if CanGetValueAs() returns @true when called with @c wxGRID_VALUE_FLOAT argument. Default implementation always return 0.0. */ virtual double GetValueAsDouble(int row, int col); /** Returns the value of the given cell as a boolean. This should only be called if CanGetValueAs() returns @true when called with @c wxGRID_VALUE_BOOL argument. Default implementation always return false. */ virtual bool GetValueAsBool(int row, int col); /** Returns the value of the given cell as a user-defined type. This should only be called if CanGetValueAs() returns @true when called with @a typeName. Default implementation always return @NULL. */ virtual void *GetValueAsCustom(int row, int col, const wxString& typeName); /** Sets the value of the given cell as a long. This should only be called if CanSetValueAs() returns @true when called with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do anything. */ virtual void SetValueAsLong(int row, int col, long value); /** Sets the value of the given cell as a double. This should only be called if CanSetValueAs() returns @true when called with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do anything. */ virtual void SetValueAsDouble(int row, int col, double value); /** Sets the value of the given cell as a boolean. This should only be called if CanSetValueAs() returns @true when called with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do anything. */ virtual void SetValueAsBool( int row, int col, bool value ); /** Sets the value of the given cell as a user-defined type. This should only be called if CanSetValueAs() returns @true when called with @a typeName. Default implementation doesn't do anything. */ virtual void SetValueAsCustom(int row, int col, const wxString& typeName, void *value); //@} /** Called by the grid when the table is associated with it. The default implementation stores the pointer and returns it from its GetView() and so only makes sense if the table cannot be associated with more than one grid at a time. */ virtual void SetView(wxGrid *grid); /** Returns the last grid passed to SetView(). */ virtual wxGrid *GetView() const; /*! @name Table Structure Modifiers Note that none of these functions are pure virtual as they don't have to be implemented if the table structure is never modified after creation, i.e. neither rows nor columns are ever added or deleted. Also note that you do need to implement them if they are called, i.e. if your code either calls them directly or uses the matching wxGrid methods, as by default they simply do nothing which is definitely inappropriate. */ //@{ /** Clear the table contents. This method is used by wxGrid::ClearGrid(). */ virtual void Clear(); /** Insert additional rows into the table. @param pos The position of the first new row. @param numRows The number of rows to insert. */ virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); /** Append additional rows at the end of the table. This method is provided in addition to InsertRows() as some data models may only support appending rows to them but not inserting them at arbitrary locations. In such case you may implement this method only and leave InsertRows() unimplemented. @param numRows The number of rows to add. */ virtual bool AppendRows(size_t numRows = 1); /** Delete rows from the table. Notice that currently deleting a row intersecting a multi-cell (see SetCellSize()) is not supported and will result in a crash. @param pos The first row to delete. @param numRows The number of rows to delete. */ virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); /** Exactly the same as InsertRows() but for columns. */ virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); /** Exactly the same as AppendRows() but for columns. */ virtual bool AppendCols(size_t numCols = 1); /** Exactly the same as DeleteRows() but for columns. */ virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); //@} /*! @name Table Row and Column Labels By default the numbers are used for labeling rows and Latin letters for labeling columns. If the table has more than 26 columns, the pairs of letters are used starting from the 27-th one and so on, i.e. the sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ, AAA, ... */ //@{ /** Return the label of the specified row. */ virtual wxString GetRowLabelValue(int row); /** Return the label of the specified column. */ virtual wxString GetColLabelValue(int col); /** Set the given label for the specified row. The default version does nothing, i.e. the label is not stored. You must override this method in your derived class if you wish wxGrid::SetRowLabelValue() to work. */ virtual void SetRowLabelValue(int row, const wxString& label); /** Exactly the same as SetRowLabelValue() but for columns. */ virtual void SetColLabelValue(int col, const wxString& label); //@} /** @name Attributes Management By default the attributes management is delegated to wxGridCellAttrProvider class. You may override the methods in this section to handle the attributes directly if, for example, they can be computed from the cell values. */ //@{ /** Associate this attributes provider with the table. The table takes ownership of @a attrProvider pointer and will delete it when it doesn't need it any more. The pointer can be @NULL, however this won't disable attributes management in the table but will just result in a default attributes being recreated the next time any of the other functions in this section is called. To completely disable the attributes support, should this be needed, you need to override CanHaveAttributes() to return @false. */ void SetAttrProvider(wxGridCellAttrProvider *attrProvider); /** Returns the attribute provider currently being used. This function may return @NULL if the attribute provider hasn't been neither associated with this table by SetAttrProvider() nor created on demand by any other methods. */ wxGridCellAttrProvider *GetAttrProvider() const; /** Return the attribute for the given cell. By default this function is simply forwarded to wxGridCellAttrProvider::GetAttr() but it may be overridden to handle attributes directly in the table. */ virtual wxGridCellAttr *GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind); /** Set attribute of the specified cell. By default this function is simply forwarded to wxGridCellAttrProvider::SetAttr(). The table takes ownership of @a attr, i.e. will call DecRef() on it. */ virtual void SetAttr(wxGridCellAttr* attr, int row, int col); /** Set attribute of the specified row. By default this function is simply forwarded to wxGridCellAttrProvider::SetRowAttr(). The table takes ownership of @a attr, i.e. will call DecRef() on it. */ virtual void SetRowAttr(wxGridCellAttr *attr, int row); /** Set attribute of the specified column. By default this function is simply forwarded to wxGridCellAttrProvider::SetColAttr(). The table takes ownership of @a attr, i.e. will call DecRef() on it. */ virtual void SetColAttr(wxGridCellAttr *attr, int col); //@} /** Returns true if this table supports attributes or false otherwise. By default, the table automatically creates a wxGridCellAttrProvider when this function is called if it had no attribute provider before and returns @true. */ virtual bool CanHaveAttributes(); }; enum wxGridTableRequest { wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000, wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_COLS_INSERTED, wxGRIDTABLE_NOTIFY_COLS_APPENDED, wxGRIDTABLE_NOTIFY_COLS_DELETED }; /** @class wxGridTableMessage A simple class used to pass messages from the table to the grid. @library{wxadv} @category{grid} */ class wxGridTableMessage { public: wxGridTableMessage(); wxGridTableMessage( wxGridTableBase *table, int id, int comInt1 = -1, int comInt2 = -1 ); void SetTableObject( wxGridTableBase *table ); wxGridTableBase * GetTableObject() const; void SetId( int id ); int GetId(); void SetCommandInt( int comInt1 ); int GetCommandInt(); void SetCommandInt2( int comInt2 ); int GetCommandInt2(); }; /** @class wxGridStringTable Simplest type of data table for a grid for small tables of strings that are stored in memory */ class wxGridStringTable : public wxGridTableBase { public: wxGridStringTable(); wxGridStringTable( int numRows, int numCols ); // these are pure virtual in wxGridTableBase virtual int GetNumberRows(); virtual int GetNumberCols(); virtual wxString GetValue( int row, int col ); virtual void SetValue( int row, int col, const wxString& value ); // overridden functions from wxGridTableBase void Clear(); bool InsertRows( size_t pos = 0, size_t numRows = 1 ); bool AppendRows( size_t numRows = 1 ); bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); bool InsertCols( size_t pos = 0, size_t numCols = 1 ); bool AppendCols( size_t numCols = 1 ); bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); void SetRowLabelValue( int row, const wxString& ); void SetColLabelValue( int col, const wxString& ); wxString GetRowLabelValue( int row ); wxString GetColLabelValue( int col ); }; /** @class wxGridSizesInfo wxGridSizesInfo stores information about sizes of all wxGrid rows or columns. It assumes that most of the rows or columns (which are both called elements here as the difference between them doesn't matter at this class level) have the default size and so stores it separately. And it uses a wxHashMap to store the sizes of all elements which have the non-default size. This structure is particularly useful for serializing the sizes of all wxGrid elements at once. @library{wxadv} @category{grid} */ struct wxGridSizesInfo { /** Default constructor. m_sizeDefault and m_customSizes must be initialized later. */ wxGridSizesInfo(); /** Constructor. This constructor is used by wxGrid::GetRowSizes() and GetColSizes() methods. User code will usually use the default constructor instead. @param defSize The default element size. @param allSizes Array containing the sizes of @em all elements, including those which have the default size. */ wxGridSizesInfo(int defSize, const wxArrayInt& allSizes); /** Get the element size. @param pos The index of the element. @return The size for this element, using m_customSizes if @a pos is in it or m_sizeDefault otherwise. */ int GetSize(unsigned pos) const; /// Default size int m_sizeDefault; /** Map with element indices as keys and their sizes as values. This map only contains the elements with non-default size. */ wxUnsignedToIntHashMap m_customSizes; }; /** Rendering styles supported by wxGrid::Render() method. @since 2.9.4 */ enum wxGridRenderStyle { /// Draw grid row header labels. wxGRID_DRAW_ROWS_HEADER = 0x001, /// Draw grid column header labels. wxGRID_DRAW_COLS_HEADER = 0x002, /// Draw grid cell border lines. wxGRID_DRAW_CELL_LINES = 0x004, /** Draw a bounding rectangle around the rendered cell area. Useful where row or column headers are not drawn or where there is multi row or column cell clipping and therefore no cell border at the rendered outer boundary. */ wxGRID_DRAW_BOX_RECT = 0x008, /** Draw the grid cell selection highlight if a selection is present. At present the highlight colour drawn depends on whether the grid window loses focus before drawing begins. */ wxGRID_DRAW_SELECTION = 0x010, /** The default render style. Includes all except wxGRID_DRAW_SELECTION. */ wxGRID_DRAW_DEFAULT = wxGRID_DRAW_ROWS_HEADER | wxGRID_DRAW_COLS_HEADER | wxGRID_DRAW_CELL_LINES | wxGRID_DRAW_BOX_RECT }; /** @class wxGrid wxGrid and its related classes are used for displaying and editing tabular data. They provide a rich set of features for display, editing, and interacting with a variety of data sources. For simple applications, and to help you get started, wxGrid is the only class you need to refer to directly. It will set up default instances of the other classes and manage them for you. For more complex applications you can derive your own classes for custom grid views, grid data tables, cell editors and renderers. The @ref overview_grid has examples of simple and more complex applications, explains the relationship between the various grid classes and has a summary of the keyboard shortcuts and mouse functions provided by wxGrid. A wxGridTableBase class holds the actual data to be displayed by a wxGrid class. One or more wxGrid classes may act as a view for one table class. The default table class is called wxGridStringTable and holds an array of strings. An instance of such a class is created by CreateGrid(). wxGridCellRenderer is the abstract base class for rendering contents in a cell. The following renderers are predefined: - wxGridCellBoolRenderer - wxGridCellFloatRenderer - wxGridCellNumberRenderer - wxGridCellStringRenderer The look of a cell can be further defined using wxGridCellAttr. An object of this type may be returned by wxGridTableBase::GetAttr(). wxGridCellEditor is the abstract base class for editing the value of a cell. The following editors are predefined: - wxGridCellBoolEditor - wxGridCellChoiceEditor - wxGridCellFloatEditor - wxGridCellNumberEditor - wxGridCellTextEditor Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and wxGridEditorCreatedEvent for the documentation of all event types you can use with wxGrid. @library{wxadv} @category{grid} @see @ref overview_grid, wxGridUpdateLocker */ class wxGrid : public wxScrolledWindow { public: /** Different selection modes supported by the grid. */ enum wxGridSelectionModes { /** The default selection mode allowing selection of the individual cells as well as of the entire rows and columns. */ wxGridSelectCells, /** The selection mode allowing the selection of the entire rows only. The user won't be able to select any cells or columns in this mode. */ wxGridSelectRows, /** The selection mode allowing the selection of the entire columns only. The user won't be able to select any cells or rows in this mode. */ wxGridSelectColumns, /** The selection mode allowing the user to select either the entire columns or the entire rows but not individual cells nor blocks. Notice that while this constant is defined as @code wxGridSelectColumns | wxGridSelectRows @endcode this doesn't mean that all the other combinations are valid -- at least currently they are not. @since 2.9.1 */ wxGridSelectRowsOrColumns }; /** Return values for GetCellSize(). @since 2.9.1 */ enum CellSpan { /// This cell is inside a span covered by another cell. CellSpan_Inside = -1, /// This is a normal, non-spanning cell. CellSpan_None = 0, /// This cell spans several physical wxGrid cells. CellSpan_Main }; /** Constants defining different support built-in TAB handling behaviours. The elements of this enum determine what happens when TAB is pressed when the cursor is in the rightmost column (or Shift-TAB is pressed when the cursor is in the leftmost one). @see SetTabBehaviour(), @c wxEVT_GRID_TABBING @since 2.9.5 */ enum TabBehaviour { /// Do nothing, this is default. Tab_Stop, /// Move to the beginning of the next (or the end of the previous) row. Tab_Wrap, /// Move to the next (or the previous) control after the grid. Tab_Leave }; /** @name Constructors and Initialization */ //@{ /** Default constructor. You must call Create() to really create the grid window and also call CreateGrid() or SetTable() to initialize the grid contents. */ wxGrid(); /** Constructor creating the grid window. You must call either CreateGrid() or SetTable() to initialize the grid contents before using it. */ wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr); /** Destructor. This will also destroy the associated grid table unless you passed a table object to the grid and specified that the grid should not take ownership of the table (see SetTable()). */ virtual ~wxGrid(); /** Creates the grid window for an object initialized using the default constructor. You must call either CreateGrid() or SetTable() to initialize the grid contents before using it. */ bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr); /** Creates a grid with the specified initial number of rows and columns. Call this directly after the grid constructor. When you use this function wxGrid will create and manage a simple table of string values for you. All of the grid data will be stored in memory. For applications with more complex data types or relationships, or for dealing with very large datasets, you should derive your own grid table class and pass a table object to the grid with SetTable(). */ bool CreateGrid(int numRows, int numCols, wxGridSelectionModes selmode = wxGridSelectCells); /** Passes a pointer to a custom grid table to be used by the grid. This should be called after the grid constructor and before using the grid object. If @a takeOwnership is set to @true then the table will be deleted by the wxGrid destructor. Use this function instead of CreateGrid() when your application involves complex or non-string data or data sets that are too large to fit wholly in memory. */ bool SetTable(wxGridTableBase* table, bool takeOwnership = false, wxGridSelectionModes selmode = wxGridSelectCells); /** Receive and handle a message from the table. */ bool ProcessTableMessage(wxGridTableMessage& msg); //@} /** @name Grid Line Formatting */ //@{ /** Turns the drawing of grid lines on or off. */ void EnableGridLines(bool enable = true); /** Returns the pen used for vertical grid lines. This virtual function may be overridden in derived classes in order to change the appearance of individual grid lines for the given column @a col. See GetRowGridLinePen() for an example. */ virtual wxPen GetColGridLinePen(int col); /** Returns the pen used for grid lines. This virtual function may be overridden in derived classes in order to change the appearance of grid lines. Note that currently the pen width must be 1. @see GetColGridLinePen(), GetRowGridLinePen() */ virtual wxPen GetDefaultGridLinePen(); /** Returns the colour used for grid lines. @see GetDefaultGridLinePen() */ wxColour GetGridLineColour() const; /** Returns the pen used for horizontal grid lines. This virtual function may be overridden in derived classes in order to change the appearance of individual grid line for the given @a row. Example: @code // in a grid displaying music notation, use a solid black pen between // octaves (C0=row 127, C1=row 115 etc.) wxPen MidiGrid::GetRowGridLinePen(int row) { if ( row % 12 == 7 ) return wxPen(*wxBLACK, 1, wxSOLID); else return GetDefaultGridLinePen(); } @endcode */ virtual wxPen GetRowGridLinePen(int row); /** Returns @true if drawing of grid lines is turned on, @false otherwise. */ bool GridLinesEnabled() const; /** Sets the colour used to draw grid lines. */ void SetGridLineColour(const wxColour& colour); //@} /** @name Label Values and Formatting */ //@{ /** Sets the arguments to the current column label alignment values. Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void GetColLabelAlignment(int* horiz, int* vert) const; /** Returns the orientation of the column labels (either @c wxHORIZONTAL or @c wxVERTICAL). */ int GetColLabelTextOrientation() const; /** Returns the specified column label. The default grid table class provides column labels of the form A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can override wxGridTableBase::GetColLabelValue() to provide your own labels. */ wxString GetColLabelValue(int col) const; /** Returns the colour used for the background of row and column labels. */ wxColour GetLabelBackgroundColour() const; /** Returns the font used for row and column labels. */ wxFont GetLabelFont() const; /** Returns the colour used for row and column label text. */ wxColour GetLabelTextColour() const; /** Returns the alignment used for row labels. Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void GetRowLabelAlignment(int* horiz, int* vert) const; /** Returns the specified row label. The default grid table class provides numeric row labels. If you are using a custom grid table you can override wxGridTableBase::GetRowLabelValue() to provide your own labels. */ wxString GetRowLabelValue(int row) const; /** Hides the column labels by calling SetColLabelSize() with a size of 0. Show labels again by calling that method with a width greater than 0. */ void HideColLabels(); /** Hides the row labels by calling SetRowLabelSize() with a size of 0. The labels can be shown again by calling SetRowLabelSize() with a width greater than 0. */ void HideRowLabels(); /** Sets the horizontal and vertical alignment of column label text. Horizontal alignment should be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void SetColLabelAlignment(int horiz, int vert); /** Sets the orientation of the column labels (either @c wxHORIZONTAL or @c wxVERTICAL). */ void SetColLabelTextOrientation(int textOrientation); /** Set the value for the given column label. If you are using a custom grid table you must override wxGridTableBase::SetColLabelValue() for this to have any effect. */ void SetColLabelValue(int col, const wxString& value); /** Sets the background colour for row and column labels. */ void SetLabelBackgroundColour(const wxColour& colour); /** Sets the font for row and column labels. */ void SetLabelFont(const wxFont& font); /** Sets the colour for row and column label text. */ void SetLabelTextColour(const wxColour& colour); /** Sets the horizontal and vertical alignment of row label text. Horizontal alignment should be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void SetRowLabelAlignment(int horiz, int vert); /** Sets the value for the given row label. If you are using a derived grid table you must override wxGridTableBase::SetRowLabelValue() for this to have any effect. */ void SetRowLabelValue(int row, const wxString& value); /** Call this in order to make the column labels use a native look by using wxRendererNative::DrawHeaderButton() internally. There is no equivalent method for drawing row columns as there is not native look for that. This option is useful when using wxGrid for displaying tables and not as a spread-sheet. @see UseNativeColHeader() */ void SetUseNativeColLabels(bool native = true); /** Enable the use of native header window for column labels. If this function is called with @true argument, a wxHeaderCtrl is used instead to display the column labels instead of drawing them in wxGrid code itself. This has the advantage of making the grid look and feel perfectly the same as native applications (using SetUseNativeColLabels() the grid can be made to look more natively but it still doesn't feel natively, notably the column resizing and dragging still works slightly differently as it is implemented in wxWidgets itself) but results in different behaviour for column and row headers, for which there is no equivalent function, and, most importantly, is unsuitable for grids with huge numbers of columns as wxHeaderCtrl doesn't support virtual mode. Because of this, by default the grid does not use the native header control but you should call this function to enable it if you are using the grid to display tabular data and don't have thousands of columns in it. Another difference between the default behaviour and the native header behaviour is that the latter provides the user with a context menu (which appears on right clicking the header) allowing to rearrange the grid columns if CanDragColMove() returns @true. If you want to prevent this from happening for some reason, you need to define a handler for @c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in particular doesn't skip the event) as this will prevent the default right click handling from working. Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not generated for the column labels if the native columns header is used (but this limitation could possibly be lifted in the future). */ void UseNativeColHeader(bool native = true); //@} /*! @name Cell Formatting Note that wxGridCellAttr can be used alternatively to most of these methods. See the "Attributes Management" of wxGridTableBase. */ //@{ /** Sets the arguments to the horizontal and vertical text alignment values for the grid cell at the specified location. Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void GetCellAlignment(int row, int col, int* horiz, int* vert) const; /** Returns the background colour of the cell at the specified location. */ wxColour GetCellBackgroundColour(int row, int col) const; /** Returns the font for text in the grid cell at the specified location. */ wxFont GetCellFont(int row, int col) const; /** Returns the text colour for the grid cell at the specified location. */ wxColour GetCellTextColour(int row, int col) const; /** Returns the default cell alignment. Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. @see SetDefaultCellAlignment() */ void GetDefaultCellAlignment(int* horiz, int* vert) const; /** Returns the current default background colour for grid cells. */ wxColour GetDefaultCellBackgroundColour() const; /** Returns the current default font for grid cell text. */ wxFont GetDefaultCellFont() const; /** Returns the current default colour for grid cell text. */ wxColour GetDefaultCellTextColour() const; /** Sets the horizontal and vertical alignment for grid cell text at the specified location. Horizontal alignment should be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void SetCellAlignment(int row, int col, int horiz, int vert); /** Sets the horizontal and vertical alignment for grid cell text at the specified location. Horizontal alignment should be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void SetCellAlignment(int align, int row, int col); /** Set the background colour for the given cell or all cells by default. */ void SetCellBackgroundColour(int row, int col, const wxColour& colour); /** Sets the font for text in the grid cell at the specified location. */ void SetCellFont(int row, int col, const wxFont& font); /** Sets the text colour for the given cell. */ void SetCellTextColour(int row, int col, const wxColour& colour); /** Sets the text colour for the given cell. */ void SetCellTextColour(const wxColour& val, int row, int col); /** Sets the text colour for all cells by default. */ void SetCellTextColour(const wxColour& colour); /** Sets the default horizontal and vertical alignment for grid cell text. Horizontal alignment should be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. */ void SetDefaultCellAlignment(int horiz, int vert); /** Sets the default background colour for grid cells. */ void SetDefaultCellBackgroundColour(const wxColour& colour); /** Sets the default font to be used for grid cell text. */ void SetDefaultCellFont(const wxFont& font); /** Sets the current default colour for grid cell text. */ void SetDefaultCellTextColour(const wxColour& colour); //@} /*! @name Cell Values, Editors, and Renderers Note that wxGridCellAttr can be used alternatively to most of these methods. See the "Attributes Management" of wxGridTableBase. */ //@{ /** Returns @true if the in-place edit control for the current grid cell can be used and @false otherwise. This function always returns @false for the read-only cells. */ bool CanEnableCellControl() const; /** Disables in-place editing of grid cells. Equivalent to calling EnableCellEditControl(@false). */ void DisableCellEditControl(); /** Enables or disables in-place editing of grid cell data. The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or @c wxEVT_GRID_EDITOR_HIDDEN event. */ void EnableCellEditControl(bool enable = true); /** Makes the grid globally editable or read-only. If the edit argument is @false this function sets the whole grid as read-only. If the argument is @true the grid is set to the default state where cells may be editable. In the default state you can set single grid cells and whole rows and columns to be editable or read-only via wxGridCellAttr::SetReadOnly(). For single cells you can also use the shortcut function SetReadOnly(). For more information about controlling grid cell attributes see the wxGridCellAttr class and the @ref overview_grid. */ void EnableEditing(bool edit); /** Returns a pointer to the editor for the cell at the specified location. See wxGridCellEditor and the @ref overview_grid for more information about cell editors and renderers. The caller must call DecRef() on the returned pointer. */ wxGridCellEditor* GetCellEditor(int row, int col) const; /** Returns a pointer to the renderer for the grid cell at the specified location. See wxGridCellRenderer and the @ref overview_grid for more information about cell editors and renderers. The caller must call DecRef() on the returned pointer. */ wxGridCellRenderer* GetCellRenderer(int row, int col) const; /** Returns the string contained in the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with SetCellValue() to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for more information. */ wxString GetCellValue(int row, int col) const; /** Returns the string contained in the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with SetCellValue() to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for more information. */ wxString GetCellValue(const wxGridCellCoords& coords) const; /** Returns a pointer to the current default grid cell editor. See wxGridCellEditor and the @ref overview_grid for more information about cell editors and renderers. */ wxGridCellEditor* GetDefaultEditor() const; /** Returns the default editor for the specified cell. The base class version returns the editor appropriate for the current cell type but this method may be overridden in the derived classes to use custom editors for some cells by default. Notice that the same may be achieved in a usually simpler way by associating a custom editor with the given cell or cells. The caller must call DecRef() on the returned pointer. */ virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; /** Returns the default editor for the specified cell. The base class version returns the editor appropriate for the current cell type but this method may be overridden in the derived classes to use custom editors for some cells by default. Notice that the same may be achieved in a usually simpler way by associating a custom editor with the given cell or cells. The caller must call DecRef() on the returned pointer. */ wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const; /** Returns the default editor for the cells containing values of the given type. The base class version returns the editor which was associated with the specified @a typeName when it was registered RegisterDataType() but this function may be overridden to return something different. This allows to override an editor used for one of the standard types. The caller must call DecRef() on the returned pointer. */ virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; /** Returns a pointer to the current default grid cell renderer. See wxGridCellRenderer and the @ref overview_grid for more information about cell editors and renderers. The caller must call DecRef() on the returned pointer. */ wxGridCellRenderer* GetDefaultRenderer() const; /** Returns the default renderer for the given cell. The base class version returns the renderer appropriate for the current cell type but this method may be overridden in the derived classes to use custom renderers for some cells by default. The caller must call DecRef() on the returned pointer. */ virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; /** Returns the default renderer for the cell containing values of the given type. @see GetDefaultEditorForType() */ virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; /** Hides the in-place cell edit control. */ void HideCellEditControl(); /** Returns @true if the in-place edit control is currently enabled. */ bool IsCellEditControlEnabled() const; /** Returns @true if the in-place edit control is currently shown. @see HideCellEditControl() */ bool IsCellEditControlShown() const; /** Returns @true if the current cell is read-only. @see SetReadOnly(), IsReadOnly() */ bool IsCurrentCellReadOnly() const; /** Returns @false if the whole grid has been set as read-only or @true otherwise. See EnableEditing() for more information about controlling the editing status of grid cells. */ bool IsEditable() const; /** Returns @true if the cell at the specified location can't be edited. @see SetReadOnly(), IsCurrentCellReadOnly() */ bool IsReadOnly(int row, int col) const; /** Register a new data type. The data types allow to naturally associate specific renderers and editors to the cells containing values of the given type. For example, the grid automatically registers a data type with the name @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and wxGridCellTextEditor as its renderer and editor respectively -- this is the data type used by all the cells of the default wxGridStringTable, so this renderer and editor are used by default for all grid cells. However if a custom table returns @c wxGRID_VALUE_BOOL from its wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and wxGridCellBoolEditor are used for it because the grid also registers a boolean data type with this name. And as this mechanism is completely generic, you may register your own data types using your own custom renderers and editors. Just remember that the table must identify a cell as being of the given type for them to be used for this cell. @param typeName Name of the new type. May be any string, but if the type name is the same as the name of an already registered type, including one of the standard ones (which are @c wxGRID_VALUE_STRING, @c wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT and @c wxGRID_VALUE_CHOICE), then the new registration information replaces the previously used renderer and editor. @param renderer The renderer to use for the cells of this type. Its ownership is taken by the grid, i.e. it will call DecRef() on this pointer when it doesn't need it any longer. @param editor The editor to use for the cells of this type. Its ownership is also taken by the grid. */ void RegisterDataType(const wxString& typeName, wxGridCellRenderer* renderer, wxGridCellEditor* editor); /** Sets the value of the current grid cell to the current in-place edit control value. This is called automatically when the grid cursor moves from the current cell to a new cell. It is also a good idea to call this function when closing a grid since any edits to the final cell location will not be saved otherwise. */ void SaveEditControlValue(); /** Sets the editor for the grid cell at the specified location. The grid will take ownership of the pointer. See wxGridCellEditor and the @ref overview_grid for more information about cell editors and renderers. */ void SetCellEditor(int row, int col, wxGridCellEditor* editor); /** Sets the renderer for the grid cell at the specified location. The grid will take ownership of the pointer. See wxGridCellRenderer and the @ref overview_grid for more information about cell editors and renderers. */ void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer); /** Sets the string value for the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with GetCellValue() to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for more information. */ void SetCellValue(int row, int col, const wxString& s); /** Sets the string value for the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with GetCellValue() to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for more information. */ void SetCellValue(const wxGridCellCoords& coords, const wxString& s); /** @deprecated Please use SetCellValue(int,int,const wxString&) or SetCellValue(const wxGridCellCoords&,const wxString&) instead. Sets the string value for the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with GetCellValue() to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for more information. */ void SetCellValue(const wxString& val, int row, int col); /** Sets the specified column to display boolean values. @see SetColFormatCustom() */ void SetColFormatBool(int col); /** Sets the specified column to display data in a custom format. This method provides an alternative to defining a custom grid table which would return @a typeName from its GetTypeName() method for the cells in this column: while it doesn't really change the type of the cells in this column, it does associate the renderer and editor used for the cells of the specified type with them. See the @ref overview_grid for more information on working with custom data types. */ void SetColFormatCustom(int col, const wxString& typeName); /** Sets the specified column to display floating point values with the given width and precision. @see SetColFormatCustom() */ void SetColFormatFloat(int col, int width = -1, int precision = -1); /** Sets the specified column to display integer values. @see SetColFormatCustom() */ void SetColFormatNumber(int col); /** Sets the default editor for grid cells. The grid will take ownership of the pointer. See wxGridCellEditor and the @ref overview_grid for more information about cell editors and renderers. */ void SetDefaultEditor(wxGridCellEditor* editor); /** Sets the default renderer for grid cells. The grid will take ownership of the pointer. See wxGridCellRenderer and the @ref overview_grid for more information about cell editors and renderers. */ void SetDefaultRenderer(wxGridCellRenderer* renderer); /** Makes the cell at the specified location read-only or editable. @see IsReadOnly() */ void SetReadOnly(int row, int col, bool isReadOnly = true); /** Displays the in-place cell edit control for the current cell. */ void ShowCellEditControl(); //@} /** @name Column and Row Sizes @see @ref overview_grid_resizing */ //@{ /** Automatically sets the height and width of all rows and columns to fit their contents. */ void AutoSize(); /** Automatically adjusts width of the column to fit its label. */ void AutoSizeColLabelSize(int col); /** Automatically sizes the column to fit its contents. If @a setAsMin is @true the calculated width will also be set as the minimal width for the column. */ void AutoSizeColumn(int col, bool setAsMin = true); /** Automatically sizes all columns to fit their contents. If @a setAsMin is @true the calculated widths will also be set as the minimal widths for the columns. */ void AutoSizeColumns(bool setAsMin = true); /** Automatically sizes the row to fit its contents. If @a setAsMin is @true the calculated height will also be set as the minimal height for the row. */ void AutoSizeRow(int row, bool setAsMin = true); /** Automatically adjusts height of the row to fit its label. */ void AutoSizeRowLabelSize(int col); /** Automatically sizes all rows to fit their contents. If @a setAsMin is @true the calculated heights will also be set as the minimal heights for the rows. */ void AutoSizeRows(bool setAsMin = true); /** Returns @true if the cell value can overflow. A cell can overflow if the next cell in the row is empty. */ bool GetCellOverflow(int row, int col) const; /** Returns the current height of the column labels. */ int GetColLabelSize() const; /** Returns the minimal width to which a column may be resized. Use SetColMinimalAcceptableWidth() to change this value globally or SetColMinimalWidth() to do it for individual columns. @see GetRowMinimalAcceptableHeight() */ int GetColMinimalAcceptableWidth() const; /** Returns the width of the specified column. */ int GetColSize(int col) const; /** Returns @true if the specified column is not currently hidden. */ bool IsColShown(int col) const; /** Returns @true if the cells can overflow by default. */ bool GetDefaultCellOverflow() const; /** Returns the default height for column labels. */ int GetDefaultColLabelSize() const; /** Returns the current default width for grid columns. */ int GetDefaultColSize() const; /** Returns the default width for the row labels. */ int GetDefaultRowLabelSize() const; /** Returns the current default height for grid rows. */ int GetDefaultRowSize() const; /** Returns the minimal size to which rows can be resized. Use SetRowMinimalAcceptableHeight() to change this value globally or SetRowMinimalHeight() to do it for individual cells. @see GetColMinimalAcceptableWidth() */ int GetRowMinimalAcceptableHeight() const; /** Returns the current width of the row labels. */ int GetRowLabelSize() const; /** Returns the height of the specified row. */ int GetRowSize(int row) const; /** Returns @true if the specified row is not currently hidden. */ bool IsRowShown(int row) const; /** Sets the overflow permission of the cell. */ void SetCellOverflow(int row, int col, bool allow); /** Sets the height of the column labels. If @a height equals to @c wxGRID_AUTOSIZE then height is calculated automatically so that no label is truncated. Note that this could be slow for a large table. */ void SetColLabelSize(int height); /** Sets the minimal @a width to which the user can resize columns. @see GetColMinimalAcceptableWidth() */ void SetColMinimalAcceptableWidth(int width); /** Sets the minimal @a width for the specified column @a col. It is usually best to call this method during grid creation as calling it later will not resize the column to the given minimal width even if it is currently narrower than it. @a width must be greater than the minimal acceptable column width as returned by GetColMinimalAcceptableWidth(). */ void SetColMinimalWidth(int col, int width); /** Sets the width of the specified column. @param col The column index. @param width The new column width in pixels, 0 to hide the column or -1 to fit the column width to its label width. */ void SetColSize(int col, int width); /** Hides the specified column. To show the column later you need to call SetColSize() with non-0 width or ShowCol() to restore the previous column width. If the column is already hidden, this method doesn't do anything. @param col The column index. */ void HideCol(int col); /** Shows the previously hidden column by resizing it to non-0 size. The column is shown again with the same width that it had before HideCol() call. If the column is currently shown, this method doesn't do anything. @see HideCol(), SetColSize() */ void ShowCol(int col); /** Sets the default overflow permission of the cells. */ void SetDefaultCellOverflow( bool allow ); /** Sets the default width for columns in the grid. This will only affect columns subsequently added to the grid unless @a resizeExistingCols is @true. If @a width is less than GetColMinimalAcceptableWidth(), then the minimal acceptable width is used instead of it. */ void SetDefaultColSize(int width, bool resizeExistingCols = false); /** Sets the default height for rows in the grid. This will only affect rows subsequently added to the grid unless @a resizeExistingRows is @true. If @a height is less than GetRowMinimalAcceptableHeight(), then the minimal acceptable height is used instead of it. */ void SetDefaultRowSize(int height, bool resizeExistingRows = false); /** Sets the width of the row labels. If @a width equals @c wxGRID_AUTOSIZE then width is calculated automatically so that no label is truncated. Note that this could be slow for a large table. */ void SetRowLabelSize(int width); /** Sets the minimal row @a height used by default. See SetColMinimalAcceptableWidth() for more information. */ void SetRowMinimalAcceptableHeight(int height); /** Sets the minimal @a height for the specified @a row. See SetColMinimalWidth() for more information. */ void SetRowMinimalHeight(int row, int height); /** Sets the height of the specified row. See SetColSize() for more information. */ void SetRowSize(int row, int height); /** Hides the specified row. To show the row later you need to call SetRowSize() with non-0 width or ShowRow() to restore its original height. If the row is already hidden, this method doesn't do anything. @param col The row index. */ void HideRow(int col); /** Shows the previously hidden row. The row is shown again with the same height that it had before HideRow() call. If the row is currently shown, this method doesn't do anything. @see HideRow(), SetRowSize() */ void ShowRow(int col); /** Get size information for all columns at once. This method is useful when the information about all column widths needs to be saved. The widths can be later restored using SetColSizes(). @sa wxGridSizesInfo, GetRowSizes() */ wxGridSizesInfo GetColSizes() const; /** Get size information for all row at once. @sa wxGridSizesInfo, GetColSizes() */ wxGridSizesInfo GetRowSizes() const; /** Restore all columns sizes. This is usually called with wxGridSizesInfo object previously returned by GetColSizes(). @sa SetRowSizes() */ void SetColSizes(const wxGridSizesInfo& sizeInfo); /** Restore all rows sizes. @sa SetColSizes() */ void SetRowSizes(const wxGridSizesInfo& sizeInfo); /** Set the size of the cell. Specifying a value of more than 1 in @a num_rows or @a num_cols will make the cell at (@a row, @a col) span the block of the specified size, covering the other cells which would be normally shown in it. Passing 1 for both arguments resets the cell to normal appearance. @see GetCellSize() @param row The row of the cell. @param col The column of the cell. @param num_rows Number of rows to be occupied by this cell, must be >= 1. @param num_cols Number of columns to be occupied by this cell, must be >= 1. */ void SetCellSize(int row, int col, int num_rows, int num_cols); /** Get the size of the cell in number of cells covered by it. For normal cells, the function fills both @a num_rows and @a num_cols with 1 and returns CellSpan_None. For cells which span multiple cells, i.e. for which SetCellSize() had been called, the returned values are the same ones as were passed to SetCellSize() call and the function return value is CellSpan_Main. More unexpectedly, perhaps, the returned values may be @em negative for the cells which are inside a span covered by a cell occupying multiple rows or columns. They correspond to the offset of the main cell of the span from the cell passed to this functions and the function returns CellSpan_Inside value to indicate this. As an example, consider a 3*3 grid with the cell (1, 1) (the one in the middle) having a span of 2 rows and 2 columns, i.e. the grid looks like @code +----+----+----+ | | | | +----+----+----+ | | | +----+ | | | | +----+----+----+ @endcode Then the function returns 2 and 2 in @a num_rows and @a num_cols for the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1 and 0 for the cell (2, 1). @param row The row of the cell. @param col The column of the cell. @param num_rows Pointer to variable receiving the number of rows, must not be @NULL. @param num_cols Pointer to variable receiving the number of columns, must not be @NULL. @return The kind of this cell span (the return value is new in wxWidgets 2.9.1, this function was void in previous wxWidgets versions). */ CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const; /** Get the number of rows and columns allocated for this cell. This overload doesn't return a CellSpan value but the values returned may still be negative, see GetCellSize(int, int, int *, int *) for details. */ wxSize GetCellSize(const wxGridCellCoords& coords); //@} /** @name User-Resizing and Dragging Functions controlling various interactive mouse operations. By default, columns and rows can be resized by dragging the edges of their labels (this can be disabled using DisableDragColSize() and DisableDragRowSize() methods). And if grid line dragging is enabled with EnableDragGridSize() they can also be resized by dragging the right or bottom edge of the grid cells. Columns can also be moved to interactively change their order but this needs to be explicitly enabled with EnableDragColMove(). */ //@{ /** Return @true if the dragging of cells is enabled or @false otherwise. */ bool CanDragCell() const; /** Returns @true if columns can be moved by dragging with the mouse. Columns can be moved by dragging on their labels. */ bool CanDragColMove() const; /** Returns @true if the given column can be resized by dragging with the mouse. This function returns @true if resizing the columns interactively is globally enabled, i.e. if DisableDragColSize() hadn't been called, and if this column wasn't explicitly marked as non-resizable with DisableColResize(). */ bool CanDragColSize(int col) const; /** Return @true if the dragging of grid lines to resize rows and columns is enabled or @false otherwise. */ bool CanDragGridSize() const; /** Returns @true if the given row can be resized by dragging with the mouse. This is the same as CanDragColSize() but for rows. */ bool CanDragRowSize(int row) const; /** Disable interactive resizing of the specified column. This method allows to disable resizing of an individual column in a grid where the columns are otherwise resizable (which is the case by default). Notice that currently there is no way to make some columns resizable in a grid where columns can't be resized by default as there doesn't seem to be any need for this in practice. There is also no way to make the column marked as fixed using this method resizable again because it is supposed that fixed columns are used for static parts of the grid and so should remain fixed during the entire grid lifetime. Also notice that disabling interactive column resizing will not prevent the program from changing the column size. @see EnableDragColSize() */ void DisableColResize(int col); /** Disable interactive resizing of the specified row. This is the same as DisableColResize() but for rows. @see EnableDragRowSize() */ void DisableRowResize(int row); /** Disables column moving by dragging with the mouse. Equivalent to passing @false to EnableDragColMove(). */ void DisableDragColMove(); /** Disables column sizing by dragging with the mouse. Equivalent to passing @false to EnableDragColSize(). */ void DisableDragColSize(); /** Disable mouse dragging of grid lines to resize rows and columns. Equivalent to passing @false to EnableDragGridSize() */ void DisableDragGridSize(); /** Disables row sizing by dragging with the mouse. Equivalent to passing @false to EnableDragRowSize(). */ void DisableDragRowSize(); /** Enables or disables cell dragging with the mouse. */ void EnableDragCell(bool enable = true); /** Enables or disables column moving by dragging with the mouse. */ void EnableDragColMove(bool enable = true); /** Enables or disables column sizing by dragging with the mouse. @see DisableColResize() */ void EnableDragColSize(bool enable = true); /** Enables or disables row and column resizing by dragging gridlines with the mouse. */ void EnableDragGridSize(bool enable = true); /** Enables or disables row sizing by dragging with the mouse. @see DisableRowResize() */ void EnableDragRowSize(bool enable = true); /** Returns the column ID of the specified column position. */ int GetColAt(int colPos) const; /** Returns the position of the specified column. */ int GetColPos(int colID) const; /** Sets the position of the specified column. */ void SetColPos(int colID, int newPos); /** Sets the positions of all columns at once. This method takes an array containing the indices of the columns in their display order, i.e. uses the same convention as wxHeaderCtrl::SetColumnsOrder(). */ void SetColumnsOrder(const wxArrayInt& order); /** Resets the position of the columns to the default. */ void ResetColPos(); //@} /** @name Cursor Movement */ //@{ /** Returns the current grid cell column position. */ int GetGridCursorCol() const; /** Returns the current grid cell row position. */ int GetGridCursorRow() const; /** Make the given cell current and ensure it is visible. This method is equivalent to calling MakeCellVisible() and SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL event is generated by it and the selected cell doesn't change if the event is vetoed. */ void GoToCell(int row, int col); /** Make the given cell current and ensure it is visible. This method is equivalent to calling MakeCellVisible() and SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL event is generated by it and the selected cell doesn't change if the event is vetoed. */ void GoToCell(const wxGridCellCoords& coords); /** Moves the grid cursor down by one row. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorDown(bool expandSelection); /** Moves the grid cursor down in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorDownBlock(bool expandSelection); /** Moves the grid cursor left by one column. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorLeft(bool expandSelection); /** Moves the grid cursor left in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorLeftBlock(bool expandSelection); /** Moves the grid cursor right by one column. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorRight(bool expandSelection); /** Moves the grid cursor right in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorRightBlock(bool expandSelection); /** Moves the grid cursor up by one row. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorUp(bool expandSelection); /** Moves the grid cursor up in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is @true or be cleared if the argument is @false. */ bool MoveCursorUpBlock(bool expandSelection); /** Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row. */ bool MovePageDown(); /** Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row. */ bool MovePageUp(); /** Set the grid cursor to the specified cell. The grid cursor indicates the current cell and can be moved by the user using the arrow keys or the mouse. Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and if the event handler vetoes this event, the cursor is not moved. This function doesn't make the target call visible, use GoToCell() to do this. */ void SetGridCursor(int row, int col); /** Set the grid cursor to the specified cell. The grid cursor indicates the current cell and can be moved by the user using the arrow keys or the mouse. Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and if the event handler vetoes this event, the cursor is not moved. This function doesn't make the target call visible, use GoToCell() to do this. */ void SetGridCursor(const wxGridCellCoords& coords); /** Set the grid's behaviour when the user presses the TAB key. Pressing the TAB key moves the grid cursor right in the current row, if there is a cell at the right and, similarly, Shift-TAB moves the cursor to the left in the current row if it's not in the first column. What happens if the cursor can't be moved because it it's already at the beginning or end of the row can be configured using this function, see wxGrid::TabBehaviour documentation for the detailed description. IF none of the standard behaviours is appropriate, you can always handle @c wxEVT_GRID_TABBING event directly to implement a custom TAB-handling logic. @since 2.9.5 */ void SetTabBehaviour(TabBehaviour behaviour); //@} /** @name User Selection */ //@{ /** Deselects all cells that are currently selected. */ void ClearSelection(); /** Deselects a row of cells. */ void DeselectRow( int row ); /** Deselects a column of cells. */ void DeselectCol( int col ); /** Deselects a cell. */ void DeselectCell( int row, int col ); /** Returns an array of individually selected cells. Notice that this array does @em not contain all the selected cells in general as it doesn't include the cells selected as part of column, row or block selection. You must use this method, GetSelectedCols(), GetSelectedRows() and GetSelectionBlockTopLeft() and GetSelectionBlockBottomRight() methods to obtain the entire selection in general. Please notice this behaviour is by design and is needed in order to support grids of arbitrary size (when an entire column is selected in a grid with a million of columns, we don't want to create an array with a million of entries in this function, instead it returns an empty array and GetSelectedCols() returns an array containing one element). */ wxGridCellCoordsArray GetSelectedCells() const; /** Returns an array of selected columns. Please notice that this method alone is not sufficient to find all the selected columns as it contains only the columns which were individually selected but not those being part of the block selection or being selected in virtue of all of their cells being selected individually, please see GetSelectedCells() for more details. */ wxArrayInt GetSelectedCols() const; /** Returns an array of selected rows. Please notice that this method alone is not sufficient to find all the selected rows as it contains only the rows which were individually selected but not those being part of the block selection or being selected in virtue of all of their cells being selected individually, please see GetSelectedCells() for more details. */ wxArrayInt GetSelectedRows() const; /** Returns the colour used for drawing the selection background. */ wxColour GetSelectionBackground() const; /** Returns an array of the bottom right corners of blocks of selected cells. Please see GetSelectedCells() for more information about the selection representation in wxGrid. @see GetSelectionBlockTopLeft() */ wxGridCellCoordsArray GetSelectionBlockBottomRight() const; /** Returns an array of the top left corners of blocks of selected cells. Please see GetSelectedCells() for more information about the selection representation in wxGrid. @see GetSelectionBlockBottomRight() */ wxGridCellCoordsArray GetSelectionBlockTopLeft() const; /** Returns the colour used for drawing the selection foreground. */ wxColour GetSelectionForeground() const; /** Returns the current selection mode. @see SetSelectionMode(). */ wxGridSelectionModes GetSelectionMode() const; /** Returns @true if the given cell is selected. */ bool IsInSelection(int row, int col) const; /** Returns @true if the given cell is selected. */ bool IsInSelection(const wxGridCellCoords& coords) const; /** Returns @true if there are currently any selected cells, rows, columns or blocks. */ bool IsSelection() const; /** Selects all cells in the grid. */ void SelectAll(); /** Selects a rectangular block of cells. If @a addToSelected is @false then any existing selection will be deselected; if @true the column will be added to the existing selection. */ void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, bool addToSelected = false); /** Selects a rectangular block of cells. If @a addToSelected is @false then any existing selection will be deselected; if @true the column will be added to the existing selection. */ void SelectBlock(const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight, bool addToSelected = false); /** Selects the specified column. If @a addToSelected is @false then any existing selection will be deselected; if @true the column will be added to the existing selection. This method won't select anything if the current selection mode is wxGridSelectRows. */ void SelectCol(int col, bool addToSelected = false); /** Selects the specified row. If @a addToSelected is @false then any existing selection will be deselected; if @true the row will be added to the existing selection. This method won't select anything if the current selection mode is wxGridSelectColumns. */ void SelectRow(int row, bool addToSelected = false); /** Set the colour to be used for drawing the selection background. */ void SetSelectionBackground(const wxColour& c); /** Set the colour to be used for drawing the selection foreground. */ void SetSelectionForeground(const wxColour& c); /** Set the selection behaviour of the grid. The existing selection is converted to conform to the new mode if possible and discarded otherwise (e.g. any individual selected cells are deselected if the new mode allows only the selection of the entire rows or columns). */ void SetSelectionMode(wxGridSelectionModes selmode); //@} /** @name Scrolling */ //@{ /** Returns the number of pixels per horizontal scroll increment. The default is 15. @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY() */ int GetScrollLineX() const; /** Returns the number of pixels per vertical scroll increment. The default is 15. @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY() */ int GetScrollLineY() const; /** Returns @true if a cell is either entirely or at least partially visible in the grid window. By default, the cell must be entirely visible for this function to return @true but if @a wholeCellVisible is @false, the function returns @true even if the cell is only partially visible. */ bool IsVisible(int row, int col, bool wholeCellVisible = true) const; /** Returns @true if a cell is either entirely or at least partially visible in the grid window. By default, the cell must be entirely visible for this function to return @true but if @a wholeCellVisible is @false, the function returns @true even if the cell is only partially visible. */ bool IsVisible(const wxGridCellCoords& coords, bool wholeCellVisible = true) const; /** Brings the specified cell into the visible grid cell area with minimal scrolling. Does nothing if the cell is already visible. */ void MakeCellVisible(int row, int col); /** Brings the specified cell into the visible grid cell area with minimal scrolling. Does nothing if the cell is already visible. */ void MakeCellVisible(const wxGridCellCoords& coords); /** Sets the number of pixels per horizontal scroll increment. The default is 15. @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY() */ void SetScrollLineX(int x); /** Sets the number of pixels per vertical scroll increment. The default is 15. @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX() */ void SetScrollLineY(int y); //@} /** @name Cell and Device Coordinate Translation */ //@{ /** Convert grid cell coordinates to grid window pixel coordinates. This function returns the rectangle that encloses the block of cells limited by @a topLeft and @a bottomRight cell in device coords and clipped to the client size of the grid window. @see CellToRect() */ wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight) const; /** Return the rectangle corresponding to the grid cell's size and position in logical coordinates. @see BlockToDeviceRect() */ wxRect CellToRect(int row, int col) const; /** Return the rectangle corresponding to the grid cell's size and position in logical coordinates. @see BlockToDeviceRect() */ wxRect CellToRect(const wxGridCellCoords& coords) const; /** Returns the column at the given pixel position. @param x The x position to evaluate. @param clipToMinMax If @true, rather than returning @c wxNOT_FOUND, it returns either the first or last column depending on whether @a x is too far to the left or right respectively. @return The column index or @c wxNOT_FOUND. */ int XToCol(int x, bool clipToMinMax = false) const; /** Returns the column whose right hand edge is close to the given logical @a x position. If no column edge is near to this position @c wxNOT_FOUND is returned. */ int XToEdgeOfCol(int x) const; /** Translates logical pixel coordinates to the grid cell coordinates. Notice that this function expects logical coordinates on input so if you use this function in a mouse event handler you need to translate the mouse position, which is expressed in device coordinates, to logical ones. @see XToCol(), YToRow() */ wxGridCellCoords XYToCell(int x, int y) const; /** Translates logical pixel coordinates to the grid cell coordinates. Notice that this function expects logical coordinates on input so if you use this function in a mouse event handler you need to translate the mouse position, which is expressed in device coordinates, to logical ones. @see XToCol(), YToRow() */ wxGridCellCoords XYToCell(const wxPoint& pos) const; // XYToCell(int, int, wxGridCellCoords&) overload is intentionally // undocumented, using it is ugly and non-const reference parameters are // not used in wxWidgets API /** Returns the row whose bottom edge is close to the given logical @a y position. If no row edge is near to this position @c wxNOT_FOUND is returned. */ int YToEdgeOfRow(int y) const; /** Returns the grid row that corresponds to the logical @a y coordinate. Returns @c wxNOT_FOUND if there is no row at the @a y position. */ int YToRow(int y, bool clipToMinMax = false) const; //@} /** @name Miscellaneous Functions */ //@{ /** Appends one or more new columns to the right of the grid. The @a updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::AppendCols(). See InsertCols() for further information. @return @true on success or @false if appending columns failed. */ bool AppendCols(int numCols = 1, bool updateLabels = true); /** Appends one or more new rows to the bottom of the grid. The @a updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::AppendRows(). See InsertRows() for further information. @return @true on success or @false if appending rows failed. */ bool AppendRows(int numRows = 1, bool updateLabels = true); /** Return @true if the horizontal grid lines stop at the last column boundary or @false if they continue to the end of the window. The default is to clip grid lines. @see ClipHorzGridLines(), AreVertGridLinesClipped() */ bool AreHorzGridLinesClipped() const; /** Return @true if the vertical grid lines stop at the last row boundary or @false if they continue to the end of the window. The default is to clip grid lines. @see ClipVertGridLines(), AreHorzGridLinesClipped() */ bool AreVertGridLinesClipped() const; /** Increments the grid's batch count. When the count is greater than zero repainting of the grid is suppressed. Each call to BeginBatch must be matched by a later call to EndBatch(). Code that does a lot of grid modification can be enclosed between BeginBatch() and EndBatch() calls to avoid screen flicker. The final EndBatch() call will cause the grid to be repainted. Notice that you should use wxGridUpdateLocker which ensures that there is always a matching EndBatch() call for this BeginBatch() if possible instead of calling this method directly. */ void BeginBatch(); /** Clears all data in the underlying grid table and repaints the grid. The table is not deleted by this function. If you are using a derived table class then you need to override wxGridTableBase::Clear() for this function to have any effect. */ void ClearGrid(); /** Change whether the horizontal grid lines are clipped by the end of the last column. By default the grid lines are not drawn beyond the end of the last column but after calling this function with @a clip set to @false they will be drawn across the entire grid window. @see AreHorzGridLinesClipped(), ClipVertGridLines() */ void ClipHorzGridLines(bool clip); /** Change whether the vertical grid lines are clipped by the end of the last row. By default the grid lines are not drawn beyond the end of the last row but after calling this function with @a clip set to @false they will be drawn across the entire grid window. @see AreVertGridLinesClipped(), ClipHorzGridLines() */ void ClipVertGridLines(bool clip); /** Deletes one or more columns from a grid starting at the specified position. The @a updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::DeleteCols(). See InsertCols() for further information. @return @true on success or @false if deleting columns failed. */ bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true); /** Deletes one or more rows from a grid starting at the specified position. The @a updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::DeleteRows(). See InsertRows() for further information. @return @true on success or @false if appending rows failed. */ bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true); /** Decrements the grid's batch count. When the count is greater than zero repainting of the grid is suppressed. Each previous call to BeginBatch() must be matched by a later call to EndBatch(). Code that does a lot of grid modification can be enclosed between BeginBatch() and EndBatch() calls to avoid screen flicker. The final EndBatch() will cause the grid to be repainted. @see wxGridUpdateLocker */ void EndBatch(); /** Overridden wxWindow method. */ virtual void Fit(); /** Causes immediate repainting of the grid. Use this instead of the usual wxWindow::Refresh(). */ void ForceRefresh(); /** Returns the number of times that BeginBatch() has been called without (yet) matching calls to EndBatch(). While the grid's batch count is greater than zero the display will not be updated. */ int GetBatchCount(); /** Returns the total number of grid columns. This is the same as the number of columns in the underlying grid table. */ int GetNumberCols() const; /** Returns the total number of grid rows. This is the same as the number of rows in the underlying grid table. */ int GetNumberRows() const; /** Returns the attribute for the given cell creating one if necessary. If the cell already has an attribute, it is returned. Otherwise a new attribute is created, associated with the cell and returned. In any case the caller must call DecRef() on the returned pointer. This function may only be called if CanHaveAttributes() returns @true. */ wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; /** Returns a base pointer to the current table object. The returned pointer is still owned by the grid. */ wxGridTableBase *GetTable() const; /** Inserts one or more new columns into a grid with the first new column at the specified position. Notice that inserting the columns in the grid requires grid table cooperation: when this method is called, grid object begins by requesting the underlying grid table to insert new columns. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called CreateGrid()) this process is automatic. If you are using a custom grid table (specified with SetTable()) then you must override wxGridTableBase::InsertCols() in your derived table class. @param pos The position which the first newly inserted column will have. @param numCols The number of columns to insert. @param updateLabels Currently not used. @return @true if the columns were successfully inserted, @false if an error occurred (most likely the table couldn't be updated). */ bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true); /** Inserts one or more new rows into a grid with the first new row at the specified position. Notice that you must implement wxGridTableBase::InsertRows() if you use a grid with a custom table, please see InsertCols() for more information. @param pos The position which the first newly inserted row will have. @param numRows The number of rows to insert. @param updateLabels Currently not used. @return @true if the rows were successfully inserted, @false if an error occurred (most likely the table couldn't be updated). */ bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true); /** Invalidates the cached attribute for the given cell. For efficiency reasons, wxGrid may cache the recently used attributes (currently it caches only the single most recently used one, in fact) which can result in the cell appearance not being refreshed even when the attribute returned by your custom wxGridCellAttrProvider-derived class has changed. To force the grid to refresh the cell attribute, this function may be used. Notice that calling it will not result in actually redrawing the cell, you still need to call wxWindow::RefreshRect() to invalidate the area occupied by the cell in the window to do this. Also note that you don't need to call this function if you store the attributes in wxGrid itself, i.e. use its SetAttr() and similar methods, it is only useful when using a separate custom attributes provider. @param row The row of the cell whose attribute needs to be queried again. @param col The column of the cell whose attribute needs to be queried again. @since 2.9.2 */ void RefreshAttr(int row, int col); /** Draws part or all of a wxGrid on a wxDC for printing or display. Pagination can be accomplished by using sequential Render() calls with appropriate values in wxGridCellCoords topLeft and bottomRight. @param dc The wxDC to be drawn on. @param pos The position on the wxDC where rendering should begin. If not specified drawing will begin at the wxDC MaxX() and MaxY(). @param size The size of the area on the wxDC that the rendered wxGrid should occupy. If not specified the drawing will be scaled to fit the available dc width or height. The wxGrid's aspect ratio is maintained whether or not size is specified. @param topLeft The top left cell of the block to be drawn. Defaults to ( 0, 0 ). @param bottomRight The bottom right cell of the block to be drawn. Defaults to row and column counts. @param style A combination of values from wxGridRenderStyle. @since 2.9.4 */ void Render( wxDC& dc, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxGridCellCoords& topLeft = wxGridCellCoords( -1, -1 ), const wxGridCellCoords& bottomRight = wxGridCellCoords( -1, -1 ), int style = wxGRID_DRAW_DEFAULT ); /** Sets the cell attributes for the specified cell. The grid takes ownership of the attribute pointer. See the wxGridCellAttr class for more information about controlling cell attributes. */ void SetAttr(int row, int col, wxGridCellAttr *attr); /** Sets the cell attributes for all cells in the specified column. For more information about controlling grid cell attributes see the wxGridCellAttr cell attribute class and the @ref overview_grid. */ void SetColAttr(int col, wxGridCellAttr* attr); /** Sets the extra margins used around the grid area. A grid may occupy more space than needed for its data display and this function allows to set how big this extra space is */ void SetMargins(int extraWidth, int extraHeight); /** Sets the cell attributes for all cells in the specified row. The grid takes ownership of the attribute pointer. See the wxGridCellAttr class for more information about controlling cell attributes. */ void SetRowAttr(int row, wxGridCellAttr* attr); wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ); wxArrayInt CalcColLabelsExposed( const wxRegion& reg ); wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ); //@} /** @name Sorting support. wxGrid doesn't provide any support for sorting the data but it does generate events allowing the user code to sort it and supports displaying the sort indicator in the column used for sorting. To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT event (and not veto it) and resort the data displayed in the grid. The grid will automatically update the sorting indicator on the column which was clicked. You can also call the functions in this section directly to update the sorting indicator. Once again, they don't do anything with the grid data, it remains your responsibility to actually sort it appropriately. */ //@{ /** Return the column in which the sorting indicator is currently displayed. Returns @c wxNOT_FOUND if sorting indicator is not currently displayed at all. @see SetSortingColumn() */ int GetSortingColumn() const; /** Return @true if this column is currently used for sorting. @see GetSortingColumn() */ bool IsSortingBy(int col) const; /** Return @true if the current sorting order is ascending or @false if it is descending. It only makes sense to call this function if GetSortingColumn() returns a valid column index and not @c wxNOT_FOUND. @see SetSortingColumn() */ bool IsSortOrderAscending() const; /** Set the column to display the sorting indicator in and its direction. @param col The column to display the sorting indicator in or @c wxNOT_FOUND to remove any currently displayed sorting indicator. @param ascending If @true, display the ascending sort indicator, otherwise display the descending sort indicator. @see GetSortingColumn(), IsSortOrderAscending() */ void SetSortingColumn(int col, bool ascending = true); /** Remove any currently shown sorting indicator. This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND first argument. */ void UnsetSortingColumn(); //@} /** @name Accessors for component windows. Return the various child windows of wxGrid. wxGrid is an empty parent window for 4 children representing the column labels window (top), the row labels window (left), the corner window (top left) and the main grid window. It may be necessary to use these individual windows and not the wxGrid window itself if you need to handle events for them (this can be done using wxEvtHandler::Connect() or wxWindow::PushEventHandler()) or do something else requiring the use of the correct window pointer. Notice that you should not, however, change these windows (e.g. reposition them or draw over them) because they are managed by wxGrid itself. */ //@{ /** Return the main grid window containing the grid cells. This window is always shown. */ wxWindow *GetGridWindow() const; /** Return the row labels window. This window is not shown if the row labels were hidden using HideRowLabels(). */ wxWindow *GetGridRowLabelWindow() const; /** Return the column labels window. This window is not shown if the columns labels were hidden using HideColLabels(). Depending on whether UseNativeColHeader() was called or not this can be either a wxHeaderCtrl or a plain wxWindow. This function returns a valid window pointer in either case but in the former case you can also use GetGridColHeader() to access it if you need wxHeaderCtrl-specific functionality. */ wxWindow *GetGridColLabelWindow() const; /** Return the window in the top left grid corner. This window is shown only of both columns and row labels are shown and normally doesn't contain anything. Clicking on it is handled by wxGrid however and can be used to select the entire grid. */ wxWindow *GetGridCornerLabelWindow() const; /** Return the header control used for column labels display. This function can only be called if UseNativeColHeader() had been called. */ wxHeaderCtrl *GetGridColHeader() const; //@} virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows ); virtual void DrawRowLabel( wxDC& dc, int row ); virtual void DrawColLabels( wxDC& dc, const wxArrayInt& cols ); virtual void DrawColLabel( wxDC& dc, int col ); virtual void DrawCornerLabel(wxDC& dc); void DrawTextRectangle( wxDC& dc, const wxString& text, const wxRect& rect, int horizontalAlignment = wxALIGN_LEFT, int verticalAlignment = wxALIGN_TOP, int textOrientation = wxHORIZONTAL ) const; void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect& rect, int horizontalAlignment = wxALIGN_LEFT, int verticalAlignment = wxALIGN_TOP, int textOrientation = wxHORIZONTAL ) const; wxColour GetCellHighlightColour() const; int GetCellHighlightPenWidth() const; int GetCellHighlightROPenWidth() const; void SetCellHighlightColour( const wxColour& ); void SetCellHighlightPenWidth(int width); void SetCellHighlightROPenWidth(int width); protected: /** Returns @true if this grid has support for cell attributes. The grid supports attributes if it has the associated table which, in turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes() returns @true. */ bool CanHaveAttributes() const; /** Get the minimal width of the given column/row. The value returned by this function may be different than that returned by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been called for this column. */ int GetColMinimalWidth(int col) const; /** Returns the coordinate of the right border specified column. */ int GetColRight(int col) const; /** Returns the coordinate of the left border specified column. */ int GetColLeft(int col) const; /** Returns the minimal size for the given column. The value returned by this function may be different than that returned by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been called for this row. */ int GetRowMinimalHeight(int col) const; }; /** @class wxGridUpdateLocker This small class can be used to prevent wxGrid from redrawing during its lifetime by calling wxGrid::BeginBatch() in its constructor and wxGrid::EndBatch() in its destructor. It is typically used in a function performing several operations with a grid which would otherwise result in flicker. For example: @code void MyFrame::Foo() { m_grid = new wxGrid(this, ...); wxGridUpdateLocker noUpdates(m_grid); m_grid-AppendColumn(); // ... many other operations with m_grid ... m_grid-AppendRow(); // destructor called, grid refreshed } @endcode Using this class is easier and safer than calling wxGrid::BeginBatch() and wxGrid::EndBatch() because you don't risk missing the call the latter (due to an exception for example). @library{wxadv} @category{grid} */ class wxGridUpdateLocker { public: /** Creates an object preventing the updates of the specified @a grid. The parameter could be @NULL in which case nothing is done. If @a grid is non-@NULL then the grid must exist for longer than this wxGridUpdateLocker object itself. The default constructor could be followed by a call to Create() to set the grid object later. */ wxGridUpdateLocker(wxGrid* grid = NULL); /** Destructor reenables updates for the grid this object is associated with. */ ~wxGridUpdateLocker(); /** This method can be called if the object had been constructed using the default constructor. It must not be called more than once. */ void Create(wxGrid* grid); }; /** @class wxGridEvent This event class contains information about various grid events. Notice that all grid event table macros are available in two versions: @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the two is that the former doesn't allow to specify the grid window identifier and so takes a single parameter, the event handler, but is not suitable if there is more than one grid control in the window where the event table is used (as it would catch the events from all the grids). The version with @c CMD takes the id as first argument and the event handler as the second one and so can be used with multiple grids as well. Otherwise there are no difference between the two and only the versions without the id are documented below for brevity. @beginEventTable{wxGridEvent} @event{EVT_GRID_CELL_CHANGING(func)} The user is about to change the data in a cell. The new cell value as string is available from GetString() event object method. This event can be vetoed if the change is not allowed. Processes a @c wxEVT_GRID_CELL_CHANGING event type. @event{EVT_GRID_CELL_CHANGED(func)} The user changed the data in a cell. The old cell value as string is available from GetString() event object method. Notice that vetoing this event still works for backwards compatibility reasons but any new code should only veto EVT_GRID_CELL_CHANGING event and not this one. Processes a @c wxEVT_GRID_CELL_CHANGED event type. @event{EVT_GRID_CELL_LEFT_CLICK(func)} The user clicked a cell with the left mouse button. Processes a @c wxEVT_GRID_CELL_LEFT_CLICK event type. @event{EVT_GRID_CELL_LEFT_DCLICK(func)} The user double-clicked a cell with the left mouse button. Processes a @c wxEVT_GRID_CELL_LEFT_DCLICK event type. @event{EVT_GRID_CELL_RIGHT_CLICK(func)} The user clicked a cell with the right mouse button. Processes a @c wxEVT_GRID_CELL_RIGHT_CLICK event type. @event{EVT_GRID_CELL_RIGHT_DCLICK(func)} The user double-clicked a cell with the right mouse button. Processes a @c wxEVT_GRID_CELL_RIGHT_DCLICK event type. @event{EVT_GRID_EDITOR_HIDDEN(func)} The editor for a cell was hidden. Processes a @c wxEVT_GRID_EDITOR_HIDDEN event type. @event{EVT_GRID_EDITOR_SHOWN(func)} The editor for a cell was shown. Processes a @c wxEVT_GRID_EDITOR_SHOWN event type. @event{EVT_GRID_LABEL_LEFT_CLICK(func)} The user clicked a label with the left mouse button. Processes a @c wxEVT_GRID_LABEL_LEFT_CLICK event type. @event{EVT_GRID_LABEL_LEFT_DCLICK(func)} The user double-clicked a label with the left mouse button. Processes a @c wxEVT_GRID_LABEL_LEFT_DCLICK event type. @event{EVT_GRID_LABEL_RIGHT_CLICK(func)} The user clicked a label with the right mouse button. Processes a @c wxEVT_GRID_LABEL_RIGHT_CLICK event type. @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)} The user double-clicked a label with the right mouse button. Processes a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type. @event{EVT_GRID_SELECT_CELL(func)} The given cell was made current, either by user or by the program via a call to SetGridCursor() or GoToCell(). Processes a @c wxEVT_GRID_SELECT_CELL event type. @event{EVT_GRID_COL_MOVE(func)} The user tries to change the order of the columns in the grid by dragging the column specified by GetCol(). This event can be vetoed to either prevent the user from reordering the column change completely (but notice that if you don't want to allow it at all, you simply shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed but handled in some way in the handler, e.g. by really moving the column to the new position at the associated table level, or allowed to proceed in which case wxGrid::SetColPos() is used to reorder the columns display order without affecting the use of the column indices otherwise. This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type. @event{EVT_GRID_COL_SORT(func)} This event is generated when a column is clicked by the user and its name is explained by the fact that the custom reaction to a click on a column is to sort the grid contents by this column. However the grid itself has no special support for sorting and it's up to the handler of this event to update the associated table. But if the event is handled (and not vetoed) the grid supposes that the table was indeed resorted and updates the column to indicate the new sort order and refreshes itself. This event macro corresponds to @c wxEVT_GRID_COL_SORT event type. @event{EVT_GRID_TABBING(func)} This event is generated when the user presses TAB or Shift-TAB in the grid. It can be used to customize the simple default TAB handling logic, e.g. to go to the next non-empty cell instead of just the next cell. See also wxGrid::SetTabBehaviour(). This event is new since wxWidgets 2.9.5. @endEventTable @library{wxadv} @category{grid,events} */ class wxGridEvent : public wxNotifyEvent { public: /** Default constructor. */ wxGridEvent(); /** Constructor for initializing all event attributes. */ wxGridEvent(int id, wxEventType type, wxObject* obj, int row = -1, int col = -1, int x = -1, int y = -1, bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); /** Returns @true if the Alt key was down at the time of the event. */ bool AltDown() const; /** Returns @true if the Control key was down at the time of the event. */ bool ControlDown() const; /** Column at which the event occurred. Notice that for a @c wxEVT_GRID_SELECT_CELL event this column is the column of the newly selected cell while the previously selected cell can be retrieved using wxGrid::GetGridCursorCol(). */ virtual int GetCol(); /** Position in pixels at which the event occurred. */ wxPoint GetPosition(); /** Row at which the event occurred. Notice that for a @c wxEVT_GRID_SELECT_CELL event this row is the row of the newly selected cell while the previously selected cell can be retrieved using wxGrid::GetGridCursorRow(). */ virtual int GetRow(); /** Returns @true if the Meta key was down at the time of the event. */ bool MetaDown() const; /** Returns @true if the user is selecting grid cells, or @false if deselecting. */ bool Selecting(); /** Returns @true if the Shift key was down at the time of the event. */ bool ShiftDown() const; }; /** @class wxGridSizeEvent This event class contains information about a row/column resize event. @beginEventTable{wxGridSizeEvent} @event{EVT_GRID_CMD_COL_SIZE(id, func)} The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event type. @event{EVT_GRID_CMD_ROW_SIZE(id, func)} The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event type. @event{EVT_GRID_COL_SIZE(func)} Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id. @event{EVT_GRID_COL_AUTO_SIZE(func)} This event is sent when a column must be resized to its best size, e.g. when the user double clicks the column divider. The default implementation simply resizes the column to fit the column label (but not its contents as this could be too slow for big grids). This macro corresponds to @c wxEVT_GRID_COL_AUTO_SIZE event type and is new since wxWidgets 2.9.5. @event{EVT_GRID_ROW_SIZE(func)} Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id. @endEventTable @library{wxadv} @category{grid,events} */ class wxGridSizeEvent : public wxNotifyEvent { public: /** Default constructor. */ wxGridSizeEvent(); /** Constructor for initializing all event attributes. */ wxGridSizeEvent(int id, wxEventType type, wxObject* obj, int rowOrCol = -1, int x = -1, int y = -1, const wxKeyboardState& kbd = wxKeyboardState()); /** Returns @true if the Alt key was down at the time of the event. */ bool AltDown() const; /** Returns @true if the Control key was down at the time of the event. */ bool ControlDown() const; /** Position in pixels at which the event occurred. */ wxPoint GetPosition(); /** Row or column at that was resized. */ int GetRowOrCol(); /** Returns @true if the Meta key was down at the time of the event. */ bool MetaDown() const; /** Returns @true if the Shift key was down at the time of the event. */ bool ShiftDown() const; }; /** @class wxGridRangeSelectEvent @beginEventTable{wxGridRangeSelectEvent} @event{EVT_GRID_RANGE_SELECT(func)} The user selected a group of contiguous cells. Processes a @c wxEVT_GRID_RANGE_SELECT event type. @event{EVT_GRID_CMD_RANGE_SELECT(id, func)} The user selected a group of contiguous cells; variant taking a window identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type. @endEventTable @library{wxadv} @category{grid,events} */ class wxGridRangeSelectEvent : public wxNotifyEvent { public: /** Default constructor. */ wxGridRangeSelectEvent(); /** Constructor for initializing all event attributes. */ wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj, const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight, bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); /** Returns @true if the Alt key was down at the time of the event. */ bool AltDown() const; /** Returns @true if the Control key was down at the time of the event. */ bool ControlDown() const; /** Top left corner of the rectangular area that was (de)selected. */ wxGridCellCoords GetBottomRightCoords(); /** Bottom row of the rectangular area that was (de)selected. */ int GetBottomRow(); /** Left column of the rectangular area that was (de)selected. */ int GetLeftCol(); /** Right column of the rectangular area that was (de)selected. */ int GetRightCol(); /** Top left corner of the rectangular area that was (de)selected. */ wxGridCellCoords GetTopLeftCoords(); /** Top row of the rectangular area that was (de)selected. */ int GetTopRow(); /** Returns @true if the Meta key was down at the time of the event. */ bool MetaDown() const; /** Returns @true if the area was selected, @false otherwise. */ bool Selecting(); /** Returns @true if the Shift key was down at the time of the event. */ bool ShiftDown() const; }; /** @class wxGridEditorCreatedEvent @beginEventTable{wxGridEditorCreatedEvent} @event{EVT_GRID_EDITOR_CREATED(func)} The editor for a cell was created. Processes a @c wxEVT_GRID_EDITOR_CREATED event type. @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)} The editor for a cell was created; variant taking a window identifier. Processes a @c wxEVT_GRID_EDITOR_CREATED event type. @endEventTable @library{wxadv} @category{grid,events} */ class wxGridEditorCreatedEvent : public wxCommandEvent { public: /** Default constructor. */ wxGridEditorCreatedEvent(); /** Constructor for initializing all event attributes. */ wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, int row, int col, wxControl* ctrl); /** Returns the column at which the event occurred. */ int GetCol(); /** Returns the edit control. */ wxControl* GetControl(); /** Returns the row at which the event occurred. */ int GetRow(); /** Sets the column at which the event occurred. */ void SetCol(int col); /** Sets the edit control. */ void SetControl(wxControl* ctrl); /** Sets the row at which the event occurred. */ void SetRow(int row); }; wxEventType wxEVT_GRID_CELL_LEFT_CLICK; wxEventType wxEVT_GRID_CELL_RIGHT_CLICK; wxEventType wxEVT_GRID_CELL_LEFT_DCLICK; wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK; wxEventType wxEVT_GRID_LABEL_LEFT_CLICK; wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK; wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK; wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK; wxEventType wxEVT_GRID_ROW_SIZE; wxEventType wxEVT_GRID_COL_SIZE; wxEventType wxEVT_GRID_COL_AUTO_SIZE; wxEventType wxEVT_GRID_RANGE_SELECT; wxEventType wxEVT_GRID_CELL_CHANGING; wxEventType wxEVT_GRID_CELL_CHANGED; wxEventType wxEVT_GRID_SELECT_CELL; wxEventType wxEVT_GRID_EDITOR_SHOWN; wxEventType wxEVT_GRID_EDITOR_HIDDEN; wxEventType wxEVT_GRID_EDITOR_CREATED; wxEventType wxEVT_GRID_CELL_BEGIN_DRAG; wxEventType wxEVT_GRID_COL_MOVE; wxEventType wxEVT_GRID_COL_SORT; wxEventType wxEVT_GRID_TABBING;
31.526347
92
0.657464
08de872e2ff8caf2af6948aba6553a11105e5022
59,753
c
C
src/m2m/lib/lang/M2MString.c
mtsmys/cep
2d4873f957e7e612f68915eaea29f0fe85e7e83b
[ "BSD-2-Clause" ]
6
2015-09-06T07:33:13.000Z
2021-09-02T05:58:50.000Z
src/m2m/lib/lang/M2MString.c
mtsmys/cep
2d4873f957e7e612f68915eaea29f0fe85e7e83b
[ "BSD-2-Clause" ]
null
null
null
src/m2m/lib/lang/M2MString.c
mtsmys/cep
2d4873f957e7e612f68915eaea29f0fe85e7e83b
[ "BSD-2-Clause" ]
2
2016-04-23T10:46:07.000Z
2017-12-05T13:10:51.000Z
/******************************************************************************* * M2MString.c * * Copyright (c) 2014, Akihisa Yasuda * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ #include "m2m/lib/lang/M2MString.h" /******************************************************************************* * Declaration of private function ******************************************************************************/ /** * This method copies local time string into indicated "buffer" memory.<br> * Output string format is "yyyy/MM/dd HH:mm:ss.SSS"; * This method doesn't allocation, so caller needs to prepare memory<br> * before call this method.<br> * * @param[out] buffer memory buffer for copying local time string * @param[in] bufferLength memory buffer length(max size) * @return length of local time string or 0(means error) */ static size_t this_getLocalTimeString (M2MString *buffer, const size_t bufferLength); /** * Initialize "errorno" variable.<br> */ static void this_initErrorNumber (); /******************************************************************************* * Private function ******************************************************************************/ /** * Copy the log message to the argument "buffer" pointer.<br> * Buffering of array for copying is executed inside the function.<br> * Therefore, it is necessary for caller to call the "M2MHeap_free()" function <br> * in order to prevent memory leak after using the variable.<br> * * @param[in] functionName String indicating function name * @param[in] lineNumber Line number in source file (can be embedded with "__LINE__") * @param[in] message Message string * @param[out] buffer Buffer to copy the created log message * @return The pointer of "buffer" copied the created log message string or NULL (in case of error) */ static M2MString *this_createNewLogMessage (const M2MString *functionName, const uint32_t lineNumber, const M2MString *message, M2MString **buffer) { //========== Variable ========== M2MString *logLevelString = (M2MString *)"ERROR"; M2MString time[64]; M2MString lineNumberString[16]; M2MString errnoMessage[256]; M2MString threadID[128]; size_t functionNameLength = 0; size_t messageLength = 0; //===== Check argument ===== if (functionName!=NULL && (functionNameLength=M2MString_length(functionName))>0 && message!=NULL && (messageLength=M2MString_length(message))>0 && buffer!=NULL) { //===== Get line number string ===== memset(lineNumberString, 0, sizeof(lineNumberString)); snprintf(lineNumberString, sizeof(lineNumberString)-1, (M2MString *)"%d", lineNumber); //===== Initialize array ===== memset(time, 0, sizeof(time)); //===== Get current time string from local calendar ====== if (this_getLocalTimeString(time, sizeof(time))>0 && M2MSystem_getThreadIDString(threadID, sizeof(threadID))!=NULL) { //===== In the case of existing error number ===== if (errno!=0 && strerror_r(errno, errnoMessage, sizeof(errnoMessage))==0) { //===== Create new log message string ===== if (M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, time)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, logLevelString)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, (M2MString *)"tid=")!=NULL && M2MString_append(buffer, threadID)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, functionName)!=NULL && M2MString_append(buffer, M2MString_COLON)!=NULL && M2MString_append(buffer, lineNumberString)!=NULL && M2MString_append(buffer, (M2MString *)"l")!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, errnoMessage)!=NULL && M2MString_append(buffer, M2MString_COLON)!=NULL && M2MString_append(buffer, M2MString_SPACE)!=NULL && M2MString_append(buffer, message)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL ) { //===== Initialize error number ===== this_initErrorNumber(); //===== Return created log message string ===== return (*buffer); } //===== Error handling ===== else if ((*buffer)!=NULL) { //===== Release allocated memory ===== M2MHeap_free((*buffer)); //===== Initialize error number ===== this_initErrorNumber(); return NULL; } else { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } } //===== In the case of not existing error number ===== else { //===== Create new log message string ===== if (M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, time)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, logLevelString)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, (M2MString *)"tid=")!=NULL && M2MString_append(buffer, threadID)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, functionName)!=NULL && M2MString_append(buffer, M2MString_COLON)!=NULL && M2MString_append(buffer, lineNumberString)!=NULL && M2MString_append(buffer, (M2MString *)"l")!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, M2MString_LEFT_SQUARE_BRACKET)!=NULL && M2MString_append(buffer, message)!=NULL && M2MString_append(buffer, M2MString_RIGHT_SQUARE_BRACKET)!=NULL ) { //===== Initialize error number ===== this_initErrorNumber(); //===== Return created log message string ===== return (*buffer); } //===== Error handling ===== else if ((*buffer)!=NULL) { //===== Release allocated memory ===== M2MHeap_free((*buffer)); //===== Initialize error number ===== this_initErrorNumber(); return NULL; } else { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } } } //===== Error handling ===== else { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } } //===== Argument error ===== else if (logLevelString==NULL) { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } else if (functionName==NULL || functionNameLength<=0) { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } else if (message==NULL || messageLength<=0) { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } else { //===== Initialize error number ===== this_initErrorNumber(); return NULL; } } /** * This method copies local time string into indicated "buffer" memory.<br> * Output string format is "yyyy/MM/dd HH:mm:ss.SSS"; * This method doesn't allocation, so caller needs to prepare memory<br> * before call this method.<br> * * @param[out] buffer memory buffer for copying local time string * @param[in] bufferLength memory buffer length(max size) * @return length of local time string or 0(means error) */ static size_t this_getLocalTimeString (M2MString *buffer, const size_t bufferLength) { //========== Variable ========== struct timeval currentTime; struct tm *localCalendar = NULL; size_t miliSecondLength = 0; M2MString *miliSecond = NULL; M2MString second[8]; const M2MString *FORMAT = (M2MString *)"%Y-%m-%d %H:%M:%S."; //===== Check argument ===== if (buffer!=NULL && bufferLength>0) { //===== Initialize buffer ===== memset(buffer, 0, bufferLength); //===== Get current time ===== if (gettimeofday(&currentTime, NULL)==0 && (localCalendar=localtime(&(currentTime.tv_sec)))!=NULL) { //===== Convert time to string ===== strftime(buffer, bufferLength-1, FORMAT, localCalendar); //===== Convert millisecond to string ===== if (M2MString_convertFromSignedLongToString((signed long)(currentTime.tv_usec/1000UL), &miliSecond)!=NULL && (miliSecondLength=M2MString_length(miliSecond))>0) { //===== In the case of digit number of millisecond is 1 ===== if (miliSecondLength==1) { memset(second, 0, sizeof(second)); //===== Convert millisecond into second format ===== M2MString_format(second, sizeof(second)-1, (M2MString *)"00%s", miliSecond); M2MHeap_free(miliSecond); } //===== In the case of digit number of millisecond is 2 ===== else if (miliSecondLength==2) { memset(second, 0, sizeof(second)); //===== Convert millisecond into second format ===== M2MString_format(second, sizeof(second)-1, (M2MString *)"0%s", miliSecond); M2MHeap_free(miliSecond); } //===== In the case of digit number of millisecond is 3 ===== else if (miliSecondLength==3) { memset(second, 0, sizeof(second)); //===== Convert millisecond into second format ===== M2MString_format(second, sizeof(second)-1, (M2MString *)"%s", miliSecond); M2MHeap_free(miliSecond); } //===== Error handling ===== else { //===== Initialize buffer ===== memset(buffer, 0, bufferLength); M2MHeap_free(miliSecond); return 0; } //===== Check buffer length for copying millisecond string ===== if (M2MString_length(second)<(bufferLength-M2MString_length(buffer)-1)) { //===== Copy millisecond string ===== memcpy(&(buffer[M2MString_length(buffer)]), second, M2MString_length(second)); //===== Release allocated memory ===== M2MHeap_free(miliSecond); return M2MString_length(buffer); } //===== Error handling ===== else { //===== Initialize buffer ===== M2MHeap_free(miliSecond); memset(buffer, 0, bufferLength); return 0; } } //===== Error handling ===== else { //===== Initialize buffer ===== M2MHeap_free(miliSecond); memset(buffer, 0, bufferLength); return 0; } } //===== Error handling ===== else { return 0; } } //===== Error handling ===== else { return 0; } } /** * Initialize "errorno" variable.<br> */ static void this_initErrorNumber () { errno = 0; return; } /** * Print out error message to standard error output.<br> * * @param[in] functionName String indicating function name * @param[in] lineNumber Line number in source file (can be embedded with "__LINE__") * @param[in] message Message string indicating error content */ static void this_printErrorMessage (const M2MString *functionName, const uint32_t lineNumber, const M2MString *message) { //========== Variable ========== M2MString *logMessage = NULL; //===== Create new log message ===== if (this_createNewLogMessage(functionName, lineNumber, message, &logMessage)!=NULL) { //===== Print out log ===== M2MSystem_errPrintln(logMessage); //===== Release allocated memory ===== M2MHeap_free(logMessage); } //===== Error handling ===== else { } return; } /******************************************************************************* * Public function ******************************************************************************/ /** * This function adds "string" into after the "self" string.<br> * Memory allocation is executed in this function, so caller must release<br> * the memory of "self" string.<br> * * @param[in,out] self The original string or NULL("self" = "self + string") * @param[in] string additional string * @return Pointer of connected string or NULL (in case of error) */ M2MString *M2MString_append (M2MString **self, const M2MString *string) { //========== Variable ========== M2MString *tmp = NULL; size_t selfLength = 0; size_t stringLength = 0; //===== Check argument ===== if (self!=NULL && string!=NULL && (stringLength=M2MString_length(string))>0) { //===== In the case of concatenation string existing ===== if ((*self)!=NULL) { //===== Preparation for temporarily copying the original string ===== if( (selfLength=M2MString_length((*self)))>0 && (tmp=(M2MString *)M2MHeap_malloc(selfLength+1))!=NULL) { //===== Temporarily copy the source string ===== memcpy(tmp, (*self), selfLength); //===== Release heap memory of consolidation string ===== M2MHeap_free((*self)); //===== Acquire heap memory of concatenated string ===== if (((*self)=(M2MString *)M2MHeap_malloc(selfLength+stringLength+1))!=NULL) { //===== Concatenate strings ===== memcpy(&((*self)[0]), tmp, selfLength); memcpy(&((*self)[selfLength]), string, stringLength); //===== Release temporary heap memory ===== M2MHeap_free(tmp); //===== Return pointer of concatenated string ===== return (*self); } //===== Error handling ===== else { M2MHeap_free(tmp); this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string temporary"); return NULL; } } //===== In the case of not existing of the concatenation string ===== else { //===== Acquire heap memory of string copy ===== if (((*self)=(M2MString *)M2MHeap_malloc(stringLength+1))!=NULL) { //===== Copy string ===== memcpy((*self), string, stringLength); //===== Returns a pointer to the string ===== return (*self); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } } //===== Argument error ===== else if (self==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"self\" pointer is NULL"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL or vacant"); return NULL; } } /** * Add the string after the "self" string. <br> * The length [Byte] of the additional string is specified by argument.<br> * * @param[in,out] self The original string to be added to the string (the string after addition is self = self + string) * @param[in] string String to be added * @param[in] stringLength Length of the string to be added[Byte] * @return Pointer of the buffer to which the string was added or NULL (in case of error) */ M2MString *M2MString_appendLength (M2MString **self, const M2MString *string, const size_t stringLength) { //========== Variable ========== M2MString *tmp = NULL; size_t thisLength = 0; //===== Check argument ===== if (self!=NULL && string!=NULL && 0<stringLength && stringLength<=M2MString_length(string)) { //===== When the string of the concatenation source exists ===== if ((*self)!=NULL) { //===== Preparation for temporarily copying the original string ===== if( (thisLength=M2MString_length((*self)))>0 && (tmp=(M2MString *)M2MHeap_malloc(thisLength+1))!=NULL) { //===== Temporarily copy the source string ===== memcpy(tmp, (*self), thisLength); //===== Rlease heap memory of consolidation source ===== M2MHeap_free((*self)); //===== Get heap memory of concatenated string ===== if (((*self)=(M2MString *)M2MHeap_malloc(thisLength+stringLength+1))!=NULL) { //===== Concatenate strings ===== memcpy(&((*self)[0]), tmp, thisLength); memcpy(&((*self)[thisLength]), string, stringLength); //===== Release temporary buffer heap memory ===== M2MHeap_free(tmp); //===== Return pointer of concatenated string ===== return (*self); } //===== Error handling ===== else { M2MHeap_free(tmp); this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string temporary"); return NULL; } } //===== When the string of the concatenation source does not exist ===== else { //===== Get heap memory for copying string ===== if (((*self)=(M2MString *)M2MHeap_malloc(stringLength+1))!=NULL) { //===== Copy string ===== memcpy((*self), string, stringLength); //===== Return pointer of concatenated string ===== return (*self); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } } //===== Argument error ===== else if (self==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"self\" pointer is NULL"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL or \"stringLength\" is invalid"); return NULL; } } /** * Compares the two strings specified by the argument and returns the result.<br> * The comparing length of text is defined by the "string" data.<br> * * @param[in] self The original string to be compared * @param[in] string Another string to be compared * @return 0: two are equal, negative: In case of self < string, positive: In case of self > string */ int32_t M2MString_compareTo (const M2MString *self, const M2MString *string) { //========== Variable ========== size_t stringLength = 0; //===== Check argument ===== if (self!=NULL && M2MString_length(self)>0 && string!=NULL && (stringLength=M2MString_length(string))>0) { //===== Return the result of comparison ===== return memcmp(self, string, stringLength); } //===== Argument error ===== else if (self==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"self\" string is NULL or vacant"); return -1; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL or vacant"); return -1; } } /** * This method converts character code with "iconv".<br> * * @param fromString Conversion target string * @param fromCharacterSetName Character set name of original string * @param toCharacterSetName Convert character set name * @param toString Pointer for copying converted string(buffering is executed in this method) * @return Pointer of converted string or NULL(means error) */ M2MString *M2MString_convertCharacterSet (const M2MString *fromString, const M2MString *fromCharacterSetName, const M2MString *toCharacterSetName, M2MString **toString) { //========== Variable ========== iconv_t conversionDescryptor = NULL; size_t srcLength = M2MString_length(fromString); size_t bufferLength = srcLength * 2; M2MString src[srcLength+1]; M2MString buffer[bufferLength+1]; M2MString *srcPointer = NULL; M2MString *bufferPointer = NULL; //===== Check argument ===== if (fromString!=NULL && srcLength>0 && fromCharacterSetName!=NULL && toCharacterSetName!=NULL && toString!=NULL) { //===== Initialize buffer ===== memset(src, 0, sizeof(src)); memcpy(src, fromString, srcLength); memset(buffer, 0, sizeof(buffer)); //===== Get conversion descriptor ===== if ((conversionDescryptor=iconv_open(toCharacterSetName, fromCharacterSetName))>0) { //===== Get pointer for call "iconv" ===== srcPointer = src; bufferPointer = buffer; //===== Convert character code ===== if (iconv(conversionDescryptor, (char **)&srcPointer, &srcLength, (char **)&bufferPointer, &bufferLength)==0) { //===== Allocate new memory ===== if ((bufferLength=M2MString_length(buffer))>0 && ((*toString)=(M2MString *)M2MHeap_malloc(bufferLength+1))!=NULL) { //===== Copy converted string ===== memcpy((*toString), buffer, bufferLength); iconv_close(conversionDescryptor); return (*toString); } //===== Error handling ===== else { iconv_close(conversionDescryptor); return NULL; } } //===== Error handling ===== else { iconv_close(conversionDescryptor); return NULL; } } //===== Error handling ===== else { return NULL; } } //===== Argument error ===== else if (fromString==NULL || srcLength<=0) { return NULL; } else if (fromCharacterSetName==NULL) { return NULL; } else if (toCharacterSetName==NULL) { return NULL; } else { return NULL; } } /** * * @param binary * @param binaryLength * @param buffer * @return Pointer of converted hexadecimal string or NULL (in case of error) */ M2MString *M2MString_convertFromBinaryToHexadecimalString (unsigned char *binary, const size_t binaryLength, M2MString **buffer) { //========== Variable ========== size_t i = 0; size_t bufferLength = 0; const size_t HEXADECIMAL_SIZE = 2; unsigned char HEXADECIMAL_STRING[HEXADECIMAL_SIZE+1]; const M2MString *FORMAT = (M2MString *)"%02x"; //===== Check argument ===== if (binary!=NULL && binaryLength>0 && buffer!=NULL) { //===== Get heap memory for storing converted string ===== if ((bufferLength=(binaryLength*HEXADECIMAL_SIZE)+1)>0 && ((*buffer)=(M2MString *)M2MHeap_malloc(bufferLength))!=NULL) { //===== Initialize buffer ===== memset((*buffer), 0, bufferLength); //===== Repeat conversion ===== for (i=0; i<binaryLength; i++) { memset(HEXADECIMAL_STRING, 0, sizeof(HEXADECIMAL_STRING)); //===== Convert from binary data into hexadecimal string ===== if (snprintf(HEXADECIMAL_STRING, sizeof(HEXADECIMAL_STRING), FORMAT, binary[i])>0) { //===== Connect strings ===== memcpy(&((*buffer)[i * HEXADECIMAL_SIZE]), HEXADECIMAL_STRING, HEXADECIMAL_SIZE); continue; } //===== Error handling ===== else { //===== Release heap memory ===== M2MHeap_free((*buffer)); this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to convert from binary to hexadecimal string"); return NULL; } } //===== Return the pointer of hexadecimal string ===== return (*buffer); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for storing converted hexadecimal string"); return NULL; } } //===== Argument error ===== else if (binary==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"binary\" data is NULL"); return NULL; } else if (binaryLength<=0) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"binaryLength\" is an integer less than or equal to 0"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"buffer\" pointer is NULL"); return NULL; } } /** * @param[in] boolean * @param[out] buffer * @param[in] bufferLength */ M2MString *M2MString_convertFromBooleanToString (const bool boolean, M2MString *buffer, const size_t bufferLength) { //========== Variable ========== const M2MString *TRUE = (M2MString *)"true"; const M2MString *FALSE = (M2MString *)"false"; //===== Check argument ===== if (bufferLength>=M2MString_length(FALSE)) { //===== In the case of "true" ===== if (boolean==true) { //===== Copy "true" string into buffer ===== memset(buffer, 0, bufferLength); M2MString_format(buffer, bufferLength-1, TRUE); return buffer; } //===== In the case of "false" ===== else { //===== Copy "false" string into buffer ===== memset(buffer, 0, bufferLength); M2MString_format(buffer, bufferLength-1, FALSE); return buffer; } } //===== Argument error ===== else { return NULL; } } /** * Convert double value into a string and copies it to the pointer. <br> * Since buffering of arrays is executed inside this function, so call <br> * "M2MHeap_free()" function on the caller side in order to prevent memory <br> * leak after using the string. <br> * * @param[in] number Real number to be converted * @param[out] string Pointer for copying the converted string (buffering is executed inside the function) * @return Copied string or NULL (in case of error) */ M2MString *M2MString_convertFromDoubleToString (const double number, M2MString **string) { //========== Variable ========== M2MString tmpBuffer[128]; size_t stringLength = 0; //===== Check argument ===== if (string!=NULL) { //===== Initialize array ===== memset(tmpBuffer, 0, sizeof(tmpBuffer)); //===== Convert from long to string ===== if (snprintf(tmpBuffer, sizeof(tmpBuffer), "%f", number)>=0 && (stringLength=M2MString_length(tmpBuffer))>0) { //===== Get heap memory for copying ===== if (((*string)=(M2MString *)M2MHeap_malloc(stringLength+1))!=NULL) { memcpy((*string), tmpBuffer, stringLength); return (*string); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to convert double number into string"); return NULL; } } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" pointer is NULL"); return NULL; } } /** * M2MString converter from hexadecimal string into binary data.<br> * * @param[in] hexadecimalString Hexadecimal string * @param[out] buffer Buffer for storing converted binary data * @return Pointer of converted binary data or NULL (in case of error) */ unsigned char *M2MString_convertFromHexadecimalStringToBinary (const M2MString *hexadecimalString, unsigned char **buffer) { //========== Variable ========== size_t hexadecimalStringLength = 0; size_t bufferLength = 0; size_t i = 0; unsigned int binary = 0; const size_t HEXADECIMAL_SIZE = 2; M2MString tmpString[HEXADECIMAL_SIZE+1]; const M2MString *FORMAT = (M2MString *)"%02hhx"; //===== ===== if (hexadecimalString!=NULL && (hexadecimalStringLength=M2MString_length(hexadecimalString))>0 && (hexadecimalStringLength%HEXADECIMAL_SIZE)==0 && buffer!=NULL) { //===== ===== bufferLength = hexadecimalStringLength / 2; //===== ===== if (((*buffer)=(M2MString *)M2MHeap_malloc(bufferLength))!=NULL) { //===== ===== for (i=0; i<bufferLength; i++) { //===== ===== binary = 0; memset(tmpString, 0, sizeof(tmpString)); //===== ===== memcpy(tmpString, &(hexadecimalString[i * HEXADECIMAL_SIZE]), HEXADECIMAL_SIZE); //===== ===== sscanf(tmpString, FORMAT, &binary); //===== ===== memcpy(&((*buffer)[i]), &binary, 1); } //===== ===== return (*buffer); } //===== ===== else { return NULL; } } //===== ===== else { return NULL; } } /** * M2MString converter from hexadecimal string into long number.<br> * * @param self Hexadecimal string * @param selfLength Length of hexadecimal string[Byte] * @return Converted number from hexadecimal string */ uint32_t M2MString_convertFromHexadecimalStringToUnsignedLong (const M2MString *self, const size_t selfLength) { //========== Variable ========== uint32_t decimal = 0; uint32_t i = 0; int16_t n = 0; M2MString c; //===== Check argument ====== if (self!=NULL && 0<selfLength && selfLength<=M2MString_length(self)) { //===== ====== for (i=0; i<selfLength; i++) { //===== ====== if ('0'<=self[i] && self[i]<='9') { n = self[i] - '0'; } //===== ====== else if ('a'<=(c=tolower(self[i])) && c<='f') { n = c - 'a' + 10; } //===== ====== else { } //===== ====== decimal = decimal *16 + n; } return decimal; } //===== Argument error ====== else { return 0; } } /** * Convert the line feed code from LF to CRLF for the argument string.<br> * * @param[in] self The original string to convert line feed code * @param[out] string Pointer to store string corrected line feed code (buffering itself is executed inside the function) * @return Pointer of CSV string with corrected line feed code or NULL (in case of error) */ M2MString *M2MString_convertFromLFToCRLF (const M2MString *self, M2MString **string) { //========== Variable ========== M2MString *lineStart = NULL; M2MString *lineEnd = NULL; size_t lineLength = 0; const size_t LF_LENGTH = M2MString_length(M2MString_LF); const size_t CRLF_LENGTH = M2MString_length(M2MString_CRLF); //===== Check argument ===== if (self!=NULL && M2MString_length(self)>0 && string!=NULL) { //===== When there is even one CRLF in the string (correction is not executed) ===== if ((lineEnd=M2MString_indexOf(self, M2MString_CRLF))!=NULL) { //===== Copy original string as it is ===== if (M2MString_append(string, self)!=NULL) { return (*string); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to append string"); return NULL; } } //===== When there is no CRLF in the string (to execute correction) ===== else { //===== Get the start position of input data ===== lineStart = (M2MString *)self; //===== Repeat search until LF disappears ===== while ((lineEnd=M2MString_indexOf(lineStart, M2MString_LF))!=NULL) { //===== When string data exists in one line ===== if ((lineLength=M2MString_length(lineStart)-M2MString_length(lineEnd))>0) { //===== Copy string data ===== M2MString_appendLength(string, lineStart, lineLength); //===== Add CRLF ===== M2MString_appendLength(string, M2MString_CRLF, CRLF_LENGTH); } //===== When string data doesn't exist ===== else { //===== Add CRLF ===== M2MString_append(string, M2MString_CRLF); } //===== Move the pointer to the beginning of the next line ===== lineEnd += LF_LENGTH; lineStart = lineEnd; } //===== When string data of the last line exists ===== if ((lineLength=M2MString_length(lineStart))>0) { //===== Copy string data ===== M2MString_appendLength(string, lineStart, lineLength); } //===== When string data of the last line doesn't exist ===== else { // do nothing } //===== Return output data ===== return (*string); } } //===== Argument error ===== else if (self==NULL || M2MString_length(self)<=0) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"self\" string is NULL or vacant"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" pointer is NULL"); return NULL; } } /** * Convert signed integer value into a string and copies it to the pointer. <br> * Since buffering of arrays is executed inside this function, so call <br> * "M2MHeap_free()" function on the caller side in order to prevent memory <br> * leak after using the string. <br> * * @param[in] number Signed integer number to be converted * @param[out] string Pointer for copying the converted string (buffering is executed inside the function) * @return Copied string or NULL (in case of error) */ M2MString *M2MString_convertFromSignedIntegerToString (const int32_t number, M2MString **string) { //========== Variable ========== M2MString tmpBuffer[128]; size_t stringLength = 0; //===== Check argument ===== if (string!=NULL) { //===== Initialize array ===== memset(tmpBuffer, 0, sizeof(tmpBuffer)); //===== Convert from long to string ===== if (snprintf(tmpBuffer, sizeof(tmpBuffer), "%d", number)>=0 && (stringLength=M2MString_length(tmpBuffer))>0) { //===== Get heap memory for copying ===== if (((*string)=(M2MString *)M2MHeap_malloc(stringLength+1))!=NULL) { memcpy((*string), tmpBuffer, stringLength); return (*string); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to convert integer number into string"); return NULL; } } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" pointer is NULL"); return NULL; } } /** * Convert signed long value into a string and copies it to the pointer. <br> * Since buffering of arrays is executed inside this function, so call <br> * "M2MHeap_free()" function on the caller side in order to prevent memory <br> * leak after using the string. <br> * * @param[in] number Signed long number to be converted * @param[out] string Pointer for copying the converted string (buffering is executed inside the function) * @return Copied string or NULL (in case of error) */ M2MString *M2MString_convertFromSignedLongToString (const signed long number, M2MString **string) { //========== Variable ========== M2MString tmpBuffer[128]; size_t stringLength = 0; //===== Check argument ===== if (string!=NULL) { //===== Initialize array ===== memset(tmpBuffer, 0, sizeof(tmpBuffer)); //===== Convert from long to string ===== if (snprintf(tmpBuffer, sizeof(tmpBuffer), "%ld", number)>=0 && (stringLength=M2MString_length(tmpBuffer))>0) { //===== Get heap memory for copying ===== if (((*string)=(unsigned char *)M2MHeap_malloc(stringLength+1))!=NULL) { memcpy((*string), tmpBuffer, stringLength); return (*string); } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to get heap memory for copying string into pointer"); return NULL; } } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to convert long integer number into string"); return NULL; } } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" pointer is NULL"); return NULL; } } /** * @param[in] string * @return */ bool M2MString_convertFromStringToBoolean (const M2MString *string) { //========== Variable ========== M2MString upperCaseValue[8]; //===== Check argument ===== if (string!=NULL) { //===== Convert into upper case ===== memset(upperCaseValue, 0, sizeof(upperCaseValue)); M2MString_toUpperCase(string, upperCaseValue, sizeof(upperCaseValue)); //===== ===== if (M2MString_compareTo((M2MString *)"TRUE", upperCaseValue)==0) { return true; } //===== In case of no-append ===== else { return false; } } //===== Argument error ===== else { return false; } } /** * Convert the argument string to double number.<br> * * @param[in] string String indicating double integer * @param[in] stringLength Size of string[Byte] * @return Double converted from string */ double M2MString_convertFromStringToDouble (const M2MString *string, const size_t stringLength) { //========== Variable ========== M2MString STRING_ARRAY[stringLength+1]; //===== Check argument ===== if (string!=NULL && stringLength<=M2MString_length(string)) { //===== Initialize buffer ===== memset(STRING_ARRAY, 0, sizeof(STRING_ARRAY)); //===== Copy string to buffer ===== memcpy(STRING_ARRAY, string, stringLength); //===== Convert string to double number ===== return strtod(STRING_ARRAY, NULL); } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL or stringLength is invalid"); return (double)-1; } } /** * Convert the argument string to long integer number.<br> * * @param[in] string String indicating signed long integer * @param[in] stringLength Size of string[Byte] * @return Signed long integer converted from string */ int32_t M2MString_convertFromStringToSignedLong (const M2MString *string, const size_t stringLength) { //========== Variable ========== M2MString STRING_ARRAY[stringLength+1]; M2MString MESSAGE[1024]; //===== Check argument ===== if (string!=NULL && stringLength<=M2MString_length(string)) { //===== Initialize buffer ===== memset(STRING_ARRAY, 0, sizeof(STRING_ARRAY)); //===== Copy string to buffer ===== memcpy(STRING_ARRAY, string, stringLength); //===== Convert string to long number ===== return atoi(STRING_ARRAY); } //===== Argument error ===== else if (string==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL"); return (int)-1; } else { memset(MESSAGE, 0, sizeof(MESSAGE)); snprintf(MESSAGE, sizeof(MESSAGE)-1, (M2MString *)"Argument error! Length of indicated \"string\" string (=\"%s\") is shorter than stringLength(=\"%zu\")", string, stringLength); this_printErrorMessage(__func__, __LINE__, MESSAGE); return (int)-1; } } /** * Convert the argument string to integer number.<br> * * @param[in] string String indicating signed integer * @param[in] stringLength Size of string[Byte] * @return Signed integer converted from string */ int32_t M2MString_convertFromStringToSignedInteger (const M2MString *string, const size_t stringLength) { //========== Variable ========== M2MString buffer[stringLength+1]; //===== Check argument ===== if (string!=NULL && stringLength<=M2MString_length(string)) { //===== Initialize buffer ===== memset(buffer, 0, sizeof(buffer)); //===== Copy string to buffer ===== memcpy(buffer, string, stringLength); //===== Convert string to signed integer number ===== return atoi(buffer); } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL or stringLength is invalid"); return (signed int)0; } } /** * This method convert from string to 64bit integer number.<br> * * @param[in] string String indicating signed long * @param[in] stringLength Size of string for convert[Byte] * @return Signed 64bit integer number converted from string */ int64_t M2MString_convertFromStringToSignedLongLong (const M2MString *string, const size_t stringLength) { //========== Variable ========== M2MString buffer[stringLength+1]; const uint32_t BASE = 10; //===== Check argument ===== if (string!=NULL && M2MString_length(string)>=stringLength) { //===== Copy string into buffer ===== memset(buffer, 0, sizeof(buffer)); memcpy(buffer, string, stringLength); //===== Convert string into integer ===== return (int64_t)strtoll(buffer, NULL, BASE); } //===== Argument error ===== else if (string==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL"); return (int64_t)0L; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"stringLength\" is bigger than length of \"string\""); return (int64_t)0L; } } /** * This method convert from string to 32bit unsigned integer number.<br> * * @param[in] string String indicating signed long * @param[in] stringLength Size of string[Byte] * @return Unsigned 32bit integer number converted from string */ uint32_t M2MString_convertFromStringToUnsignedInteger (const M2MString *string, const size_t stringLength) { //========== Variable ========== const uint32_t NUMBER = M2MString_convertFromStringToUnsignedLong(string, stringLength); //===== Check size of number ===== if (NUMBER<=UINT_MAX) { return (uint32_t)NUMBER; } //===== Error handling ===== else { return (uint32_t)0; } } /** * This method convert from string to 32bit unsigned long number.<br> * * @param[in] string String indicating signed long * @param[in] stringLength Size of string[Byte] * @return 32bit unsigned long number converted from string */ uint32_t M2MString_convertFromStringToUnsignedLong (const M2MString *string, const size_t stringLength) { //========== Variable ========== M2MString STRING_ARRAY[stringLength+1]; const uint32_t BASE = (uint32_t)10; //===== Check argument ===== if (string!=NULL && 0<stringLength) { //===== Copy string into buffer ===== memset(STRING_ARRAY, 0, sizeof(STRING_ARRAY)); memcpy(STRING_ARRAY, string, stringLength); //===== Convert string into integer ===== return strtoul(STRING_ARRAY, NULL, BASE); } //===== Argument error ===== else { return (uint32_t)0L; } } /** * This method converts from 32bit unsigned integer to string.<br> * Caller must provide enough buffers as "buffer" argument.<br> * * @param[in] number conversion target number * @param[out] buffer Buffer for copying unsigned integer string * @param[in] bufferLength Length of Buffer[Byte] * @return Converted number string or NULL (in case of error) */ M2MString *M2MString_convertFromUnsignedIntegerToString (const uint32_t number, M2MString *buffer, const size_t bufferLength) { //===== Check argument ===== if (bufferLength>0) { //===== Initialize temporary buffer ===== memset(buffer, 0, bufferLength); //===== Convert from unsigned integer to string ===== if (M2MString_format(buffer, bufferLength-1, "%u", number)>0) { return buffer; } //===== Error handling ===== else { return NULL; } } //===== Argument error ===== else { return NULL; } } /** * This method converts from unsigned long to string.<br> * Caller must provide enough buffers as "buffer" argument.<br> * * @param[in] number Conversion target number * @param[out] buffer Array for copying integer string * @param[in] bufferLength Length of array[Byte] * @return Converted hexadecimal number string or NULL (in case of error) */ M2MString *M2MString_convertFromUnsignedLongToHexadecimalString (const uint32_t number, M2MString *buffer, const size_t bufferLength) { //===== Check argument ===== if (buffer!=NULL && bufferLength>0) { //===== Initialize temporary buffer ===== memset(buffer, 0, bufferLength); //===== Convert from unsigned long to string ===== if (M2MString_format(buffer, bufferLength-1, "%lx", number)>0) { return buffer; } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to convert unsigned long to hexadecimal number"); return NULL; } } //===== Argument error ===== else if (buffer==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"buffer\" is NULL"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"bufferLength\" isn't positive"); return NULL; } } /** * This method converts from unsigned long to string.<br> * Caller must provide enough buffers as "buffer" argument.<br> * * @param[in] number Conversion target number * @param[out] buffer Array for copying integer string * @param[in] bufferLength Length of array[Byte] */ M2MString *M2MString_convertFromUnsignedLongToString (const uint32_t number, M2MString *buffer, const size_t bufferLength) { //===== Check argument ===== if (bufferLength>0) { //===== Initialize temporary buffer ===== memset(buffer, 0, bufferLength); //===== Convert from unsigned long to string ===== if (M2MString_format(buffer, bufferLength-1, "%lu", number)>0) { return buffer; } //===== Error handling ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Failed to convert \"uint32_t\" number into string"); return NULL; } } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"bufferLength\" isn't positive"); return NULL; } } /** * Converts a UTF-16 string to UTF-8. Returns a new string that must be freed<br> * or NULL if no conversion was needed.<br> * * @param[in,out] string * @param[in] stringLength * @return */ M2MString *M2MString_convertFromUTF16ToUTF8 (M2MString **string, size_t *stringLength) { //========== Variable ========== M2MString *u = NULL; size_t l = 0; size_t sl = 0; size_t max = *stringLength; int32_t c = 0L; int32_t d = 0L; int32_t b = 0; int32_t be = (**string==(M2MString)'\xFE') ? 1 : (**string==(M2MString)'\xFF') ? 0 : -1; const uint32_t XMLParser_BUFSIZE = 1024; //===== ===== if (be == -1) { return NULL; // not UTF-16 } //===== ===== u = (M2MString *)M2MHeap_malloc((*stringLength)); //===== ===== for (sl=2; sl<*stringLength-1; sl+=2) { c = (be) ? (((*string)[sl] & 0xFF) << 8) | ((*string)[sl + 1] & 0xFF) // UTF-16BE : (((*string)[sl + 1] & 0xFF) << 8) | ((*string)[sl] & 0xFF); // UTF-16LE if (c>=0xD800 && c<=0xDFFF && (sl+=2)<*stringLength-1) { // high-half d = (be) ? (((*string)[sl] & 0xFF) << 8) | ((*string)[sl + 1] & 0xFF) : (((*string)[sl + 1] & 0xFF) << 8) | ((*string)[sl] & 0xFF); c = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000; } while (l + 6 > max) { u = (M2MString *)M2MHeap_realloc(u, max += XMLParser_BUFSIZE); } if (c < 0x80) { u[l++] = c; // US-ASCII subset } //===== multi-byte UTF-8 sequence ===== else { for (b=0, d=c; d; d/=2) { b++; // bits in c } b = (b - 2) / 5; // bytes in payload u[l++] = (0xFF << (7 - b)) | (c >> (6 * b)); // head while (b) { u[l++] = 0x80 | ((c >> (6 * --b)) & 0x3F); // payload } } } return ((*string)=(M2MString *)M2MHeap_realloc(u, (*stringLength)=l)); } /** * Compare the two strings and return result.<br> * * @param[in] one String to be compared * @param[in] another Another string to be compared * @param[in] length Length of string to be compared [byte] * @return true: When the same case, false: When they do not match */ bool M2MString_equals (const M2MString *one, const M2MString *another, const size_t length) { //===== Check argument ===== if (one!=NULL && another!=NULL && length>0) { //===== When the strings match ===== if (memcmp(one, another, length)==0) { return true; } //===== When the strings don't match ===== else { return false; } } //===== Argument error ===== else if (one==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"one\" string is NULL"); return false; } else if (another==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"another\" string is NULL"); return false; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"length\" is invalid"); return false; } } /** * This method converts variables into string in the indicated format.<br> * * @param buffer Buffer for copying translated strings * @param bufferLength Length of buffer[Byte] * @param format Format for translation into string * @return Length of converted strings[Byte] or -1(means error) */ int M2MString_format (M2MString *buffer, const size_t bufferLength, const M2MString *format, ...) { //========== Variable ========== va_list variableList; int result = 0; //===== Check argument ===== if (buffer!=NULL && bufferLength>0 && format!=NULL && M2MString_length(format)>0) { va_start(variableList, format); result = vsnprintf(buffer, bufferLength, format, variableList); va_end(variableList); return result; } //===== Argument error ===== else if (buffer==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"buffer\" is NULL"); return -1; } else if (bufferLength<=0) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"bufferLength\" isn't positive"); return -1; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"format\" string is NULL or vacant"); return -1; } } /** * Returns the pointer that the "keyword" string first appears. <br> * If "keyword" string isn't found, returns NULL. * * @param[in] string Search target string * @param[in] keyword Detection string * @return Pointer indicating keyword start position or NULL (in case of error) */ M2MString *M2MString_indexOf (const M2MString *string, const M2MString *keyword) { //===== Check argument ===== if (string!=NULL && keyword!=NULL) { //===== Return the result of search ===== return (M2MString *)strstr(string, keyword); } //===== Argument error ===== else if (string==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"keyword\" string is NULL"); return NULL; } } /** * @param character A character of number * @return true : argument is number, false : argument isn't number */ bool M2MString_isNumber (const M2MString character) { if (isdigit(character)!=0) { return true; } else { return false; } } /** * @param[in] self * @return */ bool M2MString_isSpace (const M2MString *self) { //===== Check argument ===== if (self!=NULL) { //===== Check head of string is space ===== if ((M2MString_compareTo(M2MString_SPACE, self)==0 || M2MString_compareTo(M2MString_ZENKAKU_SPACE, self)==0)) { return true; } //===== In the case of not space ===== else { return false; } } //===== Argument error ===== else { return false; } } /** * @param[in] self * @return */ bool M2MString_isUTF (const M2MString *self) { //===== Check argument ===== if (self!=NULL) { //===== Check length of string ===== if (M2MString_length(self)>=4) { //===== In the case of UTF ===== if ((isxdigit(self[0]) && isxdigit(self[1]) && isxdigit(self[2]) && isxdigit(self[3]))!=0) { return true; } //===== In the case of not UTF ===== else { return false; } } //===== In the case of short of length ===== else { return false; } } //===== Argument error ===== else { return false; } } /** * Returns the pointer that the "keyword" string last appears. <br> * If "keyword" string isn't found, returns NULL. * * @param[in] string Search target string * @param[in] keyword Detection string * @return Pointer indicating keyword last position or NULL (in case of error) */ M2MString *M2MString_lastIndexOf (const M2MString *string, const M2MString *keyword) { //========== Variable ========== M2MString *lastIndex = NULL; M2MString *index = (M2MString *)string; //===== Check argument ===== if (string!=NULL && keyword!=NULL) { //===== Repeat until arriving the last ===== while ((index=strstr(index, keyword))!=NULL) { lastIndex = index; index++; } //===== Return the last index ===== return lastIndex; } //===== Argument error ===== else if (string==NULL) { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"string\" string is NULL"); return NULL; } else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"fromIndex\" string is NULL"); return NULL; } } /** * Get the length of the string. <br> * * @param[in] self String (always be null terminated) * @return Length of string or 0 (in case of error) */ size_t M2MString_length (const M2MString *self) { //===== Check argument ===== if (self!=NULL) { return strlen(self); } //===== Argument error ===== else { this_printErrorMessage(__func__, __LINE__, (M2MString *)"Argument error! Indicated \"self\" string is NULL"); return 0; } } /** * This method replaces each substring of this string.<br> * It matches the literal target sequence with the specified literal <br> * replacement sequence.<br> * * @param[in] self original string * @param[in] target sequence of character values to be replaced * @param[in] replacement replacement sequence of character values * @param[out] buffer buffer for copying replaced string * @param[in] bufferLength length of buffer[Byte] * @return replaced string or NULL(means error) */ M2MString *M2MString_replace (const M2MString *self, const M2MString *target, const M2MString *replacement, M2MString *buffer, const size_t bufferLength) { //========== Variable ========== M2MString *rest = NULL; M2MString *index = NULL; size_t currentLength = 0; size_t copyM2MStringLength = 0; const size_t TARGET_LENGTH = M2MString_length(target); const size_t REPLACEMENT_LENGTH = M2MString_length(replacement); //===== Check argument ===== if (self!=NULL && M2MString_length(self)>0 && target!=NULL && M2MString_length(target)>0 && replacement!=NULL && bufferLength>0) { //===== Initialize buffer ===== memset(buffer, 0, bufferLength); rest = (M2MString *)self; //===== Detect position of target string ===== while ((index=M2MString_indexOf(rest, target))!=NULL) { //===== Check buffer length ===== if ((copyM2MStringLength=M2MString_length(rest)-M2MString_length(index))<(bufferLength-currentLength)) { //===== Copy string into buffer ===== memcpy(&(buffer[currentLength]), rest, copyM2MStringLength); //===== Update string length ===== currentLength += copyM2MStringLength; //===== Check buffer length ===== if (REPLACEMENT_LENGTH<(bufferLength-currentLength)) { //===== Replace string ===== memcpy(&(buffer[currentLength]), replacement, REPLACEMENT_LENGTH); //===== Update string length ===== currentLength += REPLACEMENT_LENGTH; //===== Proceed pointer ===== index += TARGET_LENGTH; rest = index; } //===== Error handling ===== else { memset(buffer, 0, bufferLength); return NULL; } } //===== Error handling ===== else { memset(buffer, 0, bufferLength); return NULL; } } //===== Check buffer length ===== if (M2MString_length(rest)<(bufferLength-currentLength)) { //===== Copy rest string into buffer ===== memcpy(&(buffer[currentLength]), rest, M2MString_length(rest)); return buffer; } //===== Error handling ===== else { memset(buffer, 0, bufferLength); return NULL; } } //===== Argument error ===== else { return NULL; } } /** * If you want to repeat splitting same word, must use same savePoint<br> * variable.<br> * * @param self * @param delimiter * @param savePoint * @return */ M2MString *M2MString_split (M2MString *self, const M2MString *delimiter, M2MString **savePoint) { //===== Check argument ===== if (delimiter!=NULL) { //===== Reentrant tokenization ===== return (M2MString *)strtok_r(self, delimiter, (char **)savePoint); } //===== Argument error ===== else { return self; } } /** * @param self * @param buffer * @param bufferLength * @return */ M2MString *M2MString_toLowerCase (const M2MString *self, M2MString *buffer, const size_t bufferLength) { //========== Variable ========== size_t i = 0; size_t selfLength = 0; const unsigned int CHARACTER_LENGTH = 4; M2MString character[CHARACTER_LENGTH]; //===== Check argument ===== if (self!=NULL && bufferLength>0) { //===== Get length of string ===== if ((selfLength=M2MString_length(self))>0 && selfLength<bufferLength) { //===== Initialize buffer ===== memset(character, 0, CHARACTER_LENGTH); //===== Repeat transfer ===== for (i=0; i<selfLength; i++) { //===== Transfer a character ===== character[0] = tolower(self[i]); memcpy(&(buffer[i]), character, 1); //===== Initialize buffer ===== memset(character, 0, CHARACTER_LENGTH); } return buffer; } //===== Error handling ===== else { return NULL; } } //===== Argument error ===== else if (self==NULL) { return NULL; } else { return NULL; } } /** * @param[in] self * @param[out] upperCaseM2MString buffer for upper case string(caller muse release this allocated memory) * @return */ M2MString *M2MString_toUpperCase (const M2MString *self, M2MString *buffer, const size_t bufferLength) { //========== Variable ========== size_t i = 0; size_t selfLength = 0; const unsigned int CHARACTER_LENGTH = 2; M2MString character[CHARACTER_LENGTH]; //===== Check argument ===== if (self!=NULL && bufferLength>0) { //===== Get length of string ===== if ((selfLength=M2MString_length(self))>0 && selfLength<bufferLength) { //===== Initialize buffer ===== memset(character, 0, CHARACTER_LENGTH); //===== Repeat transfer ===== for (i=0; i<selfLength; i++) { //===== Transfer a character ===== character[0] = toupper(self[i]); memcpy(&(buffer[i]), character, 1); //===== Initialize buffer ===== memset(character, 0, CHARACTER_LENGTH); } return buffer; } //===== Error handling ===== else { return NULL; } } //===== Argument error ===== else if (self==NULL) { return NULL; } else { return NULL; } } /* End Of File */
29.362654
180
0.632621
263466b89e708fd6b5870a0ed022a7bb69c8f192
2,435
h
C
lib/YetAnotherArduinoWiegandLibrary/src/Wiegand.h
KabbageInc/kaskduino
c007e99fd1f78a4da65b5f99fef1e5575da633d9
[ "MIT" ]
null
null
null
lib/YetAnotherArduinoWiegandLibrary/src/Wiegand.h
KabbageInc/kaskduino
c007e99fd1f78a4da65b5f99fef1e5575da633d9
[ "MIT" ]
2
2017-09-10T21:56:30.000Z
2017-09-10T21:58:14.000Z
lib/YetAnotherArduinoWiegandLibrary/src/Wiegand.h
KabbageInc/kaskduino
c007e99fd1f78a4da65b5f99fef1e5575da633d9
[ "MIT" ]
4
2017-08-11T17:33:23.000Z
2020-09-17T16:02:26.000Z
#define WIEGAND_LENGTH_AUTO 0 #define WIEGAND_TIMEOUT 100 #define WIEGAND_MAX_BYTES 4 #include <stdint.h> class Wiegand { private: typedef void (*data_callback)(uint8_t* data, uint8_t bits, void* param); typedef void (*state_callback)(bool plugged, void* param); uint8_t expected_bits; uint8_t bits; uint8_t state; unsigned long timestamp; uint8_t data[WIEGAND_MAX_BYTES]; data_callback func_data; state_callback func_state; void* func_data_param; void* func_state_param; inline void writeBit(uint8_t i, bool value); inline bool readBit(uint8_t i); void addBit(bool value); void flushData(); void reset(); public: // Start things up // If the number of bits is specified (usually 26 or 34), the data Callback will be notified immedialy aftern the last bit. // Otherwise, you will need to call `flush()` inside your main loop to receive notifications. void begin(uint8_t bits=WIEGAND_LENGTH_AUTO); // Stops it void end(); // Sends pending Data Received notifications. // When using automatic length detection, this method has to be called frequently. void flush(); // Checks if the class has started and a scanner is detected operator bool(); //Attaches a Data Receive Callback. This will be called whenever a message has been received without errors. template<typename T> void onReceive(void (*func)(uint8_t* data, uint8_t bits, T* param), T* param=nullptr) { func_data = (data_callback)func; func_data_param = (void*)param; } //Attaches a State Change Callback. This is called whenever a device is attached or dettached. //If you have a dettachable device, add pull down resistors to both data lines, otherwise random noise will produce lots of bogus State Change notifications (and a few Data Received notifications) template<typename T> void onStateChange(void (*func)(bool plugged, T* param), T* param=nullptr) { func_state = (state_callback)func; func_state_param = (void*)param; } //Notifies the library that the pin Data-`pin_value` has changed to `pin_state` void setPinState(uint8_t pin, bool pin_state); //Notifies the library that the pin Data0 has changed to `pin_state` inline void setPin0State(bool state) { setPinState(0, state); } //Notifies the library that the pin Data1 has changed to `pin_state` inline void setPin1State(bool state) { setPinState(1, state); } };
35.289855
198
0.729363
4d1da5c5e19473f5b0c3932ed40ce8616ecd0deb
20,162
h
C
System/Library/PrivateFrameworks/GameCenterUI.framework/GKGridLayout.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
2
2021-11-02T09:23:27.000Z
2022-03-28T08:21:57.000Z
System/Library/PrivateFrameworks/GameCenterUI.framework/GKGridLayout.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/GameCenterUI.framework/GKGridLayout.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
1
2022-03-28T08:21:59.000Z
2022-03-28T08:21:59.000Z
/* * This header is generated by classdump-dyld 1.5 * on Wednesday, October 27, 2021 at 3:17:17 PM Mountain Standard Time * Operating System: Version 13.5.1 (Build 17F80) * Image Source: /System/Library/PrivateFrameworks/GameCenterUI.framework/GameCenterUI * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ #import <GameCenterUI/GameCenterUI-Structs.h> #import <UIKitCore/UICollectionViewLayout.h> @class NSPointerArray, NSMutableArray, NSMutableOrderedSet, NSMutableDictionary, NSMutableIndexSet, NSMutableSet, NSIndexPath, NSArray, GKCollectionViewDataSource, GKCollectionViewLayoutAttributes, NSSet, GKSectionMetrics, GKDataSourceMetrics; @interface GKGridLayout : UICollectionViewLayout { BOOL _showPlaceholder; BOOL _hideSearchBarOnAppear; BOOL _hideAboveSegmentOnAppear; BOOL _ignoreBoundsForSizeCalculation; BOOL _noMoreShowMore; BOOL _movedItemsInUpdateCarrySections; BOOL _displayClipView; BOOL _displayingOverlay; BOOL _shouldLayoutRTL; unsigned long long _portraitInterleavedSectionsCount; unsigned long long _landscapeInterleavedSectionsCount; double _leftLayoutGuideOffset; double _rightLayoutGuideOffset; double _bottomContentPadding; NSPointerArray* _sectionToPresentationData; NSPointerArray* _sectionToMetricData; NSMutableArray* _laidOutAttributes; NSMutableOrderedSet* _laidOutPinnableAttributes; NSMutableDictionary* _indexPathToSupplementary; NSMutableDictionary* _indexPathToDecoration; NSMutableDictionary* _indexPathToItem; NSMutableDictionary* _oldIndexPathToSupplementary; NSMutableDictionary* _oldIndexPathToDecoration; NSMutableDictionary* _oldIndexPathToItem; NSMutableDictionary* _indexPathToMetrics; NSMutableIndexSet* _sectionsWithPinnedHeaders; NSMutableSet* _revealedIndexPaths; NSIndexPath* _indexPathOfTouchedShowMore; NSMutableDictionary* _keyToMetricData; NSMutableDictionary* _oldSectionToMetricKeys; long long _metricsInvalidationCount; NSArray* _currentUpdateItems; NSMutableSet* _knownSupplementaryKinds; GKCollectionViewDataSource* _dataSourceForUpdate; unsigned long long _updateType; GKCollectionViewLayoutAttributes* _clipViewAttributes; unsigned long long _invalidationFlags; double _segmentedBoxY; NSSet* _visibleIndexPathsFilter; GKSectionMetrics* _defaultSectionMetricsInternal; GKDataSourceMetrics* _dataSourceMetrics; double _hiddenSearchBarOffset; double _segmentedHeaderPinningOffset; CGSize _laidOutContentSize; CGSize _minimumLaidOutContentSize; CGSize _oldLaidOutContentSize; } @property (nonatomic,retain) NSPointerArray * sectionToPresentationData; //@synthesize sectionToPresentationData=_sectionToPresentationData - In the implementation block @property (nonatomic,retain) NSPointerArray * sectionToMetricData; //@synthesize sectionToMetricData=_sectionToMetricData - In the implementation block @property (nonatomic,retain) NSMutableArray * laidOutAttributes; //@synthesize laidOutAttributes=_laidOutAttributes - In the implementation block @property (nonatomic,retain) NSMutableOrderedSet * laidOutPinnableAttributes; //@synthesize laidOutPinnableAttributes=_laidOutPinnableAttributes - In the implementation block @property (assign,nonatomic) CGSize laidOutContentSize; //@synthesize laidOutContentSize=_laidOutContentSize - In the implementation block @property (assign,nonatomic) CGSize oldLaidOutContentSize; //@synthesize oldLaidOutContentSize=_oldLaidOutContentSize - In the implementation block @property (assign,nonatomic) CGSize minimumLaidOutContentSize; //@synthesize minimumLaidOutContentSize=_minimumLaidOutContentSize - In the implementation block @property (nonatomic,retain) NSMutableDictionary * indexPathToSupplementary; //@synthesize indexPathToSupplementary=_indexPathToSupplementary - In the implementation block @property (nonatomic,retain) NSMutableDictionary * indexPathToDecoration; //@synthesize indexPathToDecoration=_indexPathToDecoration - In the implementation block @property (nonatomic,retain) NSMutableDictionary * indexPathToItem; //@synthesize indexPathToItem=_indexPathToItem - In the implementation block @property (nonatomic,retain) NSMutableDictionary * oldIndexPathToSupplementary; //@synthesize oldIndexPathToSupplementary=_oldIndexPathToSupplementary - In the implementation block @property (nonatomic,retain) NSMutableDictionary * oldIndexPathToDecoration; //@synthesize oldIndexPathToDecoration=_oldIndexPathToDecoration - In the implementation block @property (nonatomic,retain) NSMutableDictionary * oldIndexPathToItem; //@synthesize oldIndexPathToItem=_oldIndexPathToItem - In the implementation block @property (nonatomic,retain) NSMutableDictionary * indexPathToMetrics; //@synthesize indexPathToMetrics=_indexPathToMetrics - In the implementation block @property (nonatomic,retain) NSMutableIndexSet * sectionsWithPinnedHeaders; //@synthesize sectionsWithPinnedHeaders=_sectionsWithPinnedHeaders - In the implementation block @property (nonatomic,retain) NSMutableSet * revealedIndexPaths; //@synthesize revealedIndexPaths=_revealedIndexPaths - In the implementation block @property (nonatomic,retain) NSIndexPath * indexPathOfTouchedShowMore; //@synthesize indexPathOfTouchedShowMore=_indexPathOfTouchedShowMore - In the implementation block @property (assign,nonatomic) BOOL noMoreShowMore; //@synthesize noMoreShowMore=_noMoreShowMore - In the implementation block @property (nonatomic,retain) NSMutableDictionary * keyToMetricData; //@synthesize keyToMetricData=_keyToMetricData - In the implementation block @property (nonatomic,retain) NSMutableDictionary * oldSectionToMetricKeys; //@synthesize oldSectionToMetricKeys=_oldSectionToMetricKeys - In the implementation block @property (assign,nonatomic) long long metricsInvalidationCount; //@synthesize metricsInvalidationCount=_metricsInvalidationCount - In the implementation block @property (nonatomic,retain) NSArray * currentUpdateItems; //@synthesize currentUpdateItems=_currentUpdateItems - In the implementation block @property (nonatomic,retain) NSMutableSet * knownSupplementaryKinds; //@synthesize knownSupplementaryKinds=_knownSupplementaryKinds - In the implementation block @property (nonatomic,retain) GKCollectionViewDataSource * dataSourceForUpdate; //@synthesize dataSourceForUpdate=_dataSourceForUpdate - In the implementation block @property (assign,nonatomic) unsigned long long updateType; //@synthesize updateType=_updateType - In the implementation block @property (assign,nonatomic) BOOL movedItemsInUpdateCarrySections; //@synthesize movedItemsInUpdateCarrySections=_movedItemsInUpdateCarrySections - In the implementation block @property (assign,nonatomic) BOOL displayClipView; //@synthesize displayClipView=_displayClipView - In the implementation block @property (nonatomic,retain) GKCollectionViewLayoutAttributes * clipViewAttributes; //@synthesize clipViewAttributes=_clipViewAttributes - In the implementation block @property (assign,nonatomic) unsigned long long invalidationFlags; //@synthesize invalidationFlags=_invalidationFlags - In the implementation block @property (assign,nonatomic) BOOL displayingOverlay; //@synthesize displayingOverlay=_displayingOverlay - In the implementation block @property (assign,nonatomic) double segmentedBoxY; //@synthesize segmentedBoxY=_segmentedBoxY - In the implementation block @property (assign,nonatomic) BOOL shouldLayoutRTL; //@synthesize shouldLayoutRTL=_shouldLayoutRTL - In the implementation block @property (nonatomic,retain) NSSet * visibleIndexPathsFilter; //@synthesize visibleIndexPathsFilter=_visibleIndexPathsFilter - In the implementation block @property (nonatomic,retain) GKSectionMetrics * defaultSectionMetricsInternal; //@synthesize defaultSectionMetricsInternal=_defaultSectionMetricsInternal - In the implementation block @property (nonatomic,retain) GKDataSourceMetrics * dataSourceMetrics; //@synthesize dataSourceMetrics=_dataSourceMetrics - In the implementation block @property (assign,nonatomic) double hiddenSearchBarOffset; //@synthesize hiddenSearchBarOffset=_hiddenSearchBarOffset - In the implementation block @property (assign,nonatomic) double segmentedHeaderPinningOffset; //@synthesize segmentedHeaderPinningOffset=_segmentedHeaderPinningOffset - In the implementation block @property (assign,nonatomic) BOOL showPlaceholder; //@synthesize showPlaceholder=_showPlaceholder - In the implementation block @property (assign,nonatomic) unsigned long long portraitInterleavedSectionsCount; //@synthesize portraitInterleavedSectionsCount=_portraitInterleavedSectionsCount - In the implementation block @property (assign,nonatomic) unsigned long long landscapeInterleavedSectionsCount; //@synthesize landscapeInterleavedSectionsCount=_landscapeInterleavedSectionsCount - In the implementation block @property (assign,nonatomic) double leftLayoutGuideOffset; //@synthesize leftLayoutGuideOffset=_leftLayoutGuideOffset - In the implementation block @property (assign,nonatomic) double rightLayoutGuideOffset; //@synthesize rightLayoutGuideOffset=_rightLayoutGuideOffset - In the implementation block @property (assign,nonatomic) BOOL hideSearchBarOnAppear; //@synthesize hideSearchBarOnAppear=_hideSearchBarOnAppear - In the implementation block @property (assign,nonatomic) BOOL hideAboveSegmentOnAppear; //@synthesize hideAboveSegmentOnAppear=_hideAboveSegmentOnAppear - In the implementation block @property (assign,nonatomic) double bottomContentPadding; //@synthesize bottomContentPadding=_bottomContentPadding - In the implementation block @property (assign,nonatomic) BOOL ignoreBoundsForSizeCalculation; //@synthesize ignoreBoundsForSizeCalculation=_ignoreBoundsForSizeCalculation - In the implementation block +(Class)invalidationContextClass; +(Class)layoutAttributesClass; -(id)init; -(void)dealloc; -(double)scale; -(void)invalidateLayoutWithContext:(id)arg1 ; -(void)prepareLayout; -(id)layoutAttributesForElementsInRect:(CGRect)arg1 ; -(id)layoutAttributesForItemAtIndexPath:(id)arg1 ; -(id)invalidationContextForBoundsChange:(CGRect)arg1 ; -(void)finalizeCollectionViewUpdates; -(id)indexPathsToDeleteForSupplementaryViewOfKind:(id)arg1 ; -(CGSize)collectionViewContentSize; -(id)layoutAttributesForSupplementaryViewOfKind:(id)arg1 atIndexPath:(id)arg2 ; -(id)layoutAttributesForDecorationViewOfKind:(id)arg1 atIndexPath:(id)arg2 ; -(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)arg1 ; -(void)prepareForCollectionViewUpdates:(id)arg1 ; -(id)finalLayoutAttributesForDisappearingItemAtIndexPath:(id)arg1 ; -(void)prepareForAnimatedBoundsChange:(CGRect)arg1 ; -(CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)arg1 ; -(id)finalLayoutAttributesForDisappearingSupplementaryElementOfKind:(id)arg1 atIndexPath:(id)arg2 ; -(id)initialLayoutAttributesForAppearingItemAtIndexPath:(id)arg1 ; -(id)initialLayoutAttributesForAppearingSupplementaryElementOfKind:(id)arg1 atIndexPath:(id)arg2 ; -(void)finalizeAnimatedBoundsChange; -(/*^block*/id)_animationForReusableView:(id)arg1 toLayoutAttributes:(id)arg2 type:(unsigned long long)arg3 ; -(CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)arg1 withScrollingVelocity:(CGPoint)arg2 ; -(double)bottomContentPadding; -(unsigned long long)updateType; -(void)setUpdateType:(unsigned long long)arg1 ; -(void)_resetState; -(long long)searchResultsCount; -(CGRect)layoutBounds; -(void)setShowPlaceholder:(BOOL)arg1 ; -(BOOL)showPlaceholder; -(void)setDataSourceMetrics:(GKDataSourceMetrics *)arg1 ; -(id)_gkDescriptionWithChildren:(int)arg1 ; -(GKDataSourceMetrics *)dataSourceMetrics; -(void)updatePlaceholderVisibility; -(BOOL)shouldUpdateVisibleCellLayoutAttributes; -(id)metricDataForSection:(long long)arg1 ; -(unsigned long long)filteredTotalItemCountForSection:(long long)arg1 ; -(void)setDefaultSectionMetricsInternal:(GKSectionMetrics *)arg1 ; -(CGSize)_sizeAdjustedForTabBarSettingsBasedOnSize:(CGSize)arg1 ; -(void)refreshMetrics; -(void)_filterPinnedAttributes; -(id)metricsForSection:(long long)arg1 ; -(long long)indexOfSupplementaryMetricsOfKind:(id)arg1 inList:(id)arg2 ; -(unsigned long long)sectionsPerRow; -(id)presentationDataForSection:(long long)arg1 ; -(double)calculatedBottomPaddingForSection:(long long)arg1 ; -(id)_existingPresentationDataForSection:(long long)arg1 ; -(BOOL)_areWePortrait; -(NSMutableIndexSet *)sectionsWithPinnedHeaders; -(double)yOffsetForSection:(long long)arg1 ; -(double)leftLayoutGuideOffset; -(double)rightLayoutGuideOffset; -(void)updatePresentationDataInSection:(long long)arg1 withAttributes:(id)arg2 supplementaryLocation:(unsigned long long)arg3 ; -(void)setClipViewAttributes:(GKCollectionViewLayoutAttributes *)arg1 ; -(id)firstVisibleIndexAtOrAfterItem:(long long)arg1 itemCount:(long long)arg2 inSection:(long long)arg3 ; -(void)fullyRebuildLayout; -(long long)_prepareSupplementaryLayoutForSection:(long long)arg1 atLocation:(unsigned long long)arg2 offset:(long long)arg3 globalOffset:(long long*)arg4 ; -(long long)_prepareOverlayLayoutForSection:(long long)arg1 offset:(long long)arg2 ; -(unsigned long long)_prepareItemLayoutForSection:(long long)arg1 ; -(void)updatePresentationDataForLastInterleavedSections; -(void)finalizeGlobalPresentationDataWithSectionRange:(NSRange)arg1 ; -(void)calculateCollectionViewContentSize; -(void)_prepareSegmentedBoxLayoutWithOffset:(long long)arg1 ; -(double)applyBottomPinningToAttributes:(id)arg1 minY:(double)arg2 maxY:(double)arg3 ; -(double)applyTopPinningToAttributes:(id)arg1 minY:(double)arg2 maxY:(double)arg3 ; -(double)layoutTopPinningAttributes:(id)arg1 minY:(double)arg2 maxY:(double)arg3 ; -(void)finalizePinnedAttributes:(id)arg1 forSection:(long long)arg2 footer:(BOOL)arg3 ; -(double)layoutBottomPinningAttributes:(id)arg1 minY:(double)arg2 maxY:(double)arg3 ; -(void)enumerateSectionsIndexesOverlappingYOffset:(double)arg1 block:(/*^block*/id)arg2 ; -(id)revealMoreForSectionIndex:(long long)arg1 revealCount:(unsigned long long)arg2 andDeleteItemCount:(unsigned long long)arg3 ; -(void)setIndexPathOfTouchedShowMore:(NSIndexPath *)arg1 ; -(void)setRevealedIndexPaths:(NSMutableSet *)arg1 ; -(double)yOffsetForSlidingUpdate; -(id)initialLayoutAttributesForSlidingInItemAtIndexPath:(id)arg1 ; -(id)finalLayoutAttributesForSlidingAwayItemAtIndexPath:(id)arg1 ; -(BOOL)shouldSlideInSupplementaryElementOfKind:(id)arg1 forUpdateItem:(id)arg2 atIndexPath:(id)arg3 ; -(BOOL)shouldSlideOutSupplementaryElementOfKind:(id)arg1 forUpdateItem:(id)arg2 atIndexPath:(id)arg3 ; -(void)setCurrentUpdateItems:(NSArray *)arg1 ; -(void)setDataSourceForUpdate:(GKCollectionViewDataSource *)arg1 ; -(void)setMovedItemsInUpdateCarrySections:(BOOL)arg1 ; -(void)prepareForUpdate:(unsigned long long)arg1 inDataSource:(id)arg2 ; -(id)metricDataForKey:(id)arg1 ; -(void)setMetricData:(id)arg1 forSection:(long long)arg2 ; -(id)attributesForSupplementaryIndexPath:(id)arg1 ; -(void)setPortraitInterleavedSectionsCount:(unsigned long long)arg1 ; -(void)setLandscapeInterleavedSectionsCount:(unsigned long long)arg1 ; -(GKSectionMetrics *)defaultSectionMetricsInternal; -(void)setVisibleIndexPathsFilter:(NSSet *)arg1 ; -(void)setLeftLayoutGuideOffset:(double)arg1 ; -(void)setRightLayoutGuideOffset:(double)arg1 ; -(void)updatePinnableAreas; -(void)enableClipView; -(void)disableClipView; -(void)forceFullInvalidate; -(unsigned long long)currentMaxVisibleItemCountForSection:(long long)arg1 ; -(id)revealMoreForSectionIndex:(long long)arg1 ; -(void)prepareForMovingItemsCarryingSections; -(unsigned long long)portraitInterleavedSectionsCount; -(unsigned long long)landscapeInterleavedSectionsCount; -(BOOL)hideSearchBarOnAppear; -(void)setHideSearchBarOnAppear:(BOOL)arg1 ; -(BOOL)hideAboveSegmentOnAppear; -(void)setHideAboveSegmentOnAppear:(BOOL)arg1 ; -(CGSize)laidOutContentSize; -(void)setLaidOutContentSize:(CGSize)arg1 ; -(CGSize)minimumLaidOutContentSize; -(void)setMinimumLaidOutContentSize:(CGSize)arg1 ; -(void)setBottomContentPadding:(double)arg1 ; -(BOOL)ignoreBoundsForSizeCalculation; -(void)setIgnoreBoundsForSizeCalculation:(BOOL)arg1 ; -(NSPointerArray *)sectionToPresentationData; -(void)setSectionToPresentationData:(NSPointerArray *)arg1 ; -(NSPointerArray *)sectionToMetricData; -(void)setSectionToMetricData:(NSPointerArray *)arg1 ; -(NSMutableArray *)laidOutAttributes; -(void)setLaidOutAttributes:(NSMutableArray *)arg1 ; -(NSMutableOrderedSet *)laidOutPinnableAttributes; -(void)setLaidOutPinnableAttributes:(NSMutableOrderedSet *)arg1 ; -(CGSize)oldLaidOutContentSize; -(void)setOldLaidOutContentSize:(CGSize)arg1 ; -(NSMutableDictionary *)indexPathToSupplementary; -(void)setIndexPathToSupplementary:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)indexPathToDecoration; -(void)setIndexPathToDecoration:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)indexPathToItem; -(void)setIndexPathToItem:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)oldIndexPathToSupplementary; -(void)setOldIndexPathToSupplementary:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)oldIndexPathToDecoration; -(void)setOldIndexPathToDecoration:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)oldIndexPathToItem; -(void)setOldIndexPathToItem:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)indexPathToMetrics; -(void)setIndexPathToMetrics:(NSMutableDictionary *)arg1 ; -(void)setSectionsWithPinnedHeaders:(NSMutableIndexSet *)arg1 ; -(NSMutableSet *)revealedIndexPaths; -(NSIndexPath *)indexPathOfTouchedShowMore; -(BOOL)noMoreShowMore; -(void)setNoMoreShowMore:(BOOL)arg1 ; -(NSMutableDictionary *)keyToMetricData; -(void)setKeyToMetricData:(NSMutableDictionary *)arg1 ; -(NSMutableDictionary *)oldSectionToMetricKeys; -(void)setOldSectionToMetricKeys:(NSMutableDictionary *)arg1 ; -(long long)metricsInvalidationCount; -(void)setMetricsInvalidationCount:(long long)arg1 ; -(NSArray *)currentUpdateItems; -(NSMutableSet *)knownSupplementaryKinds; -(void)setKnownSupplementaryKinds:(NSMutableSet *)arg1 ; -(GKCollectionViewDataSource *)dataSourceForUpdate; -(BOOL)movedItemsInUpdateCarrySections; -(BOOL)displayClipView; -(void)setDisplayClipView:(BOOL)arg1 ; -(GKCollectionViewLayoutAttributes *)clipViewAttributes; -(unsigned long long)invalidationFlags; -(void)setInvalidationFlags:(unsigned long long)arg1 ; -(BOOL)displayingOverlay; -(void)setDisplayingOverlay:(BOOL)arg1 ; -(double)segmentedBoxY; -(void)setSegmentedBoxY:(double)arg1 ; -(BOOL)shouldLayoutRTL; -(void)setShouldLayoutRTL:(BOOL)arg1 ; -(NSSet *)visibleIndexPathsFilter; -(double)hiddenSearchBarOffset; -(void)setHiddenSearchBarOffset:(double)arg1 ; -(double)segmentedHeaderPinningOffset; -(void)setSegmentedHeaderPinningOffset:(double)arg1 ; @end
71.243816
243
0.777998
031de0b7568504c3676635efc2a07703f6cd4bd7
2,585
h
C
src/utils/bench.h
ut-osa/nightcore
f041db04bd369d9bd7a617b48892338fc11c090c
[ "Apache-2.0" ]
34
2021-01-18T17:19:11.000Z
2022-03-31T06:48:49.000Z
src/utils/bench.h
ut-osa/nightcore
f041db04bd369d9bd7a617b48892338fc11c090c
[ "Apache-2.0" ]
5
2021-04-16T05:08:10.000Z
2021-11-15T17:41:01.000Z
src/utils/bench.h
ut-osa/nightcore
f041db04bd369d9bd7a617b48892338fc11c090c
[ "Apache-2.0" ]
7
2021-01-28T02:16:25.000Z
2022-01-23T00:37:50.000Z
#pragma once #ifndef __FAAS_SRC #error utils/bench.h cannot be included outside #endif #include "base/common.h" #include "utils/perf_event.h" namespace faas { namespace bench_utils { void PinCurrentThreadToCpu(int cpu); std::unique_ptr<utils::PerfEventGroup> SetupCpuRelatedPerfEvents(int cpu = -1); void ReportCpuRelatedPerfEventValues(std::string_view header, utils::PerfEventGroup* perf_event_group, absl::Duration duration, size_t loop_count); class BenchLoop { public: typedef std::function<bool()> LoopFn; explicit BenchLoop(LoopFn fn); BenchLoop(absl::Duration max_duration, LoopFn fn); BenchLoop(size_t max_loop_count, LoopFn fn); ~BenchLoop(); absl::Duration elapsed_time() const; size_t loop_count() const; private: LoopFn fn_; absl::Duration max_duration_; size_t max_loop_count_; bool finished_; absl::Duration duration_; size_t loop_count_; void Run(); DISALLOW_COPY_AND_ASSIGN(BenchLoop); }; template<class T> class Samples { public: explicit Samples(size_t buffer_size) : buffer_size_(buffer_size), buffer_(new T[buffer_size]), count_(0), pos_(0) {} ~Samples() { delete[] buffer_; } void Add(T value) { count_++; pos_++; if (pos_ == buffer_size_) { LOG(WARNING) << "Internal buffer of Samples not big enough"; pos_ = 0; } buffer_[pos_] = value; } size_t count() const { return count_; } void ReportStatistics(std::string_view header) { size_t size = std::min(count_, buffer_size_); std::sort(buffer_, buffer_ + size); LOG(INFO) << header << ": count=" << count_ << ", " << "p50=" << buffer_[percentile(size, 0.5)] << ", " << "p70=" << buffer_[percentile(size, 0.7)] << ", " << "p90=" << buffer_[percentile(size, 0.9)] << ", " << "p99=" << buffer_[percentile(size, 0.99)] << ", " << "p99.9=" << buffer_[percentile(size, 0.999)]; } private: size_t buffer_size_; T* buffer_; size_t count_; size_t pos_; size_t percentile(size_t size, double p) { size_t idx = gsl::narrow_cast<size_t>(size * p + 0.5); if (idx < 0) { return 0; } else if (idx >= size) { return size - 1; } else { return idx; } } DISALLOW_COPY_AND_ASSIGN(Samples); }; } // namespace bench_utils } // namespace faas
25.85
81
0.579884
83cf396424159e345e7c0073a36ba979493573e5
1,620
h
C
Include/osProductVersion.h
GPUOpen-Tools/common-src-AMDTOSWrappers
80f8902c78d52435ac04f66ac190d689e5badbc1
[ "MIT" ]
2
2017-01-28T14:11:35.000Z
2018-02-01T08:22:03.000Z
Include/osProductVersion.h
GPUOpen-Tools/common-src-AMDTOSWrappers
80f8902c78d52435ac04f66ac190d689e5badbc1
[ "MIT" ]
null
null
null
Include/osProductVersion.h
GPUOpen-Tools/common-src-AMDTOSWrappers
80f8902c78d52435ac04f66ac190d689e5badbc1
[ "MIT" ]
2
2018-02-01T08:22:04.000Z
2019-11-01T23:00:21.000Z
//===================================================================== // Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved. // /// \author AMD Developer Tools Team /// \file osProductVersion.h /// //===================================================================== //------------------------------ osProductVersion.h ------------------------------ #ifndef __OSPRODUCTVERSION #define __OSPRODUCTVERSION class gtASCIIString; class gtString; // Local: #include <AMDTOSWrappers/Include/osOSWrappersDLLBuild.h> // ---------------------------------------------------------------------------------- // Struct Name: osProductVersion // General Description: Represents a product version. // Author: AMD Developer Tools Team // Creation Date: 29/6/2004 // ---------------------------------------------------------------------------------- struct OS_API osProductVersion { public: osProductVersion(); void initToZeroVersion(); bool fromString(const gtString& version); bool fromString(const gtASCIIString& version); gtString toString(bool fullNumber = true) const; bool operator>(const osProductVersion& otherVersion) const; bool operator<(const osProductVersion& otherVersion) const; bool operator==(const osProductVersion& otherVersion) const; // The product major version: int _majorVersion; // The product minor version: int _minorVersion; // The patch number (patch level): int _patchNumber; // The revision number (Source Control revision number): int _revisionNumber; }; #endif // __OSPRODUCTVERSION
29.454545
85
0.555556
64411a602a582c8dc51723a099cd7e97a60f52c9
2,210
h
C
demo/DemoApp/bitmap.h
NVIDIAGameWorks/Flow
ce313c470ad1b3d290a3f7ffbb4f8268d9722f05
[ "Zlib" ]
51
2021-02-02T22:25:21.000Z
2022-03-29T22:44:42.000Z
demo/DemoApp/bitmap.h
NVIDIAGameWorks/Flow
ce313c470ad1b3d290a3f7ffbb4f8268d9722f05
[ "Zlib" ]
null
null
null
demo/DemoApp/bitmap.h
NVIDIAGameWorks/Flow
ce313c470ad1b3d290a3f7ffbb4f8268d9722f05
[ "Zlib" ]
16
2021-01-27T01:20:54.000Z
2022-03-27T11:00:29.000Z
// This code contains NVIDIA Confidential Information and is disclosed to you // under a form of NVIDIA software license agreement provided separately to you. // // Notice // NVIDIA Corporation and its licensors retain all intellectual property and // proprietary rights in and to this software and related documentation and // any modifications thereto. Any use, reproduction, disclosure, or // distribution of this software and related documentation without an express // license agreement from NVIDIA Corporation is strictly prohibited. // // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. // // Information and code furnished is believed to be accurate and reliable. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such // information or for any infringement of patents or other rights of third parties that may // result from its use. No license is granted by implication or otherwise under any patent // or patent rights of NVIDIA Corporation. Details are subject to change without notice. // This code supersedes and replaces all information previously supplied. // NVIDIA Corporation products are not authorized for use as critical // components in life support devices or systems without express written approval of // NVIDIA Corporation. // // Copyright (c) 2014-2021 NVIDIA Corporation. All rights reserved. struct Bitmap { // Header Elements char headerField0, headerField1; unsigned int size; unsigned short reserved1; unsigned short reserved2; unsigned int offset; unsigned int headerSize; unsigned int width; unsigned int height; unsigned short colorPlanes; unsigned short bitsPerPixel; unsigned int compressionMethod; unsigned int imageSize; unsigned int hRes; unsigned int vRes; unsigned int numColors; unsigned int numImportantColors; // Internal unsigned char* data; Bitmap(); ~Bitmap(); int create(int w, int h, int bpp); int write(FILE* stream); int read(FILE* stream); };
38.77193
92
0.78552
c10b9ed75f04094040fb9951fae73f0f05d31ebc
2,832
h
C
Assets/header/BaseMessageViewModel.h
NuolanNuolan/IPAPatch-master
0f1821950c9b26d504c73681673901b8efa1e44c
[ "MIT" ]
5
2017-09-21T06:56:18.000Z
2021-01-02T22:15:23.000Z
Assets/header/BaseMessageViewModel.h
NuolanNuolan/IPAPatch-master
0f1821950c9b26d504c73681673901b8efa1e44c
[ "MIT" ]
null
null
null
Assets/header/BaseMessageViewModel.h
NuolanNuolan/IPAPatch-master
0f1821950c9b26d504c73681673901b8efa1e44c
[ "MIT" ]
5
2017-11-14T03:18:42.000Z
2019-12-30T03:09:35.000Z
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Mar 29 2017 23:22:24). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import "BaseChatViewModel.h" #import "IMessageNodeStatusExt-Protocol.h" @class CBaseContact, CMessageWrap, NSString; @interface BaseMessageViewModel : BaseChatViewModel <IMessageNodeStatusExt> { CBaseContact *m_contact; CMessageWrap *m_messageWrap; struct CGSize m_contentViewSize; long long m_orientation; NSString *m_cpKeyForChatRoomMessage; NSString *m_cpKeyForChatRoomDisplayName; _Bool m_isChatRoomMessageUnsafe; _Bool m_isChatRoomDisplayNameUnsafe; _Bool m_isSender; _Bool _isShowStatusView; _Bool _highlighted; } + (_Bool)canCreateMessageViewModelWithMessageWrap:(id)arg1; + (id)createMessageViewModelWithMessageWrap:(id)arg1 contact:(id)arg2 chatContact:(id)arg3; + (void)initMessageViewModelClassList; + (void)registerMessageViewModelClass:(Class)arg1; @property(nonatomic) _Bool highlighted; // @synthesize highlighted=_highlighted; @property(nonatomic) _Bool isShowStatusView; // @synthesize isShowStatusView=_isShowStatusView; @property(readonly, nonatomic) struct CGSize contentViewSize; // @synthesize contentViewSize=m_contentViewSize; @property(nonatomic) _Bool isChatRoomDisplayNameUnsafe; // @synthesize isChatRoomDisplayNameUnsafe=m_isChatRoomDisplayNameUnsafe; @property(nonatomic) _Bool isChatRoomMessageUnsafe; // @synthesize isChatRoomMessageUnsafe=m_isChatRoomMessageUnsafe; @property(retain, nonatomic) NSString *cpKeyForChatRoomDisplayName; // @synthesize cpKeyForChatRoomDisplayName=m_cpKeyForChatRoomDisplayName; @property(retain, nonatomic) NSString *cpKeyForChatRoomMessage; // @synthesize cpKeyForChatRoomMessage=m_cpKeyForChatRoomMessage; @property(readonly, nonatomic) _Bool isSender; // @synthesize isSender=m_isSender; @property(retain, nonatomic) CMessageWrap *messageWrap; // @synthesize messageWrap=m_messageWrap; @property(retain, nonatomic) CBaseContact *contact; // @synthesize contact=m_contact; - (void).cxx_destruct; - (void)onMessageUpdateStatus; - (id)chatRoomDisplayName; - (struct CGSize)measureContentViewSize:(struct CGSize)arg1; - (struct CGSize)measure:(struct CGSize)arg1; - (void)resetLayoutCache; - (void)updateContentViewHeight:(double)arg1; - (_Bool)isShowSendOKView; - (void)updateCrashProtectedState; - (id)additionalAccessibilityDescription; - (id)accessibilityDescription; - (void)dealloc; - (id)initWithMessageWrap:(id)arg1 contact:(id)arg2 chatContact:(id)arg3; @property(readonly, nonatomic) unsigned int msgStatus; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
43.569231
141
0.804732
c1a06472b8e6d9f202c43f2c5dfb731b35beb85b
7,360
h
C
nfc/src/DOOM/neo/idlib/geometry/Surface.h
1337programming/leviathan
ca9a31b45c25fd23f361d67136ae5ac6b98d2628
[ "Apache-2.0" ]
null
null
null
nfc/src/DOOM/neo/idlib/geometry/Surface.h
1337programming/leviathan
ca9a31b45c25fd23f361d67136ae5ac6b98d2628
[ "Apache-2.0" ]
null
null
null
nfc/src/DOOM/neo/idlib/geometry/Surface.h
1337programming/leviathan
ca9a31b45c25fd23f361d67136ae5ac6b98d2628
[ "Apache-2.0" ]
null
null
null
/* =========================================================================== Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code 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. Doom 3 BFG Edition Source Code 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 Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. =========================================================================== */ #ifndef __SURFACE_H__ #define __SURFACE_H__ /* =============================================================================== Surface base class. A surface is tesselated to a triangle mesh with each edge shared by at most two triangles. =============================================================================== */ typedef struct surfaceEdge_s { int verts[2]; // edge vertices always with ( verts[0] < verts[1] ) int tris[2]; // edge triangles } surfaceEdge_t; class idSurface { public: idSurface(); explicit idSurface( const idSurface &surf ); explicit idSurface( const idDrawVert *verts, const int numVerts, const int *indexes, const int numIndexes ); ~idSurface(); const idDrawVert & operator[]( const int index ) const; idDrawVert & operator[]( const int index ); idSurface & operator+=( const idSurface &surf ); int GetNumIndexes() const { return indexes.Num(); } const int * GetIndexes() const { return indexes.Ptr(); } int GetNumVertices() const { return verts.Num(); } const idDrawVert * GetVertices() const { return verts.Ptr(); } const int * GetEdgeIndexes() const { return edgeIndexes.Ptr(); } const surfaceEdge_t * GetEdges() const { return edges.Ptr(); } void Clear(); void TranslateSelf( const idVec3 &translation ); void RotateSelf( const idMat3 &rotation ); // splits the surface into a front and back surface, the surface itself stays unchanged // frontOnPlaneEdges and backOnPlaneEdges optionally store the indexes to the edges that lay on the split plane // returns a SIDE_? int Split( const idPlane &plane, const float epsilon, idSurface **front, idSurface **back, int *frontOnPlaneEdges = NULL, int *backOnPlaneEdges = NULL ) const; // cuts off the part at the back side of the plane, returns true if some part was at the front // if there is nothing at the front the number of points is set to zero bool ClipInPlace( const idPlane &plane, const float epsilon = ON_EPSILON, const bool keepOn = false ); // returns true if each triangle can be reached from any other triangle by a traversal bool IsConnected() const; // returns true if the surface is closed bool IsClosed() const; // returns true if the surface is a convex hull bool IsPolytope( const float epsilon = 0.1f ) const; float PlaneDistance( const idPlane &plane ) const; int PlaneSide( const idPlane &plane, const float epsilon = ON_EPSILON ) const; // returns true if the line intersects one of the surface triangles bool LineIntersection( const idVec3 &start, const idVec3 &end, bool backFaceCull = false ) const; // intersection point is start + dir * scale bool RayIntersection( const idVec3 &start, const idVec3 &dir, float &scale, bool backFaceCull = false ) const; protected: idList<idDrawVert, TAG_IDLIB_LIST_SURFACE> verts; // vertices idList<int, TAG_IDLIB_LIST_SURFACE> indexes; // 3 references to vertices for each triangle idList<surfaceEdge_t, TAG_IDLIB_LIST_SURFACE> edges; // edges idList<int, TAG_IDLIB_LIST_SURFACE> edgeIndexes; // 3 references to edges for each triangle, may be negative for reversed edge protected: void GenerateEdgeIndexes(); int FindEdge( int v1, int v2 ) const; }; /* ==================== idSurface::idSurface ==================== */ ID_INLINE idSurface::idSurface() { } /* ================= idSurface::idSurface ================= */ ID_INLINE idSurface::idSurface( const idDrawVert *verts, const int numVerts, const int *indexes, const int numIndexes ) { assert( verts != NULL && indexes != NULL && numVerts > 0 && numIndexes > 0 ); this->verts.SetNum( numVerts ); memcpy( this->verts.Ptr(), verts, numVerts * sizeof( verts[0] ) ); this->indexes.SetNum( numIndexes ); memcpy( this->indexes.Ptr(), indexes, numIndexes * sizeof( indexes[0] ) ); GenerateEdgeIndexes(); } /* ==================== idSurface::idSurface ==================== */ ID_INLINE idSurface::idSurface( const idSurface &surf ) { this->verts = surf.verts; this->indexes = surf.indexes; this->edges = surf.edges; this->edgeIndexes = surf.edgeIndexes; } /* ==================== idSurface::~idSurface ==================== */ ID_INLINE idSurface::~idSurface() { } /* ================= idSurface::operator[] ================= */ ID_INLINE const idDrawVert &idSurface::operator[]( const int index ) const { return verts[ index ]; }; /* ================= idSurface::operator[] ================= */ ID_INLINE idDrawVert &idSurface::operator[]( const int index ) { return verts[ index ]; }; /* ================= idSurface::operator+= ================= */ ID_INLINE idSurface &idSurface::operator+=( const idSurface &surf ) { int i, m, n; n = verts.Num(); m = indexes.Num(); verts.Append( surf.verts ); // merge verts where possible ? indexes.Append( surf.indexes ); for ( i = m; i < indexes.Num(); i++ ) { indexes[i] += n; } GenerateEdgeIndexes(); return *this; } /* ================= idSurface::Clear ================= */ ID_INLINE void idSurface::Clear() { verts.Clear(); indexes.Clear(); edges.Clear(); edgeIndexes.Clear(); } /* ================= idSurface::TranslateSelf ================= */ ID_INLINE void idSurface::TranslateSelf( const idVec3 &translation ) { for ( int i = 0; i < verts.Num(); i++ ) { verts[i].xyz += translation; } } /* ================= idSurface::RotateSelf ================= */ ID_INLINE void idSurface::RotateSelf( const idMat3 &rotation ) { for ( int i = 0; i < verts.Num(); i++ ) { verts[i].xyz *= rotation; verts[i].SetNormal( verts[i].GetNormal() * rotation ); verts[i].SetTangent( verts[i].GetTangent() * rotation ); } } #endif /* !__SURFACE_H__ */
33.454545
366
0.642391
aff7b7c423a69f555bc038e4250c6faca5f78d49
4,031
h
C
modules/basegl/include/modules/basegl/processors/embeddedvolumeslice.h
NissimHadar/inviwo
35777ba90439d7e79c884f12df7dfef4ada4861d
[ "BSD-2-Clause" ]
null
null
null
modules/basegl/include/modules/basegl/processors/embeddedvolumeslice.h
NissimHadar/inviwo
35777ba90439d7e79c884f12df7dfef4ada4861d
[ "BSD-2-Clause" ]
null
null
null
modules/basegl/include/modules/basegl/processors/embeddedvolumeslice.h
NissimHadar/inviwo
35777ba90439d7e79c884f12df7dfef4ada4861d
[ "BSD-2-Clause" ]
null
null
null
/********************************************************************************* * * Inviwo - Interactive Visualization Workshop * * Copyright (c) 2019 Inviwo Foundation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. * *********************************************************************************/ #pragma once #include <modules/basegl/baseglmoduledefine.h> #include <inviwo/core/common/inviwo.h> #include <inviwo/core/datastructures/geometry/typedmesh.h> #include <inviwo/core/datastructures/geometry/geometrytype.h> #include <inviwo/core/ports/imageport.h> #include <inviwo/core/ports/volumeport.h> #include <inviwo/core/interaction/cameratrackball.h> #include <inviwo/core/processors/processor.h> #include <inviwo/core/properties/ordinalproperty.h> #include <inviwo/core/properties/transferfunctionproperty.h> #include <inviwo/core/properties/cameraproperty.h> #include <modules/opengl/shader/shader.h> #include <modules/opengl/inviwoopengl.h> #include <inviwo/core/interaction/pickingmapper.h> namespace inviwo { class Mesh; /** \docpage{org.inviwo.EmbeddedVolumeSlice, Embedded Volume Slice} * ![](org.inviwo.EmbeddedVolumeSlice.png?classIdentifier=org.inviwo.EmbeddedVolumeSlice) * * Render an arbitrary slice of a volume in place, i.e. the slice will be oriented as it would * have been in the volume. * * ### Inports * * __volume__ The input volume * * __background__ Optional background image * ### Outports * * __outport__ Rendered slice * * ### Properties * * __Plane Normal__ Defines the normal of the plane in texture/data space [0,1] * * __Plane Position__ Defines a point in the plane in texture/data space [0,1] * * __Transfer Function__ Defines the transfer function for mapping voxel values to color and * opacity * * __Camera__ Camera used for rendering * * __Trackball__ Trackball for handling interaction */ class IVW_MODULE_BASEGL_API EmbeddedVolumeSlice : public Processor { public: EmbeddedVolumeSlice(); virtual ~EmbeddedVolumeSlice() = default; virtual const ProcessorInfo getProcessorInfo() const override; static const ProcessorInfo processorInfo_; virtual void initializeResources() override; protected: virtual void process() override; void planeSettingsChanged(); void handlePicking(PickingEvent* p); private: VolumeInport inport_; ImageInport backgroundPort_; ImageOutport outport_; Shader shader_; FloatVec3Property planeNormal_; FloatVec3Property planePosition_; TransferFunctionProperty transferFunction_; CameraProperty camera_; CameraTrackball trackball_; TypedMesh<buffertraits::PositionsBuffer> embeddedMesh_; PickingMapper picking_; }; } // namespace inviwo
38.390476
96
0.732821
8879ecf111420bf3c77b952ac11d689cacb20003
1,063
h
C
DemoPatterns.h
mikelduke/rocketship-lamp-esp8266
32d0d70c9f89dd57ae9bdd36f2b438aaf786020e
[ "Apache-2.0" ]
2
2019-05-05T08:55:06.000Z
2019-09-09T16:01:23.000Z
DemoPatterns.h
mikelduke/rocketship-lamp-esp8266
32d0d70c9f89dd57ae9bdd36f2b438aaf786020e
[ "Apache-2.0" ]
null
null
null
DemoPatterns.h
mikelduke/rocketship-lamp-esp8266
32d0d70c9f89dd57ae9bdd36f2b438aaf786020e
[ "Apache-2.0" ]
null
null
null
#ifndef _DEMO_PATTERNS_H #define _DEMO_PATTERNS_H void rainbow() { static uint8_t hue = 0; fill_rainbow( leds, NUM_LEDS, hue++, 7); FastLED.show(); delay(DELAY / 2); } void addGlitter( fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { leds[ random16(NUM_LEDS) ] += CRGB::White; } } void rainbowWithGlitter() { static uint8_t hue = 0; fill_rainbow( leds, NUM_LEDS, hue++, 7); addGlitter(80); FastLED.show(); delay(DELAY / 2); } void confetti() { // random colored speckles that blink in and fade smoothly static uint8_t hue = 0; fadeToBlackBy( leds, NUM_LEDS, 10); int pos = random16(NUM_LEDS); leds[pos] += CHSV( hue, 200, 255); hue += random8(64); FastLED.show(); delay(DELAY / 2); } void juggle() { // eight colored dots, weaving in and out of sync with each other fadeToBlackBy( leds, NUM_LEDS, 20); byte dothue = 0; for( int i = 0; i < 8; i++) { leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); dothue += 32; } FastLED.show(); delay(DELAY / 2); } #endif
20.056604
68
0.634995
29cd22bd2a7dccaac61857b41f3e0d7c536f2869
617
h
C
data/train/cpp/29cd22bd2a7dccaac61857b41f3e0d7c536f2869ChunkConnectEvent.h
harshp8l/deep-learning-lang-detection
2a54293181c1c2b1a2b840ddee4d4d80177efb33
[ "MIT" ]
84
2017-10-25T15:49:21.000Z
2021-11-28T21:25:54.000Z
data/train/cpp/29cd22bd2a7dccaac61857b41f3e0d7c536f2869ChunkConnectEvent.h
vassalos/deep-learning-lang-detection
cbb00b3e81bed3a64553f9c6aa6138b2511e544e
[ "MIT" ]
5
2018-03-29T11:50:46.000Z
2021-04-26T13:33:18.000Z
data/train/cpp/29cd22bd2a7dccaac61857b41f3e0d7c536f2869ChunkConnectEvent.h
vassalos/deep-learning-lang-detection
cbb00b3e81bed3a64553f9c6aa6138b2511e544e
[ "MIT" ]
24
2017-11-22T08:31:00.000Z
2022-03-27T01:22:31.000Z
#ifndef CHUNKCONNECTEVENT_H #define CHUNKCONNECTEVENT_H #include "ChunkEvent.h" const int EVENTID_CHUNKCONNECT = 4; class ChunkConnectEvent : public ChunkEvent { public: /*! What we can be our new relation to the chunk */ enum ChunkConnection { ChunkConnection_Connect, ChunkConnection_Disconnect }; ChunkConnectEvent(const ChunkPosition& position, ChunkConnection connectionType); inline virtual int id() {return EVENTID_CHUNKCONNECT;} virtual void perform(Server& server) const; virtual QByteArray serialize() const; protected: ChunkConnection m_connectionType; }; #endif // CHUNKCONNECTEVENT_H
21.275862
82
0.794165
29f839cdb48649dc3278d2c8ffe22fd19145186e
11,155
h
C
linux-5.2/drivers/media/platform/s3c-camif/camif-regs.h
TakuKitamura/expirefile-syscall
2b91994a7fe984e146d090fc7d80fa1a698025aa
[ "MIT" ]
1
2022-01-30T20:01:25.000Z
2022-01-30T20:01:25.000Z
linux-5.2/drivers/media/platform/s3c-camif/camif-regs.h
TakuKitamura/expirefile-syscall
2b91994a7fe984e146d090fc7d80fa1a698025aa
[ "MIT" ]
null
null
null
linux-5.2/drivers/media/platform/s3c-camif/camif-regs.h
TakuKitamura/expirefile-syscall
2b91994a7fe984e146d090fc7d80fa1a698025aa
[ "MIT" ]
1
2019-10-11T07:35:58.000Z
2019-10-11T07:35:58.000Z
/* SPDX-License-Identifier: GPL-2.0-only */ /* * Register definition file for s3c24xx/s3c64xx SoC CAMIF driver * * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com> * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com> */ #ifndef CAMIF_REGS_H_ #define CAMIF_REGS_H_ #include "camif-core.h" #include <media/drv-intf/s3c_camif.h> /* * The id argument indicates the processing path: * id = 0 - codec (FIMC C), 1 - preview (FIMC P). */ /* Camera input format */ #define S3C_CAMIF_REG_CISRCFMT 0x00 #define CISRCFMT_ITU601_8BIT (1 << 31) #define CISRCFMT_ITU656_8BIT (0 << 31) #define CISRCFMT_ORDER422_YCBYCR (0 << 14) #define CISRCFMT_ORDER422_YCRYCB (1 << 14) #define CISRCFMT_ORDER422_CBYCRY (2 << 14) #define CISRCFMT_ORDER422_CRYCBY (3 << 14) #define CISRCFMT_ORDER422_MASK (3 << 14) #define CISRCFMT_SIZE_CAM_MASK (0x1fff << 16 | 0x1fff) /* Window offset */ #define S3C_CAMIF_REG_CIWDOFST 0x04 #define CIWDOFST_WINOFSEN (1 << 31) #define CIWDOFST_CLROVCOFIY (1 << 30) #define CIWDOFST_CLROVRLB_PR (1 << 28) /* #define CIWDOFST_CLROVPRFIY (1 << 27) */ #define CIWDOFST_CLROVCOFICB (1 << 15) #define CIWDOFST_CLROVCOFICR (1 << 14) #define CIWDOFST_CLROVPRFICB (1 << 13) #define CIWDOFST_CLROVPRFICR (1 << 12) #define CIWDOFST_OFST_MASK (0x7ff << 16 | 0x7ff) /* Window offset 2 */ #define S3C_CAMIF_REG_CIWDOFST2 0x14 #define CIWDOFST2_OFST2_MASK (0xfff << 16 | 0xfff) /* Global control */ #define S3C_CAMIF_REG_CIGCTRL 0x08 #define CIGCTRL_SWRST (1 << 31) #define CIGCTRL_CAMRST (1 << 30) #define CIGCTRL_TESTPATTERN_NORMAL (0 << 27) #define CIGCTRL_TESTPATTERN_COLOR_BAR (1 << 27) #define CIGCTRL_TESTPATTERN_HOR_INC (2 << 27) #define CIGCTRL_TESTPATTERN_VER_INC (3 << 27) #define CIGCTRL_TESTPATTERN_MASK (3 << 27) #define CIGCTRL_INVPOLPCLK (1 << 26) #define CIGCTRL_INVPOLVSYNC (1 << 25) #define CIGCTRL_INVPOLHREF (1 << 24) #define CIGCTRL_IRQ_OVFEN (1 << 22) #define CIGCTRL_HREF_MASK (1 << 21) #define CIGCTRL_IRQ_LEVEL (1 << 20) /* IRQ_CLR_C, IRQ_CLR_P */ #define CIGCTRL_IRQ_CLR(id) (1 << (19 - (id))) #define CIGCTRL_FIELDMODE (1 << 2) #define CIGCTRL_INVPOLFIELD (1 << 1) #define CIGCTRL_CAM_INTERLACE (1 << 0) /* Y DMA output frame start address. n = 0..3. */ #define S3C_CAMIF_REG_CIYSA(id, n) (0x18 + (id) * 0x54 + (n) * 4) /* Cb plane output DMA start address. n = 0..3. Only codec path. */ #define S3C_CAMIF_REG_CICBSA(id, n) (0x28 + (id) * 0x54 + (n) * 4) /* Cr plane output DMA start address. n = 0..3. Only codec path. */ #define S3C_CAMIF_REG_CICRSA(id, n) (0x38 + (id) * 0x54 + (n) * 4) /* CICOTRGFMT, CIPRTRGFMT - Target format */ #define S3C_CAMIF_REG_CITRGFMT(id, _offs) (0x48 + (id) * (0x34 + (_offs))) #define CITRGFMT_IN422 (1 << 31) /* only for s3c24xx */ #define CITRGFMT_OUT422 (1 << 30) /* only for s3c24xx */ #define CITRGFMT_OUTFORMAT_YCBCR420 (0 << 29) /* only for s3c6410 */ #define CITRGFMT_OUTFORMAT_YCBCR422 (1 << 29) /* only for s3c6410 */ #define CITRGFMT_OUTFORMAT_YCBCR422I (2 << 29) /* only for s3c6410 */ #define CITRGFMT_OUTFORMAT_RGB (3 << 29) /* only for s3c6410 */ #define CITRGFMT_OUTFORMAT_MASK (3 << 29) /* only for s3c6410 */ #define CITRGFMT_TARGETHSIZE(x) ((x) << 16) #define CITRGFMT_FLIP_NORMAL (0 << 14) #define CITRGFMT_FLIP_X_MIRROR (1 << 14) #define CITRGFMT_FLIP_Y_MIRROR (2 << 14) #define CITRGFMT_FLIP_180 (3 << 14) #define CITRGFMT_FLIP_MASK (3 << 14) /* Preview path only */ #define CITRGFMT_ROT90_PR (1 << 13) #define CITRGFMT_TARGETVSIZE(x) ((x) << 0) #define CITRGFMT_TARGETSIZE_MASK ((0x1fff << 16) | 0x1fff) /* CICOCTRL, CIPRCTRL. Output DMA control. */ #define S3C_CAMIF_REG_CICTRL(id, _offs) (0x4c + (id) * (0x34 + (_offs))) #define CICTRL_BURST_MASK (0xfffff << 4) /* xBURSTn - 5-bits width */ #define CICTRL_YBURST1(x) ((x) << 19) #define CICTRL_YBURST2(x) ((x) << 14) #define CICTRL_RGBBURST1(x) ((x) << 19) #define CICTRL_RGBBURST2(x) ((x) << 14) #define CICTRL_CBURST1(x) ((x) << 9) #define CICTRL_CBURST2(x) ((x) << 4) #define CICTRL_LASTIRQ_ENABLE (1 << 2) #define CICTRL_ORDER422_MASK (3 << 0) /* CICOSCPRERATIO, CIPRSCPRERATIO. Pre-scaler control 1. */ #define S3C_CAMIF_REG_CISCPRERATIO(id, _offs) (0x50 + (id) * (0x34 + (_offs))) /* CICOSCPREDST, CIPRSCPREDST. Pre-scaler control 2. */ #define S3C_CAMIF_REG_CISCPREDST(id, _offs) (0x54 + (id) * (0x34 + (_offs))) /* CICOSCCTRL, CIPRSCCTRL. Main scaler control. */ #define S3C_CAMIF_REG_CISCCTRL(id, _offs) (0x58 + (id) * (0x34 + (_offs))) #define CISCCTRL_SCALERBYPASS (1 << 31) /* s3c244x preview path only, s3c64xx both */ #define CIPRSCCTRL_SAMPLE (1 << 31) /* 0 - 16-bit RGB, 1 - 24-bit RGB */ #define CIPRSCCTRL_RGB_FORMAT_24BIT (1 << 30) /* only for s3c244x */ #define CIPRSCCTRL_SCALEUP_H (1 << 29) /* only for s3c244x */ #define CIPRSCCTRL_SCALEUP_V (1 << 28) /* only for s3c244x */ /* s3c64xx */ #define CISCCTRL_SCALEUP_H (1 << 30) #define CISCCTRL_SCALEUP_V (1 << 29) #define CISCCTRL_SCALEUP_MASK (0x3 << 29) #define CISCCTRL_CSCR2Y_WIDE (1 << 28) #define CISCCTRL_CSCY2R_WIDE (1 << 27) #define CISCCTRL_LCDPATHEN_FIFO (1 << 26) #define CISCCTRL_INTERLACE (1 << 25) #define CISCCTRL_SCALERSTART (1 << 15) #define CISCCTRL_INRGB_FMT_RGB565 (0 << 13) #define CISCCTRL_INRGB_FMT_RGB666 (1 << 13) #define CISCCTRL_INRGB_FMT_RGB888 (2 << 13) #define CISCCTRL_INRGB_FMT_MASK (3 << 13) #define CISCCTRL_OUTRGB_FMT_RGB565 (0 << 11) #define CISCCTRL_OUTRGB_FMT_RGB666 (1 << 11) #define CISCCTRL_OUTRGB_FMT_RGB888 (2 << 11) #define CISCCTRL_OUTRGB_FMT_MASK (3 << 11) #define CISCCTRL_EXTRGB_EXTENSION (1 << 10) #define CISCCTRL_ONE2ONE (1 << 9) #define CISCCTRL_MAIN_RATIO_MASK (0x1ff << 16 | 0x1ff) /* CICOTAREA, CIPRTAREA. Target area for DMA (Hsize x Vsize). */ #define S3C_CAMIF_REG_CITAREA(id, _offs) (0x5c + (id) * (0x34 + (_offs))) #define CITAREA_MASK 0xfffffff /* Codec (id = 0) or preview (id = 1) path status. */ #define S3C_CAMIF_REG_CISTATUS(id, _offs) (0x64 + (id) * (0x34 + (_offs))) #define CISTATUS_OVFIY_STATUS (1 << 31) #define CISTATUS_OVFICB_STATUS (1 << 30) #define CISTATUS_OVFICR_STATUS (1 << 29) #define CISTATUS_OVF_MASK (0x7 << 29) #define CIPRSTATUS_OVF_MASK (0x3 << 30) #define CISTATUS_VSYNC_STATUS (1 << 28) #define CISTATUS_FRAMECNT_MASK (3 << 26) #define CISTATUS_FRAMECNT(__reg) (((__reg) >> 26) & 0x3) #define CISTATUS_WINOFSTEN_STATUS (1 << 25) #define CISTATUS_IMGCPTEN_STATUS (1 << 22) #define CISTATUS_IMGCPTENSC_STATUS (1 << 21) #define CISTATUS_VSYNC_A_STATUS (1 << 20) #define CISTATUS_FRAMEEND_STATUS (1 << 19) /* 17 on s3c64xx */ /* Image capture enable */ #define S3C_CAMIF_REG_CIIMGCPT(_offs) (0xa0 + (_offs)) #define CIIMGCPT_IMGCPTEN (1 << 31) #define CIIMGCPT_IMGCPTEN_SC(id) (1 << (30 - (id))) /* Frame control: 1 - one-shot, 0 - free run */ #define CIIMGCPT_CPT_FREN_ENABLE(id) (1 << (25 - (id))) #define CIIMGCPT_CPT_FRMOD_ENABLE (0 << 18) #define CIIMGCPT_CPT_FRMOD_CNT (1 << 18) /* Capture sequence */ #define S3C_CAMIF_REG_CICPTSEQ 0xc4 /* Image effects */ #define S3C_CAMIF_REG_CIIMGEFF(_offs) (0xb0 + (_offs)) #define CIIMGEFF_IE_ENABLE(id) (1 << (30 + (id))) #define CIIMGEFF_IE_ENABLE_MASK (3 << 30) /* Image effect: 1 - after scaler, 0 - before scaler */ #define CIIMGEFF_IE_AFTER_SC (1 << 29) #define CIIMGEFF_FIN_MASK (7 << 26) #define CIIMGEFF_FIN_BYPASS (0 << 26) #define CIIMGEFF_FIN_ARBITRARY (1 << 26) #define CIIMGEFF_FIN_NEGATIVE (2 << 26) #define CIIMGEFF_FIN_ARTFREEZE (3 << 26) #define CIIMGEFF_FIN_EMBOSSING (4 << 26) #define CIIMGEFF_FIN_SILHOUETTE (5 << 26) #define CIIMGEFF_PAT_CBCR_MASK ((0xff << 13) | 0xff) #define CIIMGEFF_PAT_CB(x) ((x) << 13) #define CIIMGEFF_PAT_CR(x) (x) /* MSCOY0SA, MSPRY0SA. Y/Cb/Cr frame start address for input DMA. */ #define S3C_CAMIF_REG_MSY0SA(id) (0xd4 + ((id) * 0x2c)) #define S3C_CAMIF_REG_MSCB0SA(id) (0xd8 + ((id) * 0x2c)) #define S3C_CAMIF_REG_MSCR0SA(id) (0xdc + ((id) * 0x2c)) /* MSCOY0END, MSCOY0END. Y/Cb/Cr frame end address for input DMA. */ #define S3C_CAMIF_REG_MSY0END(id) (0xe0 + ((id) * 0x2c)) #define S3C_CAMIF_REG_MSCB0END(id) (0xe4 + ((id) * 0x2c)) #define S3C_CAMIF_REG_MSCR0END(id) (0xe8 + ((id) * 0x2c)) /* MSPRYOFF, MSPRYOFF. Y/Cb/Cr offset. n: 0 - codec, 1 - preview. */ #define S3C_CAMIF_REG_MSYOFF(id) (0x118 + ((id) * 0x2c)) #define S3C_CAMIF_REG_MSCBOFF(id) (0x11c + ((id) * 0x2c)) #define S3C_CAMIF_REG_MSCROFF(id) (0x120 + ((id) * 0x2c)) /* Real input DMA data size. n = 0 - codec, 1 - preview. */ #define S3C_CAMIF_REG_MSWIDTH(id) (0xf8 + (id) * 0x2c) #define AUTOLOAD_ENABLE (1 << 31) #define ADDR_CH_DIS (1 << 30) #define MSHEIGHT(x) (((x) & 0x3ff) << 16) #define MSWIDTH(x) ((x) & 0x3ff) /* Input DMA control. n = 0 - codec, 1 - preview */ #define S3C_CAMIF_REG_MSCTRL(id) (0xfc + (id) * 0x2c) #define MSCTRL_ORDER422_M_YCBYCR (0 << 4) #define MSCTRL_ORDER422_M_YCRYCB (1 << 4) #define MSCTRL_ORDER422_M_CBYCRY (2 << 4) #define MSCTRL_ORDER422_M_CRYCBY (3 << 4) /* 0 - camera, 1 - DMA */ #define MSCTRL_SEL_DMA_CAM (1 << 3) #define MSCTRL_INFORMAT_M_YCBCR420 (0 << 1) #define MSCTRL_INFORMAT_M_YCBCR422 (1 << 1) #define MSCTRL_INFORMAT_M_YCBCR422I (2 << 1) #define MSCTRL_INFORMAT_M_RGB (3 << 1) #define MSCTRL_ENVID_M (1 << 0) /* CICOSCOSY, CIPRSCOSY. Scan line Y/Cb/Cr offset. */ #define S3C_CAMIF_REG_CISSY(id) (0x12c + (id) * 0x0c) #define S3C_CAMIF_REG_CISSCB(id) (0x130 + (id) * 0x0c) #define S3C_CAMIF_REG_CISSCR(id) (0x134 + (id) * 0x0c) #define S3C_CISS_OFFS_INITIAL(x) ((x) << 16) #define S3C_CISS_OFFS_LINE(x) ((x) << 0) /* ------------------------------------------------------------------ */ void camif_hw_reset(struct camif_dev *camif); void camif_hw_clear_pending_irq(struct camif_vp *vp); void camif_hw_clear_fifo_overflow(struct camif_vp *vp); void camif_hw_set_lastirq(struct camif_vp *vp, int enable); void camif_hw_set_input_path(struct camif_vp *vp); void camif_hw_enable_scaler(struct camif_vp *vp, bool on); void camif_hw_enable_capture(struct camif_vp *vp); void camif_hw_disable_capture(struct camif_vp *vp); void camif_hw_set_camera_bus(struct camif_dev *camif); void camif_hw_set_source_format(struct camif_dev *camif); void camif_hw_set_camera_crop(struct camif_dev *camif); void camif_hw_set_scaler(struct camif_vp *vp); void camif_hw_set_flip(struct camif_vp *vp); void camif_hw_set_output_dma(struct camif_vp *vp); void camif_hw_set_target_format(struct camif_vp *vp); void camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern); void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect, unsigned int cr, unsigned int cb); void camif_hw_set_output_addr(struct camif_vp *vp, struct camif_addr *paddr, int index); void camif_hw_dump_regs(struct camif_dev *camif, const char *label); static inline u32 camif_hw_get_status(struct camif_vp *vp) { return readl(vp->camif->io_base + S3C_CAMIF_REG_CISTATUS(vp->id, vp->offset)); } #endif /* CAMIF_REGS_H_ */
41.779026
78
0.69117
c612716b30e56a5533a27b6a198a19cfe424a240
10,491
h
C
arch/x86_64/include/intel64/irq.h
ErikkEnglund/incubator-nuttx
88d59bac405b4f9f0efe1a91def2909579a46600
[ "Apache-2.0" ]
1
2021-02-05T03:21:54.000Z
2021-02-05T03:21:54.000Z
arch/x86_64/include/intel64/irq.h
ErikkEnglund/incubator-nuttx
88d59bac405b4f9f0efe1a91def2909579a46600
[ "Apache-2.0" ]
1
2020-03-21T16:25:54.000Z
2020-03-24T09:41:03.000Z
arch/x86_64/include/intel64/irq.h
ErikkEnglund/incubator-nuttx
88d59bac405b4f9f0efe1a91def2909579a46600
[ "Apache-2.0" ]
null
null
null
/**************************************************************************** * arch/x86_64/include/intel64/irq.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ /* This file should never be included directed but, rather, only indirectly * through nuttx/irq.h */ #ifndef __ARCH_X86_64_INCLUDE_INTEL64_IRQ_H #define __ARCH_X86_64_INCLUDE_INTEL64_IRQ_H /**************************************************************************** * Included Files ****************************************************************************/ #ifndef __ASSEMBLY__ # include <stdint.h> # include <stdbool.h> # include <arch/arch.h> # include <semaphore.h> # include <time.h> # include <debug.h> # include <nuttx/config.h> #endif /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* ISR and IRQ numbers */ #define ISR0 0 /* Division by zero exception */ #define ISR1 1 /* Debug exception */ #define ISR2 2 /* Non maskable interrupt */ #define ISR3 3 /* Breakpoint exception */ #define ISR4 4 /* 'Into detected overflow' */ #define ISR5 5 /* Out of bounds exception */ #define ISR6 6 /* Invalid opcode exception */ #define ISR7 7 /* No coprocessor exception */ #define ISR8 8 /* Double fault (pushes an error code) */ #define ISR9 9 /* Coprocessor segment overrun */ #define ISR10 10 /* Bad TSS (pushes an error code) */ #define ISR11 11 /* Segment not present (pushes an error code) */ #define ISR12 12 /* Stack fault (pushes an error code) */ #define ISR13 13 /* General protection fault (pushes an error code) */ #define ISR14 14 /* Page fault (pushes an error code) */ #define ISR15 15 /* Unknown interrupt exception */ #define ISR16 16 /* Coprocessor fault */ #define ISR17 17 /* Alignment check exception */ #define ISR18 18 /* Machine check exception */ #define ISR19 19 /* SIMD Float-Point Exception*/ #define ISR20 20 /* Virtualization Exception */ #define ISR21 21 /* Reserved */ #define ISR22 22 /* Reserved */ #define ISR23 23 /* Reserved */ #define ISR24 24 /* Reserved */ #define ISR25 25 /* Reserved */ #define ISR26 26 /* Reserved */ #define ISR27 27 /* Reserved */ #define ISR28 28 /* Reserved */ #define ISR29 29 /* Reserved */ #define ISR30 30 /* Security Exception */ #define ISR31 31 /* Reserved */ #define IRQ0 32 /* System timer (cannot be changed) */ #define IRQ1 33 /* Keyboard controller (cannot be changed) */ #define IRQ2 34 /* Cascaded signals from IRQs 8~15 */ #define IRQ3 35 /* Serial port controller for COM2/4 */ #define IRQ4 36 /* serial port controller for COM1/3 */ #define IRQ5 37 /* LPT port 2 or sound card */ #define IRQ6 38 /* Floppy disk controller */ #define IRQ7 39 /* LPT port 1 or sound card */ #define IRQ8 40 /* Real time clock (RTC) */ #define IRQ9 41 /* Open interrupt/available or SCSI host adapter */ #define IRQ10 42 /* Open interrupt/available or SCSI or NIC */ #define IRQ11 43 /* Open interrupt/available or SCSI or NIC */ #define IRQ12 44 /* Mouse on PS/2 connector */ #define IRQ13 45 /* Math coprocessor */ #define IRQ14 46 /* Primary ATA channel */ #define IRQ15 47 /* Secondary ATA channel */ #define IRQ_ERROR 51 /* APIC Error */ #define IRQ_SPURIOUS 0xff /* Spurious Interrupts */ #define NR_IRQS 48 /* Common register save structure created by up_saveusercontext() and by * ISR/IRQ interrupt processing. */ #define XCPTCONTEXT_XMM_AREA_SIZE 512 #define XMMAREA_OFFSET XCPTCONTEXT_XMM_AREA_SIZE / 8 /* Data segments */ #define REG_ALIGN (0 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_FS (1 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_GS (2 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_ES (3 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_DS (4 + XMMAREA_OFFSET) /* Data segment selector */ /* Remaining regs */ #define REG_RAX (5 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_RBX (6 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_RBP (7 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R10 (8 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R11 (9 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R12 (10 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R13 (11 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R14 (12 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R15 (13 + XMMAREA_OFFSET) /* " " "" " " */ /* ABI calling convention */ #define REG_R9 (14 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_R8 (15 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_RCX (16 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_RDX (17 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_RSI (18 + XMMAREA_OFFSET) /* " " "" " " */ #define REG_RDI (19 + XMMAREA_OFFSET) /* " " "" " " */ /* IRQ saved */ #define REG_ERRCODE (20 + XMMAREA_OFFSET) /* Error code */ #define REG_RIP (21 + XMMAREA_OFFSET) /* Pushed by process on interrupt processing */ #define REG_CS (22 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_RFLAGS (23 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_RSP (24 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ #define REG_SS (25 + XMMAREA_OFFSET) /* " " "" " " "" " " " " */ /* NOTE 2: This is not really state data. Rather, this is just a convenient * way to pass parameters from the interrupt handler to C code. */ #define XCPTCONTEXT_REGS (26 + XCPTCONTEXT_XMM_AREA_SIZE / 8) #define XCPTCONTEXT_SIZE (8 * XCPTCONTEXT_REGS + XCPTCONTEXT_XMM_AREA_SIZE) /**************************************************************************** * Public Types ****************************************************************************/ #ifndef __ASSEMBLY__ enum ioapic_trigger_mode { TRIGGER_RISING_EDGE = 0, TRIGGER_FALLING_EDGE = (1 << 13), TRIGGER_LEVEL_ACTIVE_HIGH = 1 << 15, TRIGGER_LEVEL_ACTIVE_LOW = (1 << 15) | (1 << 13), }; /* This struct defines the way the registers are stored */ struct xcptcontext { /* The following function pointer is non-zero if there are pending signals * to be processed. */ #ifndef CONFIG_DISABLE_SIGNALS void *sigdeliver; /* Actual type is sig_deliver_t */ /* These are saved copies of instruction pointer and EFLAGS used during * signal processing. */ uint64_t saved_rip; uint64_t saved_rflags; uint64_t saved_rsp; #endif /* Register save area */ uint64_t regs[XCPTCONTEXT_REGS] __attribute__((aligned (16))); }; #endif /**************************************************************************** * Inline functions ****************************************************************************/ #ifndef __ASSEMBLY__ /* Name: up_irq_save, up_irq_restore, and friends. * * NOTE: This function should never be called from application code and, * as a general rule unless you really know what you are doing, this * function should not be called directly from operation system code either: * Typically, the wrapper functions, enter_critical_section() and * leave_critical section(), are probably what you really want. */ /* Get the current FLAGS register contents */ static inline irqstate_t irqflags() { irqstate_t flags; asm volatile( "\tpushfq\n" "\tpopq %0\n" : "=rm" (flags) : : "memory"); return flags; } /* Get a sample of the FLAGS register, determine if interrupts are disabled. * If the X86_FLAGS_IF is cleared by cli, then interrupts are disabled. If * if the X86_FLAGS_IF is set by sti, then interrupts are enable. */ static inline bool up_irq_disabled(irqstate_t flags) { return ((flags & X86_64_RFLAGS_IF) == 0); } static inline bool up_irq_enabled(irqstate_t flags) { return ((flags & X86_64_RFLAGS_IF) != 0); } /* Disable interrupts unconditionally */ static inline void up_irq_disable(void) { asm volatile("cli": : :"memory"); } /* Enable interrupts unconditionally */ static inline void up_irq_enable(void) { asm volatile("sti": : :"memory"); } /* Disable interrupts, but return previous interrupt state */ static inline irqstate_t up_irq_save(void) { irqstate_t flags = irqflags(); up_irq_disable(); return flags; } /* Conditionally disable interrupts */ static inline void up_irq_restore(irqstate_t flags) { if (up_irq_enabled(flags)) { up_irq_enable(); } } static inline unsigned int up_apic_cpu_id(void) { return read_msr(MSR_X2APIC_ID); } /**************************************************************************** * Public Data ****************************************************************************/ /**************************************************************************** * Public Function Prototypes ****************************************************************************/ void up_ioapic_pin_set_vector(unsigned int pin, enum ioapic_trigger_mode trigger_mode, unsigned int vector); #ifdef __cplusplus #define EXTERN extern "C" extern "C" { #else #define EXTERN extern #endif #undef EXTERN #ifdef __cplusplus } #endif #endif /* __ASSEMBLY__ */ #endif /* __ARCH_X86_INCLUDE_I486_IRQ_H */
34.396721
95
0.570108
635e700d6bd4432ca83daf732354a57fca40251f
750
h
C
PrivateFrameworks/Safari/RemoteNotificationAgentProxyPrivate.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/Safari/RemoteNotificationAgentProxyPrivate.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/Safari/RemoteNotificationAgentProxyPrivate.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" #import "SafariNotificationAgentProxy.h" __attribute__((visibility("hidden"))) @interface RemoteNotificationAgentProxyPrivate : NSObject <SafariNotificationAgentProxy> { } - (void)agentDidUnregisterForRemoteNotifications:(unsigned long long)arg1 disallowedDomains:(id)arg2; - (void)agentDidRegisterForRemoteNotifications:(unsigned long long)arg1 allowedDomains:(id)arg2 deviceToken:(id)arg3; - (void)agentDidVerifyRemoteNotificationProviderRequest:(unsigned long long)arg1 withResult:(int)arg2 websiteName:(id)arg3 lowResIcon:(id)arg4 highResIcon:(id)arg5 errorMessages:(id)arg6; @end
34.090909
187
0.786667
124f88095183153b5d74650b4ea7724f5ce3d5b3
2,534
h
C
src/include/simpler_nms_inst.h
kyper999/clDNN_neuset
85148cef898dbf1b314ef742092824c447474f2d
[ "BSL-1.0", "Intel", "Apache-2.0" ]
1
2018-06-07T09:21:08.000Z
2018-06-07T09:21:08.000Z
src/include/simpler_nms_inst.h
kyper999/clDNN_neuset
85148cef898dbf1b314ef742092824c447474f2d
[ "BSL-1.0", "Intel", "Apache-2.0" ]
null
null
null
src/include/simpler_nms_inst.h
kyper999/clDNN_neuset
85148cef898dbf1b314ef742092824c447474f2d
[ "BSL-1.0", "Intel", "Apache-2.0" ]
null
null
null
/* // Copyright (c) 2017 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. */ /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "api/CPP/simpler_nms.hpp" #include "primitive_inst.h" namespace cldnn { template <> struct typed_program_node<simpler_nms> : public typed_program_node_base<simpler_nms> { auto& cls_score() const { return get_dependency(0); } auto& bbox_pred() const { return get_dependency(1); } auto& image_info() const { return get_dependency(2); } }; using simpler_nms_node = typed_program_node<simpler_nms>; template <> class typed_primitive_inst<simpler_nms> : public typed_primitive_inst_base<simpler_nms> { using parent = typed_primitive_inst_base<simpler_nms>; public: struct anchor { float start_x; float start_y; float end_x; float end_y; anchor() { start_x = start_y = end_x = end_y = 0.0f; } anchor(float s_x, float s_y, float e_x, float e_y) { start_x = s_x; start_y = s_y; end_x = e_x; end_y = e_y; } }; // indices of the memory objects used by the layer enum input_index { cls_scores_index, bbox_pred_index, image_info_index }; // indices of the image info parameters inside the image_info memory object (the object // is an integer array of these parameters) enum image_info_size_index { image_info_width_index = 0, image_info_height_index = 1, image_info_depth_index = 2 }; static layout calc_output_layout(simpler_nms_node const& node); static std::string to_string(simpler_nms_node const& node); public: typed_primitive_inst(network_impl& network, simpler_nms_node const& desc); const std::vector<anchor>& get_anchors() const { return _anchors; } private: std::vector<anchor> _anchors; }; using simpler_nms_inst = typed_primitive_inst<simpler_nms>; }
27.543478
99
0.662194
3eac48efc5e5c8e0442bf38303c33e47da81d5ac
976
h
C
examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/src/tiff/contrib/dbs/xtiff/xtifficon.h
madanagopaltcomcast/pxCore
c4a3a40a190521c8b6383d126c87612eca5b3c42
[ "Apache-2.0" ]
4,538
2017-10-20T05:19:03.000Z
2022-03-30T02:29:30.000Z
examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/src/tiff/contrib/dbs/xtiff/xtifficon.h
madanagopaltcomcast/pxCore
c4a3a40a190521c8b6383d126c87612eca5b3c42
[ "Apache-2.0" ]
4,246
2016-03-26T01:21:45.000Z
2022-03-31T23:10:47.000Z
examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/src/tiff/contrib/dbs/xtiff/xtifficon.h
madanagopaltcomcast/pxCore
c4a3a40a190521c8b6383d126c87612eca5b3c42
[ "Apache-2.0" ]
1,860
2017-10-20T05:22:35.000Z
2022-03-27T10:54:14.000Z
#define xtifficon_width 32 #define xtifficon_height 32 static char xtifficon_bits[] = { 0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60, 0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c, 0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03, 0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00, 0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06, 0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06, 0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00, 0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03, 0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f, 0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f, 0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff}; /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */
44.363636
74
0.645492
e25c56b65ab4f0864aa7ee2d657af2ff69a69ab8
1,294
h
C
bme280.h
link-forte/bme280_for_m5stack
3ccb0cd1dde40ba5f863493bddabc2bb53bb29b4
[ "MIT" ]
null
null
null
bme280.h
link-forte/bme280_for_m5stack
3ccb0cd1dde40ba5f863493bddabc2bb53bb29b4
[ "MIT" ]
null
null
null
bme280.h
link-forte/bme280_for_m5stack
3ccb0cd1dde40ba5f863493bddabc2bb53bb29b4
[ "MIT" ]
null
null
null
#ifndef _BME280_H_ #define _BME280_H_ #include <M5Stack.h> #define BME280_SLAVE_ADDRESS (0x77) class BME280 { public: BME280(); ~BME280(); bool begin(CommUtil *_i2c); bool init(); void offsetSenser(); bool offsetTemp(); bool offsetPres(); bool offsetHum(); void updateSenser(); void calcTemp(); void calcHum(); void calcPres(); long int getTemp(); // -40〜85 'C long int getHum(); // 0〜100%RH unsigned long int getPres(); // 30,000 Pa〜110,000 Pa bool isConnected(); private: CommUtil *i2c; uint16_t dig_T1; uint16_t dig_P1; uint16_t dig_H1; uint16_t dig_H3; uint16_t dig_H6; int16_t dig_T2; int16_t dig_T3; int16_t dig_P2; int16_t dig_P3; int16_t dig_P4; int16_t dig_P5; int16_t dig_P6; int16_t dig_P7; int16_t dig_P8; int16_t dig_P9; int16_t dig_H2; int16_t dig_H4; int16_t dig_H5; unsigned long int temp_raw; unsigned long int pres_raw; unsigned long int hum_raw; long int t_fine; long int temp; long int hum; unsigned long int pres; }; #endif
22.701754
60
0.553323
12c65b76f0c1d4f89bc78c2ed139e2443c95510f
16,741
h
C
src/symbol.h
dibyendumajumdar/dmr_c
649df517c9169931d5423d1c77010ea0d2d4768e
[ "MIT" ]
51
2017-03-26T21:16:18.000Z
2022-03-10T03:15:36.000Z
src/symbol.h
dibyendumajumdar/dmr_c
649df517c9169931d5423d1c77010ea0d2d4768e
[ "MIT" ]
33
2017-01-20T01:02:38.000Z
2018-07-09T07:21:37.000Z
src/symbol.h
dibyendumajumdar/dmr_c
649df517c9169931d5423d1c77010ea0d2d4768e
[ "MIT" ]
2
2017-11-05T20:08:51.000Z
2019-07-07T14:36:51.000Z
#ifndef DMR_C_SYMBOL_H #define DMR_C_SYMBOL_H /* * Basic symbol and namespace definitions. * * Copyright (C) 2003 Transmeta Corp. * 2003 Linus Torvalds * * 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. */ /* * This version is part of the dmr_c project. * Copyright (C) 2017 Dibyendu Majumdar */ #include <target.h> #include <token.h> #ifdef __cplusplus extern "C" { #endif /* * An identifier with semantic meaning is a "symbol". * * There's a 1:n relationship: each symbol is always * associated with one identifier, while each identifier * can have one or more semantic meanings due to C scope * rules. * * The progression is symbol -> token -> identifier. The * token contains the information on where the symbol was * declared. */ enum namespace_type { NS_NONE = 0, NS_MACRO = 1, NS_TYPEDEF = 2, NS_STRUCT = 4, // Also used for unions and enums. NS_LABEL = 8, NS_SYMBOL = 16, NS_ITERATOR = 32, NS_PREPROCESSOR = 64, NS_UNDEF = 128, NS_KEYWORD = 256, }; enum type { SYM_UNINITIALIZED, SYM_PREPROCESSOR, SYM_BASETYPE, SYM_NODE, SYM_PTR, SYM_FN, SYM_ARRAY, SYM_STRUCT, SYM_UNION, SYM_ENUM, SYM_TYPEDEF, SYM_TYPEOF, SYM_MEMBER, SYM_BITFIELD, SYM_LABEL, SYM_RESTRICT, SYM_FOULED, SYM_KEYWORD, SYM_BAD, }; enum keyword { KW_SPECIFIER = 1 << 0, KW_MODIFIER = 1 << 1, KW_QUALIFIER = 1 << 2, KW_ATTRIBUTE = 1 << 3, KW_STATEMENT = 1 << 4, KW_ASM = 1 << 5, KW_MODE = 1 << 6, KW_SHORT = 1 << 7, KW_LONG = 1 << 8, KW_EXACT = 1 << 9, }; struct context { struct expression *context_expr; unsigned int in, out; }; DECLARE_PTR_LIST(context_list, struct context); struct phi_map; struct ctype { unsigned long modifiers; unsigned long alignment; struct context_list *contexts; unsigned int as; struct symbol *base_type; }; struct decl_state { struct ctype ctype; struct ident **ident; struct symbol_op *mode; unsigned char prefer_abstract, is_inline, storage_class, is_tls; }; struct symbol; DECLARE_PTR_LIST(symbol_list, struct symbol); struct symbol_op { enum keyword type; int (*evaluate)(struct dmr_C *, struct expression *); int (*expand)(struct dmr_C *, struct expression *, int); int (*args)(struct dmr_C *, struct expression *); /* keywords */ struct token *(*declarator)(struct dmr_C *, struct token *token, struct decl_state *ctx); struct token *(*statement)(struct dmr_C *, struct token *token, struct statement *stmt); struct token *(*toplevel)(struct dmr_C *, struct token *token, struct symbol_list **list); struct token *(*attribute)(struct dmr_C *, struct token *token, struct symbol *attr, struct decl_state *ctx); struct symbol *(*to_mode)(struct dmr_C *, struct symbol *); int test, set, cls; }; #define SYM_ATTR_WEAK 0 #define SYM_ATTR_NORMAL 1 #define SYM_ATTR_STRONG 2 struct symbol { enum type type : 8; enum namespace_type ns : 9; unsigned char used : 1, attr : 2, enum_member : 1, bound : 1; struct position pos; /* Where this symbol was declared */ struct position endpos; /* Where this symbol ends*/ struct ident *ident; /* What identifier this symbol is associated with */ struct symbol *next_id; /* Next semantic symbol that shares this identifier */ struct symbol *replace; /* What is this symbol shadowed by in copy-expression */ struct scope *scope; union { struct symbol *same_symbol; struct symbol *next_subobject; }; struct symbol_op *op; union { struct /* NS_MACRO */ { struct token *expansion; struct token *arglist; struct scope *used_in; }; struct /* NS_PREPROCESSOR */ { int (*handler)(struct dmr_C *, struct stream *, struct token **, struct token *); int normal; }; struct /* NS_SYMBOL */ { unsigned long offset; int bit_size; unsigned int bit_offset:8, arg_count:10, variadic:1, initialized:1, examined:1, expanding:1, evaluated:1, string:1, designated_init:1, forced_arg:1, transparent_union:1; struct expression *array_size; struct ctype ctype; struct symbol_list *arguments; struct statement *stmt; struct symbol_list *symbol_list; struct statement *inline_stmt; struct symbol_list *inline_symbol_list; struct expression *initializer; struct entrypoint *ep; long long value; /* Initial value */ struct symbol *definition; }; }; union /* backend */ { struct basic_block *bb_target; /* label */ void *aux; /* Auxiliary info, e.g. backend information */ struct { /* sparse ctags */ char kind; unsigned char visited:1; }; }; pseudo_t pseudo; DMRC_BACKEND_TYPE priv; }; /* Modifiers */ #define MOD_AUTO 0x0001 #define MOD_REGISTER 0x0002 #define MOD_STATIC 0x0004 #define MOD_EXTERN 0x0008 #define MOD_CONST 0x0010 #define MOD_VOLATILE 0x0020 #define MOD_SIGNED 0x0040 #define MOD_UNSIGNED 0x0080 #define MOD_CHAR 0x0100 #define MOD_SHORT 0x0200 #define MOD_LONG 0x0400 #define MOD_LONGLONG 0x0800 #define MOD_LONGLONGLONG 0x1000 #define MOD_PURE 0x2000 #define MOD_TYPEDEF 0x10000 #define MOD_TLS 0x20000 #define MOD_INLINE 0x40000 #define MOD_ADDRESSABLE 0x80000 #define MOD_NOCAST 0x100000 #define MOD_NODEREF 0x200000 #define MOD_ACCESSED 0x400000 #define MOD_TOPLEVEL 0x800000 // scoping.. #define MOD_ASSIGNED 0x2000000 #define MOD_TYPE 0x4000000 #define MOD_SAFE 0x8000000 // non-null/non-trapping pointer #define MOD_USERTYPE 0x10000000 #define MOD_NORETURN 0x20000000 #define MOD_EXPLICITLY_SIGNED 0x40000000 #define MOD_BITWISE 0x80000000 #define MOD_NONLOCAL (MOD_EXTERN | MOD_TOPLEVEL) #define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN | MOD_INLINE | MOD_TOPLEVEL) #define MOD_SIGNEDNESS (MOD_SIGNED | MOD_UNSIGNED | MOD_EXPLICITLY_SIGNED) #define MOD_LONG_ALL (MOD_LONG | MOD_LONGLONG | MOD_LONGLONGLONG) #define MOD_SPECIFIER (MOD_CHAR | MOD_SHORT | MOD_LONG_ALL | MOD_SIGNEDNESS) #define MOD_SIZE (MOD_CHAR | MOD_SHORT | MOD_LONG_ALL) #define MOD_IGNORE (MOD_TOPLEVEL | MOD_STORAGE | MOD_ADDRESSABLE | \ MOD_ASSIGNED | MOD_USERTYPE | MOD_ACCESSED | MOD_EXPLICITLY_SIGNED) #define MOD_PTRINHERIT (MOD_VOLATILE | MOD_CONST | MOD_NODEREF | MOD_NORETURN | MOD_NOCAST) /* modifiers preserved by typeof() operator */ #define MOD_TYPEOF (MOD_VOLATILE | MOD_CONST | MOD_NOCAST | MOD_SPECIFIER) struct ctype_name { struct symbol *sym; const char *name; }; struct global_symbols_t { struct dmr_C *C; /* Abstract types */ struct symbol int_type, fp_type; /* C types */ struct symbol bool_ctype, void_ctype, type_ctype, char_ctype, schar_ctype, uchar_ctype, short_ctype, sshort_ctype, ushort_ctype, int_ctype, sint_ctype, uint_ctype, long_ctype, slong_ctype, ulong_ctype, llong_ctype, sllong_ctype, ullong_ctype, lllong_ctype, slllong_ctype, ulllong_ctype, float_ctype, double_ctype, ldouble_ctype, string_ctype, ptr_ctype, lazy_ptr_ctype, incomplete_ctype, label_ctype, bad_ctype, null_ctype; /* Special internal symbols */ struct symbol zero_int; /* * Secondary symbol list for stuff that needs to be output because it * was used. */ struct symbol_list *translation_unit_used_list; struct allocator context_allocator; struct allocator symbol_allocator; struct allocator global_ident_allocator; struct symbol_list *restr, *fouled; struct ctype_name typenames[30]; #define __IDENT(n, str, res) struct ident *n #include "ident-list.h" #undef __IDENT }; extern void dmrC_init_symbols(struct dmr_C *C); extern void dmrC_init_ctype(struct dmr_C *C); extern void dmrC_init_builtins(struct dmr_C *C, int stream); extern void dmrC_destroy_symbols(struct dmr_C *C); extern struct context *dmrC_alloc_context(struct global_symbols_t *S); extern void dmrC_access_symbol(struct global_symbols_t *S, struct symbol *sym); extern const char *dmrC_type_difference(struct dmr_C *C, struct ctype *c1, struct ctype *c2, unsigned long mod1, unsigned long mod2); extern struct symbol *dmrC_lookup_symbol(struct ident *, enum namespace_type); extern struct symbol *dmrC_create_symbol(struct global_symbols_t *S, int stream, const char *name, int type, int ns); extern struct symbol *dmrC_alloc_symbol(struct global_symbols_t *S, struct position pos, int type); extern void dmrC_show_type(struct dmr_C *C, struct symbol *); extern const char *dmrC_modifier_string(struct dmr_C *C, unsigned long mod); extern void dmrC_show_symbol(struct dmr_C *C, struct symbol *); extern int dmrC_show_symbol_expr_init(struct dmr_C *C, struct symbol *sym); extern void dmrC_show_symbol_list(struct dmr_C *C, struct symbol_list *, const char *); extern void dmrC_bind_symbol(struct global_symbols_t *S, struct symbol *sym, struct ident *ident, enum namespace_type ns); extern struct symbol *dmrC_examine_symbol_type(struct global_symbols_t *S, struct symbol *sym); extern struct symbol *dmrC_examine_pointer_target(struct global_symbols_t *S, struct symbol *sym); extern const char *dmrC_show_typename(struct dmr_C *C, struct symbol *sym); extern const char *dmrC_builtin_typename(struct dmr_C *C, struct symbol *sym); extern const char *dmrC_builtin_ctypename(struct dmr_C *C, struct ctype *ctype); extern const char *dmrC_get_type_name(enum type type); extern void dmrC_debug_symbol(struct dmr_C *C, struct symbol *); extern void dmrC_merge_type(struct symbol *sym, struct symbol *base_type); extern void dmrC_check_declaration(struct global_symbols_t *S, struct symbol *sym); static inline struct symbol *dmrC_get_base_type(struct global_symbols_t *S, const struct symbol *sym) { return dmrC_examine_symbol_type(S, sym->ctype.base_type); } static inline int dmrC_is_int_type(struct global_symbols_t *S, const struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; if (type->type == SYM_ENUM) type = type->ctype.base_type; return type->type == SYM_BITFIELD || type->ctype.base_type == &S->int_type; } static inline int dmrC_is_enum_type(const struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return (type->type == SYM_ENUM); } static inline int dmrC_is_type_type(struct symbol *type) { return (type->ctype.modifiers & MOD_TYPE) != 0; } static inline int dmrC_is_ptr_type(struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return type->type == SYM_PTR || type->type == SYM_ARRAY || type->type == SYM_FN; } static inline int dmrC_is_func_type(struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return type->type == SYM_FN; } static inline int dmrC_is_array_type(struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return type->type == SYM_ARRAY; } static inline int dmrC_is_float_type(struct global_symbols_t *S, struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return type->ctype.base_type == &S->fp_type; } static inline int dmrC_is_byte_type(const struct target_t *target, struct symbol *type) { return type->bit_size == target->bits_in_char && type->type != SYM_BITFIELD; } static inline int dmrC_is_void_type(struct global_symbols_t *S, struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return type == &S->void_ctype; } static inline int dmrC_is_bool_type(struct global_symbols_t *S, struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; return type == &S->bool_ctype; } static inline int dmrC_is_scalar_type(struct global_symbols_t *S, struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; switch (type->type) { case SYM_ENUM: case SYM_BITFIELD: case SYM_PTR: case SYM_ARRAY: // OK, will be a PTR after conversion case SYM_FN: case SYM_RESTRICT: // OK, always integer types return 1; default: break; } if (type->ctype.base_type == &S->int_type) return 1; if (type->ctype.base_type == &S->fp_type) return 1; return 0; } // From Luc - sssa-mini static inline int dmrC_is_simple_type(struct global_symbols_t *S, struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; switch (type->type) { case SYM_ENUM: case SYM_BITFIELD: case SYM_PTR: case SYM_RESTRICT: // OK, always integer types return 1; // Following is causing failures because the IR // attempts to store values into unions or structs //case SYM_STRUCT: //case SYM_UNION: // return type->bit_size <= S->long_ctype.bit_size; default: break; } if (type->ctype.base_type == &S->int_type) return 1; if (type->ctype.base_type == &S->fp_type) return 1; return 0; } // From Luc - sssa-mini static inline int dmrC_is_simple_var(struct global_symbols_t *S, struct symbol *var) { if (!dmrC_is_simple_type(S, var)) return 0; #define MOD_NONREG (MOD_STATIC|MOD_NONLOCAL|MOD_ADDRESSABLE|MOD_VOLATILE) if (var->ctype.modifiers & MOD_NONREG) return 0; return 1; } static inline int dmrC_is_function(struct symbol *type) { return type && type->type == SYM_FN; } static inline int dmrC_is_extern_inline(struct symbol *sym) { return (sym->ctype.modifiers & MOD_EXTERN) && (sym->ctype.modifiers & MOD_INLINE) && dmrC_is_function(sym->ctype.base_type); } static inline int dmrC_is_toplevel(struct symbol *sym) { return (sym->ctype.modifiers & MOD_TOPLEVEL); } static inline int dmrC_is_extern(struct symbol *sym) { return (sym->ctype.modifiers & MOD_EXTERN); } static inline int dmrC_is_static(struct symbol *sym) { return (sym->ctype.modifiers & MOD_STATIC); } static int dmrC_is_signed_type(struct symbol *sym) { if (sym->type == SYM_NODE) sym = sym->ctype.base_type; if (sym->type == SYM_PTR) return 0; return !(sym->ctype.modifiers & MOD_UNSIGNED); } static inline int dmrC_is_unsigned(struct symbol *sym) { return !dmrC_is_signed_type(sym); } static inline int dmrC_get_sym_type(struct symbol *type) { if (type->type == SYM_NODE) type = type->ctype.base_type; if (type->type == SYM_ENUM) type = type->ctype.base_type; return type->type; } static inline struct symbol *dmrC_get_nth_symbol(struct symbol_list *list, unsigned int idx) { return (struct symbol *)ptrlist_nth_entry((struct ptr_list *)list, idx); } static inline struct symbol *dmrC_lookup_keyword(struct ident *ident, enum namespace_type ns) { if (!ident->keyword) return NULL; return dmrC_lookup_symbol(ident, ns); } static inline void dmrC_concat_symbol_list(struct symbol_list *from, struct symbol_list **to) { ptrlist_concat((struct ptr_list *)from, (struct ptr_list **) to); } static inline void dmrC_add_symbol(struct dmr_C *C, struct symbol_list **list, struct symbol *sym) { ptrlist_add((struct ptr_list**)list, sym, &C->ptrlist_allocator); } static inline int dmrC_symbol_list_size(struct symbol_list *list) { return ptrlist_size((struct ptr_list *)list); } static inline void dmrC_concat_context_list(struct context_list *from, struct context_list **to) { ptrlist_concat((struct ptr_list *)from, (struct ptr_list **)to); } static inline void dmrC_add_context(struct dmr_C *C, struct context_list **list, struct context *ctx) { ptrlist_add((struct ptr_list **)list, ctx, &C->ptrlist_allocator); } static inline int dmrC_is_prototype(struct symbol *sym) { if (sym->type == SYM_NODE) sym = sym->ctype.base_type; return sym && sym->type == SYM_FN && !sym->stmt; } #define dmrC_is_restricted_type(type) (dmrC_get_sym_type(type) == SYM_RESTRICT) #define dmrC_is_fouled_type(type) (dmrC_get_sym_type(type) == SYM_FOULED) #define dmrC_is_bitfield_type(type) (dmrC_get_sym_type(type) == SYM_BITFIELD) extern void dmrC_create_fouled(struct global_symbols_t *S, struct symbol *type); extern struct symbol *dmrC_befoul(struct global_symbols_t *S, struct symbol *type); #ifdef __cplusplus } #endif #endif
28.088926
117
0.740099
12d35be653a6c2d5b1c4bf7cfd6f08a8c20e8382
29,993
h
C
inc/stm32_hcd.h
andreili/STM32F4
9054d699ec1f65e7de8aa5dd7d3ee0522dad18dc
[ "MIT" ]
6
2019-04-16T11:38:45.000Z
2020-12-12T16:55:03.000Z
inc/stm32_hcd.h
andreili/STM32F4
9054d699ec1f65e7de8aa5dd7d3ee0522dad18dc
[ "MIT" ]
1
2020-12-15T10:45:53.000Z
2021-02-22T11:59:19.000Z
inc/stm32_hcd.h
andreili/STM32F4
9054d699ec1f65e7de8aa5dd7d3ee0522dad18dc
[ "MIT" ]
2
2019-05-23T03:08:25.000Z
2020-10-10T12:43:06.000Z
#ifndef __STM32_HCD_H__ #define __STM32_HCD_H__ /* * Based on HAL-F4 v1.21.0 * */ #include "stm32_inc.h" #ifdef STM32_USE_USB_HOST #define USB_OTG_HS_MAX_PACKET_SIZE 512U #define USB_OTG_FS_MAX_PACKET_SIZE 64U #define USB_OTG_MAX_EP0_SIZE 64U #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0U << 1U) #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1U << 1U) #define DSTS_ENUMSPD_LS_PHY_6MHZ (2U << 1U) #define DSTS_ENUMSPD_FS_PHY_48MHZ (3U << 1U) #define DCFG_FRAME_INTERVAL_80 0U #define DCFG_FRAME_INTERVAL_85 1U #define DCFG_FRAME_INTERVAL_90 2U #define DCFG_FRAME_INTERVAL_95 3U #define DEP0CTL_MPS_64 0U #define DEP0CTL_MPS_32 1U #define DEP0CTL_MPS_16 2U #define DEP0CTL_MPS_8 3U #define HPRT0_PRTSPD_HIGH_SPEED 0U #define HPRT0_PRTSPD_FULL_SPEED 1U #define HPRT0_PRTSPD_LOW_SPEED 2U #define HCCHAR_CTRL (0U << USB_OTG_HCCHAR_EPTYP_Pos) #define HCCHAR_ISOC (1U << USB_OTG_HCCHAR_EPTYP_Pos) #define HCCHAR_BULK (2U << USB_OTG_HCCHAR_EPTYP_Pos) #define HCCHAR_INTR (3U << USB_OTG_HCCHAR_EPTYP_Pos) #define GRXSTS_PKTSTS_IN 2U #define GRXSTS_PKTSTS_IN_XFER_COMP 3U #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5U #define GRXSTS_PKTSTS_CH_HALTED 7U #define USB_OTG_FIFO_ONE_SIZE (USB_OTG_FIFO_SIZE / 4) #define USB_IN_EP_COUNT ((USB_OTG_OUT_ENDPOINT_BASE - USB_OTG_IN_ENDPOINT_BASE) / USB_OTG_EP_REG_SIZE) #define USB_OUT_EP_COUNT ((USB_OTG_PCGCCTL_BASE - USB_OTG_OUT_ENDPOINT_BASE) / USB_OTG_EP_REG_SIZE) #define USB_HOST_PORTS_COUNT ((USB_OTG_HOST_CHANNEL_BASE - USB_OTG_HOST_PORT_BASE) / sizeof(uint32_t)) #define USB_HOST_CHANNELS_COUNT ((USB_OTG_DEVICE_BASE - USB_OTG_HOST_CHANNEL_BASE) / USB_OTG_HOST_CHANNEL_SIZE) #define USB_PCGCCTL_COUNT ((USB_OTG_FIFO_BASE - USB_OTG_PCGCCTL_BASE) / sizeof(uint32_t)) #define USB_DFIFO_COUNT (USB_OTG_FIFO_SIZE / sizeof(uint32_t)) #define TX_FIFO_COUNT 0x10 #define deactivate_dedicated_endpoint deactivate_endpoint class STM32_HCD { public: enum class EPID: uint8_t { DATA0 = 0U, DATA2 = 1U, DATA1 = 2U, SETUP = 3U, }; enum class EEPSpeed: uint8_t { LOW = 0U, FULL = 1U, HIGH = 2U, }; enum class ESTS: uint8_t { GOUT_NAK = 1U, DATA_UPDT = 2U, XFER_COMP = 3U, SETUP_COMP = 4U, SETUP_UPDT = 6U, }; enum class EOTGDeviceMode: uint32_t { DEVICE = 0, HOST = 1, DRD = 2, }; enum class EURBState: uint8_t { IDLE = 0, DONE, NOT_READY, NYET, ERROR, STALL, }; enum class EHCState: uint8_t { IDLE = 0, XFRC, HALTED, NAK, NYET, STALL, XACTERR, BBLERR, DATATGLERR, }; enum class EOTGSpeed: uint8_t { HIGH = 0, HIGH_IN_FULL = 1, LOW = 2, FULL = 3, }; enum class EOTG_PHY: uint32_t { ULPI = 1, EMBEDDED = 2, }; enum class EHCDState: uint32_t { RESET_ = 0, READY, ERROR, BUSY, TIMEOUT, }; enum class EClockSpeed: uint32_t { _30_60_MHZ = 0, _48_MHZ, _6_MHZ, }; enum class EEPType: uint8_t { CTRL = 0, ISOC, BULK, INTR, MSK, }; #pragma pack(push, 4) typedef struct { USB_OTG_GlobalTypeDef global; uint32_t dummy0[176]; USB_OTG_HostTypeDef host; uint32_t dummy1[9]; uint32_t ports[USB_HOST_PORTS_COUNT]; USB_OTG_HostChannelTypeDef channels[USB_HOST_CHANNELS_COUNT]; USB_OTG_DeviceTypeDef device; uint32_t dummy2[30]; USB_OTG_INEndpointTypeDef in_eps[USB_IN_EP_COUNT]; USB_OTG_OUTEndpointTypeDef out_eps[USB_OUT_EP_COUNT]; uint32_t PCGCCTL[USB_PCGCCTL_COUNT]; uint32_t DFIFO[USB_DFIFO_COUNT]; } OTGRegs_t; #pragma pack(pop) typedef struct { uint8_t dev_addr; /*!< USB device address. This parameter must be a number between Min_Data = 1 and Max_Data = 255 */ uint8_t ch_num; /*!< Host channel number. This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ uint8_t ep_num; /*!< Endpoint number. This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ bool ep_is_in; /*!< Endpoint direction This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ bool do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */ bool toggle_out; /*!< OUT transfer current toggle flag This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */ EPID data_pid; /*!< Initial data PID. This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */ uint8_t toggle_in; /*!< IN transfer current toggle flag. This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ EURBState urb_state; /*!< URB state. This parameter can be any value of @ref USB_OTG_URBStateTypeDef */ EHCState state; /*!< Host Channel state. This parameter can be any value of @ref USB_OTG_HCStateTypeDef */ uint8_t dummy; EOTGSpeed speed; /*!< USB Host speed. This parameter can be any value of @ref USB_Core_Speed_ */ EEPType ep_type; /*!< Endpoint Type. This parameter can be any value of @ref USB_EP_Type_ */ uint16_t max_packet; /*!< Endpoint Max packet size. This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ uint32_t xfer_len; /*!< Current transfer length. */ uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */ uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */ uint32_t ErrCnt; /*!< Host channel error count.*/ } OTG_HC_t; uint32_t init(USB_OTG_GlobalTypeDef *regs_addr, EOTG_PHY phy, bool use_ext_vbus, bool dma_enable, EOTGSpeed speed, uint8_t host_channels); void deInit(); FORCE_INLINE void set_data(void* data) { m_data = data; } FORCE_INLINE void* get_data() { return m_data; } FORCE_INLINE void enable() { enable_global_int(); } FORCE_INLINE void disable() { disable_global_int(); } FORCE_INLINE uint32_t get_flag(uint32_t mask) { return (read_IT() & mask) == mask; } FORCE_INLINE void clear_flag(uint32_t mask) { m_regs->global.GINTSTS = mask; } FORCE_INLINE bool is_invalid_IT() { return (read_IT() == 0); } FORCE_INLINE uint32_t get_HC_int(uint8_t ch_num) { return m_regs->channels[ch_num].HCINT; } FORCE_INLINE bool is_HC_int(uint8_t ch_num, uint32_t mask) { return (m_regs->channels[ch_num].HCINT & mask) == mask; } FORCE_INLINE void clear_HC_int(uint8_t ch_num, uint32_t mask) { m_regs->channels[ch_num].HCINT = mask; } FORCE_INLINE void set_HC_int(uint8_t ch_num, uint32_t val) { m_regs->channels[ch_num].HCINTMSK = val; } FORCE_INLINE void mask_HC_int(uint8_t ch_num, uint32_t mask) { m_regs->channels[ch_num].HCINTMSK &= ~mask; } FORCE_INLINE void unmask_HC_int(uint8_t ch_num, uint32_t mask) { m_regs->channels[ch_num].HCINTMSK |= mask; } FORCE_INLINE void mask_halt_HC_int(uint8_t ch_num) { m_regs->channels[ch_num].HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM; } FORCE_INLINE void mask_all_HC_int(uint8_t ch_num) { m_regs->channels[ch_num].HCINTMSK = 0; } FORCE_INLINE void unmask_halt_HC_int(uint8_t ch_num) { m_regs->channels[ch_num].HCINTMSK |= USB_OTG_HCINTMSK_CHHM; } FORCE_INLINE void mask_ack_HC_int(uint8_t ch_num) { m_regs->channels[ch_num].HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM; } FORCE_INLINE void unmask_ack_HC_int(uint8_t ch_num) { m_regs->channels[ch_num].HCINTMSK |= USB_OTG_HCINTMSK_ACKM; } FORCE_INLINE void mask_IT(uint32_t mask) { m_regs->global.GINTMSK &= ~mask; } FORCE_INLINE void unmask_IT(uint32_t mask) { m_regs->global.GINTMSK |= mask; } FORCE_INLINE void clear_in_ep_intr(uint8_t ep_num, uint32_t mask) { m_regs->in_eps[ep_num].DIEPINT = mask; } FORCE_INLINE void clear_out_ep_intr(uint8_t ep_num, uint32_t mask) { m_regs->out_eps[ep_num].DOEPINT = mask; } FORCE_INLINE uint32_t get_current_frame() { return (m_regs->host.HFNUM & USB_OTG_HFNUM_FRNUM); } FORCE_INLINE uint32_t is_cur_frame_odd() { return (m_regs->host.HFNUM & 0x01) ? 0 : 1; } FORCE_INLINE EOTGSpeed get_current_speed() { return get_host_speed(); } void set_toggle(uint8_t pipe, uint8_t toggle); uint8_t get_toggle(uint8_t pipe); void reset_port(); FORCE_INLINE void reset_port_st1(uint32_t val) { m_regs->ports[0] = val; } uint32_t start(); uint32_t stop(); FORCE_INLINE EHCDState get_state() { return m_state; } FORCE_INLINE void enable_host_IT(uint8_t ch_num) { m_regs->host.HAINTMSK |= (1 << ch_num); } FORCE_INLINE void set_host_IT(uint32_t val) { m_regs->host.HAINT = val; } uint32_t HC_init(uint8_t ch_num, uint8_t ep_num, uint8_t dev_address, EOTGSpeed speed, EEPType ep_type, uint16_t mps); FORCE_INLINE void HC_set_params(uint8_t ch_num, uint8_t ep_num, uint8_t dev_address, EOTGSpeed speed, EEPType ep_type, uint16_t mps) { m_regs->channels[ch_num].HCCHAR = ((dev_address << USB_OTG_HCCHAR_DAD_Pos) & USB_OTG_HCCHAR_DAD) | (((ep_num & 0x7f) << USB_OTG_HCCHAR_EPNUM_Pos) & USB_OTG_HCCHAR_EPNUM) | ((((ep_num & 0x80) == 0x80) << USB_OTG_HCCHAR_EPDIR_Pos) & USB_OTG_HCCHAR_EPDIR) | (((speed == EOTGSpeed::LOW) << USB_OTG_HCCHAR_LSDEV_Pos) & USB_OTG_HCCHAR_LSDEV) | ((static_cast<uint32_t>(ep_type) << USB_OTG_HCCHAR_EPTYP_Pos) & USB_OTG_HCCHAR_EPTYP) | (mps & USB_OTG_HCCHAR_MPSIZ); } FORCE_INLINE bool HC_get_dir(uint8_t ch_num) { return ((m_regs->channels[ch_num].HCCHAR & USB_OTG_HCCHAR_EPDIR) == USB_OTG_HCCHAR_EPDIR); } FORCE_INLINE uint32_t HC_get_params(uint8_t ch_num) { return m_regs->channels[ch_num].HCCHAR; } FORCE_INLINE void HC_set_param_RAW(uint8_t ch_num, uint32_t val) { m_regs->channels[ch_num].HCCHAR = val; } FORCE_INLINE void HC_enable_param(uint8_t ch_num, uint32_t mask) { m_regs->channels[ch_num].HCCHAR |= mask; } FORCE_INLINE void HC_disable_param(uint8_t ch_num, uint32_t mask) { m_regs->channels[ch_num].HCCHAR &= ~mask; } void HC_submit_request(uint8_t ch_num, bool is_in, EEPType ep_type, bool token, uint8_t* pbuff, uint16_t length, bool do_ping); uint32_t HC_halt(uint8_t hc_num); FORCE_INLINE uint32_t HC_get_Xfer_count(uint8_t chnum) { return m_HC[chnum].xfer_count; } FORCE_INLINE EURBState HC_get_URB_state(uint8_t chnum) { return m_HC[chnum].urb_state; } FORCE_INLINE EHCState HC_get_state(uint8_t chnum) { return m_HC[chnum].state; } void IRQ_handler(); private: OTGRegs_t* m_regs; OTG_HC_t m_HC[15]; uint32_t m_lock; EHCDState m_state; void* m_data; bool m_dma_enable; uint8_t m_host_channels; EOTG_PHY m_phy; EOTGSpeed m_speed; void init_gpio(); void deInit_gpio(); uint32_t core_init(bool use_ext_vbus); FORCE_INLINE void power_down() { m_regs->global.GCCFG &= ~USB_OTG_GCCFG_PWRDWN; } FORCE_INLINE void power_up() { m_regs->global.GCCFG = USB_OTG_GCCFG_PWRDWN; } FORCE_INLINE void init_phy_ULPI() { m_regs->global.GUSBCFG &= ~(USB_OTG_GUSBCFG_TSDPS | USB_OTG_GUSBCFG_ULPIFSLS | USB_OTG_GUSBCFG_PHYSEL); } FORCE_INLINE void init_phy_embedded() { m_regs->global.GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL; } FORCE_INLINE void reset_ULPI_VBUS() { m_regs->global.GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI); } FORCE_INLINE void set_ULPI_VBUS() { m_regs->global.GUSBCFG |= USB_OTG_GUSBCFG_ULPIEVBUSD; } FORCE_INLINE void enable_DMA() { m_regs->global.GAHBCFG |= (USB_OTG_GAHBCFG_HBSTLEN_2 | USB_OTG_GAHBCFG_DMAEN); } void dev_init(bool vbus_sending_enable, uint32_t ep_count, bool sof_enable); ENDIS_REG_FLAG_NAME_SL(VBUS_A, m_regs->global.GCCFG, USB_OTG_GCCFG_VBUSASEN) ENDIS_REG_FLAG_NAME_SL(VBUS_B, m_regs->global.GCCFG, USB_OTG_GCCFG_VBUSBSEN) ENDIS_REG_FLAG_NAME_SL(VBUS, m_regs->global.GCCFG, USB_OTG_GCCFG_NOVBUSSENS) FORCE_INLINE void restart_phy_clock() { m_regs->PCGCCTL[0] = 0; } FORCE_INLINE void mode_device_configuration() { m_regs->device.DCFG |= DCFG_FRAME_INTERVAL_80; } FORCE_INLINE void clear_all_ITs() { clear_in_IT(); clear_out_IT(); clear_shared_IT(); m_regs->device.DAINTMSK = 0; } FORCE_INLINE bool is_in_endpoint_enable(uint32_t ep_idx) { return (m_regs->in_eps[ep_idx].DIEPCTL & USB_OTG_DIEPCTL_EPENA) == USB_OTG_DIEPCTL_EPENA; } FORCE_INLINE void disable_NAK_in_endpoint(uint32_t ep_idx) { m_regs->in_eps[ep_idx].DIEPCTL = (USB_OTG_DIEPCTL_EPDIS | USB_OTG_DIEPCTL_SNAK); } FORCE_INLINE void disable_in_endpoint(uint32_t ep_idx) { m_regs->in_eps[ep_idx].DIEPCTL = 0; } FORCE_INLINE void in_endpoint_reset_Xfer_size(uint32_t ep_idx) { m_regs->in_eps[ep_idx].DIEPTSIZ = 0; } FORCE_INLINE void in_endpoint_reset_IT(uint32_t ep_idx) { m_regs->in_eps[ep_idx].DIEPINT = 0xff; } FORCE_INLINE bool is_out_endpoint_enable(uint32_t ep_idx) { return (m_regs->out_eps[ep_idx].DOEPCTL & USB_OTG_DOEPCTL_EPENA) == USB_OTG_DOEPCTL_EPENA; } FORCE_INLINE void disable_NAK_out_endpoint(uint32_t ep_idx) { m_regs->out_eps[ep_idx].DOEPCTL = (USB_OTG_DOEPCTL_EPDIS | USB_OTG_DOEPCTL_SNAK); } FORCE_INLINE void disable_out_endpoint(uint32_t ep_idx) { m_regs->out_eps[ep_idx].DOEPCTL = 0; } FORCE_INLINE void out_endpoint_reset_Xfer_size(uint32_t ep_idx) { m_regs->out_eps[ep_idx].DOEPTSIZ = 0; } FORCE_INLINE void out_endpoint_reset_IT(uint32_t ep_idx) { m_regs->out_eps[ep_idx].DOEPINT = 0xff; } FORCE_INLINE void reset_FIFO_underrun_flag() { m_regs->device.DIEPMSK &= ~USB_OTG_DIEPMSK_TXFURM; } FORCE_INLINE void set_DMA_thresshold() { m_regs->device.DTHRCTL = (USB_OTG_DTHRCTL_TXTHRLEN_6 | USB_OTG_DTHRCTL_RXTHRLEN_6 | USB_OTG_DTHRCTL_RXTHREN | USB_OTG_DTHRCTL_ISOTHREN | USB_OTG_DTHRCTL_NONISOTHREN); __IO uint32_t tmp = m_regs->device.DTHRCTL; UNUSED(tmp); } FORCE_INLINE void disable_all_IT() { m_regs->global.GINTMSK = 0; } FORCE_INLINE void clear_all_IT() { m_regs->global.GINTSTS = 0xbfffffff; } FORCE_INLINE void clear_all_IT1() { m_regs->global.GINTSTS = 0xffffffff; } FORCE_INLINE void enable_IT(uint32_t mask) { m_regs->global.GINTMSK |= mask; } FORCE_INLINE void enable_global_int() { m_regs->global.GAHBCFG |= USB_OTG_GAHBCFG_GINT; } FORCE_INLINE void disable_global_int() { m_regs->global.GAHBCFG &= ~USB_OTG_GAHBCFG_GINT; } void set_current_mode(EOTGDeviceMode mode); FORCE_INLINE void reset_mode() { m_regs->global.GUSBCFG &= ~(USB_OTG_GUSBCFG_FHMOD | USB_OTG_GUSBCFG_FDMOD); } FORCE_INLINE void set_mode_host() { m_regs->global.GUSBCFG |= USB_OTG_GUSBCFG_FHMOD; } FORCE_INLINE void set_mode_device() { m_regs->global.GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; } FORCE_INLINE void set_dev_speed(EOTGSpeed speed) { m_regs->device.DCFG |= static_cast<uint32_t>(speed); } FORCE_INLINE uint32_t get_dev_speed_RAW() { return (m_regs->device.DSTS & USB_OTG_DSTS_ENUMSPD); } EOTGSpeed get_dev_speed(); uint32_t flush_RX_FIFO(); uint32_t flush_TX_FIFO(uint32_t num); FORCE_INLINE bool is_frame_odd() { return (m_regs->device.DSTS & (1 << USB_OTG_DSTS_FNSOF_Pos)) == 0; } void activate_endpoint(bool ep_is_in, uint8_t ep_num, uint32_t ep_maxpacket, uint8_t ep_type); uint32_t deactivate_endpoint(bool ep_is_in, uint8_t ep_num); void activate_dedicated_endpoint(bool ep_is_in, uint8_t ep_num, uint32_t ep_maxpacket, uint8_t ep_type); FORCE_INLINE void set_ep_IT_mask(uint32_t mask) { m_regs->device.DAINTMSK |= mask; } FORCE_INLINE void set_ded_ep_IT_mask(uint32_t mask) { m_regs->device.DEACHMSK |= mask; } FORCE_INLINE void clear_ep_IT_mask(uint32_t mask) { m_regs->device.DAINTMSK &= ~mask; } FORCE_INLINE bool is_ep_in_active(uint8_t ep_num) { return (m_regs->in_eps[ep_num].DIEPCTL & USB_OTG_DIEPCTL_USBAEP) == USB_OTG_DIEPCTL_USBAEP; } FORCE_INLINE void deactivate_ep_in(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL &= ~USB_OTG_DIEPCTL_USBAEP; } FORCE_INLINE void set_NAK_ep_in(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL = USB_OTG_DIEPCTL_SNAK; } FORCE_INLINE bool is_ep_in_disabled(uint8_t ep_num) { return (m_regs->in_eps[ep_num].DIEPINT & USB_OTG_DIEPCTL_EPDIS) == USB_OTG_DIEPCTL_EPDIS; } FORCE_INLINE void disable_ep_in(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL = USB_OTG_DIEPCTL_EPDIS; } FORCE_INLINE void undisable_ep_in(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL &= ~USB_OTG_DIEPCTL_EPDIS; } FORCE_INLINE void activate_ep_in(uint8_t ep_num, uint32_t ep_maxpacket, uint8_t ep_type) { m_regs->in_eps[ep_num].DIEPCTL |= (ep_maxpacket & USB_OTG_DIEPCTL_MPSIZ) | (ep_type << USB_OTG_DIEPCTL_EPTYP_Pos) | (ep_num << USB_OTG_DIEPCTL_TXFNUM_Pos) | USB_OTG_DIEPCTL_SD0PID_SEVNFRM | USB_OTG_DIEPCTL_USBAEP; } FORCE_INLINE bool is_ep_out_active(uint8_t ep_num) { return (m_regs->out_eps[ep_num].DOEPCTL & USB_OTG_DOEPCTL_USBAEP) == USB_OTG_DOEPCTL_USBAEP; } FORCE_INLINE void deactivate_ep_out(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP; } FORCE_INLINE void set_NAK_ep_out(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL = USB_OTG_DOEPCTL_SNAK; } FORCE_INLINE bool is_ep_out_disabled(uint8_t ep_num) { return (m_regs->out_eps[ep_num].DOEPINT & USB_OTG_DOEPINT_OTEPDIS) == USB_OTG_DOEPINT_OTEPDIS; } FORCE_INLINE void disable_ep_out(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL = USB_OTG_DOEPCTL_EPDIS; } FORCE_INLINE void undisable_ep_out(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL &= ~USB_OTG_DOEPCTL_EPDIS; } FORCE_INLINE void clear_global_NAK() { m_regs->device.DCTL |= USB_OTG_DCTL_CGONAK; } FORCE_INLINE void activate_ep_out(uint8_t ep_num, uint32_t ep_maxpacket, uint8_t ep_type) { m_regs->out_eps[ep_num].DOEPCTL |= (ep_maxpacket & USB_OTG_DOEPCTL_MPSIZ) | (ep_type << USB_OTG_DOEPCTL_EPTYP_Pos) | (ep_num << 22) | USB_OTG_DIEPCTL_SD0PID_SEVNFRM | USB_OTG_DOEPCTL_USBAEP; } void EP_start_Xfer(bool ep_is_in, uint8_t ep_num, uint32_t ep_maxpacket, uint8_t* xfer_buff, uint16_t xfer_len, EEPType ep_type, bool dma, uint32_t dma_addr); void EP0_start_Xfer(bool ep_is_in, uint8_t ep_num, uint16_t ep_maxpacket, uint8_t* xfer_buff, uint16_t xfer_len, bool dma, uint32_t dma_addr); FORCE_INLINE void set_dev_empty_mask(uint32_t ep_num) { m_regs->device.DIEPEMPMSK |= (1 << ep_num); } FORCE_INLINE void Xfer_in_pkt_start(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPTSIZ &= ~USB_OTG_DIEPTSIZ_XFRSIZ; m_regs->in_eps[ep_num].DIEPTSIZ &= ~USB_OTG_DIEPTSIZ_PKTCNT; } FORCE_INLINE void Xfer_in_pkt_size(uint8_t ep_num, uint32_t len) { m_regs->in_eps[ep_num].DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (len << USB_OTG_DIEPTSIZ_PKTCNT_Pos)); } FORCE_INLINE void Xfer_in_pkt_end(uint8_t ep_num, uint32_t len) { m_regs->in_eps[ep_num].DIEPTSIZ |= (USB_OTG_DIEPTSIZ_XFRSIZ & len); } FORCE_INLINE void Xfer_in_pkt_multi(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPTSIZ &= ~USB_OTG_DIEPTSIZ_MULCNT; m_regs->in_eps[ep_num].DIEPTSIZ |= (USB_OTG_DIEPTSIZ_MULCNT & (1 <USB_OTG_DIEPTSIZ_MULCNT_Pos)); } FORCE_INLINE void Xfer_in_enable_DMA(uint8_t ep_num, uint32_t dma_addr) { m_regs->in_eps[ep_num].DIEPDMA = dma_addr; } FORCE_INLINE void Xfer_in_set_odd_frame(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL |= USB_OTG_DIEPCTL_SODDFRM; } FORCE_INLINE void Xfer_in_set_data0_pid(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL |= USB_OTG_DIEPCTL_SD0PID_SEVNFRM; } FORCE_INLINE void Xfer_in_ep_enable(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA); } FORCE_INLINE void Xfer_out_pkt_start(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPTSIZ &= ~USB_OTG_DIEPTSIZ_XFRSIZ; m_regs->out_eps[ep_num].DOEPTSIZ &= ~USB_OTG_DOEPTSIZ_PKTCNT; } FORCE_INLINE void Xfer_out_pkt_size(uint8_t ep_num, uint32_t len) { m_regs->out_eps[ep_num].DOEPTSIZ |= (USB_OTG_DOEPTSIZ_PKTCNT & (len << USB_OTG_DOEPTSIZ_PKTCNT_Pos)); } FORCE_INLINE void Xfer_out_pkt_end(uint8_t ep_num, uint32_t len) { m_regs->out_eps[ep_num].DOEPTSIZ |= (USB_OTG_DOEPTSIZ_XFRSIZ & len); } FORCE_INLINE void Xfer_out_enable_DMA(uint8_t ep_num, uint32_t dma_addr) { m_regs->out_eps[ep_num].DOEPDMA = dma_addr; } FORCE_INLINE void Xfer_out_set_odd_frame(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL |= USB_OTG_DOEPCTL_SODDFRM; } FORCE_INLINE void Xfer_out_set_data0_pid(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL |= USB_OTG_DOEPCTL_SD0PID_SEVNFRM; } FORCE_INLINE void Xfer_out_ep_enable(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL |= (USB_OTG_DOEPCTL_CNAK | USB_OTG_DOEPCTL_EPENA); } void write_packet(uint8_t* src, uint8_t ch_ep_num, uint32_t len, uint8_t dma); void* read_packet(uint8_t* dest, uint32_t len); FORCE_INLINE void write_FIFO(uint8_t cp_ep_num, uint32_t data) { m_regs->DFIFO[cp_ep_num * USB_OTG_FIFO_ONE_SIZE] = data; } FORCE_INLINE uint32_t read_FIFO(uint8_t cp_ep_num) { return m_regs->DFIFO[cp_ep_num * USB_OTG_FIFO_ONE_SIZE]; } void EP_set_stall(bool ep_is_in, uint8_t ep_num); void EP_clear_stall(bool ep_is_in, uint8_t ep_num, EEPType ep_type); FORCE_INLINE void ep_in_set_stall(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL |= USB_OTG_DIEPCTL_STALL; } FORCE_INLINE void ep_in_clear_stall(uint8_t ep_num) { m_regs->in_eps[ep_num].DIEPCTL &= ~USB_OTG_DIEPCTL_STALL; } FORCE_INLINE void ep_out_set_stall(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL |= USB_OTG_DOEPCTL_STALL; } FORCE_INLINE void ep_out_clear_stall(uint8_t ep_num) { m_regs->out_eps[ep_num].DOEPCTL &= ~USB_OTG_DOEPCTL_STALL; } void set_dev_address(uint8_t address); FORCE_INLINE void clear_dev_address() { m_regs->device.DCFG &= ~USB_OTG_DCFG_DAD; } FORCE_INLINE void set_dev_addr_RAW(uint8_t addr) { m_regs->device.DCFG |= (addr << 4) & USB_OTG_DCFG_DAD; } FORCE_INLINE void dev_connect() { m_regs->device.DCTL &= ~USB_OTG_DCTL_SDIS; STM32::SYSTICK::delay(3); } FORCE_INLINE void dev_disconnect() { m_regs->device.DCTL |= USB_OTG_DCTL_SDIS; STM32::SYSTICK::delay(3); } void stop_device(); FORCE_INLINE void clear_shared_IT() { m_regs->device.DAINT = 0xffffffff; } FORCE_INLINE void clear_in_IT() { m_regs->device.DIEPMSK = 0; } FORCE_INLINE void clear_out_IT() { m_regs->device.DOEPMSK = 0; } void activate_setup(); FORCE_INLINE void reset_max_pkt_size() { m_regs->in_eps[0].DIEPCTL &= ~USB_OTG_DIEPCTL_MPSIZ; } FORCE_INLINE void set_in_max_pkt_size(uint32_t max_size) { m_regs->in_eps[0].DIEPCTL |= max_size; } FORCE_INLINE void clear_in_global_NAK() { m_regs->device.DCTL |= USB_OTG_DCTL_CGINAK; } void EP0_out_start(uint8_t dma, uint8_t* psetup); FORCE_INLINE void ep_out_setup_packet_count() { m_regs->out_eps[0].DOEPTSIZ |= USB_OTG_DOEPTSIZ_STUPCNT; } FORCE_INLINE void ep_out_start_enable() { m_regs->out_eps[0].DOEPCTL |= (USB_OTG_DOEPCTL_USBAEP | USB_OTG_DOEPCTL_EPENA); } FORCE_INLINE EOTGDeviceMode get_mode() { return static_cast<EOTGDeviceMode>(m_regs->global.GINTSTS & 0x1); } FORCE_INLINE uint32_t read_IT() { return m_regs->global.GINTSTS & m_regs->global.GINTMSK; } FORCE_INLINE uint32_t read_dev_all_out_EP_IT() { return (((m_regs->device.DAINT & m_regs->device.DAINTMSK) & 0xffff0000) >> 16); } FORCE_INLINE uint32_t read_dev_out_EP_IT(uint8_t ep_num) { return (m_regs->out_eps[ep_num].DOEPINT & m_regs->device.DOEPMSK); } FORCE_INLINE uint32_t read_dev_all_in_EP_ITt() { return ((m_regs->device.DAINT & m_regs->device.DAINTMSK) & 0x0000ffff); } FORCE_INLINE uint32_t read_dev_in_EP_IT(uint8_t ep_num) { return (m_regs->in_eps[ep_num].DIEPINT & ((((m_regs->device.DIEPEMPMSK >> ep_num) & 1) << 7) | m_regs->device.DIEPMSK)); } FORCE_INLINE void clear_IT(uint32_t interrupts) { m_regs->global.GINTSTS |= interrupts; } uint32_t core_reset(); FORCE_INLINE bool is_master_idle() { return ((m_regs->global.GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == USB_OTG_GRSTCTL_AHBIDL); } FORCE_INLINE void core_soft_reset() { m_regs->global.GRSTCTL |= USB_OTG_GRSTCTL_CSRST; } FORCE_INLINE bool is_core_reseted() { return ((m_regs->global.GRSTCTL & USB_OTG_GRSTCTL_CSRST) != USB_OTG_GRSTCTL_CSRST); } void host_init(); ENDIS_REG_FLAG_NAME_SL(FS_LS_only, m_regs->host.HCFG, USB_OTG_HCFG_FSLSS) FORCE_INLINE void set_RX_FIFO_size(uint32_t size) { m_regs->global.GRXFSIZ = size; } FORCE_INLINE void set_RX_EP0_FIFO_size(uint32_t s0, uint32_t size) { m_regs->global.DIEPTXF0_HNPTXFSIZ = (((s0 << USB_OTG_NPTXFD_Pos) & USB_OTG_NPTXFD) | size); } FORCE_INLINE void set_TX_FIFO_size(uint32_t s0, uint32_t s1) { m_regs->global.HPTXFSIZ = (((s0 << USB_OTG_HPTXFSIZ_PTXFD_Pos) & USB_OTG_HPTXFSIZ_PTXFD) | s1); } void init_FSLSPClk_sel(EClockSpeed freq); ENDIS_REG_FLAG_NAME_SL(FS_LS_clock_sel, m_regs->host.HCFG, USB_OTG_HCFG_FSLSPCS) FORCE_INLINE void set_FSLSPClk(uint32_t val) { m_regs->host.HFIR = val; } void drive_VBUS(uint8_t state); FORCE_INLINE EOTGSpeed get_host_speed() { return static_cast<EOTGSpeed>((m_regs->ports[0] & USB_OTG_HPRT_PSPD) >> USB_OTG_HPRT_PSPD_Pos); } void HC_start_Xfer(OTG_HC_t *hc); FORCE_INLINE uint32_t HC_get_Xfer_size(uint8_t ch_num) { return m_regs->channels[ch_num].HCTSIZ; } FORCE_INLINE void HC_set_Xfer_size(uint8_t ch_num, uint32_t size, uint32_t numpkt, uint8_t PID) { m_regs->channels[ch_num].HCTSIZ = (size & USB_OTG_HCTSIZ_XFRSIZ) | ((numpkt << USB_OTG_HCTSIZ_PKTCNT_Pos) & USB_OTG_HCTSIZ_PKTCNT) | ((PID << USB_OTG_HCTSIZ_DPID_Pos) & USB_OTG_HCTSIZ_DPID); } FORCE_INLINE void HC_set_Xfer_DMA(uint8_t ch_num, uint8_t *buf) { m_regs->channels[ch_num].HCDMA = reinterpret_cast<uint32_t>(buf); } FORCE_INLINE void set_HC_odd_frame(uint8_t ch_num, uint32_t val) { m_regs->channels[ch_num].HCCHAR |= val; } FORCE_INLINE void disable_HC_odd_frame(uint8_t ch_num) { m_regs->channels[ch_num].HCCHAR &= ~USB_OTG_HCCHAR_ODDFRM; } FORCE_INLINE uint16_t get_TX_NP_FIFO_size() { return m_regs->global.HNPTXSTS & 0xffff; } FORCE_INLINE uint16_t get_TX_NP_FIFO_hi_size() { return m_regs->global.HNPTXSTS & 0xff0000; } FORCE_INLINE uint16_t get_TX_P_FIFO_size() { return m_regs->host.HPTXSTS & 0xffff; } FORCE_INLINE uint32_t HC_read_IT() { return m_regs->host.HAINT & 0xffff; } void do_ping(uint8_t ch_num); FORCE_INLINE void do_ping_LL(uint8_t ch_num) { m_regs->channels[ch_num].HCTSIZ = ((1 << USB_OTG_HCTSIZ_PKTCNT_Pos) & USB_OTG_HCTSIZ_PKTCNT) | USB_OTG_HCTSIZ_DOPING; } void stop_host(); FORCE_INLINE void HC_reactivate(uint8_t ch_num) { uint32_t tmp = HC_get_params(ch_num); tmp &= ~USB_OTG_HCCHAR_CHDIS; tmp |= USB_OTG_HCCHAR_CHENA; HC_set_param_RAW(ch_num, tmp); } void port_IRQ_handler(); void HC_in_IRQ_handler(uint8_t chnum); void HC_out_IRQ_handler(uint8_t chnum); void RXQLVL_IRQ_handler(); }; void connect_callback(STM32_HCD *hcd); void disconnect_callback(STM32_HCD *hcd); void SOF_callback(STM32_HCD *hcd); void HC_notify_URB_change_callback(STM32_HCD *hcd, uint8_t ch_num, STM32_HCD::EURBState urb_state); #ifdef STM32_USE_USB_FS extern STM32_HCD usb_fs; #endif #ifdef STM32_USE_USB_HS extern STM32_HCD usb_hs; #endif #endif //STM32_USE_USB_HOST #endif
56.166667
175
0.676391
8b776e58a3ec434d85341b1b297517b55e67eb39
3,532
c
C
bin/rs-canopen-ds401.c
follower/libcanopen
6e4758b55cca179f63105bc6f4d717b73d9e631e
[ "BSD-3-Clause" ]
46
2015-03-25T15:20:51.000Z
2022-02-25T02:52:55.000Z
bin/rs-canopen-ds401.c
follower/libcanopen
6e4758b55cca179f63105bc6f4d717b73d9e631e
[ "BSD-3-Clause" ]
9
2016-09-03T08:07:48.000Z
2019-04-22T12:32:56.000Z
bin/rs-canopen-ds401.c
follower/libcanopen
6e4758b55cca179f63105bc6f4d717b73d9e631e
[ "BSD-3-Clause" ]
28
2015-03-10T21:54:41.000Z
2021-11-12T12:34:50.000Z
//------------------------------------------------------------------------------ // Copyright (C) 2012, Robert Johansson <rob@raditex.nu>, Raditex AB // All rights reserved. // // This file is part of rSCADA. // // rSCADA // http://www.rSCADA.se // info@rscada.se //------------------------------------------------------------------------------ // sphinx documentation // //S //S rs-canopen-ds401 //S --------------------- //S //S Command line tool for reading and writing the state of CANopen DS401 nodes. //S #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <net/if.h> #include <unistd.h> #include <linux/can.h> #include <linux/can/raw.h> #include <string.h> #include <stdio.h> #include <canopen/canopen.h> int usage() { fprintf(stderr, "usage: rs-canopen-ds401 INTERFACE NODE COMMAND DEVICE ADDRESS [VALUE]\n"); fprintf(stderr, "\tINTERFACE = can0 | can1 | ...\n"); fprintf(stderr, "\tNODE\t = 0 .. 127\n"); fprintf(stderr, "\tCOMMAND\t = read | write\n"); fprintf(stderr, "\tDEVICE\t = di | do\n"); fprintf(stderr, "\tADDRESS\t = 0 .. 3\n"); fprintf(stderr, "\tVALUE\t = 0 | 1 [only for COMMAND = write]\n"); } int main(int argc, char **argv) { struct sockaddr_can addr; struct ifreq ifr; struct can_frame can_frame; canopen_frame_t canopen_frame; int sock, nbytes, n = 0, exp = 1; uint8_t node, address, subindex, data_array[256], value; uint16_t index; uint32_t data; bzero((void *)data_array, sizeof(data_array)); if (argc != 6 && argc != 7) { usage(); return 1; } if ((sock = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { fprintf(stderr, "Error: Failed to create socket.\n"); return 1; } strcpy(ifr.ifr_name, argv[1]); ioctl(sock, SIOCGIFINDEX, &ifr); // XXX add check addr.can_family = AF_CAN; addr.can_ifindex = ifr.ifr_ifindex; bind(sock, (struct sockaddr*)&addr, sizeof(addr)); // XXX Add check node = strtol(argv[2], NULL, 16); address = atoi(argv[5]); if (address > 8) { fprintf(stderr, "ERROR: address out of range [%d]\n", address); return 1; } if (strcmp(argv[4], "do") == 0) { index = 0x6200; } else if (strcmp(argv[4], "di") == 0) { index = 0x6000; } else { usage(); return; } if (strcmp(argv[3], "read") == 0 && argc == 6) { subindex = 0x01; if (canopen_sdo_upload_exp(sock, node, index, subindex, &data) != 0) { fprintf(stderr, "ERROR: expediated SDO upload failed\n"); return 1; } printf("%d\n", (data & (1<<address)) ? 1 : 0); } else if (strcmp(argv[3], "write") == 0 && index == 0x6200 && argc == 7) { subindex = 0x01; value = strcmp(argv[6], "1") == 0 ? 1 : 0; if (canopen_sdo_upload_exp(sock, node, index, subindex, &data) != 0) { fprintf(stderr, "ERROR: expediated SDO upload failed\n"); return 1; } if (value) { data |= (1 << address) & 0xFF; } else { data &= (~(1 << address)) & 0xFF; } if (canopen_sdo_download_exp(sock, node, index, subindex, data, 1) != 0) { printf("ERROR: Expediated SDO download failed.\n"); return 1; } } else { usage(); return 1; } return 0; }
23.236842
95
0.509343
6a68bc179da0f8966ec83d58dc53c85e6f04f80c
1,209
h
C
locomotion_framework/common/include/mwoibn/common/stack.h
ADVRHumanoids/DrivingFramework
34715c37bfe3c1f2bd92aeacecc12704a1a7820e
[ "Zlib" ]
1
2019-12-02T07:10:42.000Z
2019-12-02T07:10:42.000Z
locomotion_framework/common/include/mwoibn/common/stack.h
ADVRHumanoids/DrivingFramework
34715c37bfe3c1f2bd92aeacecc12704a1a7820e
[ "Zlib" ]
null
null
null
locomotion_framework/common/include/mwoibn/common/stack.h
ADVRHumanoids/DrivingFramework
34715c37bfe3c1f2bd92aeacecc12704a1a7820e
[ "Zlib" ]
2
2020-10-22T19:06:44.000Z
2021-06-07T03:32:52.000Z
#ifndef __MWOIBN__COMMON__STACK_H #define __MWOIBN__COMMON__STACK_H #include "mwoibn/common/types.h" #include "mwoibn/common/interfaces.h" #include "mwoibn/common/pipe.h" //#include <rbdl/rbdl.h> namespace mwoibn::common { template <typename Key, typename Type> class Stack { public: Stack() = default; Stack(const Stack& other) = default; Stack(Stack&& other) = default; Stack(std::initializer_list<Key> names) { for(auto& name: names) _interfaces[name] = Type(); } bool add(Key name){ if(_interfaces.count(name)) return false; _interfaces[name] = Type(); return true; } bool add(Key name, int size){ if(_interfaces.count(name)) return false; _interfaces[name] = Type(size); return true; } bool has(const Key& name){ return _interfaces.count(name); } void init(int dofs){ for(auto& name: _interfaces) name.second.init(dofs); } const Type& operator[] (const Key& name) const { return _interfaces.at(name); } Type& operator[] (const Key& name) { return _interfaces.at(name); } protected: std::map<Key, Type> _interfaces; }; } #endif // STATE_H
18.044776
50
0.632754
1dc831be39ffc6ef67c58669a793411e0e60ed75
13,923
h
C
source/util_api/http/include/http_wsto_interface.h
lgirdk/ccsp-common-library
8d912984e96f960df6dadb4b0e6bc76c76376776
[ "Apache-2.0" ]
4
2018-02-26T05:41:14.000Z
2019-12-20T07:31:39.000Z
source/util_api/http/include/http_wsto_interface.h
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
null
null
null
source/util_api/http/include/http_wsto_interface.h
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
3
2017-07-30T15:35:16.000Z
2020-08-18T20:44:08.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * 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. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **********************************************************************/ /********************************************************************** module: http_wsto_interface.h For HyperText Transfer Protocol Implementation (HTTP), BroadWay Service Delivery System --------------------------------------------------------------- description: This wrapper file defines all the platform-independent functions and macros for the Http Webs Trans Object. --------------------------------------------------------------- environment: platform independent --------------------------------------------------------------- author: Xuechen Yang --------------------------------------------------------------- revision: 03/07/02 initial revision. **********************************************************************/ #ifndef _HTTP_WSTO_INTERFACE_ #define _HTTP_WSTO_INTERFACE_ /* * This object is derived a virtual base object defined by the underlying framework. We include the * interface header files of the base object here to shield other objects from knowing the derived * relationship between this object and its base class. */ #include "ansc_co_interface.h" #include "ansc_co_external_api.h" #include "http_properties.h" /*********************************************************** HTTP WEBS TRANS OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the object mapper object definition. */ #define HTTP_WSTO_STATE_INITIALIZED 0 #define HTTP_WSTO_STATE_CLIENT_CONNECTED 1 #define HTTP_WSTO_STATE_ESTABLISHED 2 #define HTTP_WSTO_STATE_FINISHED 3 #define HTTP_WSTO_QMODE_COLLECT 1 #define HTTP_WSTO_QMODE_PROCESS 2 #define HTTP_WSTO_SFLAG_HEADERS 0x00000001 #define HTTP_WSTO_SFLAG_BODY 0x00000002 /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_HTTPWSTO_GET_CONTEXT) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_SET_CONTEXT) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hContext ); typedef ANSC_HANDLE (*PFN_HTTPWSTO_GET_IF) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_SET_IF) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hInterface ); typedef ULONG (*PFN_HTTPWSTO_GET_MODE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_SET_MODE) ( ANSC_HANDLE hThisObject, ULONG ulMode ); typedef ULONG (*PFN_HTTPWSTO_GET_STATE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_SET_STATE) ( ANSC_HANDLE hThisObject, ULONG ulState ); typedef PUCHAR (*PFN_HTTPWSTO_GET_ADDR) ( ANSC_HANDLE hThisObject ); typedef USHORT (*PFN_HTTPWSTO_GET_PORT) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_GET_PROPERTY) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hProperty ); typedef ANSC_STATUS (*PFN_HTTPWSTO_SET_PROPERTY) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hProperty ); typedef ANSC_STATUS (*PFN_HTTPWSTO_RETURN) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_RESET) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_OPEN) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_CLOSE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_ENGAGE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_CANCEL) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_ACQUIRE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_RELEASE) ( ANSC_HANDLE hThisObject ); typedef ANSC_HANDLE (*PFN_HTTPWSTO_GET_BMO) ( ANSC_HANDLE hThisObject ); typedef ANSC_HANDLE (*PFN_HTTPWSTO_GET_BMO_BYID) ( ANSC_HANDLE hThisObject, ULONG id ); typedef ANSC_HANDLE (*PFN_HTTPWSTO_ADD_BMO) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_HTTPWSTO_DEL_ALL) ( ANSC_HANDLE hThisObject ); typedef ANSC_HANDLE (*PFN_HTTPWSTO_GET_BUFFER) ( ANSC_HANDLE hThisObject ); typedef ULONG (*PFN_HTTPWSTO_QUERY) ( ANSC_HANDLE hThisObject, PVOID buffer, ULONG ulSize, ANSC_HANDLE hBufferContext ); typedef ANSC_STATUS (*PFN_HTTPWSTO_RECV) ( ANSC_HANDLE hThisObject, PVOID buffer, ULONG ulSize, ANSC_HANDLE hBufferContext ); typedef ANSC_STATUS (*PFN_HTTPWSTO_SEND) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hMessage, ULONG ulSendFlags ); typedef ANSC_STATUS (*PFN_HTTPWSTO_FINISH) ( ANSC_HANDLE hThisObject, PVOID buffer, ULONG ulSize, ANSC_HANDLE hBufferContext ); typedef ANSC_STATUS (*PFN_HTTPWSTO_TMH_NOTIFY) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hMessage, ULONG ulEvent, ANSC_HANDLE hReserved ); typedef ANSC_STATUS (*PFN_HTTPWSTO_TMH_SERIALIZE) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hMessage, PVOID buffer, ULONG ulSize, ANSC_HANDLE hSerializeContext ); /* * A significant difference between HTTP/1.1 and earlier versions of HTTP is that persistent co- * nnetions are the default behavior of any HTTP connection. That is, unless otherwise indicated, * the client SHOULD assme that the server will maintain a persistent connection, even after error * responses from the server. * * The HTTP Simple Proxy Object creates a unique outbound session for each inbound HTTP session: * the closing of either session will bring down the other. The proxy itself does NOT contribute * to the maintainence of the persistent connection. Note that more sophisticated HTTP proxies MAY * employ different session management to cope with following requirements: * * $ providing cached response directly to the clients * $ enable outbound session sharing if multiple clients is requesting the same URL * $ maintain inbound and outbound sessions separately for better efficiency */ #define HTTP_WEBS_TRANS_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSCCO_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hWspIf; \ ANSC_HANDLE hHfpIf; \ ANSC_HANDLE hTmhIf; \ ANSC_HANDLE hWebsSession; \ ANSC_HANDLE hBmoReq; \ ANSC_HANDLE hBmoRep; \ ANSC_HANDLE hWebSocket; \ ULONG TransState; \ ANSC_LOCK AccessLock; \ \ PFN_HTTPWSTO_GET_IF GetWspIf; \ PFN_HTTPWSTO_SET_IF SetWspIf; \ PFN_HTTPWSTO_GET_IF GetHfpIf; \ PFN_HTTPWSTO_SET_IF SetHfpIf; \ \ PFN_HTTPWSTO_GET_CONTEXT GetWebsSession; \ PFN_HTTPWSTO_SET_CONTEXT SetWebsSession; \ PFN_HTTPWSTO_GET_CONTEXT GetBmoReq; \ PFN_HTTPWSTO_SET_CONTEXT SetBmoReq; \ PFN_HTTPWSTO_GET_CONTEXT GetBmoRep; \ PFN_HTTPWSTO_SET_CONTEXT SetBmoRep; \ PFN_HTTPWSTO_GET_CONTEXT GetWebSocket; \ PFN_HTTPWSTO_SET_CONTEXT SetWebSocket; \ PFN_HTTPWSTO_GET_ADDR GetClientAddr; \ PFN_HTTPWSTO_GET_PORT GetClientPort; \ PFN_HTTPWSTO_GET_STATE GetTransState; \ PFN_HTTPWSTO_SET_STATE SetTransState; \ \ PFN_HTTPWSTO_RETURN Return; \ PFN_HTTPWSTO_RESET Reset; \ \ PFN_HTTPWSTO_OPEN Open; \ PFN_HTTPWSTO_CLOSE Close; \ \ PFN_HTTPWSTO_ACQUIRE AcquireAccess; \ PFN_HTTPWSTO_RELEASE ReleaseAccess; \ \ PFN_HTTPWSTO_QUERY Query; \ PFN_HTTPWSTO_RECV Recv; \ PFN_HTTPWSTO_SEND Send; \ PFN_HTTPWSTO_FINISH Finish; \ \ PFN_HTTPWSTO_TMH_NOTIFY TmhNotify; \ PFN_HTTPWSTO_TMH_SERIALIZE TmhSerialize; \ /* end of object class content */ \ typedef struct _HTTP_WEBS_TRANS_OBJECT { HTTP_WEBS_TRANS_CLASS_CONTENT } HTTP_WEBS_TRANS_OBJECT, *PHTTP_WEBS_TRANS_OBJECT; #define ACCESS_HTTP_WEBS_TRANS_OBJECT(p) \ ACCESS_CONTAINER(p, HTTP_WEBS_TRANS_OBJECT, Linkage) #endif
35.159091
99
0.463621
3d93bc15b686bb98abc9cf1f15a370d573218025
335
c
C
src/logmsg/logmsg.c
hacpjc/libgdu
b1a4ff9a279442c2fad968c58dee6d32d01e2a60
[ "MIT" ]
null
null
null
src/logmsg/logmsg.c
hacpjc/libgdu
b1a4ff9a279442c2fad968c58dee6d32d01e2a60
[ "MIT" ]
null
null
null
src/logmsg/logmsg.c
hacpjc/libgdu
b1a4ff9a279442c2fad968c58dee6d32d01e2a60
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <stdarg.h> #include <syslog.h> #include <string.h> #include "logmsg.h" /*! * open syslog * * \param name */ void logmsg_init(const char *name) { openlog(name, LOG_NDELAY | LOG_NOWAIT, LOG_DAEMON); } void logmsg_exit(void) { closelog(); }
12.884615
52
0.671642
d46084632cb4e9e98062ec19df8f08d1c11567e5
3,899
h
C
freebsd3/sys/pci/pci_ioctl.h
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
91
2015-01-05T15:18:31.000Z
2022-03-11T16:43:28.000Z
freebsd3/sys/pci/pci_ioctl.h
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
1
2016-02-25T15:57:55.000Z
2016-02-25T16:01:02.000Z
freebsd3/sys/pci/pci_ioctl.h
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
21
2015-02-07T08:23:07.000Z
2021-12-14T06:01:49.000Z
#ifndef _PCI_IOCTL_H #define _PCI_IOCTL_H 1 #include <sys/ioccom.h> #define PCI_MAXNAMELEN 16 /* max no. of characters in a device name */ typedef enum { PCI_GETCONF_LAST_DEVICE, PCI_GETCONF_LIST_CHANGED, PCI_GETCONF_MORE_DEVS, PCI_GETCONF_ERROR } pci_getconf_status; typedef enum { PCI_GETCONF_NO_MATCH = 0x00, PCI_GETCONF_MATCH_BUS = 0x01, PCI_GETCONF_MATCH_DEV = 0x02, PCI_GETCONF_MATCH_FUNC = 0x04, PCI_GETCONF_MATCH_NAME = 0x08, PCI_GETCONF_MATCH_UNIT = 0x10, PCI_GETCONF_MATCH_VENDOR = 0x20, PCI_GETCONF_MATCH_DEVICE = 0x40, PCI_GETCONF_MATCH_CLASS = 0x80 } pci_getconf_flags; struct pcisel { u_int8_t pc_bus; /* bus number */ u_int8_t pc_dev; /* device on this bus */ u_int8_t pc_func; /* function on this device */ }; struct pci_conf { struct pcisel pc_sel; /* bus+slot+function */ u_int8_t pc_hdr; /* PCI header type */ u_int16_t pc_subvendor; /* card vendor ID */ u_int16_t pc_subdevice; /* card device ID, assigned by card vendor */ u_int16_t pc_vendor; /* chip vendor ID */ u_int16_t pc_device; /* chip device ID, assigned by chip vendor */ u_int8_t pc_class; /* chip PCI class */ u_int8_t pc_subclass; /* chip PCI subclass */ u_int8_t pc_progif; /* chip PCI programming interface */ u_int8_t pc_revid; /* chip revision ID */ char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral device */ u_long pd_unit; /* Unit number */ }; struct pci_match_conf { struct pcisel pc_sel; /* bus+slot+function */ char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral device */ u_long pd_unit; /* Unit number */ u_int16_t pc_vendor; /* PCI Vendor ID */ u_int16_t pc_device; /* PCI Device ID */ u_int8_t pc_class; /* PCI class */ pci_getconf_flags flags; /* Matching expression */ }; struct pci_conf_io { u_int32_t pat_buf_len; /* * Length of buffer passed in from * user space. */ u_int32_t num_patterns; /* * Number of pci_match_conf structures * passed in by the user. */ struct pci_match_conf *patterns; /* * Patterns passed in by the user. */ u_int32_t match_buf_len;/* * Length of match buffer passed * in by the user. */ u_int32_t num_matches; /* * Number of matches returned by * the kernel. */ struct pci_conf *matches; /* * PCI device matches returned by * the kernel. */ u_int32_t offset; /* * Passed in by the user code to * indicate where the kernel should * start traversing the device list. * The value passed out by the kernel * points to the record immediately * after the last one returned. * i.e. this value may be passed back * unchanged by the user for a * subsequent call. */ u_int32_t generation; /* * PCI configuration generation. * This only needs to be set if the * offset is set. The kernel will * compare its current generation * number to the generation passed * in by the user to determine * whether the PCI device list has * changed since the user last * called the GETCONF ioctl. */ pci_getconf_status status; /* * Status passed back from the * kernel. */ }; struct pci_io { struct pcisel pi_sel; /* device to operate on */ int pi_reg; /* configuration register to examine */ int pi_width; /* width (in bytes) of read or write */ u_int32_t pi_data; /* data to write or result of read */ }; #define PCIOCGETCONF _IOWR('p', 1, struct pci_conf_io) #define PCIOCREAD _IOWR('p', 2, struct pci_io) #define PCIOCWRITE _IOWR('p', 3, struct pci_io) #define PCIOCATTACHED _IOWR('p', 4, struct pci_io) #endif /* _PCI_IOCTL_H */
30.224806
70
0.639908
89059cdade20164dd9bbc31353ce0b166d7a3857
1,607
c
C
platform/baikal_t1_board/board/uart.c
zanon005/hellfire-hypervisor
695ebba6ce8cd5c7c547158d68c8351c4f43ddef
[ "ISC" ]
36
2016-07-08T17:53:39.000Z
2021-03-04T17:32:16.000Z
platform/baikal_t1_board/board/uart.c
zanon005/hellfire-hypervisor
695ebba6ce8cd5c7c547158d68c8351c4f43ddef
[ "ISC" ]
7
2017-01-06T21:03:43.000Z
2017-11-27T14:21:48.000Z
platform/baikal_t1_board/board/uart.c
zanon005/hellfire-hypervisor
695ebba6ce8cd5c7c547158d68c8351c4f43ddef
[ "ISC" ]
10
2016-09-24T15:13:01.000Z
2018-09-26T19:14:32.000Z
/* * Copyright (c) 2016, prpl Foundation * * Permission to use, copy, modify, and/or distribute this software for any purpose with or without * fee is hereby granted, provided that the above copyright notice and this permission notice appear * in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. * */ #include <config.h> #include <types.h> #include <baikal-t1.h> #include <uart.h> /** * @file uart.c * * @section DESCRIPTION * * UART initialization and low level UART functions. * */ /** * @brief Configures UART2 as stdout and UART6 as alternative. * @param baudrate_u2 UART2 baudrate. * @param baudrate_u6 UART6 baudrate. * @param sysclk System clock. */ void init_uart(uint32_t baudrate_u2, uint32_t baudrate_u6, uint32_t sysclk){ } /** * @brief Write char to UART2. * @param c Character to be writed. */ void putchar(uint8_t c){ while( !(UART0_LSR&0x40) ); UART0_RBR = c; } /** * @brief Block and wait for a character. * @return Read character. */ uint32_t getchar(void){ }
26.344262
107
0.713752
c70da7cf5ee5780f3580ffb2d0c5a12a182c5df4
2,030
h
C
helpers/include/SimpleGL/helpers/camera.h
danem/SimpleGL
aa9e1a1b5ac8de0a294b5e1f3e3146aec4de4251
[ "MIT" ]
3
2017-10-10T21:19:07.000Z
2022-01-14T02:15:03.000Z
helpers/include/SimpleGL/helpers/camera.h
danem/SimpleGL
aa9e1a1b5ac8de0a294b5e1f3e3146aec4de4251
[ "MIT" ]
null
null
null
helpers/include/SimpleGL/helpers/camera.h
danem/SimpleGL
aa9e1a1b5ac8de0a294b5e1f3e3146aec4de4251
[ "MIT" ]
null
null
null
#pragma once #include "event.h" #include <glm/vec3.hpp> #include <glm/vec4.hpp> #include <glm/mat4x4.hpp> namespace sgl { class CameraBase { public: glm::vec3 position; glm::vec3 up; glm::vec3 looking; glm::mat4 viewMatrix; CameraBase () : up(0.f, 1.f, 0.f) { update(); } void updateViewMatrix (); virtual void update (); float * getView (); }; class PerspectiveCamera : public CameraBase { protected: public: glm::mat4 perspectiveMatrix; float width; float height; float aspect; float near = 0.1f; float far = 1000; float zoom = 1; float fov = 45; float focus = 10; PerspectiveCamera (uint32_t w, uint32_t h) : CameraBase(), width(w), height(h), aspect((float)w/h) { update(); } void updateProjection (); void update () override; float * getProjection (); }; class OrthoCamera : public CameraBase { protected: public: glm::mat4 perspectiveMatrix; float near = 1.0f; float far = 7.5f; float left = -10.0f; float right = 10.0f; float top = 10.0f; float bottom = -10.0f; OrthoCamera (float near, float far) : CameraBase(), near(near), far(far) { update(); } void updateProjection (); void update () override; float * getProjection (); void setFrustrum (float left, float right, float top, float bottom, float near, float far); }; class CameraController : public MouseDraggerBase { private: float _width; float _height; CameraBase& _camera; glm::vec3 _originalPos; glm::vec3 _originalLook; public: CameraController (float w, float h, CameraBase& camera) : MouseDraggerBase(), _width(w), _height(h), _camera(camera) {} void onDragStart () override; void onDragEnd () override; void onDrag (const sgl::DragEvent& event) override; void onScroll(double sx, double sy) override; }; } // end namespace
18.288288
95
0.60197
54ca600f07ce17c50570c474d9457aa8a44334d7
240
c
C
Chapter8/Lecture6/lecture6.c
jmhong-simulation/tbc-workbook
e342856573537e89472a12f1d3fc373c8a227949
[ "Unlicense" ]
35
2020-05-17T04:26:19.000Z
2022-03-01T03:05:10.000Z
Chapter8/Lecture6/lecture6.c
learner-nosilv/TBC-workbook
77365b2ed482a7695a64283c846e67b88dd66f64
[ "Unlicense" ]
null
null
null
Chapter8/Lecture6/lecture6.c
learner-nosilv/TBC-workbook
77365b2ed482a7695a64283c846e67b88dd66f64
[ "Unlicense" ]
16
2020-05-27T10:29:10.000Z
2022-03-01T03:05:19.000Z
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> //long get_long(void); int main() { return 0; } //long get_long(void) //{ // printf("Please input an integer and press enter.\n"); // // long input; // // // // // return input; //}
9.6
56
0.616667
0730f0c6de3d0644c60ebae8e26a6da1b78fb23e
993
h
C
System/Library/Frameworks/HealthKit.framework/_HKAppURLSpecification.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
1
2020-11-11T06:05:23.000Z
2020-11-11T06:05:23.000Z
System/Library/Frameworks/HealthKit.framework/_HKAppURLSpecification.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
System/Library/Frameworks/HealthKit.framework/_HKAppURLSpecification.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.5 * on Tuesday, November 10, 2020 at 10:14:54 PM Mountain Standard Time * Operating System: Version 14.2 (Build 18K57) * Image Source: /System/Library/Frameworks/HealthKit.framework/HealthKit * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @interface _HKAppURLSpecification : NSObject +(BOOL)isClinicalOnboardingURL:(id)arg1 ; +(BOOL)isClinicalLoginRedirectURL:(id)arg1 ; +(BOOL)parseClinicalOnboardingURL:(id)arg1 resultHandler:(/*^block*/id)arg2 errorHandler:(/*^block*/id)arg3 ; +(BOOL)parseClinicalLoginRedirectURL:(id)arg1 resultHandler:(/*^block*/id)arg2 errorHandler:(/*^block*/id)arg3 ; +(BOOL)isAtrialFibrillationEventURL:(id)arg1 ; +(BOOL)isViewHealthRecordsURL:(id)arg1 ; +(BOOL)isHealthRecordsProviderSearchURL:(id)arg1 ; @end
49.65
130
0.668681
32e9d01393a7f495124ec3c8e7ce72cd9f506cdd
705
h
C
c_aacgmv2/include/mlt_v2.h
gagatust/aacgmv2
fdc1aefe72f747d256a9a666982d7ac09d571203
[ "MIT" ]
16
2018-05-09T08:04:46.000Z
2022-02-11T19:10:49.000Z
c_aacgmv2/include/mlt_v2.h
gagatust/aacgmv2
fdc1aefe72f747d256a9a666982d7ac09d571203
[ "MIT" ]
48
2018-03-08T22:57:57.000Z
2021-12-07T10:18:37.000Z
c_aacgmv2/include/mlt_v2.h
gagatust/aacgmv2
fdc1aefe72f747d256a9a666982d7ac09d571203
[ "MIT" ]
11
2018-03-16T12:50:58.000Z
2021-08-19T17:35:54.000Z
#ifndef _MLT_v2_H #define _MLT_v2_H double MLTConvert_v2(int yr, int mo, int dy, int hr, int mt ,int sc, double mlon); double inv_MLTConvert_v2(int yr, int mo, int dy, int hr, int mt ,int sc, double mlt); double MLTConvertYMDHMS_v2(int yr,int mo,int dy,int hr,int mt,int sc, double mlon); double inv_MLTConvertYMDHMS_v2(int yr,int mo,int dy,int hr,int mt,int sc, double mlt); double MLTConvertYrsec_v2(int yr,int yrsec, double mlon); double inv_MLTConvertYrsec_v2(int yr,int yrsec, double mlt); double MLTConvertEpoch_v2(double epoch, double mlon); double inv_MLTConvertEpoch_v2(double epoch, double mlt); #endif
35.25
73
0.679433
b0a1c3525e7f9ac8517aa1cf40751ef2460eb952
887
h
C
libsupport/IconEx.h
gA4ss/cerberus
0023dba54a27e6f87acb9dfec9b5fcda0e611bbf
[ "MIT" ]
7
2020-08-17T09:09:53.000Z
2022-02-02T07:23:57.000Z
libsupport/IconEx.h
gA4ss/cerberus
0023dba54a27e6f87acb9dfec9b5fcda0e611bbf
[ "MIT" ]
null
null
null
libsupport/IconEx.h
gA4ss/cerberus
0023dba54a27e6f87acb9dfec9b5fcda0e611bbf
[ "MIT" ]
7
2020-08-17T09:09:55.000Z
2021-09-24T03:49:36.000Z
typedef struct tagHEADER { __word idReserved; __word idType; __word idCount; }HEADER, *LPHEADER; typedef struct tagICONDIRENTRY { __byte bWidth; __byte bHeight; __byte bColorCount; __byte bReserved; __word wPlanes; __word wBitCount; __dword dwBytesInRes; __dword dwImageOffset; } ICONDIRENTRY, *LPICONDIRENTRY; #pragma pack( push ) #pragma pack( 2 ) typedef struct tagGRPICONDIRENTRY { __byte bWidth; __byte bHeight; __byte bColorCount; __byte bReserved; __word wPlanes; __word wBitCount; __dword dwBytesInRes; __word nID; } GRPICONDIRENTRY, *LPGRPICONDIRENTRY;; typedef struct tagGRPICONDIR { __word idReserved; __word idType; __word idCount; GRPICONDIRENTRY idEntries[1]; }GRPICONDIR, *LPGRPICONDIR; #pragma pack( pop )
23.342105
41
0.657272
11d0f615f54863a4a904a12b6033a156fdfba364
4,453
h
C
src/nxt/NXTControl.h
AsafeSilva/NXTControl
d8578dae9ad5d7b2fdd22daf0ef49f5e0f058b51
[ "Apache-2.0" ]
null
null
null
src/nxt/NXTControl.h
AsafeSilva/NXTControl
d8578dae9ad5d7b2fdd22daf0ef49f5e0f058b51
[ "Apache-2.0" ]
null
null
null
src/nxt/NXTControl.h
AsafeSilva/NXTControl
d8578dae9ad5d7b2fdd22daf0ef49f5e0f058b51
[ "Apache-2.0" ]
null
null
null
/** * * NXTControl.h * * Biblioteca para controle do NXT via Arduino * * Criado em 2016 * Por Asafe Silva (github: @AsafeSilva | e-mail: asafesilva01@gmail.com) * */ #ifndef NXTControl_h #define NXTControl_h #include <Arduino.h> #include "HardwareSerial.h" #define DIRECT_COMMAND 0x80 #define DIRECT_COMMAND_RESPONSE 0x00 // Direct commands #define COMMAND_START_PROGRAM 0x00 #define COMMAND_STOP_PROGRAM 0x01 #define COMMAND_PLAY_SOUND_FILE 0x02 #define COMMAND_PLAY_TONE 0x03 #define COMMAND_SET_OUTPUT_STATE 0x04 #define COMMAND_SET_INPUT_MODE 0x05 #define COMMAND_GET_OUTPUT_STATE 0x06 #define COMMAND_GET_INPUT_VALUES 0x07 #define COMMAND_RESET_INPUT_SCALED_VALUE 0x08 #define COMMAND_MESSAGE_WRITE 0x09 #define COMMAND_RESET_MOTOR_POSITION 0x0A #define COMMAND_GET_BATTERY_LEVEL 0x0B #define COMMAND_STOP_SOUND_PLAYBACK 0x0C #define COMMAND_KEEP_ALIVE 0x0D #define COMMAND_LS_GET_STATUS 0x0E #define COMMAND_LS_WRITE 0x0F #define COMMAND_LS_READ 0x10 #define COMMAND_GET_CURRENT_PROGRAM_NAME 0x11 #define COMMAND_MESSAGE_READ 0x13 // Valide enumaration for "Output Port" #define OUT_A 0x00 #define OUT_B 0x01 #define OUT_C 0x02 #define OUT_AB 0x03 #define OUT_AC 0x04 #define OUT_BC 0x05 #define OUT_ABC 0x06 // Valide enumaration for "Output Mode" #define MODE_MOTOR_ON 0x01 #define MODE_BRAKE 0x02 #define MODE_REGULATED 0x04 // Valide enumaration for Output "Regulation Mode" #define REGMODE_IDLE 0x00 #define REGMODE_SPEED 0x01 #define REGMODE_SYNC 0x02 // Valide enumaration for Output "Run State" #define RUNSTATE_IDLE 0x00 #define RUNSTATE_RAMPUP 0x10 #define RUNSTATE_RUNNING 0x20 #define RUNSTATE_RAMPDOWN 0x40 // Valide enumaration for Input "Port" #define S1 0 #define S2 1 #define S3 2 #define S4 3 // Valide enumaration for Input "Sensor Type" #define NO_SENSOR 0x00 #define SWITCH 0x01 #define TEMPERATURE 0x02 #define REFLECTION 0x03 #define ANGLE 0x04 #define LIGHT_ACTIVE 0x05 #define LICHT_INACTIVE 0x06 #define SOUND_DB 0x07 #define SOUND_DBA 0x08 #define CUSTOM 0x09 #define LOWSPEED 0x0A #define LOWSPEED_9V 0x0B #define NO_OF_SENSOR_TYPES 0x0C // Valide enumaration for Input "Sensor Mode" #define RAW_MODE 0x00 #define BOOLEAN_MODE 0x20 #define TRANSITION_COUNTER_MODE 0x40 #define PERIOD_COUNTER_MODE 0x60 #define PCT_FULL_SCALE_MODE 0x80 #define CELSIUS_MODE 0xA0 #define FAHRENHEIT_MODE 0xC0 #define ANGLE_STEPS_MODE 0xE0 #define SLOPE_MASK 0x1F #define MODE_MASK 0xE0 typedef int8_t sbyte; // Package returned by GetOutputState function struct OutputState{ byte statusByte = 1; byte port; sbyte power; byte mode; byte regulationMode; sbyte turnRatio; byte runState; unsigned long tachoLimit; long tachoCount; long blockTachoCount; long rotationCount; }; // Package returned by GetInputValues function struct InputValues{ byte statusByte = 1; byte port; bool isValid; bool isCalibrated; byte sensorType; byte sensorMode; unsigned int rawValue; unsigned int normalizedValue; int scaledValue; int calibratedValue; }; #define WAIT_TIME 45 #define byteRead(x,n) ((uint8_t) ((x >> 8*n) & 0xFF)) class NXTControl{ public: NXTControl(); NXTControl(Stream &serial); void StartProgram(String name); void StopProgram(); void PlayTone(unsigned int frequency, unsigned int duration); void SetOutputState(byte port, sbyte power, byte mode, byte regulationMode, sbyte turnRatio, byte runState, unsigned long tachoLimit = 0); void OnFwd(byte port, sbyte power); void OnRev(byte port, sbyte power); void OnFwdReg(byte port, sbyte power, byte regMode); void OnRevReg(byte port, sbyte power, byte regMode); void Off(byte port); void SetInputMode(byte port, byte sensorType, byte sensorMode); bool GetOutputState(byte port, OutputState &params); bool GetInputValues(byte port, InputValues &params); // void ResetInputScaledValue(byte port); // void MessageWrite(byte inboxNumber, int messageSize, byte* messageData); // byte* MessageRead(byte remoteInboxNumber, byte localInboxNumber, bool remove); void ResetMotorPosition(byte port, bool isRelative); void RotateMotor(byte port, sbyte power, int degrees); // int GetBateryLevel(); // void LSWrite(); // void LSGetStatus(); // void LSRead(); private: Stream *_serial; }; #endif
22.953608
83
0.752302
3e6959413d4a99582d12634e2c488f1f0e693cdf
2,727
h
C
src/LoadFasta.h
qwang-big/flexbar
e2f5382895edae9d63f76f07aaaa79c055f8c5ec
[ "BSD-3-Clause" ]
88
2015-09-10T14:18:33.000Z
2022-03-10T12:37:43.000Z
src/LoadFasta.h
qwang-big/flexbar
e2f5382895edae9d63f76f07aaaa79c055f8c5ec
[ "BSD-3-Clause" ]
33
2015-11-13T09:42:09.000Z
2022-01-18T13:14:24.000Z
src/LoadFasta.h
qwang-big/flexbar
e2f5382895edae9d63f76f07aaaa79c055f8c5ec
[ "BSD-3-Clause" ]
38
2015-09-11T10:14:17.000Z
2022-01-18T13:02:06.000Z
// LoadFasta.h #ifndef FLEXBAR_LOADFASTA_H #define FLEXBAR_LOADFASTA_H template <typename TSeqStr, typename TString> class LoadFasta { private: std::ostream *out; tbb::concurrent_vector<flexbar::TBar> bars; const bool m_isAdapter; const flexbar::RevCompMode m_rcMode; public: LoadFasta(const Options &o, const bool isAdapter) : out(o.out), m_rcMode(o.rcMode), m_isAdapter(isAdapter){ }; virtual ~LoadFasta(){}; void loadSequences(const std::string filePath){ using namespace std; using namespace flexbar; seqan::DatFastaSeqFileIn seqFileIn; if(! open(seqFileIn, filePath.c_str())){ cerr << "\nERROR: Could not open file " << filePath << "\n" << endl; exit(1); } try{ TSeqStrs seqs; TStrings ids; readRecords(ids, seqs, seqFileIn); map<TString, short> idMap; for(unsigned int i = 0; i < length(ids); ++i){ if(idMap.count(ids[i]) == 1){ cerr << "Two "; if(m_isAdapter) cerr << "adapters"; else cerr << "barcodes"; cerr << " have the same name.\n"; cerr << "Please use unique names and restart.\n" << endl; exit(1); } else idMap[ids[i]] = 1; if(! m_isAdapter || m_rcMode == RCOFF || m_rcMode == RCON){ TBar bar; bar.id = ids[i]; bar.seq = seqs[i]; bars.push_back(bar); } if(m_isAdapter && (m_rcMode == RCON || m_rcMode == RCONLY)){ TString id = ids[i]; TSeqStr seq = seqs[i]; append(id, "_rc"); seqan::reverseComplement(seq); TBar barRC; barRC.id = id; barRC.seq = seq; barRC.rcAdapter = true; bars.push_back(barRC); } } } catch(seqan::Exception const &e){ cerr << "\nERROR: " << e.what() << "\nProgram execution aborted.\n" << endl; close(seqFileIn); exit(1); } close(seqFileIn); }; tbb::concurrent_vector<flexbar::TBar> getBars(){ return bars; } void setBars(tbb::concurrent_vector<flexbar::TBar> &newBars){ bars = newBars; } void printBars(std::string adapterName) const { using namespace std; const unsigned int maxSpaceLen = 23; stringstream s; s << adapterName; int len = s.str().length() + 1; if(len + 2 > maxSpaceLen) len = maxSpaceLen - 2; *out << adapterName << ":" << string(maxSpaceLen - len, ' ') << "Sequence:" << "\n"; for(unsigned int i=0; i < bars.size(); ++i){ TString seqTag = bars.at(i).id; int whiteSpaceLen = maxSpaceLen - length(seqTag); if(whiteSpaceLen < 2) whiteSpaceLen = 2; string whiteSpace = string(whiteSpaceLen, ' '); *out << seqTag << whiteSpace << bars.at(i).seq << "\n"; } *out << endl; } }; #endif
20.051471
86
0.586359
e983e6aa01706755065bae9bb7d62e18a1b812ac
1,123
c
C
SvinLog/SvinLog/SvinLog/Logs/SLSocketLog/SLSocketLogServer.c
svinvy/SvinLog
d5bf5691a1ff8817e267e0b3a7cc90c1d5ffb408
[ "MIT" ]
null
null
null
SvinLog/SvinLog/SvinLog/Logs/SLSocketLog/SLSocketLogServer.c
svinvy/SvinLog
d5bf5691a1ff8817e267e0b3a7cc90c1d5ffb408
[ "MIT" ]
null
null
null
SvinLog/SvinLog/SvinLog/Logs/SLSocketLog/SLSocketLogServer.c
svinvy/SvinLog
d5bf5691a1ff8817e267e0b3a7cc90c1d5ffb408
[ "MIT" ]
null
null
null
// // SLSocketLogServer.c // SvinLog // // include this file for your routine program and call the function to bind the port and listening... // Created by GJP on 2018/3/23. // Copyright © 2018年 svinvy.lnc. All rights reserved. // #include "SLSocketLogServer.h" void listening(int port,char**err) { int listenfd,connfd; pid_t childpid; socklen_t cli_len; IPv4 cliaddr,servaddr; listenfd = socket(AF_INET, SOCK_STREAM, 0); if (listenfd) { *err = "Create socket fd failed!!!";return; } servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(port); if (bind(listenfd, (SA*)&servaddr, sizeof(servaddr))==-1) { *err = "bind port fail!";return; } if (listen(listenfd, 10)!=0) { *err = "listen at fd fail!";return; } while (1) { cli_len = sizeof(cliaddr); connfd = accept(listenfd, (SA*)&cliaddr, &cli_len); if ((childpid=fork())!=0) {close(connfd);} else { close(listenfd); /* read the messages */ } } }
25.522727
102
0.590383
e9997ccb778e512a4604a695226aae20e28d2d34
100,681
c
C
third_party/mesa/src/src/mesa/main/fbobject.c
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
third_party/mesa/src/src/mesa/main/fbobject.c
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
third_party/mesa/src/src/mesa/main/fbobject.c
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
/* * Mesa 3-D graphics library * Version: 7.1 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 1999-2009 VMware, 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 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 * BRIAN PAUL 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. */ /* * GL_EXT/ARB_framebuffer_object extensions * * Authors: * Brian Paul */ #include "buffers.h" #include "context.h" #include "enums.h" #include "fbobject.h" #include "formats.h" #include "framebuffer.h" #include "glformats.h" #include "hash.h" #include "macros.h" #include "mfeatures.h" #include "mtypes.h" #include "renderbuffer.h" #include "state.h" #include "teximage.h" #include "texobj.h" /** Set this to 1 to debug/log glBlitFramebuffer() calls */ #define DEBUG_BLIT 0 /** * Notes: * * None of the GL_EXT_framebuffer_object functions are compiled into * display lists. */ /* * When glGenRender/FramebuffersEXT() is called we insert pointers to * these placeholder objects into the hash table. * Later, when the object ID is first bound, we replace the placeholder * with the real frame/renderbuffer. */ static struct gl_framebuffer DummyFramebuffer; static struct gl_renderbuffer DummyRenderbuffer; /* We bind this framebuffer when applications pass a NULL * drawable/surface in make current. */ static struct gl_framebuffer IncompleteFramebuffer; static void delete_dummy_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { /* no op */ } static void delete_dummy_framebuffer(struct gl_framebuffer *fb) { /* no op */ } void _mesa_init_fbobjects(struct gl_context *ctx) { _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); DummyFramebuffer.Delete = delete_dummy_framebuffer; DummyRenderbuffer.Delete = delete_dummy_renderbuffer; IncompleteFramebuffer.Delete = delete_dummy_framebuffer; } struct gl_framebuffer * _mesa_get_incomplete_framebuffer(void) { return &IncompleteFramebuffer; } /** * Helper routine for getting a gl_renderbuffer. */ struct gl_renderbuffer * _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) { struct gl_renderbuffer *rb; if (id == 0) return NULL; rb = (struct gl_renderbuffer *) _mesa_HashLookup(ctx->Shared->RenderBuffers, id); return rb; } /** * Helper routine for getting a gl_framebuffer. */ struct gl_framebuffer * _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) { struct gl_framebuffer *fb; if (id == 0) return NULL; fb = (struct gl_framebuffer *) _mesa_HashLookup(ctx->Shared->FrameBuffers, id); return fb; } /** * Mark the given framebuffer as invalid. This will force the * test for framebuffer completeness to be done before the framebuffer * is used. */ static void invalidate_framebuffer(struct gl_framebuffer *fb) { fb->_Status = 0; /* "indeterminate" */ } /** * Return the gl_framebuffer object which corresponds to the given * framebuffer target, such as GL_DRAW_FRAMEBUFFER. * Check support for GL_EXT_framebuffer_blit to determine if certain * targets are legal. * \return gl_framebuffer pointer or NULL if target is illegal */ static struct gl_framebuffer * get_framebuffer_target(struct gl_context *ctx, GLenum target) { switch (target) { case GL_DRAW_FRAMEBUFFER: return ctx->Extensions.EXT_framebuffer_blit && _mesa_is_desktop_gl(ctx) ? ctx->DrawBuffer : NULL; case GL_READ_FRAMEBUFFER: return ctx->Extensions.EXT_framebuffer_blit && _mesa_is_desktop_gl(ctx) ? ctx->ReadBuffer : NULL; case GL_FRAMEBUFFER_EXT: return ctx->DrawBuffer; default: return NULL; } } /** * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding * gl_renderbuffer_attachment object. * This function is only used for user-created FB objects, not the * default / window-system FB object. * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to * the depth buffer attachment point. */ struct gl_renderbuffer_attachment * _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, GLenum attachment) { GLuint i; assert(_mesa_is_user_fbo(fb)); switch (attachment) { case GL_COLOR_ATTACHMENT0_EXT: case GL_COLOR_ATTACHMENT1_EXT: case GL_COLOR_ATTACHMENT2_EXT: case GL_COLOR_ATTACHMENT3_EXT: case GL_COLOR_ATTACHMENT4_EXT: case GL_COLOR_ATTACHMENT5_EXT: case GL_COLOR_ATTACHMENT6_EXT: case GL_COLOR_ATTACHMENT7_EXT: case GL_COLOR_ATTACHMENT8_EXT: case GL_COLOR_ATTACHMENT9_EXT: case GL_COLOR_ATTACHMENT10_EXT: case GL_COLOR_ATTACHMENT11_EXT: case GL_COLOR_ATTACHMENT12_EXT: case GL_COLOR_ATTACHMENT13_EXT: case GL_COLOR_ATTACHMENT14_EXT: case GL_COLOR_ATTACHMENT15_EXT: /* Only OpenGL ES 1.x forbids color attachments other than * GL_COLOR_ATTACHMENT0. For all other APIs the limit set by the * hardware is used. */ i = attachment - GL_COLOR_ATTACHMENT0_EXT; if (i >= ctx->Const.MaxColorAttachments || (i > 0 && ctx->API == API_OPENGLES)) { return NULL; } return &fb->Attachment[BUFFER_COLOR0 + i]; case GL_DEPTH_STENCIL_ATTACHMENT: if (!_mesa_is_desktop_gl(ctx)) return NULL; /* fall-through */ case GL_DEPTH_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_DEPTH]; case GL_STENCIL_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_STENCIL]; default: return NULL; } } /** * As above, but only used for getting attachments of the default / * window-system framebuffer (not user-created framebuffer objects). */ static struct gl_renderbuffer_attachment * _mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, GLenum attachment) { assert(_mesa_is_winsys_fbo(fb)); switch (attachment) { case GL_FRONT_LEFT: return &fb->Attachment[BUFFER_FRONT_LEFT]; case GL_FRONT_RIGHT: return &fb->Attachment[BUFFER_FRONT_RIGHT]; case GL_BACK_LEFT: return &fb->Attachment[BUFFER_BACK_LEFT]; case GL_BACK_RIGHT: return &fb->Attachment[BUFFER_BACK_RIGHT]; case GL_AUX0: if (fb->Visual.numAuxBuffers == 1) { return &fb->Attachment[BUFFER_AUX0]; } return NULL; /* Page 336 (page 352 of the PDF) of the OpenGL 3.0 spec says: * * "If the default framebuffer is bound to target, then attachment must * be one of FRONT LEFT, FRONT RIGHT, BACK LEFT, BACK RIGHT, or AUXi, * identifying a color buffer; DEPTH, identifying the depth buffer; or * STENCIL, identifying the stencil buffer." * * Revision #34 of the ARB_framebuffer_object spec has essentially the same * language. However, revision #33 of the ARB_framebuffer_object spec * says: * * "If the default framebuffer is bound to <target>, then <attachment> * must be one of FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, AUXi, * DEPTH_BUFFER, or STENCIL_BUFFER, identifying a color buffer, the * depth buffer, or the stencil buffer, and <pname> may be * FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE or * FRAMEBUFFER_ATTACHMENT_OBJECT_NAME." * * The enum values for DEPTH_BUFFER and STENCIL_BUFFER have been removed * from glext.h, so shipping apps should not use those values. * * Note that neither EXT_framebuffer_object nor OES_framebuffer_object * support queries of the window system FBO. */ case GL_DEPTH: return &fb->Attachment[BUFFER_DEPTH]; case GL_STENCIL: return &fb->Attachment[BUFFER_STENCIL]; default: return NULL; } } /** * Remove any texture or renderbuffer attached to the given attachment * point. Update reference counts, etc. */ void _mesa_remove_attachment(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) { if (att->Type == GL_TEXTURE) { ASSERT(att->Texture); if (ctx->Driver.FinishRenderTexture) { /* tell driver that we're done rendering to this texture. */ ctx->Driver.FinishRenderTexture(ctx, att); } _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ ASSERT(!att->Texture); } if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { ASSERT(!att->Texture); _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ ASSERT(!att->Renderbuffer); } att->Type = GL_NONE; att->Complete = GL_TRUE; } /** * Bind a texture object to an attachment point. * The previous binding, if any, will be removed first. */ void _mesa_set_texture_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att, struct gl_texture_object *texObj, GLenum texTarget, GLuint level, GLuint zoffset) { if (att->Texture == texObj) { /* re-attaching same texture */ ASSERT(att->Type == GL_TEXTURE); if (ctx->Driver.FinishRenderTexture) ctx->Driver.FinishRenderTexture(ctx, att); } else { /* new attachment */ if (ctx->Driver.FinishRenderTexture && att->Texture) ctx->Driver.FinishRenderTexture(ctx, att); _mesa_remove_attachment(ctx, att); att->Type = GL_TEXTURE; assert(!att->Texture); _mesa_reference_texobj(&att->Texture, texObj); } /* always update these fields */ att->TextureLevel = level; att->CubeMapFace = _mesa_tex_target_to_face(texTarget); att->Zoffset = zoffset; att->Complete = GL_FALSE; if (_mesa_get_attachment_teximage(att)) { ctx->Driver.RenderTexture(ctx, fb, att); } invalidate_framebuffer(fb); } /** * Bind a renderbuffer to an attachment point. * The previous binding, if any, will be removed first. */ void _mesa_set_renderbuffer_attachment(struct gl_context *ctx, struct gl_renderbuffer_attachment *att, struct gl_renderbuffer *rb) { /* XXX check if re-doing same attachment, exit early */ _mesa_remove_attachment(ctx, att); att->Type = GL_RENDERBUFFER_EXT; att->Texture = NULL; /* just to be safe */ att->Complete = GL_FALSE; _mesa_reference_renderbuffer(&att->Renderbuffer, rb); } /** * Fallback for ctx->Driver.FramebufferRenderbuffer() * Attach a renderbuffer object to a framebuffer object. */ void _mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, GLenum attachment, struct gl_renderbuffer *rb) { struct gl_renderbuffer_attachment *att; _glthread_LOCK_MUTEX(fb->Mutex); att = _mesa_get_attachment(ctx, fb, attachment); ASSERT(att); if (rb) { _mesa_set_renderbuffer_attachment(ctx, att, rb); if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { /* do stencil attachment here (depth already done above) */ att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT); assert(att); _mesa_set_renderbuffer_attachment(ctx, att, rb); } rb->AttachedAnytime = GL_TRUE; } else { _mesa_remove_attachment(ctx, att); } invalidate_framebuffer(fb); _glthread_UNLOCK_MUTEX(fb->Mutex); } /** * Fallback for ctx->Driver.ValidateFramebuffer() * Check if the renderbuffer's formats are supported by the software * renderer. * Drivers should probably override this. */ void _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) { gl_buffer_index buf; for (buf = 0; buf < BUFFER_COUNT; buf++) { const struct gl_renderbuffer *rb = fb->Attachment[buf].Renderbuffer; if (rb) { switch (rb->_BaseFormat) { case GL_ALPHA: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE: case GL_INTENSITY: case GL_RED: case GL_RG: fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; return; default: switch (rb->Format) { /* XXX This list is likely incomplete. */ case MESA_FORMAT_RGB9_E5_FLOAT: fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; return; default:; /* render buffer format is supported by software rendering */ } } } } } /** * For debug only. */ static void att_incomplete(const char *msg) { if (MESA_DEBUG_FLAGS & DEBUG_INCOMPLETE_FBO) { _mesa_debug(NULL, "attachment incomplete: %s\n", msg); } } /** * For debug only. */ static void fbo_incomplete(const char *msg, int index) { if (MESA_DEBUG_FLAGS & DEBUG_INCOMPLETE_FBO) { _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); } } /** * Is the given base format a legal format for a color renderbuffer? */ GLboolean _mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) { switch (baseFormat) { case GL_RGB: case GL_RGBA: return GL_TRUE; case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: case GL_INTENSITY: case GL_ALPHA: return ctx->Extensions.ARB_framebuffer_object; case GL_RED: case GL_RG: return ctx->Extensions.ARB_texture_rg; default: return GL_FALSE; } } /** * Is the given base format a legal format for a depth/stencil renderbuffer? */ static GLboolean is_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat) { switch (baseFormat) { case GL_DEPTH_COMPONENT: case GL_DEPTH_STENCIL_EXT: return GL_TRUE; default: return GL_FALSE; } } /** * Test if an attachment point is complete and update its Complete field. * \param format if GL_COLOR, this is a color attachment point, * if GL_DEPTH, this is a depth component attachment point, * if GL_STENCIL, this is a stencil component attachment point. */ static void test_attachment_completeness(const struct gl_context *ctx, GLenum format, struct gl_renderbuffer_attachment *att) { assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); /* assume complete */ att->Complete = GL_TRUE; /* Look for reasons why the attachment might be incomplete */ if (att->Type == GL_TEXTURE) { const struct gl_texture_object *texObj = att->Texture; struct gl_texture_image *texImage; GLenum baseFormat; if (!texObj) { att_incomplete("no texobj"); att->Complete = GL_FALSE; return; } texImage = texObj->Image[att->CubeMapFace][att->TextureLevel]; if (!texImage) { att_incomplete("no teximage"); att->Complete = GL_FALSE; return; } if (texImage->Width < 1 || texImage->Height < 1) { att_incomplete("teximage width/height=0"); printf("texobj = %u\n", texObj->Name); printf("level = %d\n", att->TextureLevel); att->Complete = GL_FALSE; return; } if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) { att_incomplete("bad z offset"); att->Complete = GL_FALSE; return; } baseFormat = _mesa_get_format_base_format(texImage->TexFormat); if (format == GL_COLOR) { if (!_mesa_is_legal_color_format(ctx, baseFormat)) { att_incomplete("bad format"); att->Complete = GL_FALSE; return; } if (_mesa_is_format_compressed(texImage->TexFormat)) { att_incomplete("compressed internalformat"); att->Complete = GL_FALSE; return; } } else if (format == GL_DEPTH) { if (baseFormat == GL_DEPTH_COMPONENT) { /* OK */ } else if (ctx->Extensions.EXT_packed_depth_stencil && ctx->Extensions.ARB_depth_texture && baseFormat == GL_DEPTH_STENCIL_EXT) { /* OK */ } else { att->Complete = GL_FALSE; att_incomplete("bad depth format"); return; } } else { ASSERT(format == GL_STENCIL); if (ctx->Extensions.EXT_packed_depth_stencil && ctx->Extensions.ARB_depth_texture && baseFormat == GL_DEPTH_STENCIL_EXT) { /* OK */ } else { /* no such thing as stencil-only textures */ att_incomplete("illegal stencil texture"); att->Complete = GL_FALSE; return; } } } else if (att->Type == GL_RENDERBUFFER_EXT) { const GLenum baseFormat = _mesa_get_format_base_format(att->Renderbuffer->Format); ASSERT(att->Renderbuffer); if (!att->Renderbuffer->InternalFormat || att->Renderbuffer->Width < 1 || att->Renderbuffer->Height < 1) { att_incomplete("0x0 renderbuffer"); att->Complete = GL_FALSE; return; } if (format == GL_COLOR) { if (!_mesa_is_legal_color_format(ctx, baseFormat)) { att_incomplete("bad renderbuffer color format"); att->Complete = GL_FALSE; return; } } else if (format == GL_DEPTH) { if (baseFormat == GL_DEPTH_COMPONENT) { /* OK */ } else if (ctx->Extensions.EXT_packed_depth_stencil && baseFormat == GL_DEPTH_STENCIL_EXT) { /* OK */ } else { att_incomplete("bad renderbuffer depth format"); att->Complete = GL_FALSE; return; } } else { assert(format == GL_STENCIL); if (baseFormat == GL_STENCIL_INDEX) { /* OK */ } else if (ctx->Extensions.EXT_packed_depth_stencil && baseFormat == GL_DEPTH_STENCIL_EXT) { /* OK */ } else { att->Complete = GL_FALSE; att_incomplete("bad renderbuffer stencil format"); return; } } } else { ASSERT(att->Type == GL_NONE); /* complete */ return; } } /** * Test if the given framebuffer object is complete and update its * Status field with the results. * Calls the ctx->Driver.ValidateFramebuffer() function to allow the * driver to make hardware-specific validation/completeness checks. * Also update the framebuffer's Width and Height fields if the * framebuffer is complete. */ void _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb) { GLuint numImages; GLenum intFormat = GL_NONE; /* color buffers' internal format */ GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0; GLint numSamples = -1; GLint i; GLuint j; assert(_mesa_is_user_fbo(fb)); /* we're changing framebuffer fields here */ FLUSH_VERTICES(ctx, _NEW_BUFFERS); numImages = 0; fb->Width = 0; fb->Height = 0; /* Start at -2 to more easily loop over all attachment points. * -2: depth buffer * -1: stencil buffer * >=0: color buffer */ for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { struct gl_renderbuffer_attachment *att; GLenum f; gl_format attFormat; /* * XXX for ARB_fbo, only check color buffers that are named by * GL_READ_BUFFER and GL_DRAW_BUFFERi. */ /* check for attachment completeness */ if (i == -2) { att = &fb->Attachment[BUFFER_DEPTH]; test_attachment_completeness(ctx, GL_DEPTH, att); if (!att->Complete) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; fbo_incomplete("depth attachment incomplete", -1); return; } } else if (i == -1) { att = &fb->Attachment[BUFFER_STENCIL]; test_attachment_completeness(ctx, GL_STENCIL, att); if (!att->Complete) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; fbo_incomplete("stencil attachment incomplete", -1); return; } } else { att = &fb->Attachment[BUFFER_COLOR0 + i]; test_attachment_completeness(ctx, GL_COLOR, att); if (!att->Complete) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; fbo_incomplete("color attachment incomplete", i); return; } } /* get width, height, format of the renderbuffer/texture */ if (att->Type == GL_TEXTURE) { const struct gl_texture_image *texImg = _mesa_get_attachment_teximage(att); minWidth = MIN2(minWidth, texImg->Width); maxWidth = MAX2(maxWidth, texImg->Width); minHeight = MIN2(minHeight, texImg->Height); maxHeight = MAX2(maxHeight, texImg->Height); f = texImg->_BaseFormat; attFormat = texImg->TexFormat; numImages++; if (!_mesa_is_legal_color_format(ctx, f) && !is_legal_depth_format(ctx, f)) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; fbo_incomplete("texture attachment incomplete", -1); return; } } else if (att->Type == GL_RENDERBUFFER_EXT) { minWidth = MIN2(minWidth, att->Renderbuffer->Width); maxWidth = MAX2(minWidth, att->Renderbuffer->Width); minHeight = MIN2(minHeight, att->Renderbuffer->Height); maxHeight = MAX2(minHeight, att->Renderbuffer->Height); f = att->Renderbuffer->InternalFormat; attFormat = att->Renderbuffer->Format; numImages++; } else { assert(att->Type == GL_NONE); continue; } if (att->Renderbuffer && numSamples < 0) { /* first buffer */ numSamples = att->Renderbuffer->NumSamples; } /* check if integer color */ fb->_IntegerColor = _mesa_is_format_integer_color(attFormat); /* Error-check width, height, format, samples */ if (numImages == 1) { /* save format, num samples */ if (i >= 0) { intFormat = f; } } else { if (!ctx->Extensions.ARB_framebuffer_object) { /* check that width, height, format are same */ if (minWidth != maxWidth || minHeight != maxHeight) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; fbo_incomplete("width or height mismatch", -1); return; } /* check that all color buffers are the same format */ if (intFormat != GL_NONE && f != intFormat) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; fbo_incomplete("format mismatch", -1); return; } } if (att->Renderbuffer && att->Renderbuffer->NumSamples != numSamples) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; fbo_incomplete("inconsistant number of samples", i); return; } } /* Check that the format is valid. (MESA_FORMAT_NONE means unsupported) */ if (att->Type == GL_RENDERBUFFER && att->Renderbuffer->Format == MESA_FORMAT_NONE) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; fbo_incomplete("unsupported renderbuffer format", i); return; } } #if FEATURE_GL if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) { /* Check that all DrawBuffers are present */ for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { if (fb->ColorDrawBuffer[j] != GL_NONE) { const struct gl_renderbuffer_attachment *att = _mesa_get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); assert(att); if (att->Type == GL_NONE) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; fbo_incomplete("missing drawbuffer", j); return; } } } /* Check that the ReadBuffer is present */ if (fb->ColorReadBuffer != GL_NONE) { const struct gl_renderbuffer_attachment *att = _mesa_get_attachment(ctx, fb, fb->ColorReadBuffer); assert(att); if (att->Type == GL_NONE) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; fbo_incomplete("missing readbuffer", -1); return; } } } #else (void) j; #endif if (numImages == 0) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT; fbo_incomplete("no attachments", -1); return; } /* Provisionally set status = COMPLETE ... */ fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; /* ... but the driver may say the FB is incomplete. * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED * if anything. */ if (ctx->Driver.ValidateFramebuffer) { ctx->Driver.ValidateFramebuffer(ctx, fb); if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { fbo_incomplete("driver marked FBO as incomplete", -1); } } if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) { /* * Note that if ARB_framebuffer_object is supported and the attached * renderbuffers/textures are different sizes, the framebuffer * width/height will be set to the smallest width/height. */ fb->Width = minWidth; fb->Height = minHeight; /* finally, update the visual info for the framebuffer */ _mesa_update_framebuffer_visual(ctx, fb); } } GLboolean GLAPIENTRY _mesa_IsRenderbufferEXT(GLuint renderbuffer) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); if (renderbuffer) { struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); if (rb != NULL && rb != &DummyRenderbuffer) return GL_TRUE; } return GL_FALSE; } void GLAPIENTRY _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) { struct gl_renderbuffer *newRb; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)"); return; } /* No need to flush here since the render buffer binding has no * effect on rendering state. */ if (renderbuffer) { newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer); if (newRb == &DummyRenderbuffer) { /* ID was reserved, but no real renderbuffer object made yet */ newRb = NULL; } else if (!newRb && ctx->Extensions.ARB_framebuffer_object) { /* All RB IDs must be Gen'd */ _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)"); return; } if (!newRb) { /* create new renderbuffer object */ newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); if (!newRb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); return; } ASSERT(newRb->AllocStorage); _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); newRb->RefCount = 1; /* referenced by hash table */ } } else { newRb = NULL; } ASSERT(newRb != &DummyRenderbuffer); _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); } /** * If the given renderbuffer is anywhere attached to the framebuffer, detach * the renderbuffer. * This is used when a renderbuffer object is deleted. * The spec calls for unbinding. */ static void detach_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer *rb) { GLuint i; for (i = 0; i < BUFFER_COUNT; i++) { if (fb->Attachment[i].Renderbuffer == rb) { _mesa_remove_attachment(ctx, &fb->Attachment[i]); } } invalidate_framebuffer(fb); } void GLAPIENTRY _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) { GLint i; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_BUFFERS); for (i = 0; i < n; i++) { if (renderbuffers[i] > 0) { struct gl_renderbuffer *rb; rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); if (rb) { /* check if deleting currently bound renderbuffer object */ if (rb == ctx->CurrentRenderbuffer) { /* bind default */ ASSERT(rb->RefCount >= 2); _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); } if (_mesa_is_user_fbo(ctx->DrawBuffer)) { detach_renderbuffer(ctx, ctx->DrawBuffer, rb); } if (_mesa_is_user_fbo(ctx->ReadBuffer) && ctx->ReadBuffer != ctx->DrawBuffer) { detach_renderbuffer(ctx, ctx->ReadBuffer, rb); } /* Remove from hash table immediately, to free the ID. * But the object will not be freed until it's no longer * referenced anywhere else. */ _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); if (rb != &DummyRenderbuffer) { /* no longer referenced by hash table */ _mesa_reference_renderbuffer(&rb, NULL); } } } } } void GLAPIENTRY _mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) { GET_CURRENT_CONTEXT(ctx); GLuint first; GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx); if (n < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); return; } if (!renderbuffers) return; first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); for (i = 0; i < n; i++) { GLuint name = first + i; renderbuffers[i] = name; /* insert dummy placeholder into hash table */ _glthread_LOCK_MUTEX(ctx->Shared->Mutex); _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); } } /** * Given an internal format token for a render buffer, return the * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, * GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL_EXT, GL_ALPHA, GL_LUMINANCE, * GL_LUMINANCE_ALPHA, GL_INTENSITY, etc). * * This is similar to _mesa_base_tex_format() but the set of valid * internal formats is different. * * Note that even if a format is determined to be legal here, validation * of the FBO may fail if the format is not supported by the driver/GPU. * * \param internalFormat as passed to glRenderbufferStorage() * \return the base internal format, or 0 if internalFormat is illegal */ GLenum _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) { /* * Notes: some formats such as alpha, luminance, etc. were added * with GL_ARB_framebuffer_object. */ switch (internalFormat) { case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: case GL_LUMINANCE6_ALPHA2: case GL_LUMINANCE8_ALPHA8: case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_RGB8: return GL_RGB; case GL_RGB: case GL_R3_G3_B2: case GL_RGB4: case GL_RGB5: case GL_RGB10: case GL_RGB12: case GL_RGB16: return _mesa_is_desktop_gl(ctx) ? GL_RGB : 0; case GL_SRGB8_EXT: return _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx) ? GL_RGB : 0; case GL_RGBA4: case GL_RGB5_A1: case GL_RGBA8: return GL_RGBA; case GL_RGBA: case GL_RGBA2: case GL_RGBA12: case GL_RGBA16: return _mesa_is_desktop_gl(ctx) ? GL_RGBA : 0; case GL_RGB10_A2: case GL_SRGB8_ALPHA8_EXT: return _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx) ? GL_RGBA : 0; case GL_STENCIL_INDEX: case GL_STENCIL_INDEX1_EXT: case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX16_EXT: /* There are extensions for GL_STENCIL_INDEX1 and GL_STENCIL_INDEX4 in * OpenGL ES, but Mesa does not currently support them. */ return _mesa_is_desktop_gl(ctx) ? GL_STENCIL_INDEX : 0; case GL_STENCIL_INDEX8_EXT: return GL_STENCIL_INDEX; case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT32: return _mesa_is_desktop_gl(ctx) ? GL_DEPTH_COMPONENT : 0; case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT; case GL_DEPTH_STENCIL_EXT: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_packed_depth_stencil ? GL_DEPTH_STENCIL_EXT : 0; case GL_DEPTH24_STENCIL8_EXT: return ctx->Extensions.EXT_packed_depth_stencil ? GL_DEPTH_STENCIL_EXT : 0; case GL_DEPTH_COMPONENT32F: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.ARB_depth_buffer_float) ? GL_DEPTH_COMPONENT : 0; case GL_DEPTH32F_STENCIL8: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.ARB_depth_buffer_float) ? GL_DEPTH_STENCIL : 0; case GL_RED: case GL_R16: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rg ? GL_RED : 0; case GL_R8: return ctx->API != API_OPENGLES && ctx->Extensions.ARB_texture_rg ? GL_RED : 0; case GL_RG: case GL_RG16: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rg ? GL_RG : 0; case GL_RG8: return ctx->API != API_OPENGLES && ctx->Extensions.ARB_texture_rg ? GL_RG : 0; /* signed normalized texture formats */ case GL_R8_SNORM: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) ? GL_RED : 0; case GL_RED_SNORM: case GL_R16_SNORM: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm ? GL_RED : 0; case GL_RG8_SNORM: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) ? GL_RG : 0; case GL_RG_SNORM: case GL_RG16_SNORM: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm ? GL_RG : 0; case GL_RGB8_SNORM: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) ? GL_RGB : 0; case GL_RGB_SNORM: case GL_RGB16_SNORM: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm ? GL_RGB : 0; case GL_RGBA8_SNORM: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) ? GL_RGBA : 0; case GL_RGBA_SNORM: case GL_RGBA16_SNORM: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm ? GL_RGBA : 0; case GL_ALPHA_SNORM: case GL_ALPHA8_SNORM: case GL_ALPHA16_SNORM: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; case GL_LUMINANCE_SNORM: case GL_LUMINANCE8_SNORM: case GL_LUMINANCE16_SNORM: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA_SNORM: case GL_LUMINANCE8_ALPHA8_SNORM: case GL_LUMINANCE16_ALPHA16_SNORM: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; case GL_INTENSITY_SNORM: case GL_INTENSITY8_SNORM: case GL_INTENSITY16_SNORM: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_R16F: case GL_R32F: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.ARB_texture_rg && ctx->Extensions.ARB_texture_float) ? GL_RED : 0; case GL_RG16F: case GL_RG32F: return ctx->Version >= 30 || (ctx->API == API_OPENGL && ctx->Extensions.ARB_texture_rg && ctx->Extensions.ARB_texture_float) ? GL_RG : 0; case GL_RGB16F: case GL_RGB32F: return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_float) || _mesa_is_gles3(ctx) ? GL_RGB : 0; case GL_RGBA16F: case GL_RGBA32F: return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_float) || _mesa_is_gles3(ctx) ? GL_RGBA : 0; case GL_ALPHA16F_ARB: case GL_ALPHA32F_ARB: return ctx->API == API_OPENGL && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; case GL_LUMINANCE16F_ARB: case GL_LUMINANCE32F_ARB: return ctx->API == API_OPENGL && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA16F_ARB: case GL_LUMINANCE_ALPHA32F_ARB: return ctx->API == API_OPENGL && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; case GL_INTENSITY16F_ARB: case GL_INTENSITY32F_ARB: return ctx->API == API_OPENGL && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_RGB9_E5: return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_shared_exponent) || _mesa_is_gles3(ctx) ? GL_RGB : 0; case GL_R11F_G11F_B10F: return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_packed_float) || _mesa_is_gles3(ctx) ? GL_RGB : 0; case GL_RGBA8UI_EXT: case GL_RGBA16UI_EXT: case GL_RGBA32UI_EXT: case GL_RGBA8I_EXT: case GL_RGBA16I_EXT: case GL_RGBA32I_EXT: return ctx->Version >= 30 || (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_integer) ? GL_RGBA : 0; case GL_RGB8UI_EXT: case GL_RGB16UI_EXT: case GL_RGB32UI_EXT: case GL_RGB8I_EXT: case GL_RGB16I_EXT: case GL_RGB32I_EXT: return ctx->Version >= 30 || (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_integer) ? GL_RGB : 0; case GL_R8UI: case GL_R8I: case GL_R16UI: case GL_R16I: case GL_R32UI: case GL_R32I: return ctx->Version >= 30 || (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rg && ctx->Extensions.EXT_texture_integer) ? GL_RED : 0; case GL_RG8UI: case GL_RG8I: case GL_RG16UI: case GL_RG16I: case GL_RG32UI: case GL_RG32I: return ctx->Version >= 30 || (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rg && ctx->Extensions.EXT_texture_integer) ? GL_RG : 0; case GL_INTENSITY8I_EXT: case GL_INTENSITY8UI_EXT: case GL_INTENSITY16I_EXT: case GL_INTENSITY16UI_EXT: case GL_INTENSITY32I_EXT: case GL_INTENSITY32UI_EXT: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_LUMINANCE8I_EXT: case GL_LUMINANCE8UI_EXT: case GL_LUMINANCE16I_EXT: case GL_LUMINANCE16UI_EXT: case GL_LUMINANCE32I_EXT: case GL_LUMINANCE32UI_EXT: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA8I_EXT: case GL_LUMINANCE_ALPHA8UI_EXT: case GL_LUMINANCE_ALPHA16I_EXT: case GL_LUMINANCE_ALPHA16UI_EXT: case GL_LUMINANCE_ALPHA32I_EXT: case GL_LUMINANCE_ALPHA32UI_EXT: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; case GL_ALPHA8I_EXT: case GL_ALPHA8UI_EXT: case GL_ALPHA16I_EXT: case GL_ALPHA16UI_EXT: case GL_ALPHA32I_EXT: case GL_ALPHA32UI_EXT: return ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; case GL_RGB10_A2UI: return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rgb10_a2ui) || _mesa_is_gles3(ctx) ? GL_RGBA : 0; case GL_RGB565: return _mesa_is_gles(ctx) || ctx->Extensions.ARB_ES2_compatibility ? GL_RGB : 0; default: return 0; } } /** * Invalidate a renderbuffer attachment. Called from _mesa_HashWalk(). */ static void invalidate_rb(GLuint key, void *data, void *userData) { struct gl_framebuffer *fb = (struct gl_framebuffer *) data; struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData; /* If this is a user-created FBO */ if (_mesa_is_user_fbo(fb)) { GLuint i; for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = fb->Attachment + i; if (att->Type == GL_RENDERBUFFER && att->Renderbuffer == rb) { /* Mark fb status as indeterminate to force re-validation */ fb->_Status = 0; return; } } } } /** sentinal value, see below */ #define NO_SAMPLES 1000 /** * Helper function used by _mesa_RenderbufferStorageEXT() and * _mesa_RenderbufferStorageMultisample(). * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT(). */ static void renderbuffer_storage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei samples) { const char *func = samples == NO_SAMPLES ? "glRenderbufferStorage" : "RenderbufferStorageMultisample"; struct gl_renderbuffer *rb; GLenum baseFormat; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); return; } baseFormat = _mesa_base_fbo_format(ctx, internalFormat); if (baseFormat == 0) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); return; } if (width < 0 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); return; } if (height < 0 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); return; } if (samples == NO_SAMPLES) { /* NumSamples == 0 indicates non-multisampling */ samples = 0; } else if (samples > (GLsizei) ctx->Const.MaxSamples) { /* note: driver may choose to use more samples than what's requested */ _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); return; } rb = ctx->CurrentRenderbuffer; if (!rb) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); return; } FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (rb->InternalFormat == internalFormat && rb->Width == (GLuint) width && rb->Height == (GLuint) height && rb->NumSamples == samples) { /* no change in allocation needed */ return; } /* These MUST get set by the AllocStorage func */ rb->Format = MESA_FORMAT_NONE; rb->NumSamples = samples; /* Now allocate the storage */ ASSERT(rb->AllocStorage); if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { /* No error - check/set fields now */ /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */ assert(rb->Width == (GLuint) width); assert(rb->Height == (GLuint) height); rb->InternalFormat = internalFormat; rb->_BaseFormat = baseFormat; assert(rb->_BaseFormat != 0); } else { /* Probably ran out of memory - clear the fields */ rb->Width = 0; rb->Height = 0; rb->Format = MESA_FORMAT_NONE; rb->InternalFormat = GL_NONE; rb->_BaseFormat = GL_NONE; rb->NumSamples = 0; } /* Invalidate the framebuffers the renderbuffer is attached in. */ if (rb->AttachedAnytime) { _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb); } } #if FEATURE_OES_EGL_image void GLAPIENTRY _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) { struct gl_renderbuffer *rb; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (!ctx->Extensions.OES_EGL_image) { _mesa_error(ctx, GL_INVALID_OPERATION, "glEGLImageTargetRenderbufferStorageOES(unsupported)"); return; } if (target != GL_RENDERBUFFER) { _mesa_error(ctx, GL_INVALID_ENUM, "EGLImageTargetRenderbufferStorageOES"); return; } rb = ctx->CurrentRenderbuffer; if (!rb) { _mesa_error(ctx, GL_INVALID_OPERATION, "EGLImageTargetRenderbufferStorageOES"); return; } FLUSH_VERTICES(ctx, _NEW_BUFFERS); ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); } #endif /** * Helper function for _mesa_GetRenderbufferParameterivEXT() and * _mesa_GetFramebufferAttachmentParameterivEXT() * We have to be careful to respect the base format. For example, if a * renderbuffer/texture was created with internalFormat=GL_RGB but the * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE * we need to return zero. */ static GLint get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) { if (_mesa_base_format_has_channel(baseFormat, pname)) return _mesa_get_format_bits(format, pname); else return 0; } void GLAPIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { /* GL_ARB_fbo says calling this function is equivalent to calling * glRenderbufferStorageMultisample() with samples=0. We pass in * a token value here just for error reporting purposes. */ renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); } void GLAPIENTRY _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) { renderbuffer_storage(target, internalFormat, width, height, samples); } /** * OpenGL ES version of glRenderBufferStorage. */ void GLAPIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { switch (internalFormat) { case GL_RGB565: /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ /* choose a closest format */ internalFormat = GL_RGB5; break; default: break; } renderbuffer_storage(target, internalFormat, width, height, 0); } void GLAPIENTRY _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) { struct gl_renderbuffer *rb; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetRenderbufferParameterivEXT(target)"); return; } rb = ctx->CurrentRenderbuffer; if (!rb) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetRenderbufferParameterivEXT"); return; } /* No need to flush here since we're just quering state which is * not effected by rendering. */ switch (pname) { case GL_RENDERBUFFER_WIDTH_EXT: *params = rb->Width; return; case GL_RENDERBUFFER_HEIGHT_EXT: *params = rb->Height; return; case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: *params = rb->InternalFormat; return; case GL_RENDERBUFFER_RED_SIZE_EXT: case GL_RENDERBUFFER_GREEN_SIZE_EXT: case GL_RENDERBUFFER_BLUE_SIZE_EXT: case GL_RENDERBUFFER_ALPHA_SIZE_EXT: case GL_RENDERBUFFER_DEPTH_SIZE_EXT: case GL_RENDERBUFFER_STENCIL_SIZE_EXT: *params = get_component_bits(pname, rb->_BaseFormat, rb->Format); break; case GL_RENDERBUFFER_SAMPLES: if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_framebuffer_object) || _mesa_is_gles3(ctx)) { *params = rb->NumSamples; break; } /* fallthrough */ default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetRenderbufferParameterivEXT(target)"); return; } } GLboolean GLAPIENTRY _mesa_IsFramebufferEXT(GLuint framebuffer) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); if (framebuffer) { struct gl_framebuffer *rb = _mesa_lookup_framebuffer(ctx, framebuffer); if (rb != NULL && rb != &DummyFramebuffer) return GL_TRUE; } return GL_FALSE; } /** * Check if any of the attachments of the given framebuffer are textures * (render to texture). Call ctx->Driver.RenderTexture() for such * attachments. */ static void check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) { GLuint i; ASSERT(ctx->Driver.RenderTexture); if (_mesa_is_winsys_fbo(fb)) return; /* can't render to texture with winsys framebuffers */ for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = fb->Attachment + i; if (att->Texture && _mesa_get_attachment_teximage(att)) { ctx->Driver.RenderTexture(ctx, fb, att); } } } /** * Examine all the framebuffer's attachments to see if any are textures. * If so, call ctx->Driver.FinishRenderTexture() for each texture to * notify the device driver that the texture image may have changed. */ static void check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) { if (_mesa_is_winsys_fbo(fb)) return; /* can't render to texture with winsys framebuffers */ if (ctx->Driver.FinishRenderTexture) { GLuint i; for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = fb->Attachment + i; if (att->Texture && att->Renderbuffer) { ctx->Driver.FinishRenderTexture(ctx, att); } } } } void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { struct gl_framebuffer *newDrawFb, *newReadFb; struct gl_framebuffer *oldDrawFb, *oldReadFb; GLboolean bindReadBuf, bindDrawBuf; GET_CURRENT_CONTEXT(ctx); #ifdef DEBUG if (ctx->Extensions.ARB_framebuffer_object) { ASSERT(ctx->Extensions.EXT_framebuffer_object); ASSERT(ctx->Extensions.EXT_framebuffer_blit); } #endif ASSERT_OUTSIDE_BEGIN_END(ctx); if (!ctx->Extensions.EXT_framebuffer_object) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebufferEXT(unsupported)"); return; } switch (target) { #if FEATURE_EXT_framebuffer_blit case GL_DRAW_FRAMEBUFFER_EXT: if (!ctx->Extensions.EXT_framebuffer_blit) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); return; } bindDrawBuf = GL_TRUE; bindReadBuf = GL_FALSE; break; case GL_READ_FRAMEBUFFER_EXT: if (!ctx->Extensions.EXT_framebuffer_blit) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); return; } bindDrawBuf = GL_FALSE; bindReadBuf = GL_TRUE; break; #endif case GL_FRAMEBUFFER_EXT: bindDrawBuf = GL_TRUE; bindReadBuf = GL_TRUE; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); return; } if (framebuffer) { /* Binding a user-created framebuffer object */ newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer); if (newDrawFb == &DummyFramebuffer) { /* ID was reserved, but no real framebuffer object made yet */ newDrawFb = NULL; } else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) { /* All FBO IDs must be Gen'd */ _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)"); return; } if (!newDrawFb) { /* create new framebuffer object */ newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); if (!newDrawFb) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); return; } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); } newReadFb = newDrawFb; } else { /* Binding the window system framebuffer (which was originally set * with MakeCurrent). */ newDrawFb = ctx->WinSysDrawBuffer; newReadFb = ctx->WinSysReadBuffer; } ASSERT(newDrawFb); ASSERT(newDrawFb != &DummyFramebuffer); /* save pointers to current/old framebuffers */ oldDrawFb = ctx->DrawBuffer; oldReadFb = ctx->ReadBuffer; /* check if really changing bindings */ if (oldDrawFb == newDrawFb) bindDrawBuf = GL_FALSE; if (oldReadFb == newReadFb) bindReadBuf = GL_FALSE; /* * OK, now bind the new Draw/Read framebuffers, if they're changing. * * We also check if we're beginning and/or ending render-to-texture. * When a framebuffer with texture attachments is unbound, call * ctx->Driver.FinishRenderTexture(). * When a framebuffer with texture attachments is bound, call * ctx->Driver.RenderTexture(). * * Note that if the ReadBuffer has texture attachments we don't consider * that a render-to-texture case. */ if (bindReadBuf) { FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* check if old readbuffer was render-to-texture */ check_end_texture_render(ctx, oldReadFb); _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb); } if (bindDrawBuf) { FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* check if old framebuffer had any texture attachments */ if (oldDrawFb) check_end_texture_render(ctx, oldDrawFb); /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newDrawFb); _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb); } if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) { ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb); } } void GLAPIENTRY _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) { GLint i; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_BUFFERS); for (i = 0; i < n; i++) { if (framebuffers[i] > 0) { struct gl_framebuffer *fb; fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); if (fb) { ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); /* check if deleting currently bound framebuffer object */ if (ctx->Extensions.EXT_framebuffer_blit) { /* separate draw/read binding points */ if (fb == ctx->DrawBuffer) { /* bind default */ ASSERT(fb->RefCount >= 2); _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); } if (fb == ctx->ReadBuffer) { /* bind default */ ASSERT(fb->RefCount >= 2); _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); } } else { /* only one binding point for read/draw buffers */ if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { /* bind default */ ASSERT(fb->RefCount >= 2); _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } } /* remove from hash table immediately, to free the ID */ _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); if (fb != &DummyFramebuffer) { /* But the object will not be freed until it's no longer * bound in any context. */ _mesa_reference_framebuffer(&fb, NULL); } } } } } void GLAPIENTRY _mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers) { GET_CURRENT_CONTEXT(ctx); GLuint first; GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx); if (n < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)"); return; } if (!framebuffers) return; first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); for (i = 0; i < n; i++) { GLuint name = first + i; framebuffers[i] = name; /* insert dummy placeholder into hash table */ _glthread_LOCK_MUTEX(ctx->Shared->Mutex); _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); } } GLenum GLAPIENTRY _mesa_CheckFramebufferStatusEXT(GLenum target) { struct gl_framebuffer *buffer; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); buffer = get_framebuffer_target(ctx, target); if (!buffer) { _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); return 0; } if (_mesa_is_winsys_fbo(buffer)) { /* The window system / default framebuffer is always complete */ return GL_FRAMEBUFFER_COMPLETE_EXT; } /* No need to flush here */ if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) { _mesa_test_framebuffer_completeness(ctx, buffer); } return buffer->_Status; } /** * Replicate the src attachment point. Used by framebuffer_texture() when * the same texture is attached at GL_DEPTH_ATTACHMENT and * GL_STENCIL_ATTACHMENT. */ static void reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb, gl_buffer_index dst, gl_buffer_index src) { struct gl_renderbuffer_attachment *dst_att = &fb->Attachment[dst]; struct gl_renderbuffer_attachment *src_att = &fb->Attachment[src]; assert(src_att->Texture != NULL); assert(src_att->Renderbuffer != NULL); _mesa_reference_texobj(&dst_att->Texture, src_att->Texture); _mesa_reference_renderbuffer(&dst_att->Renderbuffer, src_att->Renderbuffer); dst_att->Type = src_att->Type; dst_att->Complete = src_att->Complete; dst_att->TextureLevel = src_att->TextureLevel; dst_att->Zoffset = src_att->Zoffset; } /** * Common code called by glFramebufferTexture1D/2D/3DEXT() and * glFramebufferTextureLayerEXT(). * Note: glFramebufferTextureLayerEXT() has no textarget parameter so we'll * get textarget=0 in that case. */ static void framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) { struct gl_renderbuffer_attachment *att; struct gl_texture_object *texObj = NULL; struct gl_framebuffer *fb; GLenum maxLevelsTarget; ASSERT_OUTSIDE_BEGIN_END(ctx); fb = get_framebuffer_target(ctx, target); if (!fb) { _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferTexture%sEXT(target=0x%x)", caller, target); return; } /* check framebuffer binding */ if (_mesa_is_winsys_fbo(fb)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTexture%sEXT", caller); return; } /* The textarget, level, and zoffset parameters are only validated if * texture is non-zero. */ if (texture) { GLboolean err = GL_TRUE; texObj = _mesa_lookup_texture(ctx, texture); if (texObj != NULL) { if (textarget == 0) { /* If textarget == 0 it means we're being called by * glFramebufferTextureLayer() and textarget is not used. * The only legal texture types for that function are 3D and * 1D/2D arrays textures. */ err = (texObj->Target != GL_TEXTURE_3D) && (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) && (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT); } else { /* Make sure textarget is consistent with the texture's type */ err = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? !_mesa_is_cube_face(textarget) : (texObj->Target != textarget); } } else { /* can't render to a non-existant texture */ _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTexture%sEXT(non existant texture)", caller); return; } if (err) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTexture%sEXT(texture target mismatch)", caller); return; } if (texObj->Target == GL_TEXTURE_3D) { const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); if (zoffset < 0 || zoffset >= maxSize) { _mesa_error(ctx, GL_INVALID_VALUE, "glFramebufferTexture%sEXT(zoffset)", caller); return; } } else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) || (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT)) { if (zoffset < 0 || zoffset >= ctx->Const.MaxArrayTextureLayers) { _mesa_error(ctx, GL_INVALID_VALUE, "glFramebufferTexture%sEXT(layer)", caller); return; } } maxLevelsTarget = textarget ? textarget : texObj->Target; if ((level < 0) || (level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) { _mesa_error(ctx, GL_INVALID_VALUE, "glFramebufferTexture%sEXT(level)", caller); return; } } att = _mesa_get_attachment(ctx, fb, attachment); if (att == NULL) { _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferTexture%sEXT(attachment)", caller); return; } FLUSH_VERTICES(ctx, _NEW_BUFFERS); _glthread_LOCK_MUTEX(fb->Mutex); if (texObj) { if (attachment == GL_DEPTH_ATTACHMENT && texObj == fb->Attachment[BUFFER_STENCIL].Texture && level == fb->Attachment[BUFFER_STENCIL].TextureLevel && _mesa_tex_target_to_face(textarget) == fb->Attachment[BUFFER_STENCIL].CubeMapFace && zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) { /* The texture object is already attached to the stencil attachment * point. Don't create a new renderbuffer; just reuse the stencil * attachment's. This is required to prevent a GL error in * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL). */ reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH, BUFFER_STENCIL); } else if (attachment == GL_STENCIL_ATTACHMENT && texObj == fb->Attachment[BUFFER_DEPTH].Texture && level == fb->Attachment[BUFFER_DEPTH].TextureLevel && _mesa_tex_target_to_face(textarget) == fb->Attachment[BUFFER_DEPTH].CubeMapFace && zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) { /* As above, but with depth and stencil transposed. */ reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL, BUFFER_DEPTH); } else { _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, level, zoffset); if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { /* Above we created a new renderbuffer and attached it to the * depth attachment point. Now attach it to the stencil attachment * point too. */ assert(att == &fb->Attachment[BUFFER_DEPTH]); reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL, BUFFER_DEPTH); } } /* Set the render-to-texture flag. We'll check this flag in * glTexImage() and friends to determine if we need to revalidate * any FBOs that might be rendering into this texture. * This flag never gets cleared since it's non-trivial to determine * when all FBOs might be done rendering to this texture. That's OK * though since it's uncommon to render to a texture then repeatedly * call glTexImage() to change images in the texture. */ texObj->_RenderToTexture = GL_TRUE; } else { _mesa_remove_attachment(ctx, att); if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { assert(att == &fb->Attachment[BUFFER_DEPTH]); _mesa_remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]); } } invalidate_framebuffer(fb); _glthread_UNLOCK_MUTEX(fb->Mutex); } void GLAPIENTRY _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { GET_CURRENT_CONTEXT(ctx); if (texture != 0) { GLboolean error; switch (textarget) { case GL_TEXTURE_1D: error = GL_FALSE; break; case GL_TEXTURE_1D_ARRAY: error = !ctx->Extensions.EXT_texture_array; break; default: error = GL_TRUE; } if (error) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTexture1DEXT(textarget=%s)", _mesa_lookup_enum_by_nr(textarget)); return; } } framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, level, 0); } void GLAPIENTRY _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { GET_CURRENT_CONTEXT(ctx); if (texture != 0) { GLboolean error; switch (textarget) { case GL_TEXTURE_2D: error = GL_FALSE; break; case GL_TEXTURE_RECTANGLE: error = _mesa_is_gles(ctx) || !ctx->Extensions.NV_texture_rectangle; break; case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: error = !ctx->Extensions.ARB_texture_cube_map; break; case GL_TEXTURE_2D_ARRAY: error = (_mesa_is_gles(ctx) && ctx->Version < 30) || !ctx->Extensions.EXT_texture_array; break; default: error = GL_TRUE; } if (error) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTexture2DEXT(textarget=%s)", _mesa_lookup_enum_by_nr(textarget)); return; } } framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, level, 0); } void GLAPIENTRY _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) { GET_CURRENT_CONTEXT(ctx); if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTexture3DEXT(textarget)"); return; } framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, level, zoffset); } void GLAPIENTRY _mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) { GET_CURRENT_CONTEXT(ctx); framebuffer_texture(ctx, "Layer", target, attachment, 0, texture, level, layer); } void GLAPIENTRY _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbufferTarget, GLuint renderbuffer) { struct gl_renderbuffer_attachment *att; struct gl_framebuffer *fb; struct gl_renderbuffer *rb; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); fb = get_framebuffer_target(ctx, target); if (!fb) { _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(target)"); return; } if (renderbufferTarget != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(renderbufferTarget)"); return; } if (_mesa_is_winsys_fbo(fb)) { /* Can't attach new renderbuffers to a window system framebuffer */ _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT"); return; } att = _mesa_get_attachment(ctx, fb, attachment); if (att == NULL) { _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(invalid attachment %s)", _mesa_lookup_enum_by_nr(attachment)); return; } if (renderbuffer) { rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); if (!rb) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT(non-existant" " renderbuffer %u)", renderbuffer); return; } else if (rb == &DummyRenderbuffer) { /* This is what NVIDIA does */ _mesa_error(ctx, GL_INVALID_VALUE, "glFramebufferRenderbufferEXT(renderbuffer %u)", renderbuffer); return; } } else { /* remove renderbuffer attachment */ rb = NULL; } if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && rb && rb->Format != MESA_FORMAT_NONE) { /* make sure the renderbuffer is a depth/stencil format */ const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); if (baseFormat != GL_DEPTH_STENCIL) { _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT(renderbuffer" " is not DEPTH_STENCIL format)"); return; } } FLUSH_VERTICES(ctx, _NEW_BUFFERS); assert(ctx->Driver.FramebufferRenderbuffer); ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb); /* Some subsequent GL commands may depend on the framebuffer's visual * after the binding is updated. Update visual info now. */ _mesa_update_framebuffer_visual(ctx, fb); } void GLAPIENTRY _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params) { const struct gl_renderbuffer_attachment *att; struct gl_framebuffer *buffer; GLenum err; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); /* The error differs in GL and GLES. */ err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM; buffer = get_framebuffer_target(ctx, target); if (!buffer) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferAttachmentParameterivEXT(target)"); return; } if (_mesa_is_winsys_fbo(buffer)) { /* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec * says: * * "If the framebuffer currently bound to target is zero, then * INVALID_OPERATION is generated." * * The EXT_framebuffer_object spec has the same wording, and the * OES_framebuffer_object spec refers to the EXT_framebuffer_object * spec. */ if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetFramebufferAttachmentParameteriv(bound FBO = 0)"); return; } /* the default / window-system FBO */ att = _mesa_get_fb0_attachment(ctx, buffer, attachment); } else { /* user-created framebuffer FBO */ att = _mesa_get_attachment(ctx, buffer, attachment); } if (att == NULL) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferAttachmentParameterivEXT(attachment)"); return; } if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { /* the depth and stencil attachments must point to the same buffer */ const struct gl_renderbuffer_attachment *depthAtt, *stencilAtt; depthAtt = _mesa_get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT); stencilAtt = _mesa_get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT); if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL" " attachments differ)"); return; } } /* No need to flush here */ switch (pname) { case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: *params = _mesa_is_winsys_fbo(buffer) ? GL_FRAMEBUFFER_DEFAULT : att->Type; return; case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: if (att->Type == GL_RENDERBUFFER_EXT) { *params = att->Renderbuffer->Name; } else if (att->Type == GL_TEXTURE) { *params = att->Texture->Name; } else { assert(att->Type == GL_NONE); if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) { *params = 0; } else { goto invalid_pname_enum; } } return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: if (att->Type == GL_TEXTURE) { *params = att->TextureLevel; } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, "glGetFramebufferAttachmentParameterivEXT(pname)"); } else { goto invalid_pname_enum; } return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: if (att->Type == GL_TEXTURE) { if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; } else { *params = 0; } } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, "glGetFramebufferAttachmentParameterivEXT(pname)"); } else { goto invalid_pname_enum; } return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: if (ctx->API == API_OPENGLES) { goto invalid_pname_enum; } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, "glGetFramebufferAttachmentParameterivEXT(pname)"); } else if (att->Type == GL_TEXTURE) { if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { *params = att->Zoffset; } else { *params = 0; } } else { goto invalid_pname_enum; } return; case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) && !_mesa_is_gles3(ctx)) { goto invalid_pname_enum; } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, "glGetFramebufferAttachmentParameterivEXT(pname)"); } else { if (ctx->Extensions.EXT_framebuffer_sRGB) { *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); } else { /* According to ARB_framebuffer_sRGB, we should return LINEAR * if the sRGB conversion is unsupported. */ *params = GL_LINEAR; } } return; case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: if ((ctx->API != API_OPENGL || !ctx->Extensions.ARB_framebuffer_object) && ctx->API != API_OPENGL_CORE && !_mesa_is_gles3(ctx)) { goto invalid_pname_enum; } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, "glGetFramebufferAttachmentParameterivEXT(pname)"); } else { gl_format format = att->Renderbuffer->Format; if (format == MESA_FORMAT_S8) { /* special cases */ *params = GL_INDEX; } else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) { /* depends on the attachment parameter */ if (attachment == GL_STENCIL_ATTACHMENT) { *params = GL_INDEX; } else { *params = GL_FLOAT; } } else { *params = _mesa_get_format_datatype(format); } } return; case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) && !_mesa_is_gles3(ctx)) { goto invalid_pname_enum; } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, "glGetFramebufferAttachmentParameterivEXT(pname)"); } else if (att->Texture) { const struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target, att->TextureLevel); if (texImage) { *params = get_component_bits(pname, texImage->_BaseFormat, texImage->TexFormat); } else { *params = 0; } } else if (att->Renderbuffer) { *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat, att->Renderbuffer->Format); } else { _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:" " invalid FBO attachment structure"); } return; default: goto invalid_pname_enum; } return; invalid_pname_enum: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferAttachmentParameteriv(pname)"); return; } void GLAPIENTRY _mesa_GenerateMipmapEXT(GLenum target) { struct gl_texture_image *srcImage; struct gl_texture_object *texObj; GLboolean error; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_BUFFERS); switch (target) { case GL_TEXTURE_1D: error = _mesa_is_gles(ctx); break; case GL_TEXTURE_2D: error = GL_FALSE; break; case GL_TEXTURE_3D: error = ctx->API == API_OPENGLES; break; case GL_TEXTURE_CUBE_MAP: error = !ctx->Extensions.ARB_texture_cube_map; break; case GL_TEXTURE_1D_ARRAY: error = _mesa_is_gles(ctx) || !ctx->Extensions.EXT_texture_array; break; case GL_TEXTURE_2D_ARRAY: error = (_mesa_is_gles(ctx) && ctx->Version < 30) || !ctx->Extensions.EXT_texture_array; break; default: error = GL_TRUE; } if (error) { _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)", _mesa_lookup_enum_by_nr(target)); return; } texObj = _mesa_get_current_tex_object(ctx, target); if (texObj->BaseLevel >= texObj->MaxLevel) { /* nothing to do */ return; } if (texObj->Target == GL_TEXTURE_CUBE_MAP && !_mesa_cube_complete(texObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGenerateMipmap(incomplete cube map)"); return; } _mesa_lock_texture(ctx, texObj); srcImage = _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel); if (!srcImage) { _mesa_unlock_texture(ctx, texObj); _mesa_error(ctx, GL_INVALID_OPERATION, "glGenerateMipmap(zero size base image)"); return; } if (_mesa_is_enum_format_integer(srcImage->InternalFormat) || _mesa_is_depthstencil_format(srcImage->InternalFormat) || _mesa_is_stencil_format(srcImage->InternalFormat)) { _mesa_unlock_texture(ctx, texObj); _mesa_error(ctx, GL_INVALID_OPERATION, "glGenerateMipmap(invalid internal format)"); return; } if (target == GL_TEXTURE_CUBE_MAP) { GLuint face; for (face = 0; face < 6; face++) ctx->Driver.GenerateMipmap(ctx, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, texObj); } else { ctx->Driver.GenerateMipmap(ctx, target, texObj); } _mesa_unlock_texture(ctx, texObj); } #if FEATURE_EXT_framebuffer_blit static const struct gl_renderbuffer_attachment * find_attachment(const struct gl_framebuffer *fb, const struct gl_renderbuffer *rb) { GLuint i; for (i = 0; i < Elements(fb->Attachment); i++) { if (fb->Attachment[i].Renderbuffer == rb) return &fb->Attachment[i]; } return NULL; } /** * Helper function for checking if the datatypes of color buffers are * compatible for glBlitFramebuffer. From the 3.1 spec, page 198: * * "GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT * and any of the following conditions hold: * - The read buffer contains fixed-point or floating-point values and any * draw buffer contains neither fixed-point nor floating-point values. * - The read buffer contains unsigned integer values and any draw buffer * does not contain unsigned integer values. * - The read buffer contains signed integer values and any draw buffer * does not contain signed integer values." */ static GLboolean compatible_color_datatypes(gl_format srcFormat, gl_format dstFormat) { GLenum srcType = _mesa_get_format_datatype(srcFormat); GLenum dstType = _mesa_get_format_datatype(dstFormat); if (srcType != GL_INT && srcType != GL_UNSIGNED_INT) { assert(srcType == GL_UNSIGNED_NORMALIZED || srcType == GL_SIGNED_NORMALIZED || srcType == GL_FLOAT); /* Boil any of those types down to GL_FLOAT */ srcType = GL_FLOAT; } if (dstType != GL_INT && dstType != GL_UNSIGNED_INT) { assert(dstType == GL_UNSIGNED_NORMALIZED || dstType == GL_SIGNED_NORMALIZED || dstType == GL_FLOAT); /* Boil any of those types down to GL_FLOAT */ dstType = GL_FLOAT; } return srcType == dstType; } /** * Return the equivalent non-generic internal format. * This is useful for comparing whether two internal formats are semantically * equivalent. */ static GLenum get_nongeneric_internalformat(GLenum format) { switch (format) { /* GL 1.1 formats. */ case 4: case GL_RGBA: return GL_RGBA8; case 3: case GL_RGB: return GL_RGB8; case 2: case GL_LUMINANCE_ALPHA: return GL_LUMINANCE8_ALPHA8; case 1: case GL_LUMINANCE: return GL_LUMINANCE8; case GL_ALPHA: return GL_ALPHA8; case GL_INTENSITY: return GL_INTENSITY8; /* GL_ARB_texture_rg */ case GL_RED: return GL_R8; case GL_RG: return GL_RG8; /* GL_EXT_texture_sRGB */ case GL_SRGB: return GL_SRGB8; case GL_SRGB_ALPHA: return GL_SRGB8_ALPHA8; case GL_SLUMINANCE: return GL_SLUMINANCE8; case GL_SLUMINANCE_ALPHA: return GL_SLUMINANCE8_ALPHA8; /* GL_EXT_texture_snorm */ case GL_RGBA_SNORM: return GL_RGBA8_SNORM; case GL_RGB_SNORM: return GL_RGB8_SNORM; case GL_RG_SNORM: return GL_RG8_SNORM; case GL_RED_SNORM: return GL_R8_SNORM; case GL_LUMINANCE_ALPHA_SNORM: return GL_LUMINANCE8_ALPHA8_SNORM; case GL_LUMINANCE_SNORM: return GL_LUMINANCE8_SNORM; case GL_ALPHA_SNORM: return GL_ALPHA8_SNORM; case GL_INTENSITY_SNORM: return GL_INTENSITY8_SNORM; default: return format; } } static GLenum get_linear_internalformat(GLenum format) { switch (format) { case GL_SRGB: return GL_RGB; case GL_SRGB_ALPHA: return GL_RGBA; case GL_SRGB8: return GL_RGB8; case GL_SRGB8_ALPHA8: return GL_RGBA8; case GL_SLUMINANCE: return GL_LUMINANCE8; case GL_SLUMINANCE_ALPHA: return GL_LUMINANCE8_ALPHA8; default: return format; } } static GLboolean compatible_resolve_formats(const struct gl_renderbuffer *colorReadRb, const struct gl_renderbuffer *colorDrawRb) { GLenum readFormat, drawFormat; /* The simple case where we know the backing Mesa formats are the same. */ if (_mesa_get_srgb_format_linear(colorReadRb->Format) == _mesa_get_srgb_format_linear(colorDrawRb->Format)) { return GL_TRUE; } /* The Mesa formats are different, so we must check whether the internal * formats are compatible. * * Under some circumstances, the user may request e.g. two GL_RGBA8 * textures and get two entirely different Mesa formats like RGBA8888 and * ARGB8888. Drivers behaving like that should be able to cope with * non-matching formats by themselves, because it's not the user's fault. * * Blits between linear and sRGB formats are also allowed. */ readFormat = get_nongeneric_internalformat(colorReadRb->InternalFormat); drawFormat = get_nongeneric_internalformat(colorDrawRb->InternalFormat); readFormat = get_linear_internalformat(readFormat); drawFormat = get_linear_internalformat(drawFormat); if (readFormat == drawFormat) { return GL_TRUE; } return GL_FALSE; } /** * Blit rectangular region, optionally from one framebuffer to another. * * Note, if the src buffer is multisampled and the dest is not, this is * when the samples must be resolved to a single color. */ void GLAPIENTRY _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); const struct gl_framebuffer *readFb, *drawFb; const struct gl_renderbuffer *colorReadRb, *colorDrawRb; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, _mesa_lookup_enum_by_nr(filter)); if (ctx->NewState) { _mesa_update_state(ctx); } readFb = ctx->ReadBuffer; drawFb = ctx->DrawBuffer; if (!readFb || !drawFb) { /* This will normally never happen but someday we may want to * support MakeCurrent() with no drawables. */ return; } /* check for complete framebuffers */ if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "glBlitFramebufferEXT(incomplete draw/read buffers)"); return; } if (filter != GL_NEAREST && filter != GL_LINEAR) { _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(filter)"); return; } if (mask & ~legalMaskBits) { _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)"); return; } /* depth/stencil must be blitted with nearest filtering */ if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) && filter != GL_NEAREST) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)"); return; } /* get color read/draw renderbuffers */ if (mask & GL_COLOR_BUFFER_BIT) { colorReadRb = readFb->_ColorReadBuffer; colorDrawRb = drawFb->_ColorDrawBuffers[0]; /* From the EXT_framebuffer_object spec: * * "If a buffer is specified in <mask> and does not exist in both * the read and draw framebuffers, the corresponding bit is silently * ignored." */ if ((colorReadRb == NULL) || (colorDrawRb == NULL)) { colorReadRb = colorDrawRb = NULL; mask &= ~GL_COLOR_BUFFER_BIT; } else if (!compatible_color_datatypes(colorReadRb->Format, colorDrawRb->Format)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(color buffer datatypes mismatch)"); return; } } else { colorReadRb = colorDrawRb = NULL; } if (mask & GL_STENCIL_BUFFER_BIT) { struct gl_renderbuffer *readRb = readFb->Attachment[BUFFER_STENCIL].Renderbuffer; struct gl_renderbuffer *drawRb = drawFb->Attachment[BUFFER_STENCIL].Renderbuffer; /* From the EXT_framebuffer_object spec: * * "If a buffer is specified in <mask> and does not exist in both * the read and draw framebuffers, the corresponding bit is silently * ignored." */ if ((readRb == NULL) || (drawRb == NULL)) { mask &= ~GL_STENCIL_BUFFER_BIT; } else if (_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) { /* There is no need to check the stencil datatype here, because * there is only one: GL_UNSIGNED_INT. */ _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(stencil buffer size mismatch)"); return; } } if (mask & GL_DEPTH_BUFFER_BIT) { struct gl_renderbuffer *readRb = readFb->Attachment[BUFFER_DEPTH].Renderbuffer; struct gl_renderbuffer *drawRb = drawFb->Attachment[BUFFER_DEPTH].Renderbuffer; /* From the EXT_framebuffer_object spec: * * "If a buffer is specified in <mask> and does not exist in both * the read and draw framebuffers, the corresponding bit is silently * ignored." */ if ((readRb == NULL) || (drawRb == NULL)) { mask &= ~GL_DEPTH_BUFFER_BIT; } else if ((_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) || (_mesa_get_format_datatype(readRb->Format) != _mesa_get_format_datatype(drawRb->Format))) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(depth buffer format mismatch)"); return; } } if (readFb->Visual.samples > 0 && drawFb->Visual.samples > 0 && readFb->Visual.samples != drawFb->Visual.samples) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(mismatched samples)"); return; } /* extra checks for multisample copies... */ if (readFb->Visual.samples > 0 || drawFb->Visual.samples > 0) { /* src and dest region sizes must be the same */ if (abs(srcX1 - srcX0) != abs(dstX1 - dstX0) || abs(srcY1 - srcY0) != abs(dstY1 - dstY0)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(bad src/dst multisample region sizes)"); return; } /* color formats must match */ if (colorReadRb && colorDrawRb && !compatible_resolve_formats(colorReadRb, colorDrawRb)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(bad src/dst multisample pixel formats)"); return; } } if (filter == GL_LINEAR && (mask & GL_COLOR_BUFFER_BIT)) { /* 3.1 spec, page 199: * "Calling BlitFramebuffer will result in an INVALID_OPERATION error * if filter is LINEAR and read buffer contains integer data." */ GLenum type = _mesa_get_format_datatype(colorReadRb->Format); if (type == GL_INT || type == GL_UNSIGNED_INT) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(integer color type)"); return; } } if (!ctx->Extensions.EXT_framebuffer_blit) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT"); return; } /* Debug code */ if (DEBUG_BLIT) { printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," " 0x%x, 0x%x)\n", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); if (colorReadRb) { const struct gl_renderbuffer_attachment *att; att = find_attachment(readFb, colorReadRb); printf(" Src FBO %u RB %u (%dx%d) ", readFb->Name, colorReadRb->Name, colorReadRb->Width, colorReadRb->Height); if (att && att->Texture) { printf("Tex %u tgt 0x%x level %u face %u", att->Texture->Name, att->Texture->Target, att->TextureLevel, att->CubeMapFace); } printf("\n"); att = find_attachment(drawFb, colorDrawRb); printf(" Dst FBO %u RB %u (%dx%d) ", drawFb->Name, colorDrawRb->Name, colorDrawRb->Width, colorDrawRb->Height); if (att && att->Texture) { printf("Tex %u tgt 0x%x level %u face %u", att->Texture->Name, att->Texture->Target, att->TextureLevel, att->CubeMapFace); } printf("\n"); } } if (!mask) { return; } ASSERT(ctx->Driver.BlitFramebuffer); ctx->Driver.BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } #endif /* FEATURE_EXT_framebuffer_blit */ #if FEATURE_ARB_geometry_shader4 void GLAPIENTRY _mesa_FramebufferTextureARB(GLenum target, GLenum attachment, GLuint texture, GLint level) { GET_CURRENT_CONTEXT(ctx); _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTextureARB " "not implemented!"); } void GLAPIENTRY _mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face) { GET_CURRENT_CONTEXT(ctx); _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferTextureFaceARB " "not implemented!"); } #endif /* FEATURE_ARB_geometry_shader4 */ static void invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height, const char *name) { int i; struct gl_framebuffer *fb; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); fb = get_framebuffer_target(ctx, target); if (!fb) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", name); return; } if (numAttachments < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(numAttachments < 0)", name); return; } /* The GL_ARB_invalidate_subdata spec says: * * "If an attachment is specified that does not exist in the * framebuffer bound to <target>, it is ignored." * * It also says: * * "If <attachments> contains COLOR_ATTACHMENTm and m is greater than * or equal to the value of MAX_COLOR_ATTACHMENTS, then the error * INVALID_OPERATION is generated." * * No mention is made of GL_AUXi being out of range. Therefore, we allow * any enum that can be allowed by the API (OpenGL ES 3.0 has a different * set of retrictions). */ for (i = 0; i < numAttachments; i++) { if (_mesa_is_winsys_fbo(fb)) { switch (attachments[i]) { case GL_ACCUM: case GL_AUX0: case GL_AUX1: case GL_AUX2: case GL_AUX3: /* Accumulation buffers and auxilary buffers were removed in * OpenGL 3.1, and they never existed in OpenGL ES. */ if (ctx->API != API_OPENGL) goto invalid_enum; break; case GL_COLOR: case GL_DEPTH: case GL_STENCIL: break; case GL_BACK_LEFT: case GL_BACK_RIGHT: case GL_FRONT_LEFT: case GL_FRONT_RIGHT: if (!_mesa_is_desktop_gl(ctx)) goto invalid_enum; break; default: goto invalid_enum; } } else { switch (attachments[i]) { case GL_DEPTH_ATTACHMENT: case GL_STENCIL_ATTACHMENT: break; case GL_COLOR_ATTACHMENT0: case GL_COLOR_ATTACHMENT1: case GL_COLOR_ATTACHMENT2: case GL_COLOR_ATTACHMENT3: case GL_COLOR_ATTACHMENT4: case GL_COLOR_ATTACHMENT5: case GL_COLOR_ATTACHMENT6: case GL_COLOR_ATTACHMENT7: case GL_COLOR_ATTACHMENT8: case GL_COLOR_ATTACHMENT9: case GL_COLOR_ATTACHMENT10: case GL_COLOR_ATTACHMENT11: case GL_COLOR_ATTACHMENT12: case GL_COLOR_ATTACHMENT13: case GL_COLOR_ATTACHMENT14: case GL_COLOR_ATTACHMENT15: { const int k = attachments[i] - GL_COLOR_ATTACHMENT0; if (k >= ctx->Const.MaxColorAttachments) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(attachment >= max. color attachments)", name); return; } } default: goto invalid_enum; } } } /* We don't actually do anything for this yet. Just return after * validating the parameters and generating the required errors. */ return; invalid_enum: _mesa_error(ctx, GL_INVALID_ENUM, "%s(attachment)", name); return; } void GLAPIENTRY _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height) { invalidate_framebuffer_storage(target, numAttachments, attachments, x, y, width, height, "glInvalidateSubFramebuffer"); } void GLAPIENTRY _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) { /* The GL_ARB_invalidate_subdata spec says: * * "The command * * void InvalidateFramebuffer(enum target, * sizei numAttachments, * const enum *attachments); * * is equivalent to the command InvalidateSubFramebuffer with <x>, <y>, * <width>, <height> equal to 0, 0, <MAX_VIEWPORT_DIMS[0]>, * <MAX_VIEWPORT_DIMS[1]> respectively." */ invalidate_framebuffer_storage(target, numAttachments, attachments, 0, 0, MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT, "glInvalidateFramebuffer"); }
30.723528
83
0.636088
6be9b6141f572cdf037465b12012289cb0820847
71
c
C
src/mgos_acs712_c.c
hrithik098/ACS712
18938b7c24566480e6e72ec4e871094b79c43b1e
[ "Apache-2.0" ]
1
2021-05-26T14:57:55.000Z
2021-05-26T14:57:55.000Z
src/mgos_acs712_c.c
hrithik098/ACS712
18938b7c24566480e6e72ec4e871094b79c43b1e
[ "Apache-2.0" ]
null
null
null
src/mgos_acs712_c.c
hrithik098/ACS712
18938b7c24566480e6e72ec4e871094b79c43b1e
[ "Apache-2.0" ]
null
null
null
#include <stdbool.h> bool mgos_ACS712_init(void) { return true; }
10.142857
27
0.690141
55ebfafb0cc6cfb93b767be5fbb49e79e953e0e7
471
c
C
MiniOS/src/Store_Program.c
avrobullet/RoboMaus
1f64b32c660e6803e24df753c7d02f584f9909b7
[ "MIT" ]
null
null
null
MiniOS/src/Store_Program.c
avrobullet/RoboMaus
1f64b32c660e6803e24df753c7d02f584f9909b7
[ "MIT" ]
null
null
null
MiniOS/src/Store_Program.c
avrobullet/RoboMaus
1f64b32c660e6803e24df753c7d02f584f9909b7
[ "MIT" ]
null
null
null
#include <asf.h> #include <proj.h> static stackT S1; static stackT S2; void LineProgram() { int size = 9; int n[] = {3,3,3,-1, -2, -2,3,3,3,}; int m[] = {3,3,3, 2, 2, 2,3,3,3,}; StackInit(&S1, size); //S1 = for motor 1 StackInit(&S2, size); //S2 = for motor 2 //generateStack(n, &S1); for (int i = size; i > 0; i--) { StackPush(&S1, n[i]); //S1 = for motor 1 StackPush(&S2, m[i]); //S2 = for motor 2 } } void LineProgramRun() { LineRun(&S1, &S2); }
16.821429
42
0.549894
0db510e5a1d306f5785da462f37ca3f83a24cd00
1,931
c
C
enhanced/buildtest/tests/functional/src/test/functional/org/apache/harmony/test/func/reg/vm/btest6486/Btest6486.c
qinFamily/freeVM
9caa0256b4089d74186f84b8fb2afc95a0afc7bc
[ "Apache-2.0" ]
5
2017-03-08T20:32:39.000Z
2021-07-10T10:12:38.000Z
enhanced/buildtest/tests/functional/src/test/functional/org/apache/harmony/test/func/reg/vm/btest6486/Btest6486.c
qinFamily/freeVM
9caa0256b4089d74186f84b8fb2afc95a0afc7bc
[ "Apache-2.0" ]
null
null
null
enhanced/buildtest/tests/functional/src/test/functional/org/apache/harmony/test/func/reg/vm/btest6486/Btest6486.c
qinFamily/freeVM
9caa0256b4089d74186f84b8fb2afc95a0afc7bc
[ "Apache-2.0" ]
4
2015-07-07T07:06:59.000Z
2018-06-19T22:38:04.000Z
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** */ #include <jni.h> JNIEXPORT jboolean JNICALL Java_org_apache_harmony_test_func_reg_vm_btest6486_Btest6486_nativeFunction(JNIEnv *, jobject); JNIEXPORT jboolean JNICALL Java_org_apache_harmony_test_func_reg_vm_btest6486_Btest6486_nativeFunction(JNIEnv *jenv, jobject t) { jclass oome_class = (*jenv)->FindClass(jenv, "java/lang/OutOfMemoryError"); jclass obj_class; if (!oome_class) return JNI_FALSE; obj_class = (*jenv)->FindClass(jenv, "org/apache/harmony/test/func/reg/vm/btest6486/Btest6486"); if (!obj_class) return JNI_FALSE; for (;;) { jobject obj = (*jenv)->AllocObject(jenv, obj_class); if (!obj) { jobject exn = (*jenv)->ExceptionOccurred(jenv); jclass exn_class; if (!exn) return JNI_FALSE; (*jenv)->ExceptionClear(jenv); exn_class = (*jenv)->GetObjectClass(jenv, exn); if ((*jenv)->IsAssignableFrom(jenv, exn_class, oome_class)) return JNI_TRUE; else return JNI_FALSE; } } }
33.293103
122
0.670637
8a956d9f59a5314d642c3797c63abcfd28fcc065
856
h
C
YLCleaner/Xcode-RuntimeHeaders/IDEKit/IDESourceControlTreeItem-IDESourceControlTreeItemPropertyAdditions.h
liyong03/YLCleaner
7453187a884c8e783bda1af82cbbb51655ec41c6
[ "MIT" ]
1
2019-02-15T02:16:35.000Z
2019-02-15T02:16:35.000Z
YLCleaner/Xcode-RuntimeHeaders/IDEKit/IDESourceControlTreeItem-IDESourceControlTreeItemPropertyAdditions.h
liyong03/YLCleaner
7453187a884c8e783bda1af82cbbb51655ec41c6
[ "MIT" ]
null
null
null
YLCleaner/Xcode-RuntimeHeaders/IDEKit/IDESourceControlTreeItem-IDESourceControlTreeItemPropertyAdditions.h
liyong03/YLCleaner
7453187a884c8e783bda1af82cbbb51655ec41c6
[ "MIT" ]
null
null
null
/* * Generated by class-dump 3.3.4 (64 bit). * * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard. */ #import "IDESourceControlTreeItem.h" @class NSImage, NSNumber, NSString; @interface IDESourceControlTreeItem (IDESourceControlTreeItemPropertyAdditions) + (id)keyPathsForValuesAffectingNavigableItem_sourceControlServerStatus; + (id)keyPathsForValuesAffectingNavigableItem_sourceControlLocalStatus; + (id)keyPathsForValuesAffectingInProgress; + (id)keyPathsForValuesAffectingProgress; + (id)keyPathsForValuesAffectingNavigableItem_name; - (id)navigableItem_sourceControlServerStatus; - (id)navigableItem_sourceControlLocalStatus; @property(readonly) BOOL inProgress; @property(readonly) NSNumber *progress; @property(readonly) NSImage *navigableItem_image; @property(readonly) NSString *navigableItem_name; @end
34.24
83
0.820093
3d84689c5470eb2525df95091378898b0509e357
486
h
C
DuskEngine/src/Core/Renderer/Resources/Texture.h
qolisipo/Dusk
ad00e33af3ffdbebf9918dcfe2d38d786b3c5128
[ "BSD-3-Clause" ]
6
2021-05-03T16:30:07.000Z
2022-02-07T18:05:44.000Z
DuskEngine/src/Core/Renderer/Resources/Texture.h
qolisipo/Dusk
ad00e33af3ffdbebf9918dcfe2d38d786b3c5128
[ "BSD-3-Clause" ]
null
null
null
DuskEngine/src/Core/Renderer/Resources/Texture.h
qolisipo/Dusk
ad00e33af3ffdbebf9918dcfe2d38d786b3c5128
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include "Core/Macros/DUSK_API.h" #include "Utils/Memory/Memory.h" #include <string> namespace DuskEngine { class DUSK_EXPORT Texture { public: static Ref<Texture> Create(const std::string& filepath, const std::string& name = ""); virtual ~Texture() = default; virtual unsigned int GetRendererID() const = 0; virtual unsigned int GetWidth() const = 0; virtual unsigned int GetHeight() const = 0; virtual void Bind(unsigned int slot = 0) const = 0; }; }
22.090909
88
0.707819
3d98a44191228f8085fe169241be63e2713c2473
1,295
h
C
libs/CollapsedCrossSections.h
khurrumsaleem/QuasiMolto
02485438a6b58a0210eb0b2da3db8a7a37b57bb9
[ "BSD-3-Clause" ]
null
null
null
libs/CollapsedCrossSections.h
khurrumsaleem/QuasiMolto
02485438a6b58a0210eb0b2da3db8a7a37b57bb9
[ "BSD-3-Clause" ]
null
null
null
libs/CollapsedCrossSections.h
khurrumsaleem/QuasiMolto
02485438a6b58a0210eb0b2da3db8a7a37b57bb9
[ "BSD-3-Clause" ]
1
2021-11-02T10:28:46.000Z
2021-11-02T10:28:46.000Z
#ifndef COLLAPSEDCROSSSECTIONS_H #define COLLAPSEDCROSSSECTIONS_H #include "Mesh.h" #include "WriteData.h" using namespace std; //============================================================================== //! Class the holds collapsed one-group nuclear data class CollapsedCrossSections { public: // Constructor CollapsedCrossSections(Mesh * myMesh,int nEnergyGroups); // Variables // sigS is the flux weighted one group scattering cross section // groupSigS is the flux weighted one group to group scattering cross // section Eigen::MatrixXd sigT,sigS,sigF,rSigTR,zSigTR,neutV,neutVPast,rNeutV,\ rNeutVPast,zNeutV,zNeutVPast,qdFluxCoeff,Ezz,Err,Erz,rZeta1,rZeta2,\ rZeta,zZeta1,zZeta2,zZeta; double keff,kold; vector<Eigen::MatrixXd> groupDNPFluxCoeff; vector<Eigen::MatrixXd> groupSigS; vector<Eigen::MatrixXd> groupUpscatterCoeff; string outputDir = "1GXS/"; Mesh * mesh; // Functions double dnpFluxCoeff(int iZ,int iR,int dnpID); double groupScatterXS(int iZ,int iR,int dnpID); double upscatterCoeff(int iZ,int iR,int dnpID); void print(); void writeVars(); void resetData(); }; //============================================================================== #endif
28.777778
80
0.620077
ed1c9554a65f1bede881b8fb7a806e1032f83d20
274
c
C
src/token.c
luva-lang/luva-build-tool
832971335fde14831d130ca1b954360b8853765d
[ "Apache-2.0" ]
1
2021-11-25T19:16:38.000Z
2021-11-25T19:16:38.000Z
src/token.c
luva-lang/luva-build-tool
832971335fde14831d130ca1b954360b8853765d
[ "Apache-2.0" ]
null
null
null
src/token.c
luva-lang/luva-build-tool
832971335fde14831d130ca1b954360b8853765d
[ "Apache-2.0" ]
null
null
null
#include <token.h> #include <stdlib.h> void free_token(token_t* token) { free(token->value); free(token); } void free_token_list(token_list_t* list) { token_list_t* next; while (list) { next = list->next; free_token(list->token); free(list); list = next; } }
15.222222
42
0.667883
3761c21b49bef1cef87cd00c81abf0575d057146
234
c
C
lib/libc/mingw/secapi/_vscprintf_p.c
aruniiird/zig
fd47839064775c0cc956f12a012f0893e1f3a440
[ "MIT" ]
12,718
2018-05-25T02:00:44.000Z
2022-03-31T23:03:51.000Z
lib/libc/mingw/secapi/_vscprintf_p.c
aruniiird/zig
fd47839064775c0cc956f12a012f0893e1f3a440
[ "MIT" ]
8,483
2018-05-23T16:22:39.000Z
2022-03-31T22:18:16.000Z
lib/libc/mingw/secapi/_vscprintf_p.c
aruniiird/zig
fd47839064775c0cc956f12a012f0893e1f3a440
[ "MIT" ]
1,400
2018-05-24T22:35:25.000Z
2022-03-31T21:32:48.000Z
#include <sec_api/stdio_s.h> int __cdecl _vscprintf_p(const char *format, va_list arglist) { return _vscprintf_p_l(format, NULL, arglist); } int __cdecl (*__MINGW_IMP_SYMBOL(_vscprintf_p))(const char *, va_list) = _vscprintf_p;
26
86
0.760684
98ba66de4b11c5a8028b7c92dd01559072be64d0
2,275
h
C
WJBaseProject/categories/UIKit/UILabel+Helpers.h
WarnerWang/WJBaseProject
081df97b197de9fec40f3c59021aa5c2e73d6c20
[ "Apache-2.0" ]
5
2019-03-29T04:17:55.000Z
2022-03-07T03:18:04.000Z
WJBaseProject/categories/UIKit/UILabel+Helpers.h
WarnerWang/WJBaseProject
081df97b197de9fec40f3c59021aa5c2e73d6c20
[ "Apache-2.0" ]
null
null
null
WJBaseProject/categories/UIKit/UILabel+Helpers.h
WarnerWang/WJBaseProject
081df97b197de9fec40f3c59021aa5c2e73d6c20
[ "Apache-2.0" ]
1
2019-03-29T04:54:08.000Z
2019-03-29T04:54:08.000Z
// // UILabel+Helpers.h // WJBaseProject // // Created by 王杰 on 2019/3/22. // Copyright © 2019 和信金谷. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface UILabel (Helpers) +(UILabel*)create; +(UILabel*)createWithFont:(UIFont*)font; +(UILabel*)createWithColor:(UIColor*)color; +(UILabel*)createWithFont:(UIFont *)font textColor:(UIColor*)textColor; +(UILabel*)createWithFont:(UIFont *)font textColor:(UIColor*)textColor lineNumber:(NSInteger)number; +(UILabel *)createLabelWithText:(NSString *)text font:(UIFont *)font textColor:(UIColor *)textColor; /// 设置行间距 - (void)attributeStrWithLineSpace:(CGFloat)lineSpace; /// 设置下划线 - (void)attributeWithUnderLine; /// 设置下划线 - (void)addUnderLineWithRange:(NSRange)range; /** 自定义字符串的颜色和字体 @param strArray 不同显示的字符串组成的字符串数组 例@[@"我是",@"一只",@"小",@"小",@"鸟"] @param indexs 不同格式的字符串对应的下标数组,例@[@[@0,@2],@[@1,@3].@[@5]] @param colors 不同下标对应的颜色,例@[[UIColor redColor],[UIColor blueColor],[UIColor greenColor]] 为空则整体使用self.textColor @param fonts 不同下标对应的字体l,例@[[UIFont systemFontOfSize:10],[UIFont systemFontOfSize:14],[UIFont systemFontOfSize:12]] 为空则整体使用self.font */ - (void)setAttribute:(NSArray<NSString *> *)strArray indexs:(NSArray<NSArray <NSNumber *>*> *)indexs colors:( NSArray<UIColor *> * _Nullable )colors fonts:( NSArray<UIFont *> * _Nullable )fonts; /** 自定义字符串的颜色和字体 @param strArray 不同显示的字符串组成的字符串数组 例@[@"我是",@"一只",@"小",@"小",@"鸟"] @param indexs 不同格式的字符串对应的下标数组,例@[@[@0,@2],@[@1,@3].@[@5]] @param colors 不同下标对应的颜色,例@[[UIColor redColor],[UIColor blueColor],[UIColor greenColor]] @param font 整体字体 */ - (void)setAttribute:(NSArray<NSString *> *)strArray indexs:(NSArray<NSArray <NSNumber *>*> *)indexs colors:(NSArray<UIColor *> *)colors font:(UIFont *)font; /** 自定义字符串的颜色和字体 @param strArray 不同显示的字符串组成的字符串数组 例@[@"我是",@"一只",@"小",@"小",@"鸟"] @param indexs 不同格式的字符串对应的下标数组,例@[@[@0,@2],@[@1,@3].@[@5]] @param fonts 不同下标对应的字体l,例@[[UIFont systemFontOfSize:10],[UIFont systemFontOfSize:14],[UIFont systemFontOfSize:12]] @param color 所有字体的颜色 */ - (void)setAttribute:(NSArray<NSString *> *)strArray indexs:(NSArray<NSArray <NSNumber *>*> *)indexs fonts:(NSArray<UIFont *> *_Nullable)fonts color:(UIColor *)color; @end NS_ASSUME_NONNULL_END
32.042254
194
0.699341
f802ea33659188c58026fe00bd3e36d5c90a187a
3,710
h
C
OrionUO/Managers/GumpManager.h
BryanNoller/OrionUO
5985315969c5f3c7c7552392d9d40d4b24b718e2
[ "MIT" ]
169
2016-09-16T22:24:34.000Z
2022-03-27T09:58:20.000Z
OrionUO/Managers/GumpManager.h
BryanNoller/OrionUO
5985315969c5f3c7c7552392d9d40d4b24b718e2
[ "MIT" ]
104
2016-10-26T23:02:52.000Z
2021-10-02T17:36:04.000Z
OrionUO/Managers/GumpManager.h
BryanNoller/OrionUO
5985315969c5f3c7c7552392d9d40d4b24b718e2
[ "MIT" ]
111
2016-09-16T22:25:30.000Z
2022-03-28T07:01:40.000Z
/*********************************************************************************** ** ** GumpManager.h ** ** Copyright (C) August 2016 Hotride ** ************************************************************************************ */ //---------------------------------------------------------------------------------- #pragma once #include <SDL_events.h> //---------------------------------------------------------------------------------- //!Класс менеджера гампов class CGumpManager : public CBaseQueue { private: /*! Вычислить количество статусбаров без пати @return Количество non-party статусбыров */ int GetNonpartyStatusbarsCount(); void SaveDefaultGumpProperties(WISP_FILE::CBinaryFileWritter &writer, CGump *gump, int size); public: CGumpManager() : CBaseQueue() { } virtual ~CGumpManager() {} /*! Добавить гамп @param [__in] obj Ссылка на гамп @return */ void AddGump(CGump *obj); /*! Обновить содержимое гампа @param [__in] serial Серийник гампа @param [__in] ID ID гампа @param [__in] Type Тип гампа @return Ссылку на обновленный гамп или NULL */ CGump *UpdateContent(int serial, int id, const GUMP_TYPE &type); /*! Обновить гамп @param [__in] serial Серийник гампа @param [__in] ID ID гампа @param [__in] Type Тип гампа @return Ссылку на обновленный гамп или NULL */ CGump *UpdateGump(int serial, int id, const GUMP_TYPE &type); /*! Найти гамп @param [__in] serial Серийник гампа @param [__in] ID ID гампа @param [__in] Type Тип гампа @return Ссылку на гамп или NULL */ CGump *GetGump(int serial, int id, const GUMP_TYPE &type); /*! Получить гамп-владелец текущей активной TEntryText @return Ссылку на гамп или NULL */ CGump *GetTextEntryOwner(); /*! Проверить, существует ли гамп @param [__in] gumpID ID гампа (в памяти) @return */ CGump *GumpExists(uintptr_t gumpID); /*! Закрыть все гампы с указанными параметрами @param [__in] serial Серийник гампа @param [__in] ID ID гампа @param [__in] Type Тип гампа @return */ void CloseGump(uint serial, uint ID, GUMP_TYPE Type); /*! Удалить гамп @param [__in] obj Ссылка на гамп @return */ void RemoveGump(CGump *obj); /*! Перерисовать все гампы @return */ void RedrawAll(); /*! Событие удаления менеджера (вызывается перед удалением) @return */ void OnDelete(); /*! Удалить гампы, которые не могут быть досягаемы из-за изменения дистанции до объекта @return */ void RemoveRangedGumps(); void PrepareContent(); void RemoveMarked(); /*! Подготовка текстур @return */ void PrepareTextures(); void Draw(bool blocked); void Select(bool blocked); void InitToolTip(); void OnLeftMouseButtonDown(bool blocked); bool OnLeftMouseButtonUp(bool blocked); bool OnLeftMouseButtonDoubleClick(bool blocked); void OnRightMouseButtonDown(bool blocked); void OnRightMouseButtonUp(bool blocked); bool OnRightMouseButtonDoubleClick(bool blocked) { return false; } void OnMidMouseButtonScroll(bool up, bool blocked); void OnDragging(bool blocked); void Load(const os_path &path); void Save(const os_path &path); #if USE_WISP bool OnCharPress(const WPARAM &wParam, const LPARAM &lParam, bool blocked); bool OnKeyDown(const WPARAM &wParam, const LPARAM &lParam, bool blocked); #else virtual bool OnTextInput(const SDL_TextInputEvent &ev, bool blocked); virtual bool OnKeyDown(const SDL_KeyboardEvent &ev, bool blocked); #endif }; //---------------------------------------------------------------------------------- //!Ссылка на менеджер гампов extern CGumpManager g_GumpManager;
23.935484
97
0.616173
f772a0ad8709d730b36ef65e4a1a81df90861852
24
c
C
src/test/kc/illegal-alignment.c
jbrandwood/kickc
d4b68806f84f8650d51b0e3ef254e40f38b0ffad
[ "MIT" ]
2
2022-03-01T02:21:14.000Z
2022-03-01T04:33:35.000Z
src/test/kc/illegal-alignment.c
jbrandwood/kickc
d4b68806f84f8650d51b0e3ef254e40f38b0ffad
[ "MIT" ]
null
null
null
src/test/kc/illegal-alignment.c
jbrandwood/kickc
d4b68806f84f8650d51b0e3ef254e40f38b0ffad
[ "MIT" ]
null
null
null
byte __align($100) b;
6
21
0.625
59715596020ac9ea5f8e864b6b5aedf00b3b9ed9
663
h
C
cases/adaptive_surfers_in_channel_flow_z/param/post/objects/surfer__us_0o1__surftimeprefactor_0o0/pos/group/_member/choice.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
cases/adaptive_surfers_in_channel_flow_z/param/post/objects/surfer__us_0o1__surftimeprefactor_0o0/pos/group/_member/choice.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
cases/adaptive_surfers_in_channel_flow_z/param/post/objects/surfer__us_0o1__surftimeprefactor_0o0/pos/group/_member/choice.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
#ifndef C0P_PARAM_POST_OBJECTS_SURFER__US_0O1__SURFTIMEPREFACTOR_0O0_POS_GROUP_MEMBER_CHOICE_H #define C0P_PARAM_POST_OBJECTS_SURFER__US_0O1__SURFTIMEPREFACTOR_0O0_POS_GROUP_MEMBER_CHOICE_H #pragma once // THIS FILE SHOULD NOT BE EDITED DIRECTLY BY THE USERS. // THIS FILE WILL BE AUTOMATICALLY EDITED WHEN THE // CHOOSE COMMAND IS USED // choose your post #include "param/post/objects/surfer__us_0o1__surftimeprefactor_0o0/pos/group/_member/passive/choice.h" namespace c0p { template<typename TypeMemberStep> using PostSurferUs0O1Surftimeprefactor0O0PosGroupMember = PostSurferUs0O1Surftimeprefactor0O0PosGroupMemberPassive<TypeMemberStep>; } #endif
36.833333
135
0.859729
d35e09bef0ab226e770aa3e4330a0ba7e49f1a4c
467
h
C
Example/Pods/MGJRouterKit/MGJRouterKit/Classes/NSObject+TXTransfer.h
xtzPioneer/TXVideoRecordingKit
85ced3d2715312b3ffbb2a536288868f2a26a277
[ "MIT" ]
6
2019-03-20T15:55:22.000Z
2021-11-09T08:58:10.000Z
Example/Pods/MGJRouterKit/MGJRouterKit/Classes/NSObject+TXTransfer.h
xtzPioneer/TXVideoRecordingKit
85ced3d2715312b3ffbb2a536288868f2a26a277
[ "MIT" ]
null
null
null
Example/Pods/MGJRouterKit/MGJRouterKit/Classes/NSObject+TXTransfer.h
xtzPioneer/TXVideoRecordingKit
85ced3d2715312b3ffbb2a536288868f2a26a277
[ "MIT" ]
4
2019-03-29T08:58:41.000Z
2021-10-17T08:23:16.000Z
// // NSObject+TXTransfer.h // MGJRouter // // Created by xtz_pioneer on 2019/3/22. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN /** * 利用“runtime”传递参数,同时可以传递多个参数 */ @interface NSObject (TXTransfer) /** * 传递参数 * * @param method 方法 (例如:"routeWithParameters:") * * @param parameterss 参数集合 (例如:"@[parameters]") * */ - (void)transferParametersWithMethod:(NSString*)method parameterss:(NSArray*)parameterss; @end NS_ASSUME_NONNULL_END
15.566667
89
0.698073
97abbb355309fc00df246a42dbc6b53e65f21871
1,647
c
C
recover.c
rpiga/cs50-Pset4
7096282a52c827791ad15f0f003ceb204f5c50f7
[ "MIT" ]
null
null
null
recover.c
rpiga/cs50-Pset4
7096282a52c827791ad15f0f003ceb204f5c50f7
[ "MIT" ]
null
null
null
recover.c
rpiga/cs50-Pset4
7096282a52c827791ad15f0f003ceb204f5c50f7
[ "MIT" ]
null
null
null
/** * recover.c * * Computer Science 50 * Problem Set 4 * * Recovers JPEGs from a forensic image. */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <string.h> #include <stdint.h> // Constants #define BLOCK 512 #define INFILE "card.raw" int main(int argc, char* argv[]) { char filename[sizeof("NNN.jpg")], test[6]; uint8_t rawin[BLOCK] = { 0 }; int jpg_counter = 0, offset = 0*BLOCK; int jpg_start = 0; int soi = 0; // Open input file FILE* file = fopen(INFILE, "r"); if (file == NULL) { printf("Could not open %s.\n", INFILE); return 1; } fseek(file, offset, SEEK_SET); FILE* output = NULL; // Read blocks while ( fread(&rawin, BLOCK, 1, file) == 1) { //printf("%d", rawin[0]); sprintf(test, "%02x%02x%02x", rawin[0], rawin[1], rawin[2]); if ( strcmp("ffd8ff", test) == 0 ) { if (output) { fclose(output); jpg_counter++; } // Open output file sprintf(filename, "%03d.jpg", jpg_counter); output = fopen(filename, "w"); if (output == NULL) { printf("Could not open %s.\n", filename); fclose (file); return 2; } soi ++; jpg_start = 1; } if (jpg_start) { fwrite(&rawin, BLOCK , 1, output); } } // Close files fclose (output); fclose (file); // End. return 0; }
20.333333
68
0.465695
de2952c02bba6b799513809f52aca4ba6967b26a
4,134
h
C
lexfloatclient/LexFloatStatusCodes.h
cryptlex/lexfloatclient-go
f59775f58ca9aad3b3bcafc28b2789a48ca80ead
[ "MIT" ]
1
2021-03-25T06:07:52.000Z
2021-03-25T06:07:52.000Z
lexfloatclient/LexFloatStatusCodes.h
cryptlex/lexfloatclient-go
f59775f58ca9aad3b3bcafc28b2789a48ca80ead
[ "MIT" ]
null
null
null
lexfloatclient/LexFloatStatusCodes.h
cryptlex/lexfloatclient-go
f59775f58ca9aad3b3bcafc28b2789a48ca80ead
[ "MIT" ]
null
null
null
#ifndef LEX_FLOAT_STATUS_CODES_H #define LEX_FLOAT_STATUS_CODES_H enum LexFloatStatusCodes { /* CODE: LF_OK MESSAGE: Success code. */ LF_OK = 0, /* CODE: LF_FAIL MESSAGE: Failure code. */ LF_FAIL = 1, /* CODE: LF_E_PRODUCT_ID MESSAGE: The product id is incorrect. */ LF_E_PRODUCT_ID = 40, /* CODE: LF_E_CALLBACK MESSAGE: Invalid or missing callback function. */ LF_E_CALLBACK = 41, /* CODE: LF_E_HOST_URL MESSAGE: Missing or invalid server url. */ LF_E_HOST_URL = 42, /* CODE: LF_E_TIME MESSAGE: Ensure system date and time settings are correct. */ LF_E_TIME = 43, /* CODE: LF_E_INET MESSAGE: Failed to connect to the server due to network error. */ LF_E_INET = 44, /* CODE: LF_E_NO_LICENSE MESSAGE: License has not been leased yet. */ LF_E_NO_LICENSE = 45, /* CODE: LF_E_LICENSE_EXISTS MESSAGE: License has already been leased. */ LF_E_LICENSE_EXISTS = 46, /* CODE: LF_E_LICENSE_NOT_FOUND MESSAGE: License does not exist on server or has already expired. This happens when the request to refresh the license is delayed. */ LF_E_LICENSE_NOT_FOUND = 47, /* CODE: LF_E_LICENSE_EXPIRED_INET MESSAGE: License lease has expired due to network error. This happens when the request to refresh the license fails due to network error. */ LF_E_LICENSE_EXPIRED_INET = 48, /* CODE: LF_E_LICENSE_LIMIT_REACHED MESSAGE: The server has reached it's allowed limit of floating licenses. */ LF_E_LICENSE_LIMIT_REACHED = 49, /* CODE: LF_E_BUFFER_SIZE MESSAGE: The buffer size was smaller than required. */ LF_E_BUFFER_SIZE = 50, /* CODE: LF_E_METADATA_KEY_NOT_FOUND MESSAGE: The metadata key does not exist. */ LF_E_METADATA_KEY_NOT_FOUND = 51, /* CODE: LF_E_METADATA_KEY_LENGTH MESSAGE: Metadata key length is more than 256 characters. */ LF_E_METADATA_KEY_LENGTH = 52, /* CODE: LF_E_METADATA_VALUE_LENGTH MESSAGE: Metadata value length is more than 256 characters. */ LF_E_METADATA_VALUE_LENGTH = 53, /* CODE: LF_E_ACTIVATION_METADATA_LIMIT MESSAGE: The floating client has reached it's metadata fields limit. */ LF_E_FLOATING_CLIENT_METADATA_LIMIT = 54, /* CODE: LF_E_METER_ATTRIBUTE_NOT_FOUND MESSAGE: The meter attribute does not exist. */ LF_E_METER_ATTRIBUTE_NOT_FOUND = 55, /* CODE: LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED MESSAGE: The meter attribute has reached it's usage limit. */ LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED = 56, /* CODE: LF_E_IP MESSAGE: IP address is not allowed. */ LF_E_IP = 60, /* CODE: LF_E_CLIENT MESSAGE: Client error. */ LF_E_CLIENT = 70, /* CODE: LF_E_SERVER MESSAGE: Server error. */ LF_E_SERVER = 71, /* CODE: LF_E_SERVER_TIME_MODIFIED MESSAGE: System time on server has been tampered with. Ensure your date and time settings are correct on the server machine. */ LF_E_SERVER_TIME_MODIFIED = 72, /* CODE: LF_E_SERVER_LICENSE_NOT_ACTIVATED MESSAGE: The server has not been activated using a license key. */ LF_E_SERVER_LICENSE_NOT_ACTIVATED = 73, /* CODE: LF_E_SERVER_LICENSE_EXPIRED MESSAGE: The server license has expired. */ LF_E_SERVER_LICENSE_EXPIRED = 74, /* CODE: LF_E_SERVER_LICENSE_SUSPENDED MESSAGE: The server license has been suspended. */ LF_E_SERVER_LICENSE_SUSPENDED = 75, /* CODE: LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER MESSAGE: The grace period for server license is over. */ LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER = 76 }; #endif // LEX_FLOAT_STATUS_CODES_H
20.567164
80
0.628205
ea13d5972e1d91eb05df8afd6f7998d1aedce9ff
1,528
c
C
src/atl/util/pm/pmi_resizable_rt/pmi_resizable/shift_list.c
mshiryaev/oneccl
fb4bd69b0bfa72f0ed16ac2328205e51cf12d4aa
[ "Apache-2.0" ]
null
null
null
src/atl/util/pm/pmi_resizable_rt/pmi_resizable/shift_list.c
mshiryaev/oneccl
fb4bd69b0bfa72f0ed16ac2328205e51cf12d4aa
[ "Apache-2.0" ]
null
null
null
src/atl/util/pm/pmi_resizable_rt/pmi_resizable/shift_list.c
mshiryaev/oneccl
fb4bd69b0bfa72f0ed16ac2328205e51cf12d4aa
[ "Apache-2.0" ]
null
null
null
/* Copyright 2016-2019 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <stdio.h> #include <stdlib.h> #include "shift_list.h" void shift_list_clean(shift_list_t** list) { shift_list_t* cur_list = (*list); shift_list_t* node_to_remove; while (cur_list != NULL) { node_to_remove = cur_list; cur_list = cur_list->next; free(node_to_remove); } (*list) = NULL; } void shift_list_add(shift_list_t** list, size_t old, size_t new, change_type_t type) { shift_list_t* cur_list; if ((*list) == NULL) { (*list) = (shift_list_t*)malloc(sizeof(shift_list_t)); cur_list = (*list); } else { cur_list = (*list); while (cur_list->next != NULL) cur_list = cur_list->next; cur_list->next = (shift_list_t*)malloc(sizeof(shift_list_t)); cur_list = cur_list->next; } cur_list->shift.old = old; cur_list->shift.new = new; cur_list->shift.type = type; cur_list->next = NULL; }
27.285714
84
0.664921
6e8fb410715384b40da1190f421d3a18f73fdf51
467
h
C
platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video/layerdata.h
bavison/opensmalltalk-vm
d494240736f7c0309e3e819784feb1d53ed0985a
[ "MIT" ]
445
2016-06-30T08:19:11.000Z
2022-03-28T06:09:49.000Z
platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video/layerdata.h
bavison/opensmalltalk-vm
d494240736f7c0309e3e819784feb1d53ed0985a
[ "MIT" ]
439
2016-06-29T20:14:36.000Z
2022-03-17T19:59:58.000Z
platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video/layerdata.h
bavison/opensmalltalk-vm
d494240736f7c0309e3e819784feb1d53ed0985a
[ "MIT" ]
137
2016-07-02T17:32:07.000Z
2022-03-20T11:17:25.000Z
#ifndef LAYERDATA_H #define LAYERDATA_H typedef struct { /* sequence header */ int intra_quantizer_matrix[64], non_intra_quantizer_matrix[64]; int chroma_intra_quantizer_matrix[64], chroma_non_intra_quantizer_matrix[64]; int mpeg2; int qscale_type, altscan; /* picture coding extension */ int pict_scal; /* picture spatial scalable extension */ int scalable_mode; /* sequence scalable extension */ } mpeg3_layerdata_t; #endif
27.470588
78
0.732334
4c1df1bd4403c4571ddec7c56ceaa4110ea42b74
1,661
h
C
lib/rpc/NGClientRpc.h
lqi/ng-project
a25ad78cb1b25b6d05b03e4066b6bb54f0bfb659
[ "Apache-2.0" ]
null
null
null
lib/rpc/NGClientRpc.h
lqi/ng-project
a25ad78cb1b25b6d05b03e4066b6bb54f0bfb659
[ "Apache-2.0" ]
null
null
null
lib/rpc/NGClientRpc.h
lqi/ng-project
a25ad78cb1b25b6d05b03e4066b6bb54f0bfb659
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2010 Longyi Qi * * 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. * */ #import <Foundation/Foundation.h> #import "NGHeader.h" @class ProtocolOpenRequest; @class ProtocolSubmitRequest; @class NGClientRpcChannel; @class NGClientRpcController; @class NGClientRpcCallback; @interface NGClientRpc : NSObject { NGClientRpcChannel *channel; } @property (retain) NGClientRpcChannel *channel; - (id) initWithChannel:(NGClientRpcChannel *)aChannel; - (void) open:(NGClientRpcController *)controller request:(ProtocolOpenRequest *)request callback:(NGClientRpcCallback *)callback; - (void) submit:(NGClientRpcController *)controller request:(ProtocolSubmitRequest *)request callback:(NGClientRpcCallback *)callback; - (void) openRequest:(NGClientRpcController *)controller waveId:(NGWaveId *)waveId participantId:(NGParticipantId *)participantId snapshot:(BOOL)snapshot callback:(NGClientRpcCallback *)callback; - (void) submitRequest:(NGClientRpcController *)controller waveName:(NGWaveletName *)waveName waveletDelta:(NGWaveletDelta *)delta hashedVersion:(NGHashedVersion *)version callback:(NGClientRpcCallback *)callback; @end
38.627907
213
0.781457
34a5d00b2af4fda05ada8c40b85acc7e60836542
130
h
C
wave/Pods/gRPC-Core/src/core/ext/filters/client_channel/subchannel.h
NNiazi/Wave-IOS-App
b5a84109fb2522ad96d6ff88f254591344b78cb6
[ "MIT" ]
null
null
null
wave/Pods/gRPC-Core/src/core/ext/filters/client_channel/subchannel.h
NNiazi/Wave-IOS-App
b5a84109fb2522ad96d6ff88f254591344b78cb6
[ "MIT" ]
null
null
null
wave/Pods/gRPC-Core/src/core/ext/filters/client_channel/subchannel.h
NNiazi/Wave-IOS-App
b5a84109fb2522ad96d6ff88f254591344b78cb6
[ "MIT" ]
null
null
null
version https://git-lfs.github.com/spec/v1 oid sha256:14e6919a1406ff8ab531bb0e8eefd61034b9b40d223b56f2845273d9a5df16ab size 12164
32.5
75
0.884615
42339e389044dbafd683abac4877c2b98d5ec3be
7,967
c
C
asp3/arch/arm_gcc/bcm283x/tUART.c
AZO234/RaspberryPi_TOPPERS_ASP3
45f4623152952019aeecd51ff210d6136e1ea5c9
[ "MIT" ]
2
2021-05-04T01:09:35.000Z
2022-01-07T05:22:39.000Z
asp3/arch/arm_gcc/bcm283x/tUART.c
AZO234/RaspberryPi_TOPPERS_ASP3
45f4623152952019aeecd51ff210d6136e1ea5c9
[ "MIT" ]
null
null
null
asp3/arch/arm_gcc/bcm283x/tUART.c
AZO234/RaspberryPi_TOPPERS_ASP3
45f4623152952019aeecd51ff210d6136e1ea5c9
[ "MIT" ]
null
null
null
/* * TOPPERS/ASP Kernel * Toyohashi Open Platform for Embedded Real-Time Systems/ * Advanced Standard Profile Kernel * * Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory * Graduate School of Information Science, Nagoya Univ., JAPAN * * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー * スコード中に含まれていること. * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 * の無保証規定を掲載すること. * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ * と. * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 * 作権表示,この利用条件および下記の無保証規定を掲載すること. * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに * 報告すること. * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを * 免責すること. * * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ * の責任を負わない. * * $Id: tUART.c 720 2016-09-23 00:00:00Z azo $ */ /* * FIFO内蔵シリアルコミュニケーションインタフェース用 簡易SIOドライバ */ #include <sil.h> #include "tUART_tecsgen.h" #include "bcm283x.h" /* * UART関連 */ /* * プリミティブな送信/受信関数 */ /* * 受信バッファに文字があるか? */ Inline bool_t uart_getready(CELLCB *p_cellcb) { #if BCM283X_USE_UART == 1 #ifdef BCM283X_UART_ENABLE_FIFO return((sil_rew_mem(BCM283X_AUX_MU_LSR_REG) & 0x01) != 0); #else /* BCM283X_UART_ENABLE_FIFO */ return(1); #endif /* BCM283X_UART_ENABLE_FIFO */ #else /* BCM283X_USE_UART */ #ifdef BCM283X_UART_ENABLE_FIFO return((sil_rew_mem(BCM283X_UART0_FR) & (1 << 4)) == 0); /* Receive FIFO is not empty is true */ #else /* BCM283X_UART_ENABLE_FIFO */ return(1); #endif /* BCM283X_UART_ENABLE_FIFO */ #endif /* BCM283X_USE_UART */ } /* * 送信バッファに空きがあるか? */ Inline bool_t uart_putready(CELLCB *p_cellcb) { #if BCM283X_USE_UART == 1 if (VAR_initialized) { return((sil_rew_mem(BCM283X_AUX_MU_LSR_REG) & 0x20) != 0); } else { return(1); } #else /* BCM283X_USE_UART */ return((sil_rew_mem(BCM283X_UART0_FR) & (1 << 5)) == 0); /* Transmit FIFO is not full is true */ #endif /* BCM283X_USE_UART */ } /* * 受信した文字の取出し */ Inline char uart_getchar(CELLCB *p_cellcb) { #if BCM283X_USE_UART == 1 return((char)(sil_rew_mem(BCM283X_AUX_MU_IO_REG) & 0xFF)); #else /* BCM283X_USE_UART */ return((char)(sil_rew_mem(BCM283X_UART0_DR)) & 0xFF); /* Read DR 0:7 */ #endif /* BCM283X_USE_UART */ } /* * 送信する文字の書込み */ void uart_putchar(CELLCB *p_cellcb, char c) { #if BCM283X_USE_UART == 1 sil_wrw_mem(BCM283X_AUX_MU_IO_REG, c); #else /* BCM283X_USE_UART */ sil_wrw_mem(BCM283X_UART0_DR, c); /* Write DR 0:7 */ #endif /* BCM283X_USE_UART */ } /* * シリアルI/Oポートのオープン */ void eSIOPort_open(CELLIDX idx) { CELLCB *p_cellcb = GET_CELLCB(idx); #if BCM283X_USE_UART == 1 uint_t baud; #else /* BCM283X_USE_UART */ uint_t ibrd, fbrd; #endif /* BCM283X_USE_UART */ if (VAR_initialized) { /* * 既に初期化している場合は、二重に初期化しない. */ return; } #if BCM283X_USE_UART == 1 baud = (250000000 / (8 * ATTR_baudRate)) - 1; sil_wrw_mem(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ sil_wrw_mem(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ sil_wrw_mem(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ sil_wrw_mem(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ sil_wrw_mem(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ #ifdef BCM283X_UART_ENABLE_FIFO sil_wrw_mem(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ #else /* BCM283X_UART_ENABLE_FIFO */ sil_wrw_mem(BCM283X_AUX_MU_IIR_REG, 0) ; /* Disable FIFO */ #endif /* BCM283X_UART_ENABLE_FIFO */ sil_wrw_mem(BCM283X_AUX_MU_BAUD_REG, baud); /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */ sil_wrw_mem(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ #else /* BCM283X_USE_UART */ ibrd = 3000000 / (ATTR_baudRate * 16); fbrd = (3000000 - (ibrd * ATTR_baudRate * 16)) * 4 / ATTR_baudRate; sil_wrw_mem(BCM283X_UART0_CR, 0x0); /* Disable UART0 */ sil_wrw_mem(BCM283X_UART0_ICR, 0x7FF); /* Interrupt clear */ sil_wrw_mem(BCM283X_UART0_IBRD, ibrd); /* 3000000(300MHz) / (115200 * 16) = 625/384 = 1 + 241/384 */ sil_wrw_mem(BCM283X_UART0_FBRD, fbrd); /* 241/384 * 64 = about 40 */ #ifdef BCM283X_UART_ENABLE_FIFO sil_wrw_mem(BCM283X_UART0_LCRH, 0x70); /* FIFO Enable, 8 n 1 */ sil_wrw_mem(BCM283X_UART0_IFLS, 0x0); /* Receive interrupt FIFO 1/8, Transmit interrupt FIFO 1/8 */ sil_wrw_mem(BCM283X_UART0_CR, 0x301); /* Transmit Receive Enable UART0 */ while((sil_rew_mem(BCM283X_UART0_FR) & 0x10) == 0) { /* FIFO clear */ sil_rew_mem(BCM283X_UART0_DR); } #else /* BCM283X_UART_ENABLE_FIFO */ sil_wrw_mem(BCM283X_UART0_LCRH, 0x60); /* FIFO Disable, 8 n 1 */ sil_wrw_mem(BCM283X_UART0_CR, 0x301); /* Transmit Receive Enable UART0 */ #endif /* BCM283X_UART_ENABLE_FIFO */ #endif /* BCM283X_USE_UART */ VAR_initialized = true; } /* * シリアルI/Oポートのクローズ */ void eSIOPort_close(CELLIDX idx) { CELLCB *p_cellcb = GET_CELLCB(idx); #if BCM283X_USE_UART == 1 sil_wrw_mem(BCM283X_AUX_ENABLES, 0); /* Disable UART1 */ sil_wrw_mem(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ sil_wrw_mem(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ #else /* BCM283X_USE_UART */ sil_wrw_mem(BCM283X_UART0_CR, 0x0); /* Disable UART0 */ #endif /* BCM283X_USE_UART */ } /* * シリアルI/Oポートへの文字送信 */ bool_t eSIOPort_putChar(CELLIDX idx, char c) { CELLCB *p_cellcb = GET_CELLCB(idx); if (uart_putready(p_cellcb)){ uart_putchar(p_cellcb, c); return(true); } return(false); } /* * シリアルI/Oポートからの文字受信 */ int_t eSIOPort_getChar(CELLIDX idx) { CELLCB *p_cellcb = GET_CELLCB(idx); char c; if (uart_getready(p_cellcb)) { return((int_t)(uint8_t) uart_getchar(p_cellcb)); } return(-1); } /* * シリアルI/Oポートからのコールバックの許可 */ void eSIOPort_enableCBR(CELLIDX idx, uint_t cbrtn) { CELLCB *p_cellcb = GET_CELLCB(idx); uint32_t imsc; #if BCM283X_USE_UART == 1 imsc = sil_rew_mem(BCM283X_AUX_MU_IER_REG); #else /* BCM283X_USE_UART */ imsc = sil_rew_mem(BCM283X_UART0_IMSC); #endif /* BCM283X_USE_UART */ switch (cbrtn) { case SIOSendReady: #if BCM283X_USE_UART == 1 // imsc |= 0x2; #else /* BCM283X_USE_UART */ // imsc |= 0x20; #endif /* BCM283X_USE_UART */ break; case SIOReceiveReady: #if BCM283X_USE_UART == 1 imsc |= 0x5; #else /* BCM283X_USE_UART */ imsc |= 0x10; #endif /* BCM283X_USE_UART */ break; } #if BCM283X_USE_UART == 1 sil_wrw_mem(BCM283X_AUX_MU_IER_REG, imsc); #else /* BCM283X_USE_UART */ sil_wrw_mem(BCM283X_UART0_IMSC, imsc); #endif /* BCM283X_USE_UART */ } /* * シリアルI/Oポートからのコールバックの禁止 */ void eSIOPort_disableCBR(CELLIDX idx, uint_t cbrtn) { CELLCB *p_cellcb = GET_CELLCB(idx); uint32_t imsc; #if BCM283X_USE_UART == 1 imsc = sil_rew_mem(BCM283X_AUX_MU_IER_REG); #else /* BCM283X_USE_UART */ imsc = sil_rew_mem(BCM283X_UART0_IMSC); #endif /* BCM283X_USE_UART */ switch (cbrtn) { case SIOSendReady: #if BCM283X_USE_UART == 1 imsc &= ~(0x2); #else /* BCM283X_USE_UART */ imsc &= ~(0x20); #endif /* BCM283X_USE_UART */ break; case SIOReceiveReady: #if BCM283X_USE_UART == 1 imsc &= ~(0x5); #else /* BCM283X_USE_UART */ imsc &= ~(0x10); #endif /* BCM283X_USE_UART */ break; } #if BCM283X_USE_UART == 1 sil_wrw_mem(BCM283X_AUX_MU_IER_REG, imsc); #else /* BCM283X_USE_UART */ sil_wrw_mem(BCM283X_UART0_IMSC, imsc); #endif /* BCM283X_USE_UART */ } /* * シリアルI/Oポートに対する受信割込み処理 */ void eiISR_main(CELLIDX idx) { CELLCB *p_cellcb = GET_CELLCB(idx); if (uart_getready(p_cellcb)) { /* * 受信通知コールバックルーチンを呼び出す. */ ciSIOCBR_readyReceive(); } if (uart_putready(p_cellcb)) { /* * 送信可能コールバックルーチンを呼び出す. */ // ciSIOCBR_readySend(); } }
24.589506
110
0.700891
95204b79037ff1123aec3379335f751259b9d72c
217
h
C
protocols/PTSRowObserver.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
protocols/PTSRowObserver.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
protocols/PTSRowObserver.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser. */ @protocol PTSRowObserver <NSObject> @optional - (void)rowDidChangeImage:(PTSRow *)arg1; - (void)rowDidChangeTitle:(PTSRow *)arg1; - (void)rowDidChangeValue:(PTSRow *)arg1; @end
16.692308
41
0.732719
4e6d79a6443ca28847fe36ed140bfcca6eabbb6d
5,255
h
C
include/iftGQueue.h
Fabio-Kubo/processamento-imagens
800a5b150c69cc008ecff6528710f1c6abf63b6f
[ "MIT" ]
null
null
null
include/iftGQueue.h
Fabio-Kubo/processamento-imagens
800a5b150c69cc008ecff6528710f1c6abf63b6f
[ "MIT" ]
null
null
null
include/iftGQueue.h
Fabio-Kubo/processamento-imagens
800a5b150c69cc008ecff6528710f1c6abf63b6f
[ "MIT" ]
5
2017-03-18T00:32:00.000Z
2019-03-24T05:58:43.000Z
/** * @file iftQueue.h * @brief Definitions and collection of functions to create, destroy, and manipulate a priority queue.. * @author Alexandre Falcao -> commented by Adan Echemendia * @date August 10, 2016 */ /* This program is a collection of functions to create, destroy, and manipulate a priority queue. A priority queue Q consists of two data structures: a circular queue C and a table L that encodes all possible doubly-linked lists. Q requires that the maximum possible increment along the paths be a non-negative integer less than the number of buckets in C. An extra bucket is created to store infinity values (positive and negative) for the LIFO policy. The queue size increases dynamically whenever (maxvalue-minvalue) > (nbuckets-1). Q->C.first[i] gives the first element that is in bucket i. Q->C.last[i] gives the last element that is in bucket i. Q->C.nbuckets gives the number of buckets in C. Q->C.minvalue gives the minimum value of a node in queue. Q->C.maxvalue gives the maximum value of a node in queue. Q->C.tiebreak gives the FIFO or LIFO tie breaking policy Q->C.removal_policy gives the MINVALUE or MAXVALUE removal policy All possible doubly-linked lists are represented in L. Each bucket contains a doubly-linked list that is treated as a FIFO. Q->L.elem[i].next: the next element to i Q->L.elem[i].prev: the previous element to i Q->L.elem[i].color: the color of i (IFT_WHITE=never inserted, IFT_GRAY=inserted, IFT_BLACK=removed) Q->L.nelems: gives the total number of elements that can be inserted in Q (It is usually the number of pixels in a given image or the number of nodes in a graph) Q->L.value[i]: gives the value of element i in the graph. Insertions and updates are done in O(1). Removal may take O(K+1), where K+1 is the number of buckets. */ #ifndef IFT_GQUEUE_H_ #define IFT_GQUEUE_H_ #ifdef __cplusplus extern "C" { #endif #include "iftCommon.h" /** define queue to remove node with minimum value */ #define MINVALUE 0 /** define queue to remove node with maximum value */ #define MAXVALUE 1 /** define queue to solve ambiguity by FIFO */ #define FIFOBREAK 0 /** define queue to solve ambiguity by LIFO */ #define LIFOBREAK 1 /** define maximum size of the queue*/ #define QSIZE 65536 #define iftSetTieBreak(a,b) a->C.tiebreak=b #define iftSetRemovalPolicy(a,b) a->C.removal_policy=b typedef struct ift_gqnode { int next; /* next node */ int prev; /* prev node */ char color; /* IFT_WHITE=0, IFT_GRAY=1, IFT_BLACK=2 (IFT_WHITE=never inserted, IFT_GRAY=inserted, IFT_BLACK=removed)*/ } iftGQNode; typedef struct ift_gdoublylinkedlists { iftGQNode *elem; /* all possible doubly-linked lists of the circular queue */ int nelems; /* total number of elements */ int *value; /* the value of the nodes in the graph */ } iftGDoublyLinkedLists; typedef struct ift_gcircularqueue { int *first; /* list of the first elements of each doubly-linked list */ int *last; /* list of the last elements of each doubly-linked list */ int nbuckets; /* number of buckets in the circular queue */ int minvalue; /* minimum value of a node in queue */ int maxvalue; /* maximum value of a node in queue */ char tiebreak; /* 1 is LIFO, 0 is FIFO (default) */ char removal_policy; /* 0 is MINVALUE and 1 is MAXVALUE */ } iftGCircularQueue; typedef struct ift_gqueue { /* Priority queue by Dial implemented as proposed by A. Falcao */ iftGCircularQueue C; iftGDoublyLinkedLists L; } iftGQueue; /** * @brief Creates a priority queue * @details [long description] * * @param nbuckets Number of buckets * @param nelems Total number of elements * @param value List of element values * @return A priority queue */ iftGQueue *iftCreateGQueue(int nbuckets, int nelems, int *value); /** * @brief Destroys a priority queue * @details [long description] * * @param Q Queue to be destroyed */ void iftDestroyGQueue(iftGQueue **Q); /** * @brief Resets a priority queue to its default values * @details [long description] * * @param Q Priority queue to be reseted */ void iftResetGQueue(iftGQueue *Q); /** * @brief Verifies if a priority queue is empty or not * @details [long description] * * @param Q Target priority queue * @return Returns 1 if the priority queue is empty and 0 if not. */ int iftEmptyGQueue(iftGQueue *Q); /** * @brief Inserts an element into the priority queue * @details [long description] * * @param Q The priority queue * @param elem Element to insert */ void iftInsertGQueue(iftGQueue **Q, int elem); /** * @brief Removes the next element from the priority queue * @param The priority queue * @return The element removed */ int iftRemoveGQueue(iftGQueue *Q); /** * @brief Removes the specified element from the priority queue * @param Q The priority queue * @param elem Element to be removed */ void iftRemoveGQueueElem(iftGQueue *Q, int elem); /** * @brief Grows a priority queue * @param Old priority queue * @param nbuckets Number of buckets * @return The new priority queue */ iftGQueue *iftGrowGQueue(iftGQueue **Q, int nbuckets); #ifdef __cplusplus } #endif #endif
30.730994
103
0.713225
8e1c9c72b65435724b5c8b49baf71df1f9b6fc58
2,800
c
C
implementations/ncp-mars/amain.c
bobbyjim/x16-corewar
3df352160ddf849833707960797181bf8fc126b9
[ "MIT" ]
2
2021-08-03T14:13:02.000Z
2021-11-16T22:12:59.000Z
implementations/ncp-mars/amain.c
bobbyjim/x16-corewar
3df352160ddf849833707960797181bf8fc126b9
[ "MIT" ]
null
null
null
implementations/ncp-mars/amain.c
bobbyjim/x16-corewar
3df352160ddf849833707960797181bf8fc126b9
[ "MIT" ]
null
null
null
/* this module contains the main function, which settles open/close file i/o as well as little trivial details like adding an extension and stuff like that. It has been debuged (except for BUG NOTES) so it's safe to trust. There is a little bit of inefficiency, but that's justified since I want a more easily readable program */ #include "assem.h" #include <stdio.h> #include <malloc.h> #include <strings.h> char *outname(str) char *str; /* accepts an input string and outputs a proper output file with ".e" extension. If already has .e, as an extension, produce an error. BUG NOTE: even if it's as innoculous as .eex, etc (as long as the extension starts with .e) it will still produce an error Otherwise, remove current extension and add .e extension. returns pointer to new output name */ { char *newstr; char *dot; /* position of '.' */ if (!(newstr =(char *) malloc( (unsigned) strlen(str) + 3))) { printf("not enough memory --- outname\n"); exit(1); } strcpy(newstr,str); if (!(dot = rindex(newstr,'.'))) strcat(newstr,".e"); /* no extenstion */ else if (*(dot + 1) == 'e') /* same extension as output? */ { printf("wrong input file name: %s\n", newstr); printf("try moving to non .e extension --- outname\n"); exit(1); } else /* perform surgery */ { (*(dot + 1)) = 'e'; (*(dot + 2)) = '\0'; } return newstr; } /* main -- Open input and output files, giving default names if necessary. Detects errors like not being able to open files etc. */ main(argc, argv) int argc; char *argv[]; { FILE *f1,*f2; /* input file, output file */ char *outfile = "NONAME", /* default output file */ flag = 0; /* standard input */ if (argc == 1) /* no arguments */ { flag = 1; /* read from standard input */ argv[1] = outfile; argc = 2; /* one file */ } for (;argc > 1; argc--) { if (flag) f1 = stdin; /* set file to standard input */ else /* open input file */ if (!(f1 = fopen(argv[argc - 1],"r"))) { printf("oops cannot open file %s", argv[argc - 1]); printf("\n-- in main\n"); exit(1); /* error status 1 */ } /* open output file */ if (!(f2 = fopen(outname(argv[argc - 1]), "w"))) { printf("cannot open write file %s", outname(argv[argc - 1])); printf("\n --- in main\n"); exit(1); } printf("%s:\n", argv[argc - 1]); assemble(f1,f2); /* call assembler */ if (!flag) /* close file */ fclose(f1); fclose(f2); } } /* debugging version of assemble */ /* commented out because this module is now fully debugged */ /* --- Na Choon Piaw, 11/14 */ /* assemble(infile,outfile) FILE *infile, *outfile; { int c; while ((c = fgetc(infile)) != EOF) fputc(c, outfile); } */
23.931624
78
0.593571
16ced9f1ea9817790e70df2c5a2eb11d1a06e41d
510
h
C
PrivateFrameworks/SAObjects/SAUILParseableExpression.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/SAObjects/SAUILParseableExpression.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/SAObjects/SAUILParseableExpression.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import <SAObjects/SADomainObject.h> @class NSString; @interface SAUILParseableExpression : SADomainObject { } + (id)parseableExpressionWithDictionary:(id)arg1 context:(id)arg2; + (id)parseableExpression; @property(copy, nonatomic) NSString *expressionString; @property(retain, nonatomic) SADomainObject *context; - (id)encodedClassName; - (id)groupIdentifier; @end
21.25
83
0.739216
4afc2409cffe0e44ccd4077e693e81b1c95d0589
1,972
c
C
serializer.c
ArcTLK/contacts-manager
e2e2e4e54529fc8e88521e1078909584e08f22ac
[ "MIT" ]
null
null
null
serializer.c
ArcTLK/contacts-manager
e2e2e4e54529fc8e88521e1078909584e08f22ac
[ "MIT" ]
2
2019-03-15T03:52:41.000Z
2019-04-11T11:43:54.000Z
serializer.c
ArcTLK/contacts-manager
e2e2e4e54529fc8e88521e1078909584e08f22ac
[ "MIT" ]
null
null
null
#include <string.h> #include "serializer.h" void serialize(contact *contacts, char *output, int numOfContacts) { int i; for (i = 0; i < numOfContacts; ++i) { strcat(output, "<name>"); strcat(output, contacts[i].name); strcat(output, "</name>"); strcat(output, "<number>"); strcat(output, contacts[i].number); strcat(output, "</number>"); } } int unserialize(char *input, contact* contacts) { int contactsIndex = 0; int readElementHead = 0; int readElementContent = 0; char element[50] = ""; char elementContent[100] = ""; int elementIndex = 0; int elementContentIndex = 0; size_t i; for (i = 0; i < strlen(input); ++i) { if (input[i] == '<' && !readElementContent) { readElementHead = 1; } else if (input[i] == '/' && readElementHead) { readElementHead = 0; } else if (input[i] == '>' && readElementHead) { readElementHead = 0; readElementContent = 1; } else if (input[i] == '<' && readElementContent) { readElementContent = 0; } else if (input[i] == '>' && !readElementHead) { if (strcmp(element, "name") == 0) { strcpy(contacts[contactsIndex].name, elementContent); } else if (strcmp(element, "number") == 0) { strcpy(contacts[contactsIndex++].number, elementContent); } //reset strings memset(element, 0, sizeof element); memset(elementContent, 0, sizeof elementContent); elementIndex = 0; elementContentIndex = 0; } else if (readElementHead) { element[elementIndex++] = input[i]; } else if (readElementContent) { elementContent[elementContentIndex++] = input[i]; } } //returning number of contacts return contactsIndex; }
31.806452
73
0.532961
05ed12a244924cf289b9d5932413a64687f985d1
521
h
C
MBBiPhone6/BabyDemo/ServerConfigTheLatestRecord.h
yanalucky/MBB
90d300d57a2716e0444905395c11c686ebb29079
[ "Apache-2.0" ]
null
null
null
MBBiPhone6/BabyDemo/ServerConfigTheLatestRecord.h
yanalucky/MBB
90d300d57a2716e0444905395c11c686ebb29079
[ "Apache-2.0" ]
null
null
null
MBBiPhone6/BabyDemo/ServerConfigTheLatestRecord.h
yanalucky/MBB
90d300d57a2716e0444905395c11c686ebb29079
[ "Apache-2.0" ]
null
null
null
// // ServerConfigTheLatestRecord.h // // Created by on 16/6/21 // Copyright (c) 2016 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> @interface ServerConfigTheLatestRecord : NSObject <NSCoding, NSCopying> @property (nonatomic, strong) NSString *recordstatus; @property (nonatomic, strong) NSString *recordid; + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict; - (instancetype)initWithDictionary:(NSDictionary *)dict; - (NSDictionary *)dictionaryRepresentation; @end
23.681818
71
0.767754
39379774beac40da910a6a577332f175c41b0a9d
260
h
C
WLStream/prefs.h
rsegecin/WLStream
eaf66610f807bccabf5aabcf3882ffdb05f1adfb
[ "MIT" ]
42
2017-10-04T12:26:50.000Z
2021-12-04T23:25:45.000Z
WLStream/prefs.h
rsegecin/WLStream
eaf66610f807bccabf5aabcf3882ffdb05f1adfb
[ "MIT" ]
5
2017-08-13T12:57:47.000Z
2020-07-31T16:09:27.000Z
WLStream/prefs.h
rsegecin/WLStream
eaf66610f807bccabf5aabcf3882ffdb05f1adfb
[ "MIT" ]
9
2017-11-18T17:36:20.000Z
2022-01-19T20:25:49.000Z
// prefs.h class CPrefs { public: IMMDevice *m_pMMDevice; HMMIO m_hFile = NULL; bool m_bInt16; PWAVEFORMATEX m_pwfx; LPCWSTR m_szFilename; // set hr to S_FALSE to abort but return success CPrefs(int argc, LPCWSTR argv[], HRESULT &hr); ~CPrefs(); };
16.25
49
0.711538
79ea83ab22ed23cc1233b943edae93b97cf3cdef
7,381
h
C
include/org/apache/lucene/bkdtree/BKDTreeReader.h
lukhnos/objclucene
29c7189a0b30ab3d3dd4c8ed148235ee296128b7
[ "MIT" ]
9
2016-01-13T05:38:05.000Z
2020-06-04T23:05:03.000Z
include/org/apache/lucene/bkdtree/BKDTreeReader.h
lukhnos/objclucene
29c7189a0b30ab3d3dd4c8ed148235ee296128b7
[ "MIT" ]
4
2016-05-12T10:40:53.000Z
2016-06-11T19:08:33.000Z
include/org/apache/lucene/bkdtree/BKDTreeReader.h
lukhnos/objclucene
29c7189a0b30ab3d3dd4c8ed148235ee296128b7
[ "MIT" ]
5
2016-01-13T05:37:39.000Z
2019-07-27T16:53:10.000Z
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: ./sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java // #include "J2ObjC_header.h" #pragma push_macro("INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader") #ifdef RESTRICT_OrgApacheLuceneBkdtreeBKDTreeReader #define INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader 0 #else #define INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader 1 #endif #undef RESTRICT_OrgApacheLuceneBkdtreeBKDTreeReader #if __has_feature(nullability) #pragma clang diagnostic push #pragma GCC diagnostic ignored "-Wnullability" #pragma GCC diagnostic ignored "-Wnullability-completeness" #endif #if !defined (OrgApacheLuceneBkdtreeBKDTreeReader_) && (INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader || defined(INCLUDE_OrgApacheLuceneBkdtreeBKDTreeReader)) #define OrgApacheLuceneBkdtreeBKDTreeReader_ #define RESTRICT_OrgApacheLuceneUtilAccountable 1 #define INCLUDE_OrgApacheLuceneUtilAccountable 1 #include "org/apache/lucene/util/Accountable.h" @class OrgApacheLuceneIndexSortedNumericDocValues; @class OrgApacheLuceneSearchDocIdSet; @class OrgApacheLuceneStoreIndexInput; @protocol JavaUtilCollection; @protocol OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter; /*! @brief Handles intersection of a shape with a BKD tree previously written with <code>BKDTreeWriter</code>. */ @interface OrgApacheLuceneBkdtreeBKDTreeReader : NSObject < OrgApacheLuceneUtilAccountable > { @public jint maxDoc_; OrgApacheLuceneStoreIndexInput *in_; } #pragma mark Public - (instancetype __nonnull)initPackagePrivateWithOrgApacheLuceneStoreIndexInput:(OrgApacheLuceneStoreIndexInput *)inArg withInt:(jint)maxDoc; - (id<JavaUtilCollection>)getChildResources; - (OrgApacheLuceneSearchDocIdSet *)intersectWithDouble:(jdouble)latMin withDouble:(jdouble)latMax withDouble:(jdouble)lonMin withDouble:(jdouble)lonMax withOrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter:(id<OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter>)filter withOrgApacheLuceneIndexSortedNumericDocValues:(OrgApacheLuceneIndexSortedNumericDocValues *)sndv; - (OrgApacheLuceneSearchDocIdSet *)intersectWithDouble:(jdouble)latMin withDouble:(jdouble)latMax withDouble:(jdouble)lonMin withDouble:(jdouble)lonMax withOrgApacheLuceneIndexSortedNumericDocValues:(OrgApacheLuceneIndexSortedNumericDocValues *)sndv; - (jlong)ramBytesUsed; // Disallowed inherited constructors, do not use. - (instancetype __nonnull)init NS_UNAVAILABLE; @end J2OBJC_EMPTY_STATIC_INIT(OrgApacheLuceneBkdtreeBKDTreeReader) J2OBJC_FIELD_SETTER(OrgApacheLuceneBkdtreeBKDTreeReader, in_, OrgApacheLuceneStoreIndexInput *) FOUNDATION_EXPORT void OrgApacheLuceneBkdtreeBKDTreeReader_initPackagePrivateWithOrgApacheLuceneStoreIndexInput_withInt_(OrgApacheLuceneBkdtreeBKDTreeReader *self, OrgApacheLuceneStoreIndexInput *inArg, jint maxDoc); FOUNDATION_EXPORT OrgApacheLuceneBkdtreeBKDTreeReader *new_OrgApacheLuceneBkdtreeBKDTreeReader_initPackagePrivateWithOrgApacheLuceneStoreIndexInput_withInt_(OrgApacheLuceneStoreIndexInput *inArg, jint maxDoc) NS_RETURNS_RETAINED; FOUNDATION_EXPORT OrgApacheLuceneBkdtreeBKDTreeReader *create_OrgApacheLuceneBkdtreeBKDTreeReader_initPackagePrivateWithOrgApacheLuceneStoreIndexInput_withInt_(OrgApacheLuceneStoreIndexInput *inArg, jint maxDoc); J2OBJC_TYPE_LITERAL_HEADER(OrgApacheLuceneBkdtreeBKDTreeReader) #endif #if !defined (OrgApacheLuceneBkdtreeBKDTreeReader_Relation_) && (INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader || defined(INCLUDE_OrgApacheLuceneBkdtreeBKDTreeReader_Relation)) #define OrgApacheLuceneBkdtreeBKDTreeReader_Relation_ #define RESTRICT_JavaLangEnum 1 #define INCLUDE_JavaLangEnum 1 #include "java/lang/Enum.h" @class IOSObjectArray; typedef NS_ENUM(NSUInteger, OrgApacheLuceneBkdtreeBKDTreeReader_Relation_Enum) { OrgApacheLuceneBkdtreeBKDTreeReader_Relation_Enum_INSIDE = 0, OrgApacheLuceneBkdtreeBKDTreeReader_Relation_Enum_CROSSES = 1, OrgApacheLuceneBkdtreeBKDTreeReader_Relation_Enum_OUTSIDE = 2, }; @interface OrgApacheLuceneBkdtreeBKDTreeReader_Relation : JavaLangEnum @property (readonly, class, nonnull) OrgApacheLuceneBkdtreeBKDTreeReader_Relation *INSIDE NS_SWIFT_NAME(INSIDE); @property (readonly, class, nonnull) OrgApacheLuceneBkdtreeBKDTreeReader_Relation *CROSSES NS_SWIFT_NAME(CROSSES); @property (readonly, class, nonnull) OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OUTSIDE NS_SWIFT_NAME(OUTSIDE); #pragma mark Public + (OrgApacheLuceneBkdtreeBKDTreeReader_Relation *)valueOfWithNSString:(NSString *)name; + (IOSObjectArray *)values; #pragma mark Package-Private - (OrgApacheLuceneBkdtreeBKDTreeReader_Relation_Enum)toNSEnum; @end J2OBJC_STATIC_INIT(OrgApacheLuceneBkdtreeBKDTreeReader_Relation) /*! INTERNAL ONLY - Use enum accessors declared below. */ FOUNDATION_EXPORT OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_values_[]; inline OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_get_INSIDE(void); J2OBJC_ENUM_CONSTANT(OrgApacheLuceneBkdtreeBKDTreeReader_Relation, INSIDE) inline OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_get_CROSSES(void); J2OBJC_ENUM_CONSTANT(OrgApacheLuceneBkdtreeBKDTreeReader_Relation, CROSSES) inline OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_get_OUTSIDE(void); J2OBJC_ENUM_CONSTANT(OrgApacheLuceneBkdtreeBKDTreeReader_Relation, OUTSIDE) FOUNDATION_EXPORT IOSObjectArray *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_values(void); FOUNDATION_EXPORT OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_valueOfWithNSString_(NSString *name); FOUNDATION_EXPORT OrgApacheLuceneBkdtreeBKDTreeReader_Relation *OrgApacheLuceneBkdtreeBKDTreeReader_Relation_fromOrdinal(NSUInteger ordinal); J2OBJC_TYPE_LITERAL_HEADER(OrgApacheLuceneBkdtreeBKDTreeReader_Relation) #endif #if !defined (OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter_) && (INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader || defined(INCLUDE_OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter)) #define OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter_ @class OrgApacheLuceneBkdtreeBKDTreeReader_Relation; @protocol OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter < JavaObject > - (jboolean)acceptWithDouble:(jdouble)lat withDouble:(jdouble)lon; - (OrgApacheLuceneBkdtreeBKDTreeReader_Relation *)compareWithDouble:(jdouble)latMin withDouble:(jdouble)latMax withDouble:(jdouble)lonMin withDouble:(jdouble)lonMax; @end J2OBJC_EMPTY_STATIC_INIT(OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter) J2OBJC_TYPE_LITERAL_HEADER(OrgApacheLuceneBkdtreeBKDTreeReader_LatLonFilter) #endif #if __has_feature(nullability) #pragma clang diagnostic pop #endif #pragma pop_macro("INCLUDE_ALL_OrgApacheLuceneBkdtreeBKDTreeReader")
43.417647
229
0.817233
79625a3d11892321e984e7247ed282c2dfe25793
724
h
C
src/network.h
HaHaSDP-UCSC/haha-on-sockets
febe88fa10c45641c44e469eae38fbf0cadde9e7
[ "BSD-2-Clause" ]
null
null
null
src/network.h
HaHaSDP-UCSC/haha-on-sockets
febe88fa10c45641c44e469eae38fbf0cadde9e7
[ "BSD-2-Clause" ]
null
null
null
src/network.h
HaHaSDP-UCSC/haha-on-sockets
febe88fa10c45641c44e469eae38fbf0cadde9e7
[ "BSD-2-Clause" ]
null
null
null
/** * @file network.h * @brief Definitions of network types * @author * @version * @date 2017-03-07 */ #ifndef _HA_NETDEFS #define _HA_NETDEFS #include "halib.h" #include "flags.h" #include "neighbor.h" /* BASE COMMUNICATION */ typedef unsigned char opcode; typedef unsigned char ttl; typedef uint16_t uid; typedef struct { //Packet params here //opcode opcode; opcode opcode; flags flags; uid SRCUID; uid DESTUID; uid ORIGINUID; char SRCFIRSTNAME[MAXFIRSTNAME]; //TODO optimize for space. char SRCLASTNAME[MAXFIRSTNAME]; //TODO optimize for space. char SRCPHONE[MAXPHONE]; //TODO optimize for space. char SRCHOMEADDR[MAXHOMEADDR]; //TODO optimize for space. ttl ttl; } Packet; #endif // _HA_NETDEFS_
19.567568
60
0.730663
a7c1d243295835bf8e0fcd8b9c8e428431a36641
346
h
C
src/Items/ItemSword.h
arekinath/MCServer
745ad159f3b365ca0ac100794a921af5c123c557
[ "Apache-2.0" ]
1
2021-05-09T10:27:52.000Z
2021-05-09T10:27:52.000Z
src/Items/ItemSword.h
arekinath/MCServer
745ad159f3b365ca0ac100794a921af5c123c557
[ "Apache-2.0" ]
null
null
null
src/Items/ItemSword.h
arekinath/MCServer
745ad159f3b365ca0ac100794a921af5c123c557
[ "Apache-2.0" ]
1
2019-03-15T11:21:59.000Z
2019-03-15T11:21:59.000Z
#pragma once #include "ItemHandler.h" #include "../World.h" #include "../Entities/Player.h" class cItemSwordHandler : public cItemHandler { public: cItemSwordHandler(int a_ItemType) : cItemHandler(a_ItemType) { } virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override { return (a_BlockType == E_BLOCK_COBWEB); } } ;
11.16129
61
0.713873
80a1dcbfcd2f716c45cde35d19b0c9e1f5f39fab
219
h
C
LTChatDemo/LTChatDemo/LTIMCore/Login/Controllers/LTIMLoginViewController.h
l900416/LTChat
10cbf8202b8085cb362c01197b901f1d48867ed7
[ "MIT" ]
12
2017-10-21T07:33:22.000Z
2019-09-18T01:50:55.000Z
LTChatDemo/LTChatDemo/LTIMCore/Login/Controllers/LTIMLoginViewController.h
l900416/LTChat
10cbf8202b8085cb362c01197b901f1d48867ed7
[ "MIT" ]
1
2018-02-20T11:21:56.000Z
2018-02-20T11:21:56.000Z
LTChatDemo/LTChatDemo/LTIMCore/Login/Controllers/LTIMLoginViewController.h
l900416/LTChat
10cbf8202b8085cb362c01197b901f1d48867ed7
[ "MIT" ]
7
2017-10-21T07:33:23.000Z
2020-11-20T18:03:46.000Z
// // LTIMLoginViewController.h // LTIM // // Created by 梁通 on 2017/9/22. // Copyright © 2017年 Personal. All rights reserved. // #import <UIKit/UIKit.h> @interface LTIMLoginViewController : UIViewController @end
15.642857
53
0.707763
d59e01ba14533379f28be0f53d3c165cd5d0ae22
944
h
C
System/Library/PrivateFrameworks/iTunesStoreUI.framework/SUViewControllerFactory.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
2
2021-11-02T09:23:27.000Z
2022-03-28T08:21:57.000Z
System/Library/PrivateFrameworks/iTunesStoreUI.framework/SUViewControllerFactory.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/iTunesStoreUI.framework/SUViewControllerFactory.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
1
2022-03-28T08:21:59.000Z
2022-03-28T08:21:59.000Z
/* * This header is generated by classdump-dyld 1.5 * on Friday, April 30, 2021 at 11:36:51 AM Mountain Standard Time * Operating System: Version 13.5.1 (Build 17F80) * Image Source: /System/Library/PrivateFrameworks/iTunesStoreUI.framework/iTunesStoreUI * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @interface SUViewControllerFactory : NSObject -(id)newPlaceholderViewController; -(id)newStorePageViewControllerWithSection:(id)arg1 ; -(id)newViewControllerForPage:(id)arg1 ofType:(long long)arg2 ; -(id)newNetworkLockoutViewControllerWithSection:(id)arg1 ; -(id)newComposeReviewViewControllerWithCompositionURL:(id)arg1 ; -(id)newDownloadsViewController; -(id)newViewControllerForTrackList:(id)arg1 ; -(id)newVolumeViewController; @end
44.952381
130
0.686441
5f4f1036317af7081fd67ecd57aba8fdd32ad22b
2,247
h
C
applications/physbam/physbam-lib/External_Libraries/Archives/glux/include/glux_GL_EXT_point_parameters.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
20
2017-07-03T19:09:09.000Z
2021-09-10T02:53:56.000Z
applications/physbam/physbam-lib/External_Libraries/Archives/glux/include/glux_GL_EXT_point_parameters.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
null
null
null
applications/physbam/physbam-lib/External_Libraries/Archives/glux/include/glux_GL_EXT_point_parameters.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
9
2017-09-17T02:05:06.000Z
2020-01-31T00:12:01.000Z
// -------------------------------------------------------- // Generated by glux perl script (Wed Mar 31 17:19:35 2004) // // Sylvain Lefebvre - 2002 - Sylvain.Lefebvre@imag.fr // -------------------------------------------------------- #include "glux_no_redefine.h" #include "glux_ext_defs.h" #include "gluxLoader.h" #include "gluxPlugin.h" // -------------------------------------------------------- // Plugin creation // -------------------------------------------------------- #ifndef __GLUX_GL_EXT_point_parameters__ #define __GLUX_GL_EXT_point_parameters__ GLUX_NEW_PLUGIN(GL_EXT_point_parameters); // -------------------------------------------------------- // Extension conditions // -------------------------------------------------------- // -------------------------------------------------------- // Extension defines // -------------------------------------------------------- #ifndef GL_POINT_SIZE_MIN_EXT # define GL_POINT_SIZE_MIN_EXT 0x8126 #endif #ifndef GL_POINT_SIZE_MAX_EXT # define GL_POINT_SIZE_MAX_EXT 0x8127 #endif #ifndef GL_POINT_FADE_THRESHOLD_SIZE_EXT # define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 #endif #ifndef GL_DISTANCE_ATTENUATION_EXT # define GL_DISTANCE_ATTENUATION_EXT 0x8129 #endif // -------------------------------------------------------- // Extension gl function typedefs // -------------------------------------------------------- #ifndef __GLUX__GLFCT_glPointParameterfEXT typedef void (APIENTRYP PFNGLUXPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); #endif #ifndef __GLUX__GLFCT_glPointParameterfvEXT typedef void (APIENTRYP PFNGLUXPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); #endif // -------------------------------------------------------- // Extension gl functions // -------------------------------------------------------- namespace glux { #ifndef __GLUX__GLFCT_glPointParameterfEXT extern PFNGLUXPOINTPARAMETERFEXTPROC glPointParameterfEXT; #endif #ifndef __GLUX__GLFCT_glPointParameterfvEXT extern PFNGLUXPOINTPARAMETERFVEXTPROC glPointParameterfvEXT; #endif } // namespace glux // -------------------------------------------------------- #endif // --------------------------------------------------------
37.45
94
0.509123
2af789483b2aafa1a3ecf4599f904a1858700c24
3,369
h
C
examples/basic/src/render/ShaderProgram.h
darsto/spooky
f1d43e63137bb9179ec76683df5ee51669d35815
[ "MIT" ]
7
2016-05-03T15:58:49.000Z
2018-12-16T15:50:44.000Z
examples/basic/src/render/ShaderProgram.h
darsto/spookytom
f1d43e63137bb9179ec76683df5ee51669d35815
[ "MIT" ]
11
2016-08-14T10:56:52.000Z
2020-09-29T13:32:35.000Z
examples/basic/src/render/ShaderProgram.h
darsto/spookytom
f1d43e63137bb9179ec76683df5ee51669d35815
[ "MIT" ]
3
2016-06-28T23:37:21.000Z
2019-10-01T14:15:32.000Z
/* * Copyright (c) 2017 Dariusz Stojaczyk. All Rights Reserved. * The following source code is released under an MIT-style license, * that can be found in the LICENSE file. */ #ifndef SPOOKY_RENDER_SHADERPROGRAM_H #define SPOOKY_RENDER_SHADERPROGRAM_H #pragma once #include <glm/glm.hpp> #include <string> #include <vector> #include "render/opengl.h" class Shader; /** * Container of GLSL shaders. Wraps OpenGL shader program API. * Provides simple interface to link all the contained shaders * with a single call. */ class ShaderProgram { public: /** * The constructor. * Use id() method to check if the program has been successfully created. */ ShaderProgram(); /** * Copy constructor. Deleted. */ ShaderProgram(const ShaderProgram &) = delete; /** * Move constructor. Deleted */ ShaderProgram(ShaderProgram &&) = delete; /** * Copy assignment operator. Deleted. */ ShaderProgram &operator=(const ShaderProgram &) = delete; /** * Move assignment operator. Deleted */ ShaderProgram &operator=(ShaderProgram &&) = delete; /** * Get unique program identifier. * If equals 0, the program is invalid and should not be used. * @return unique program identifier */ GLuint id(); /** * Bind given shader's id to to this program. * The ShaderProgram does not copy, nor keep the reference of the shader. * Given shader object can be safely deleted even before the shader program * has been linked. Internal OpenGL implementation will defer that deletion * until after the whole program is deleted * @param shader shader to be added to the container * @return return code. 0 on success, -1 on error */ int addShader(const Shader &shader); /** * Upload all the shaders in the internal container to the GPU. * The internal container is emptied upon calling this method. * The shaders are accessed via global state, their corresponding * Shader objects can be safely deleted after calling this method. * @return return code. 0 on success, -1 on error */ int linkProgram(); /** * Set this program as the currently used one. * Note that it must be already linked. * @return return code. 0 on success, -1 on error */ int useProgram(); /** * Set uniform variable in the GLSL program on the GPU. * @param name name of the variable to set * @param val value to set * @return return code. 0 on success, -1 on error */ int setUniform(const std::string &name, float val); /** * @overload ShaderProgram::setUniform(const std::string &name, float value) */ int setUniform(const std::string &name, const glm::vec4 &val); /** * @overload ShaderProgram::setUniform(sconst td::string &name, float value) */ int setUniform(const std::string &name, const glm::mat4 &val); /** * @overload ShaderProgram::setUniform(conststd::string &name, float value) */ int setUniform(const std::string &name, int val); /** * The destructor. * If program will be deleted now. */ ~ShaderProgram(); private: GLuint m_id = 0; bool m_linked = false; std::vector<GLuint> m_boundShaders; }; #endif //SPOOKY_RENDER_SHADERPROGRAM_H
27.614754
80
0.6542
468b6e7e9a1dfa4d6b32cd0adc339f94ec47e9a6
534
c
C
Jumping Mario!.c
fakeid30/UVA-problems
2d31b8c48873d6813a341a3aa72d067174656d1c
[ "Unlicense" ]
1
2021-05-13T07:52:38.000Z
2021-05-13T07:52:38.000Z
Jumping Mario!.c
fakeid30/UVA-problems
2d31b8c48873d6813a341a3aa72d067174656d1c
[ "Unlicense" ]
null
null
null
Jumping Mario!.c
fakeid30/UVA-problems
2d31b8c48873d6813a341a3aa72d067174656d1c
[ "Unlicense" ]
2
2021-05-13T07:53:16.000Z
2021-05-13T07:54:36.000Z
#include<stdio.h> int main() { int T,N,Array[50],i,j,c1,c2; scanf("%d",&T); for(i=1;i<=T;i++) { c1=0; c2=0; scanf("%d",&N); for(j=0;j<N;j++) { scanf("%d",&Array[j]); } for(j=0;j<N-1;j++) { if(Array[j]<Array[j+1]) { c1++; } else if(Array[j]>Array[j+1]) { c2++; } } printf("Case %d: %d %d\n",i,c1,c2); } return 0; }
17.8
43
0.297753
00f6169cefd8da406c5b9630e55b00fe3dd190ae
10,896
c
C
fabric_management/librio/src/RapidIO_Port_Config_API.c
RapidIO/RRMAP
0e73fd45b272ceb8d732a144b7a2d8fe90dbe50e
[ "BSD-3-Clause" ]
14
2017-08-30T09:39:29.000Z
2022-03-28T13:38:44.000Z
fabric_management/librio/src/RapidIO_Port_Config_API.c
RapidIO/RRMAP
0e73fd45b272ceb8d732a144b7a2d8fe90dbe50e
[ "BSD-3-Clause" ]
null
null
null
fabric_management/librio/src/RapidIO_Port_Config_API.c
RapidIO/RRMAP
0e73fd45b272ceb8d732a144b7a2d8fe90dbe50e
[ "BSD-3-Clause" ]
5
2017-02-17T03:54:36.000Z
2019-09-05T11:04:13.000Z
/* **************************************************************************** Copyright (c) 2014, Integrated Device Technology Inc. Copyright (c) 2014, RapidIO Trade Association 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. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ************************************************************************* */ #include <stdint.h> #include <stddef.h> #include "CPS_DeviceDriver.h" #include "RXS_DeviceDriver.h" #include "Tsi721_DeviceDriver.h" #include "Tsi57x_DeviceDriver.h" #include "DSF_DB_Private.h" #ifdef __cplusplus extern "C" { #endif // Converts rio_pc_pw_t to lane count int pw_to_lanes[ (int)(rio_pc_pw_last)+1] = {1, 2, 4, 1, 2, 4, 0}; // Converts rio_pc_pw_t to string char *pw_to_str[(int)(rio_pc_pw_last) + 1] = { (char *)"1x", (char *)"2x", (char *)"4x", (char *)"1xL0", (char *)"1xL1", (char *)"1xL2", (char *)"FAIL", }; // Converts lane count to rio_pc_pw_t rio_pc_pw_t lanes_to_pw[5] = { rio_pc_pw_last, // 0, illegal rio_pc_pw_1x, // 1 rio_pc_pw_2x, // 2 rio_pc_pw_last, // 3, illegal rio_pc_pw_4x, // 4 }; // Converts lane speed to a string char *ls_to_str[(int)(rio_pc_ls_last) + 1] = { (char *)"1.25", (char *)"2.5", (char *)"3.125", (char *)"5.0", (char *)"6.25", (char *)"10.3", (char *)"12.5", (char *)"FAIL", }; // Converts reset configuration to a string char *rst_to_str[(int)(rio_pc_rst_last) + 1] = { (char *)"Dev ", (char *)"Port", (char *)"Int ", (char *)"PtWr", (char *)"Ignr", (char *)"??", }; char *fc_to_str[(int)(rio_pc_fc_last) + 1] = { (char *)"RX", (char *)"TX", (char *)"??", }; char *is_to_str[(int)(rio_pc_is_last) + 1] = { (char *)" 1", (char *)" 2", (char *)" 3", (char *)"??", }; uint32_t rio_pc_get_config(DAR_DEV_INFO_t *dev_info, rio_pc_get_config_in_t *in_parms, rio_pc_get_config_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_get_config(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_get_config(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_get_config(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_get_config(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_get_config(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_set_config(DAR_DEV_INFO_t *dev_info, rio_pc_set_config_in_t *in_parms, rio_pc_set_config_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_set_config(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_set_config(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_set_config(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_set_config(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_set_config(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_get_status(DAR_DEV_INFO_t *dev_info, rio_pc_get_status_in_t *in_parms, rio_pc_get_status_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_get_status(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_get_status(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_get_status(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_get_status(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_get_status(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_reset_port(DAR_DEV_INFO_t *dev_info, rio_pc_reset_port_in_t *in_parms, rio_pc_reset_port_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S1871, c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_reset_port(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_reset_port(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_reset_port(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_reset_port(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_reset_port(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_reset_link_partner(DAR_DEV_INFO_t *dev_info, rio_pc_reset_link_partner_in_t *in_parms, rio_pc_reset_link_partner_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S1871, c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_reset_link_partner(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_reset_link_partner(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_reset_link_partner(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_reset_link_partner(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_reset_link_partner(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_clr_errs(DAR_DEV_INFO_t *dev_info, rio_pc_clr_errs_in_t *in_parms, rio_pc_clr_errs_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S1871, c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_clr_errs(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_clr_errs(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_clr_errs(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_clr_errs(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_clr_errs(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_secure_port(DAR_DEV_INFO_t *dev_info, rio_pc_secure_port_in_t *in_parms, rio_pc_secure_port_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S1871, c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_secure_port(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_secure_port(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_secure_port(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_secure_port(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_secure_port(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_dev_reset_config(DAR_DEV_INFO_t *dev_info, rio_pc_dev_reset_config_in_t *in_parms, rio_pc_dev_reset_config_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return CPS_rio_pc_dev_reset_config(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return rxs_rio_pc_dev_reset_config(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return tsi721_rio_pc_dev_reset_config(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return tsi57x_rio_pc_dev_reset_config(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return DSF_rio_pc_dev_reset_config(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } uint32_t rio_pc_probe(DAR_DEV_INFO_t *dev_info, rio_pc_probe_in_t *in_parms, rio_pc_probe_out_t *out_parms) { NULL_CHECK if (VALIDATE_DEV_INFO(dev_info)) { //@sonar:off - c:S1871, c:S3458 switch (dev_info->driver_family) { case RIO_CPS_DEVICE: return default_rio_pc_probe(dev_info, in_parms, out_parms); case RIO_RXS_DEVICE: return default_rio_pc_probe(dev_info, in_parms, out_parms); case RIO_TSI721_DEVICE: return default_rio_pc_probe(dev_info, in_parms, out_parms); case RIO_TSI57X_DEVICE: return default_rio_pc_probe(dev_info, in_parms, out_parms); case RIO_UNKNOWN_DEVICE: return default_rio_pc_probe(dev_info, in_parms, out_parms); case RIO_UNITIALIZED_DEVICE: default: return RIO_DAR_IMP_SPEC_FAILURE; } //@sonar:on } return DAR_DB_INVALID_HANDLE; } #ifdef __cplusplus } #endif
26.970297
80
0.739629
2e35aac6596060f0a9d9e2b275aa178698bbac73
228
h
C
WPopoverViewDemo/PopoverViewController.h
codefunny/WPopoverViewDemo
915a416434f41e20d90031cbff33a2ed0c4086c3
[ "MIT" ]
null
null
null
WPopoverViewDemo/PopoverViewController.h
codefunny/WPopoverViewDemo
915a416434f41e20d90031cbff33a2ed0c4086c3
[ "MIT" ]
null
null
null
WPopoverViewDemo/PopoverViewController.h
codefunny/WPopoverViewDemo
915a416434f41e20d90031cbff33a2ed0c4086c3
[ "MIT" ]
null
null
null
// // PopoverViewController.h // WPopoverViewDemo // // Created by wenchao on 16/2/2. // Copyright © 2016年 wenchao. All rights reserved. // #import <UIKit/UIKit.h> @interface PopoverViewController : UIViewController @end
16.285714
51
0.719298
7846d7b893506227220209ffa338e69c4c49f144
768
h
C
tools/ros/project_template/ros_ws/src/logger/include/logger.h
tmori/athrill
bb271ab47e0df0ac60ea52bbf1e285fea6ec452f
[ "OLDAP-2.6" ]
44
2018-03-14T02:13:09.000Z
2022-01-23T20:14:48.000Z
tools/ros/project_template/ros_ws/src/logger/include/logger.h
tmori/athrill
bb271ab47e0df0ac60ea52bbf1e285fea6ec452f
[ "OLDAP-2.6" ]
26
2018-10-25T23:48:26.000Z
2020-06-09T07:48:19.000Z
tools/ros/projects/node1/ros_ws/src/logger/include/logger.h
tmori/athrill
bb271ab47e0df0ac60ea52bbf1e285fea6ec452f
[ "OLDAP-2.6" ]
11
2018-03-14T02:06:49.000Z
2020-12-04T15:31:28.000Z
#ifndef _ATHRILL_ROS_LOGGER_H_ #define _ATHRILL_ROS_LOGGER_H_ #include <pthread.h> #include "log_types.h" #include "log_config_type.h" #include "log_message.h" #include "log_file.h" using namespace athrill::ros::lib; namespace athrill { namespace ros { namespace lib { class Logger { public: Logger(LoggerConfigType &config); ~Logger(void); int init(void); void log(LogLevelType level, const char* fmt, ...); private: LoggerConfigType config; pthread_mutex_t mutex; LogMessage *message; LogFile *log_file[LOG_LEVEL_NUM + 1]; LogFile *lock_file; int log_backup(void); void log_lock(void); void log_unlock(void); Logger(void); }; } } } #endif /* _ATHRILL_ROS_LOGGER_H_ */
19.2
56
0.669271
a3e71128f118f1020231d8a3b49cc917f162aee4
532
c
C
tests/arch/arm/arm_irq_advanced_features/src/main.c
maxvankessel/zephyr
769d91b922b736860244b22e25328d91d9a17657
[ "Apache-2.0" ]
6,224
2016-06-24T20:04:19.000Z
2022-03-31T20:33:45.000Z
tests/arch/arm/arm_irq_advanced_features/src/main.c
Conexiotechnologies/zephyr
fde24ac1f25d09eb9722ce4edc6e2d3f844b5bce
[ "Apache-2.0" ]
32,027
2017-03-24T00:02:32.000Z
2022-03-31T23:45:53.000Z
tests/arch/arm/arm_irq_advanced_features/src/main.c
Conexiotechnologies/zephyr
fde24ac1f25d09eb9722ce4edc6e2d3f844b5bce
[ "Apache-2.0" ]
4,374
2016-08-11T07:28:47.000Z
2022-03-31T14:44:59.000Z
/* * Copyright (c) 2019 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #include <ztest.h> extern void test_arm_zero_latency_irqs(void); extern void test_arm_dynamic_direct_interrupts(void); extern void test_arm_irq_target_state(void); void test_main(void) { ztest_test_suite(arm_irq_advanced_features, ztest_unit_test(test_arm_dynamic_direct_interrupts), ztest_unit_test(test_arm_zero_latency_irqs), ztest_unit_test(test_arm_irq_target_state)); ztest_run_test_suite(arm_irq_advanced_features); }
25.333333
54
0.823308
a225c3728a135ccdce30163b5cfdcc82e93b3841
1,474
c
C
Effective-C/ch2/array.c
onioneffect/Homework
63d64f410318b17d2d3817ac5b39a365bd490dc0
[ "MIT" ]
null
null
null
Effective-C/ch2/array.c
onioneffect/Homework
63d64f410318b17d2d3817ac5b39a365bd490dc0
[ "MIT" ]
null
null
null
Effective-C/ch2/array.c
onioneffect/Homework
63d64f410318b17d2d3817ac5b39a365bd490dc0
[ "MIT" ]
null
null
null
#include <stdio.h> #define FUNC_NUM 3 /* Three simple functions to demonstrate the exercise: */ float average(int a, int b) { return (a + b) / (float) 2; } float highest(int a, int b) { return (float) ((a > b) ? a : b); } float multi(int a, int b) { float ret = 0; for(int i = 0; i < b; i++) { ret += a; } return ret; } /* Array with pointers to our three functions... Thank you, StackOverflow. */ static float (*funcArray[FUNC_NUM])(int, int) = { &average, &highest, &multi }; /* Array with the arguments for our functions: */ static const int argsArray[FUNC_NUM][2] = { {2, 3}, // average(2, 3) {500, 600}, // highest(500, 600) {2, 6} // multi(2, 6) }; /* printer_func handles each return value from our demo functions */ void printer_func(float return_value, int func_type) { switch (func_type) { case 0: /* Average */ printf("The average between your two numbers is %f!\n", return_value); break; case 1: /* Get highest number */ printf("The highest between your two numbers is %d!\n", (int)return_value); break; case 2: /* Multiply two numbers */ printf("Your numbers multiplied equal %d!\n", (int)return_value); break; } } int main(void) { /* Loop through funcArray and match each item with its arguments */ for (int i = 0; i < FUNC_NUM; i++) { float retval = (*funcArray[i])(argsArray[i][0], argsArray[i][1]); /* Then print the results */ printer_func(retval, i); } return 0; }
23.03125
68
0.62483
b114c6c0463bb5853e8daf6e4f96f8d2d76f98ec
397
h
C
esp8266/src/controller.h
phito/northernlights
a53054984756df7615fffa0f80916a0b24d42ed9
[ "MIT" ]
null
null
null
esp8266/src/controller.h
phito/northernlights
a53054984756df7615fffa0f80916a0b24d42ed9
[ "MIT" ]
null
null
null
esp8266/src/controller.h
phito/northernlights
a53054984756df7615fffa0f80916a0b24d42ed9
[ "MIT" ]
null
null
null
#ifndef CONTROLLER_H #define CONTROLLER_H #include "Arduino.h" #include <Adafruit_NeoPixel.h> class Controller : public Adafruit_NeoPixel { public: Controller(uint16_t n, uint8_t p, neoPixelType t) : Adafruit_NeoPixel(n, p, t) {} void init(); void service(); void setColor(int8_t r, int8_t g, int8_t b); void setColor(int16_t led, int8_t r, int8_t g, int8_t b); }; #endif
22.055556
86
0.70529
36a8f806b18b5904d9cba6b7190d9bb3436785b7
694
h
C
System/Library/PrivateFrameworks/TVHomeSharingServices.framework/TVHSSDAAPAssetData.h
lechium/tvOS10Headers
f0c99993da6cc502d36fdc5cb4ff90d94b12bf67
[ "MIT" ]
4
2017-03-23T00:01:54.000Z
2018-08-04T20:16:32.000Z
System/Library/PrivateFrameworks/TVHomeSharingServices.framework/TVHSSDAAPAssetData.h
lechium/tvOS10Headers
f0c99993da6cc502d36fdc5cb4ff90d94b12bf67
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/TVHomeSharingServices.framework/TVHSSDAAPAssetData.h
lechium/tvOS10Headers
f0c99993da6cc502d36fdc5cb4ff90d94b12bf67
[ "MIT" ]
4
2017-05-14T16:23:26.000Z
2019-12-21T15:07:59.000Z
/* * This header is generated by classdump-dyld 1.0 * on Wednesday, March 22, 2017 at 9:07:48 AM Mountain Standard Time * Operating System: Version 10.1 (Build 14U593) * Image Source: /System/Library/PrivateFrameworks/TVHomeSharingServices.framework/TVHomeSharingServices * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <TVHomeSharingServices/TVHSSDMAPAssetData.h> @interface TVHSSDAAPAssetData : TVHSSDMAPAssetData -(id)_valueForCode:(unsigned)arg1 data:(char*)arg2 length:(unsigned)arg3 ; -(unsigned)_codeForProperty:(id)arg1 ; -(id)_mediaTypeForMediaKind:(unsigned)arg1 ; -(id)_mediaKindsArrayFromData:(char*)arg1 length:(unsigned)arg2 ; @end
38.555556
103
0.792507
d24bbd910d7367f3e0717fcfeb819041754201b9
5,899
h
C
ext/opcache/Optimizer/zend_cfg.h
pp3345/php-src
67136fe77b24e59b185775ec308d81235666aaf9
[ "PHP-3.01" ]
null
null
null
ext/opcache/Optimizer/zend_cfg.h
pp3345/php-src
67136fe77b24e59b185775ec308d81235666aaf9
[ "PHP-3.01" ]
null
null
null
ext/opcache/Optimizer/zend_cfg.h
pp3345/php-src
67136fe77b24e59b185775ec308d81235666aaf9
[ "PHP-3.01" ]
null
null
null
/* +----------------------------------------------------------------------+ | Zend Engine, CFG - Control Flow Graph | +----------------------------------------------------------------------+ | Copyright (c) 1998-2017 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ #ifndef ZEND_CFG_H #define ZEND_CFG_H /* zend_basic_bloc.flags */ #define ZEND_BB_START (1<<0) /* fist block */ #define ZEND_BB_FOLLOW (1<<1) /* follows the next block */ #define ZEND_BB_TARGET (1<<2) /* jump taget */ #define ZEND_BB_EXIT (1<<3) /* without successors */ #define ZEND_BB_ENTRY (1<<4) /* stackless entry */ #define ZEND_BB_TRY (1<<5) /* start of try block */ #define ZEND_BB_CATCH (1<<6) /* start of catch block */ #define ZEND_BB_FINALLY (1<<7) /* start of finally block */ #define ZEND_BB_FINALLY_END (1<<8) /* end of finally block */ #define ZEND_BB_GEN_VAR (1<<9) /* start of live range */ #define ZEND_BB_KILL_VAR (1<<10) /* end of live range */ #define ZEND_BB_UNREACHABLE_FREE (1<<11) /* unreachable loop free */ #define ZEND_BB_RECV_ENTRY (1<<12) /* RECV entry */ #define ZEND_BB_LOOP_HEADER (1<<16) #define ZEND_BB_IRREDUCIBLE_LOOP (1<<17) #define ZEND_BB_REACHABLE (1<<31) #define ZEND_BB_PROTECTED (ZEND_BB_ENTRY|ZEND_BB_RECV_ENTRY|ZEND_BB_TRY|ZEND_BB_CATCH|ZEND_BB_FINALLY|ZEND_BB_FINALLY_END|ZEND_BB_GEN_VAR|ZEND_BB_KILL_VAR) typedef struct _zend_basic_block { uint32_t flags; uint32_t start; /* first opcode number */ uint32_t len; /* number of opcodes */ int successors[2]; /* up to 2 successor blocks */ int predecessors_count; /* number of predecessors */ int predecessor_offset; /* offset of 1-st predecessor */ int idom; /* immediate dominator block */ int loop_header; /* closest loop header, or -1 */ int level; /* steps away from the entry in the dom. tree */ int children; /* list of dominated blocks */ int next_child; /* next dominated block */ } zend_basic_block; /* +------------+---+---+---+---+---+ | |OP1|OP2|EXT| 0 | 1 | +------------+---+---+---+---+---+ |JMP |ADR| | |OP1| - | |JMPZ | |ADR| |OP2|FOL| |JMPNZ | |ADR| |OP2|FOL| |JMPZNZ | |ADR|ADR|OP2|EXT| |JMPZ_EX | |ADR| |OP2|FOL| |JMPNZ_EX | |ADR| |OP2|FOL| |JMP_SET | |ADR| |OP2|FOL| |COALESCE | |ADR| |OP2|FOL| |ASSERT_CHK | |ADR| |OP2|FOL| |NEW | |ADR| |OP2|FOL| |DCL_ANON* |ADR| | |OP1|FOL| |FE_RESET_* | |ADR| |OP2|FOL| |FE_FETCH_* | | |ADR|EXT|FOL| |CATCH | | |ADR|EXT|FOL| |FAST_CALL |ADR| | |OP1|FOL| |FAST_RET | | | | - | - | |RETURN* | | | | - | - | |EXIT | | | | - | - | |THROW | | | | - | - | |* | | | |FOL| - | +------------+---+---+---+---+---+ */ typedef struct _zend_cfg { int blocks_count; /* number of basic blocks */ zend_basic_block *blocks; /* array of basic blocks */ int *predecessors; uint32_t *map; unsigned int split_at_live_ranges : 1; unsigned int split_at_calls : 1; unsigned int split_at_recv : 1; } zend_cfg; /* Build Flags */ #define ZEND_RT_CONSTANTS (1<<31) #define ZEND_CFG_STACKLESS (1<<30) #define ZEND_SSA_DEBUG_LIVENESS (1<<29) #define ZEND_SSA_DEBUG_PHI_PLACEMENT (1<<28) #define ZEND_SSA_RC_INFERENCE (1<<27) #define ZEND_CFG_SPLIT_AT_LIVE_RANGES (1<<26) #define ZEND_CFG_NO_ENTRY_PREDECESSORS (1<<25) #define ZEND_CFG_RECV_ENTRY (1<<24) #define ZEND_CALL_TREE (1<<23) #define ZEND_SSA_USE_CV_RESULTS (1<<22) #define CRT_CONSTANT_EX(op_array, node, rt_constants) \ ((rt_constants) ? \ RT_CONSTANT(op_array, (node)) \ : \ CT_CONSTANT_EX(op_array, (node).constant) \ ) #define CRT_CONSTANT(node) \ CRT_CONSTANT_EX(op_array, node, (build_flags & ZEND_RT_CONSTANTS)) #define RETURN_VALUE_USED(opline) \ ((opline)->result_type != IS_UNUSED) BEGIN_EXTERN_C() int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg, uint32_t *func_flags); void zend_cfg_remark_reachable_blocks(const zend_op_array *op_array, zend_cfg *cfg); int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg); int zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg); int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg, uint32_t *flags); END_EXTERN_C() #endif /* ZEND_CFG_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: */
42.438849
162
0.528734
328533d33c0af10e7b006cfbbd8b7cf701a6bfce
5,828
h
C
src/viewer.h
BlatantlyX/DungeonsOfDaggorath
8cd3ef843c26a9303007d3741f66114957ed19fd
[ "Zlib" ]
4
2020-12-30T20:16:45.000Z
2022-01-25T16:07:18.000Z
src/viewer.h
BlatantlyX/DungeonsOfDaggorath
8cd3ef843c26a9303007d3741f66114957ed19fd
[ "Zlib" ]
1
2015-06-05T23:16:22.000Z
2015-06-06T07:06:34.000Z
src/viewer.h
BlatantlyX/DungeonsOfDaggorath
8cd3ef843c26a9303007d3741f66114957ed19fd
[ "Zlib" ]
2
2018-06-09T22:27:14.000Z
2019-10-05T22:09:55.000Z
/**************************************** Daggorath PC-Port Version 0.2.1 Richard Hunerlach November 13, 2002 The copyright for Dungeons of Daggorath is held by Douglas J. Morgan. (c) 1982, DynaMicro *****************************************/ // Dungeons of Daggorath // PC-Port // Filename: viewer.h // // This class manages drawing to the screen, including // setting up the OpenGL data. It's a work in progress. // // At the moment it is huge, which means that it really // needs to be broken into smaller, more well-defined // classes. But it works for the present. #ifndef DOD_VIEWER_HEADER #define DOD_VIEWER_HEADER #include "dod.h" #include "dodgame.h" extern dodGame game; class Viewer { public: // Constructor Viewer(); // Public Interface void setup_opengl(); void draw_game(); bool draw_fade(); void enough_fade(); void death_fade(int WIZ[]); void displayCopyright(); void displayWelcomeMessage(); void displayDeath(); void displayWinner(); void displayEnough(); void displayPrepare(); void drawArea(TXB * a); void clearArea(TXB * a); void drawTorchHighlite(); void WIZIN0(); int LUKNEW(); void PUPDAT(); void PUPSUB(); void STATUS(); void PROMPT(); void EXAMIN(); void PCRLF(); void PRTOBJ(int X, bool highlite); void OUTSTI(dodBYTE * comp); void OUTSTR(dodBYTE * str); void OUTCHR(dodBYTE c); void TXTXXX(dodBYTE c); void TXTSCR(); void VIEWER(); void SETSCL(); void DRAWIT(int * vl); void PDRAW(int * vl, dodBYTE dir, dodBYTE pdir); void CMRDRW(int * vl, int creNum); void SETFAD(); dodSHORT ScaleX(int x); dodSHORT ScaleY(int y); float ScaleXf(float x); float ScaleYf(float y); void MAPPER(); void setVidInv(bool inv); void drawVectorList(int VLA[]); void drawVector(float X0, float Y0, float X1, float Y1); void Reset(); bool ShowFade(int fadeMode); void drawMenu(menu, int, int); void drawMenuList(int, int, std::string, std::string[], int, int); void drawMenuScrollbar(std::string, int); void drawMenuStringTitle(std::string); void drawMenuString(std::string); void aboutBox(void); // Public Data Fields dodBYTE VCTFAD; dodBYTE RANGE; bool showSeerMap; Uint32 delay, delay1, delay2; bool done; int fadeVal; dodBYTE UPDATE; dodSHORT display_mode; // 0 = map, 1 = 3D, 2 = Examine, 3 = Prepare int fadChannel; int buzzStep; int midPause; int prepPause; dodBYTE Scale[21]; float Scalef[21]; int * LArch[4]; int * FArch[4]; int * RArch[4]; char textArea[(32*4)+1]; char examArea[(32*19)+1]; char statArea[(32*1)+1]; TXB TXTPRI; TXB TXTEXA; TXB TXTSTS; GLfloat bgColor[3]; GLfloat fgColor[3]; dodBYTE RLIGHT; dodBYTE MLIGHT; dodBYTE OLIGHT; dodBYTE VXSCAL; dodBYTE VYSCAL; float VXSCALf; float VYSCALf; dodBYTE TXBFLG; TXB * TXB_U; int tcaret; int tlen; dodBYTE enough1[21]; dodBYTE enough2[20]; dodBYTE winner1[21]; dodBYTE winner2[17]; dodBYTE death[21]; dodBYTE copyright[21]; dodBYTE welcome1[14]; dodBYTE welcome2[20]; dodBYTE prepstr[6]; dodBYTE exps[3]; dodBYTE exam1[9]; dodBYTE exam2[8]; dodBYTE exam3[7]; dodBYTE NEWLUK; int LINES[11]; dodBYTE HLFSTP; dodBYTE BAKSTP; dodBYTE NEWLIN; enum { MODE_MAP=0, MODE_3D, MODE_EXAMINE, MODE_TITLE, FADE_BEGIN=1, FADE_MIDDLE, FADE_DEATH, FADE_VICTORY, }; private: // Internal Implementation void drawVectorListAQ(int VLA[]); void drawCharacter(char c); void drawString(int x, int y, std::string str); void drawString_internal(int x, int y, dodBYTE * str, int len); void plotPoint(double X, double Y); char dod_to_ascii(dodBYTE c); // Data Fields dodSHORT VCNTRX; dodSHORT VCNTRY; dodBYTE OROW; dodBYTE OCOL; dodBYTE MAGFLG; dodBYTE PASFLG; int HLFSCL; int BAKSCL; int NORSCL; public: int A_VLA[33]; int B_VLA[49]; int C_VLA[41]; int D_VLA[33]; int E_VLA[33]; int F_VLA[25]; int G_VLA[49]; int H_VLA[25]; int I_VLA[25]; int J_VLA[25]; int K_VLA[65]; int L_VLA[17]; int M_VLA[41]; int N_VLA[41]; int O_VLA[33]; int P_VLA[33]; int Q_VLA[57]; int R_VLA[57]; int S_VLA[57]; int T_VLA[33]; int U_VLA[25]; int V_VLA[41]; int W_VLA[41]; int X_VLA[73]; int Y_VLA[41]; int Z_VLA[57]; int NM0_VLA[33]; int NM1_VLA[25]; int NM2_VLA[49]; int NM3_VLA[57]; int NM4_VLA[33]; int NM5_VLA[49]; int NM6_VLA[41]; int NM7_VLA[49]; int NM8_VLA[57]; int NM9_VLA[49]; int PER_VLA[9]; int UND_VLA[9]; int EXP_VLA[17]; int QSM_VLA[49]; int SHL_VLA[9]; int SHR_VLA[33]; int LHL_VLA[17]; int LHR_VLA[41]; int FSL_VLA[41]; //Forward Slash int BSL_VLA[41]; //Back Slash int PCT_VLA[57]; //Percent int PLS_VLA[17]; //Plus int DSH_VLA[9]; //Dash int * AZ_VLA[50]; int SP_VLA[39]; int WR_VLA[42]; int SC_VLA[41]; int BL_VLA[66]; int GL_VLA[141]; int VI_VLA[65]; int S1_VLA[130]; int S2_VLA[126]; int K1_VLA[153]; int K2_VLA[149]; int W0_VLA[133]; public: int W1_VLA[199]; int W2_VLA[185]; //private: int LAD_VLA[56]; int HUP_VLA[29]; int HDN_VLA[19]; int CEI_VLA[6]; int LPK_VLA[12]; int RPK_VLA[12]; int FSD_VLA[8]; int LSD_VLA[8]; int RSD_VLA[8]; int RWAL_VLA[10]; int LWAL_VLA[10]; int FWAL_VLA[11]; int RPAS_VLA[15]; int LPAS_VLA[15]; int FPAS_VLA[1]; int RDOR_VLA[24]; int LDOR_VLA[24]; int FDOR_VLA[25]; int FLATAB[3]; int ** FLATABv[3]; int * FWDOBJ[6]; int * FWDCRE[12]; int SHIE_VLA[14]; int SWOR_VLA[11]; int TORC_VLA[10]; int RING_VLA[12]; int SCRO_VLA[12]; int FLAS_VLA[10]; }; #endif // DOD_VIEWER_HEADER
20.377622
69
0.630748
5cf1f1e3c267336244eae12ad8c83510b1f413e3
1,178
h
C
modules/spaint/include/spaint/visualisation/VisualiserFactory.h
GucciPrada/spaint
b09ff1ec0d9e123cf316f2737e1b70b5ecc0beea
[ "Unlicense" ]
1
2019-05-16T06:39:21.000Z
2019-05-16T06:39:21.000Z
modules/spaint/include/spaint/visualisation/VisualiserFactory.h
GucciPrada/spaint
b09ff1ec0d9e123cf316f2737e1b70b5ecc0beea
[ "Unlicense" ]
null
null
null
modules/spaint/include/spaint/visualisation/VisualiserFactory.h
GucciPrada/spaint
b09ff1ec0d9e123cf316f2737e1b70b5ecc0beea
[ "Unlicense" ]
null
null
null
/** * spaint: VisualiserFactory.h * Copyright (c) Torr Vision Group, University of Oxford, 2016. All rights reserved. */ #ifndef H_SPAINT_VISUALISERFACTORY #define H_SPAINT_VISUALISERFACTORY #include <ITMLib/Utils/ITMLibSettings.h> #include "interface/DepthVisualiser.h" #include "interface/SemanticVisualiser.h" namespace spaint { /** * \brief This struct can be used to construct visualisers. */ struct VisualiserFactory { //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### /** * \brief Makes a depth visualiser. * * \param deviceType The device on which the visualiser should operate. * \return The visualiser. */ static DepthVisualiser_CPtr make_depth_visualiser(ITMLib::ITMLibSettings::DeviceType deviceType); /** * \brief Makes a semantic visualiser. * * \param maxLabelCount The maximum number of labels that can be in use. * \param deviceType The device on which the visualiser should operate. * \return The visualiser. */ static SemanticVisualiser_CPtr make_semantic_visualiser(size_t maxLabelCount, ITMLib::ITMLibSettings::DeviceType deviceType); }; } #endif
26.772727
127
0.704584