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
43afed1fb435a263c14fbb1c32a5a2de3463bae8
5,252
c
C
runtime/flang/red_maxval.c
kammerdienerb/flang
8cc4a02b94713750f09fe6b756d33daced0b4a74
[ "Apache-2.0" ]
1
2022-03-02T19:47:29.000Z
2022-03-02T19:47:29.000Z
runtime/flang/red_maxval.c
kammerdienerb/flang
8cc4a02b94713750f09fe6b756d33daced0b4a74
[ "Apache-2.0" ]
58
2017-10-25T17:21:13.000Z
2021-12-22T13:35:09.000Z
runtime/flang/red_maxval.c
kammerdienerb/flang
8cc4a02b94713750f09fe6b756d33daced0b4a74
[ "Apache-2.0" ]
3
2019-12-21T06:35:35.000Z
2020-06-07T23:18:58.000Z
/* * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. * * 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. * */ /* clang-format off */ /* red_maxval.c -- intrinsic reduction function */ #include "stdioInterf.h" #include "fioMacros.h" #include "red.h" CONDFNLKN(>, maxval_int1, __INT1_T, 1) CONDFNLKN(>, maxval_int2, __INT2_T, 1) CONDFNLKN(>, maxval_int4, __INT4_T, 1) CONDFNLKN(>, maxval_int8, __INT8_T, 1) CONDFNLKN(>, maxval_real4, __REAL4_T, 1) CONDFNLKN(>, maxval_real8, __REAL8_T, 1) CONDFNLKN(>, maxval_real16, __REAL16_T, 1) CONDSTRFNLKN(>, maxval_str, __STR_T, 1) CONDFNLKN(>, maxval_int1, __INT1_T, 2) CONDFNLKN(>, maxval_int2, __INT2_T, 2) CONDFNLKN(>, maxval_int4, __INT4_T, 2) CONDFNLKN(>, maxval_int8, __INT8_T, 2) CONDFNLKN(>, maxval_real4, __REAL4_T, 2) CONDFNLKN(>, maxval_real8, __REAL8_T, 2) CONDFNLKN(>, maxval_real16, __REAL16_T, 2) CONDSTRFNLKN(>, maxval_str, __STR_T, 2) CONDFNLKN(>, maxval_int1, __INT1_T, 4) CONDFNLKN(>, maxval_int2, __INT2_T, 4) CONDFNLKN(>, maxval_int4, __INT4_T, 4) CONDFNLKN(>, maxval_int8, __INT8_T, 4) CONDFNLKN(>, maxval_real4, __REAL4_T, 4) CONDFNLKN(>, maxval_real8, __REAL8_T, 4) CONDFNLKN(>, maxval_real16, __REAL16_T, 4) CONDSTRFNLKN(>, maxval_str, __STR_T, 4) CONDFNLKN(>, maxval_int1, __INT1_T, 8) CONDFNLKN(>, maxval_int2, __INT2_T, 8) CONDFNLKN(>, maxval_int4, __INT4_T, 8) CONDFNLKN(>, maxval_int8, __INT8_T, 8) CONDFNLKN(>, maxval_real4, __REAL4_T, 8) CONDFNLKN(>, maxval_real8, __REAL8_T, 8) CONDFNLKN(>, maxval_real16, __REAL16_T, 8) CONDSTRFNLKN(>, maxval_str, __STR_T, 8) CONDFNG(>, maxval_int1, __INT1_T) CONDFNG(>, maxval_int2, __INT2_T) CONDFNG(>, maxval_int4, __INT4_T) CONDFNG(>, maxval_int8, __INT8_T) CONDFNG(>, maxval_real4, __REAL4_T) CONDFNG(>, maxval_real8, __REAL8_T) CONDFNG(>, maxval_real16, __REAL16_T) CONDSTRFNG(>, maxval_str, __STR_T) static void (*l_maxval[4][__NTYPES])() = TYPELIST3LK(l_maxval_); static void (*g_maxval[__NTYPES])() = TYPELIST3(g_maxval_); /* dim absent */ void ENTFTN(MAXVALS, maxvals)(char *rb, char *ab, char *mb, F90_Desc *rs, F90_Desc *as, F90_Desc *ms) { red_parm z; INIT_RED_PARM(z); __fort_red_what = "MAXVAL"; z.kind = F90_KIND_G(as); z.len = F90_LEN_G(as); z.mask_present = (F90_TAG_G(ms) == __DESC && F90_RANK_G(ms) > 0); if (!z.mask_present) { z.lk_shift = GET_DIST_SHIFTS(__LOG); } else { z.lk_shift = GET_DIST_SHIFTS(F90_KIND_G(ms)); } z.l_fn = l_maxval[z.lk_shift][z.kind]; z.g_fn = g_maxval[z.kind]; z.zb = GET_DIST_MINS(z.kind); if (z.kind == __STR) memset(rb, *((char *)(z.zb)), z.len); I8(__fort_red_scalarlk)(&z, rb, ab, mb, rs, as, ms, NULL, __MAXVAL); } /* dim present */ void ENTFTN(MAXVAL, maxval)(char *rb, char *ab, char *mb, char *db, F90_Desc *rs, F90_Desc *as, F90_Desc *ms, F90_Desc *ds) { red_parm z; INIT_RED_PARM(z); __fort_red_what = "MAXVAL"; z.kind = F90_KIND_G(as); z.len = F90_LEN_G(as); z.mask_present = (F90_TAG_G(ms) == __DESC && F90_RANK_G(ms) > 0); if (!z.mask_present) { z.lk_shift = GET_DIST_SHIFTS(__LOG); } else { z.lk_shift = GET_DIST_SHIFTS(F90_KIND_G(ms)); } z.l_fn = l_maxval[z.lk_shift][z.kind]; z.g_fn = g_maxval[z.kind]; z.zb = GET_DIST_MINS(z.kind); if (z.kind == __STR) memset(rb, *((char *)(z.zb)), z.len); if (ISSCALAR(ms)) { DECL_HDR_VARS(ms2); mb = (char *)I8(__fort_create_conforming_mask_array)(__fort_red_what, ab, mb, as, ms, ms2); I8(__fort_red_array)(&z, rb, ab, mb, db, rs, as, ms2, ds, __MAXVAL); __fort_gfree(mb); } else { I8(__fort_red_arraylk)(&z, rb, ab, mb, db, rs, as, ms, ds, __MAXVAL); } } /* global MAXVAL accumulation */ void ENTFTN(REDUCE_MAXVAL, reduce_maxval)(char *hb, __INT_T *dimsb, __INT_T *nargb, char *rb, F90_Desc *hd, F90_Desc *dimsd, F90_Desc *nargd, F90_Desc *rd) { #if defined(DEBUG) if (dimsd == NULL || F90_TAG_G(dimsd) != __INT) __fort_abort("GLOBAL_MAXVAL: invalid dims descriptor"); if (nargd == NULL || F90_TAG_G(nargd) != __INT) __fort_abort("REDUCE_MAXVAL: invalid arg count descriptor"); if (*nargb != 1) __fort_abort("REDUCE_MAXVAL: arg count not 1"); #endif I8(__fort_global_reduce)(rb, hb, *dimsb, rd, hd, "MAXVAL", g_maxval); } void ENTFTN(GLOBAL_MAXVAL, global_maxval)(char *rb, char *hb, __INT_T *dimsb, F90_Desc *rd, F90_Desc *hd, F90_Desc *dimsd) { I8(__fort_global_reduce)(rb, hb, *dimsb, rd, hd, "MAXVAL", g_maxval); }
32.621118
81
0.650038
4d05080e8ff0f91462af731c82b643f4085501fc
390
h
C
MJExtensionDemo/MJExtensionDemo/FKClanStatusModel.h
iOS-Kel/MJExtensionUseDemo
4d3d9b4bb48269783ba2f497286087b141a3d3a0
[ "Apache-2.0" ]
1
2017-05-25T10:26:41.000Z
2017-05-25T10:26:41.000Z
MJExtensionDemo/MJExtensionDemo/FKClanStatusModel.h
iOS-Kel/MJExtensionUseDemo
4d3d9b4bb48269783ba2f497286087b141a3d3a0
[ "Apache-2.0" ]
null
null
null
MJExtensionDemo/MJExtensionDemo/FKClanStatusModel.h
iOS-Kel/MJExtensionUseDemo
4d3d9b4bb48269783ba2f497286087b141a3d3a0
[ "Apache-2.0" ]
null
null
null
// // FKClanStatusModel.h // YiShiDai // // Created by GFK on 16/12/15. // Copyright © 2016年 GFK. All rights reserved. // #import <Foundation/Foundation.h> @interface FKClanStatusModel : NSObject /** 战队id */ @property(nonatomic, assign) NSUInteger clan_id; /** 战队名称 */ @property(nonatomic, copy) NSString *clan_name; /** 战队logo */ @property(nonatomic, copy) NSString *clan_logo; @end
20.526316
48
0.702564
2ff2e8d982bea9b689050a2802fba5ec29e44b81
5,398
h
C
kernel_dvfs/linux-linaro-tracking-gem5/include/linux/blk-mq.h
lokeshjindal15/pd-gem5_transformer
f8eb40dc65a5d7e15c8aa0756b1b48dd104bd54f
[ "BSD-3-Clause" ]
null
null
null
kernel_dvfs/linux-linaro-tracking-gem5/include/linux/blk-mq.h
lokeshjindal15/pd-gem5_transformer
f8eb40dc65a5d7e15c8aa0756b1b48dd104bd54f
[ "BSD-3-Clause" ]
null
null
null
kernel_dvfs/linux-linaro-tracking-gem5/include/linux/blk-mq.h
lokeshjindal15/pd-gem5_transformer
f8eb40dc65a5d7e15c8aa0756b1b48dd104bd54f
[ "BSD-3-Clause" ]
null
null
null
#ifndef BLK_MQ_H #define BLK_MQ_H #include <linux/blkdev.h> struct blk_mq_tags; struct blk_mq_cpu_notifier { struct list_head list; void *data; void (*notify)(void *data, unsigned long action, unsigned int cpu); }; struct blk_mq_hw_ctx { struct { spinlock_t lock; struct list_head dispatch; } ____cacheline_aligned_in_smp; unsigned long state; /* BLK_MQ_S_* flags */ struct delayed_work delayed_work; unsigned long flags; /* BLK_MQ_F_* flags */ struct request_queue *queue; unsigned int queue_num; void *driver_data; unsigned int nr_ctx; struct blk_mq_ctx **ctxs; unsigned int nr_ctx_map; unsigned long *ctx_map; struct request **rqs; struct list_head page_list; struct blk_mq_tags *tags; unsigned long queued; unsigned long run; #define BLK_MQ_MAX_DISPATCH_ORDER 10 unsigned long dispatched[BLK_MQ_MAX_DISPATCH_ORDER]; unsigned int queue_depth; unsigned int numa_node; unsigned int cmd_size; /* per-request extra data */ struct blk_mq_cpu_notifier cpu_notifier; struct kobject kobj; }; struct blk_mq_reg { struct blk_mq_ops *ops; unsigned int nr_hw_queues; unsigned int queue_depth; unsigned int reserved_tags; unsigned int cmd_size; /* per-request extra data */ int numa_node; unsigned int timeout; unsigned int flags; /* BLK_MQ_F_* */ }; typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, struct request *); typedef struct blk_mq_hw_ctx *(map_queue_fn)(struct request_queue *, const int); typedef struct blk_mq_hw_ctx *(alloc_hctx_fn)(struct blk_mq_reg *,unsigned int); typedef void (free_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int); typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int); typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int); struct blk_mq_ops { /* * Queue request */ queue_rq_fn *queue_rq; /* * Map to specific hardware queue */ map_queue_fn *map_queue; /* * Called on request timeout */ rq_timed_out_fn *timeout; softirq_done_fn *complete; /* * Override for hctx allocations (should probably go) */ alloc_hctx_fn *alloc_hctx; free_hctx_fn *free_hctx; /* * Called when the block layer side of a hardware queue has been * set up, allowing the driver to allocate/init matching structures. * Ditto for exit/teardown. */ init_hctx_fn *init_hctx; exit_hctx_fn *exit_hctx; }; enum { BLK_MQ_RQ_QUEUE_OK = 0, /* queued fine */ BLK_MQ_RQ_QUEUE_BUSY = 1, /* requeue IO for later */ BLK_MQ_RQ_QUEUE_ERROR = 2, /* end IO with error */ BLK_MQ_F_SHOULD_MERGE = 1 << 0, BLK_MQ_F_SHOULD_SORT = 1 << 1, BLK_MQ_F_SHOULD_IPI = 1 << 2, BLK_MQ_S_STOPPED = 1 << 0, BLK_MQ_MAX_DEPTH = 2048, }; struct request_queue *blk_mq_init_queue(struct blk_mq_reg *, void *); int blk_mq_register_disk(struct gendisk *); void blk_mq_unregister_disk(struct gendisk *); void blk_mq_init_commands(struct request_queue *, void (*init)(void *data, struct blk_mq_hw_ctx *, struct request *, unsigned int), void *data); void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule); void blk_mq_insert_request(struct request *, bool, bool, bool); void blk_mq_run_queues(struct request_queue *q, bool async); void blk_mq_free_request(struct request *rq); bool blk_mq_can_queue(struct blk_mq_hw_ctx *); struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp); struct request *blk_mq_alloc_reserved_request(struct request_queue *q, int rw, gfp_t gfp); struct request *blk_mq_rq_from_tag(struct request_queue *q, unsigned int tag); struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index); struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_reg *, unsigned int); void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int); bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes); static inline void blk_mq_end_io(struct request *rq, int error) { bool done = !blk_mq_end_io_partial(rq, error, blk_rq_bytes(rq)); BUG_ON(!done); } void blk_mq_complete_request(struct request *rq); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_stop_hw_queues(struct request_queue *q); void blk_mq_start_stopped_hw_queues(struct request_queue *q); /* * Driver command data is immediately after the request. So subtract request * size to get back to the original request. */ static inline struct request *blk_mq_rq_from_pdu(void *pdu) { return pdu - sizeof(struct request); } static inline void *blk_mq_rq_to_pdu(struct request *rq) { return (void *) rq + sizeof(*rq); } static inline struct request *blk_mq_tag_to_rq(struct blk_mq_hw_ctx *hctx, unsigned int tag) { return hctx->rqs[tag]; } #define queue_for_each_hw_ctx(q, hctx, i) \ for ((i) = 0; (i) < (q)->nr_hw_queues && \ ({ hctx = (q)->queue_hw_ctx[i]; 1; }); (i)++) #define queue_for_each_ctx(q, ctx, i) \ for ((i) = 0; (i) < (q)->nr_queues && \ ({ ctx = per_cpu_ptr((q)->queue_ctx, (i)); 1; }); (i)++) #define hctx_for_each_ctx(hctx, ctx, i) \ for ((i) = 0; (i) < (hctx)->nr_ctx && \ ({ ctx = (hctx)->ctxs[(i)]; 1; }); (i)++) #define blk_ctx_sum(q, sum) \ ({ \ struct blk_mq_ctx *__x; \ unsigned int __ret = 0, __i; \ \ queue_for_each_ctx((q), __x, __i) \ __ret += sum; \ __ret; \ }) #endif
27.968912
144
0.723787
644c18b337d413b021cf792e67f0a14b4a89b43d
2,176
h
C
Source/EnemyBehaviour/SlimeCharacter.h
Nufotedam/Slime-Basic-Enemy-Behavior
694df9b1298028867ad67350c388ccea3148590a
[ "Apache-2.0" ]
null
null
null
Source/EnemyBehaviour/SlimeCharacter.h
Nufotedam/Slime-Basic-Enemy-Behavior
694df9b1298028867ad67350c388ccea3148590a
[ "Apache-2.0" ]
null
null
null
Source/EnemyBehaviour/SlimeCharacter.h
Nufotedam/Slime-Basic-Enemy-Behavior
694df9b1298028867ad67350c388ccea3148590a
[ "Apache-2.0" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "WaypointActor.h" #include "SlimeCharacter.generated.h" /** * The modes that the Character can be in. * PATROL - Patrolling between Waypoints. * CHASE - Chasing the Player. */ UENUM(BlueprintType) enum class StateMode : uint8 { PATROL UMETA(DisplayName = "PATROL"), CHASE UMETA(DisplayName = "CHASE") }; UCLASS() class ENEMYBEHAVIOUR_API ASlimeCharacter : public ACharacter { GENERATED_BODY() public: // Sets default values for this character's properties ASlimeCharacter(); UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Waypoints") StateMode Mode; // Total Waypoints UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Waypoints") TArray<AWaypointActor*> Waypoints; // Index of the current waypoint the character is going towards UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Waypoints") int32 CurrentWaypointIndex; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IA Movement") float WaypointDelay; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IA Movement") bool MoveToWaypoints; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IA Movement") bool MoveToRandomWaypoint; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character Movement: Walking") float WalkSpeed; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character Movement: Walking") float SprintSpeed; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Attack") bool bIsPlayerClose; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Attack") bool bIsAttack; protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; void Sprint(); void StopSprint(); // Called to change the state of the character void SetStateMode(StateMode ModeChange); };
26.864198
94
0.775735
8aeb85d00c5bcf67d9ef70be466e1ce5ab374c61
348
h
C
Embedded Software/src/Uplink.h
JaccoVeldscholten/SmartDispenser
6b3dfddaeef67293853557a0e8b6b49ca562f1db
[ "MIT" ]
null
null
null
Embedded Software/src/Uplink.h
JaccoVeldscholten/SmartDispenser
6b3dfddaeef67293853557a0e8b6b49ca562f1db
[ "MIT" ]
null
null
null
Embedded Software/src/Uplink.h
JaccoVeldscholten/SmartDispenser
6b3dfddaeef67293853557a0e8b6b49ca562f1db
[ "MIT" ]
null
null
null
#ifndef UPLINK_H #define UPLINK_H #include <HTTPClient.h> #include <ArduinoJson.h> class Uplink { private: WiFiClient client; HTTPClient http; public: Uplink(); void SendData(); String APIUrl; /* Storage for API URL */ StaticJsonDocument<200> doc; /* DataFrame object */ }; #endif
16.571429
62
0.600575
14029683694dec0847bdb9a9898c873f87d4fcd5
290
h
C
src/optimizer.h
adamharrison/liquid-cpp
d9d5ae7e5d8e8752869c56a5bf31b804642ccc01
[ "MIT", "Unlicense" ]
14
2021-03-16T20:58:26.000Z
2022-03-06T04:08:35.000Z
src/optimizer.h
adamharrison/liquid-cpp
d9d5ae7e5d8e8752869c56a5bf31b804642ccc01
[ "MIT", "Unlicense" ]
1
2021-06-28T04:36:53.000Z
2021-06-28T13:06:13.000Z
src/optimizer.h
adamharrison/liquid-cpp
d9d5ae7e5d8e8752869c56a5bf31b804642ccc01
[ "MIT", "Unlicense" ]
1
2021-10-14T09:43:17.000Z
2021-10-14T09:43:17.000Z
#ifndef LIQUIDOPTIMIZER_H #define LIQUIDOPTIMIZER_H #include "common.h" namespace Liquid { struct Renderer; struct Node; struct Optimizer { Renderer& renderer; Optimizer(Renderer& renderer); void optimize(Node& ast, Variable store); }; } #endif
15.263158
49
0.662069
533ab03d343a3e312744d0968689be36acf1b5d2
10,413
c
C
application.c
DmitriyVentil/ComgGraph
2c9b59cf10295a5372d2bb2b38b30bf88f91ec8b
[ "Unlicense" ]
null
null
null
application.c
DmitriyVentil/ComgGraph
2c9b59cf10295a5372d2bb2b38b30bf88f91ec8b
[ "Unlicense" ]
null
null
null
application.c
DmitriyVentil/ComgGraph
2c9b59cf10295a5372d2bb2b38b30bf88f91ec8b
[ "Unlicense" ]
null
null
null
/** ****************************************************************************** * File Name : application.c ****************************************************************************** */ #include "application.h" #include "main.h" #include "usart.h" #include "mb.h" #include "mbporttimer.h" #include "adc.h" #include "pwm.h" #include "eeprom.h" volatile uint8_t application_led_period = 100; /* norm */ static volatile uint8_t application_led_period_cntr = 0; volatile uint16_t application_main_loop_cntr = 0; volatile uint8_t need_soft_reset = 0; static volatile uint8_t application_test_period_cntr = 0; /* parameters */ volatile uint16_t on_i_threshold = 0; volatile uint8_t pusk_t_on = 0; volatile uint16_t off_vin_threshold = 0; volatile uint8_t off_t_mask = 0; volatile uint8_t off_timeout = 0; volatile uint8_t ready_t_mask = 0; volatile uint8_t ready_timeout_sleep = 0; volatile uint8_t timer_pusk_t_on = 0; volatile uint8_t timer_off_t_mask = 0; volatile uint8_t timer_off_timeout = 0; volatile uint8_t timer_ready_t_mask = 0; volatile uint8_t timer_ready_timeout_sleep = 0; volatile uint8_t timer_adc6_7_protect = 70; // 700 мс // Моя доработка volatile uint8_t timer_adc6_7_protect_count = 0; // Моя доработка bool powerbank_is_good = false; bool input_voltage_is_good = false; volatile uint8_t application_pwm_on = 0; typedef enum appl_state_e { appl_state_off = 0, appl_state_startup, appl_state_on, appl_state_shutdown, appl_state_sleep } appl_state_t; static appl_state_t appl_state = appl_state_off; void init() { adc_raw_data_buff[0] = adc_FRAME_START_MRKR; cli(); application_main_loop_cntr = 0; /* gpio in SIGN PORTC.2*/ DDRC &= ~(1 << DDC2); /* ENA */ DDRB |= (1 << DDB0); PORTB &= ~(1 << PB0); /* off ena */ //// PORTB |= (1 << PB0); /* on ena */ /* LED */ DDRB |= (1 << DDB2); PORTB |= (1 << PB2); /* LED OFF */ /*PORTB &= ~(1 << PB2);*/ /* LED ON */ /* debug_trace pins */ DDRD |= (1 << DDD3); PORTD &= ~(1 << PD3); DDRD |= (1 << DDD4); PORTD &= ~(1 << PD4); eeprom_init(); //// param init section mb_address = eeprom_cache[16]; /* mb_addr_new */ pwm_cntr_on_stage_timeout = eeprom_cache[17]; /* pusk_period_sinus */ on_i_threshold = ((uint16_t)(eeprom_cache[18])) << 8; pusk_t_on = eeprom_cache[19]; if (0==pusk_t_on) pusk_t_on = 1; if (250<pusk_t_on) pusk_t_on = 250; off_vin_threshold = ((uint16_t)(eeprom_cache[20])) << 8; off_t_mask = eeprom_cache[21]; if (0==off_t_mask) off_t_mask = 1; if (250<off_t_mask) off_t_mask = 250; off_timeout = eeprom_cache[22]; if (0==off_timeout) off_timeout = 1; if (250<off_timeout) off_timeout = 250; ready_t_mask = eeprom_cache[23]; if (0==ready_t_mask) ready_t_mask = 1; if (250<ready_t_mask) ready_t_mask = 250; ready_timeout_sleep = eeprom_cache[24]; if (0==ready_timeout_sleep) ready_timeout_sleep = 1; if (250<ready_timeout_sleep) ready_timeout_sleep = 250; //// periph init section usart_init_rs485(); mbporttimer_init(); adc_init(); pwm_init(); sei(); #if 0 usart_flag_send_msg = usart_flag_send_msg_EEP; #endif } volatile uint16_t adc_v_0 = 0; volatile uint16_t adc_v_1 = 0; volatile uint16_t adc_v_6 = 0; volatile uint16_t adc_v_7 = 0; static volatile uint8_t adc_frame_cntr = 0; volatile uint8_t adc_raw_data_buff[adc_RAW_DATA_BUFF_SZ] = {0}; volatile uint8_t mbporttimer_flag_100hz_local = 0; volatile uint8_t led_trace = 0; volatile uint8_t shotdawn_deceted = 0; volatile uint8_t startup_timer = 0; #define startup_timer_START (100) /*1.0sec*/ void loop() { //// application_main_loop_cntr ++; //// if ( 1000 == application_main_loop_cntr ) { //// application_main_loop_cntr = 0; //// } mbporttimer_flag_100hz_local = 0; cli(); if ( 0 != mbporttimer_flag_100hz ) { mbporttimer_flag_100hz_local = ~0; mbporttimer_flag_100hz = 0; } sei(); /* high proiritet */ if ( mbporttimer_flag_100hz_local ) { //mbporttimer_flag_100hz_local = 0; if (0==need_soft_reset) { wdt_reset(); } cli(); adc_v_0 = adc_val_0; adc_v_1 = adc_val_1; adc_v_6 = adc_val_6; adc_v_7 = adc_val_7; sei(); /* debug adc !!!!! */ #if 0 adc_raw_data_buff[1] = adc_frame_cntr; adc_frame_cntr ++; if ( 100 == adc_frame_cntr ) { adc_frame_cntr = 0; } //adc_raw_data_buff[2] = ((adc_v_0>>8)!=adc_FRAME_START_MRKR) ? (adc_v_0>>8) : (adc_FRAME_START_MRKR-1); //adc_raw_data_buff[3] = ((adc_v_1>>8)!=adc_FRAME_START_MRKR) ? (adc_v_1>>8) : (adc_FRAME_START_MRKR-1); adc_raw_data_buff[2] = ((adc_v_6>>8)!=adc_FRAME_START_MRKR) ? (adc_v_6>>8) : (adc_FRAME_START_MRKR-1); adc_raw_data_buff[3] = ((adc_v_7>>8)!=adc_FRAME_START_MRKR) ? (adc_v_7>>8) : (adc_FRAME_START_MRKR-1); usart_flag_send_msg = usart_flag_send_msg_ADC; #endif /* led */ application_led_period_cntr ++; if ( application_led_period <= application_led_period_cntr ) { application_led_period_cntr = 0; if (led_trace==0) { application_led_period = 200; } if (led_trace==1) { application_led_period = 100; } if (led_trace==2) { application_led_period = 50; } if (led_trace==3) { application_led_period = 20; } if (led_trace==4) { application_led_period = 10; } if (led_trace==5) { application_led_period = 5; } PORTB &= ~(1 << PB2); // led on #if 0 /* led toggle */ PORTB ^= (1 << PB2); #endif } else { //application_led_period_cntr PORTB |= (1 << PB2); // led off } //application_led_period_cntr if ( startup_timer_START > startup_timer ) { startup_timer ++; } else { if ( (1 << PC2) & PINC ) { application_pwm_on = 1; // cli(); ///------/////pwm_on = 1; // sei(); } else { application_pwm_on = 0; // cli(); ///------/////pwm_on = 0; // sei(); } } /* logic automat */ // always do control of voltage /* operation condition control PFC voltage power banks */ // todo other operating condition if ( ( LIMIT_450V_MAX >= adc_v_6 ) && ( LIMIT_450V_MIN <= adc_v_6 ) && ( LIMIT_225V_MAX >= adc_v_7 ) && ( LIMIT_225V_MIN <= adc_v_7 ) ) { /* good */ if ( ready_t_mask == timer_ready_t_mask) { timer_adc6_7_protect_count=0; // Моя доработка powerbank_is_good = true; // ok } else { timer_ready_t_mask ++; powerbank_is_good = false; } } else { /* bad */ // !!Моя доработка // Задержка if ( timer_adc6_7_protect <= timer_adc6_7_protect_count) { timer_ready_t_mask = 0; powerbank_is_good = false; } else { timer_adc6_7_protect_count++; } // !!Конец моей доработки //timer_ready_t_mask = 0; //powerbank_is_good = false; } /* operation condition input voltage */ if ( off_vin_threshold > adc_v_1 ) { /* power_off */ if ( off_t_mask == timer_off_t_mask ) { /* ok */ input_voltage_is_good = false; /* time window complete */ } else { /* wait... */ timer_off_t_mask ++; input_voltage_is_good = true; } } else { /* good */ timer_off_t_mask = 0; input_voltage_is_good = true; } ////####input_voltage_is_good = true; ////####powerbank_is_good = true; #define WORK (1) if ( 0!=application_pwm_on ) { /// n #ifndef WORK cli(); pwm_on = 1;// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< start sei(); #endif #ifdef WORK /* state machine */ switch ( appl_state ) { case appl_state_off: { led_trace = 1; if ( /*input_voltage_is_good && */powerbank_is_good /* && ( LIMIT_CURRENT_XX > adc_v_0 ) */) { /* ток холостого хода мал - только на балансныqй делитель и измериловку */ appl_state = appl_state_startup; timer_pusk_t_on = 0; cli(); pwm_on = 1;// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< start sei(); } break; } case appl_state_startup: { led_trace = 2; if (timer_pusk_t_on>=pusk_t_on) { //pusk complete appl_state = appl_state_on; } else { timer_pusk_t_on ++; } break; } case appl_state_on: { led_trace = 3; if ( input_voltage_is_good ) { if ( powerbank_is_good && ( on_i_threshold > adc_v_0 ) ) { // good load condition current and PFC_power_bank ; // nothing to do } else { // bad load condition --> sleep && restart appl_state = appl_state_sleep; cli(); pwm_on = 0; sei(); timer_ready_timeout_sleep = 0; } } else { // input voltage fail --> shutdown appl_state = appl_state_shutdown; timer_off_timeout = 0; } break; } case appl_state_shutdown: { led_trace = 4; if (timer_off_timeout >= off_timeout) { cli(); pwm_on = 0; sei(); appl_state = appl_state_off; led_trace = 2; //for (;;) {;} // reboot wdt } else { timer_off_timeout ++; } break; } case appl_state_sleep: { led_trace = 5; if (timer_ready_timeout_sleep>=ready_timeout_sleep) { appl_state = appl_state_off; } else { timer_ready_timeout_sleep ++; } break; } default: { appl_state = appl_state_off; cli(); pwm_on = 0; sei(); } } /* switch */ #endif } else { // application_pwm_on off appl_state = appl_state_off; led_trace = 0; cli(); pwm_on = 0; sei(); } // application_pwm_on return; /* high prioritet end-->next loop */ } // if ( mbporttimer_flag_100hz_local ) /* low prioritet */ mb_poll(); if (eeprom_need_to_save) { eeprom_need_to_save = 0; eeprom_save_from_cache(); } } /*****************************END OF FILE****/
14.24487
149
0.571977
bb3bdf6a83935daacfd31ce5e719e48a97cbf352
304
h
C
SubEthaEdit-Mac/Source/SEEMoreRecentDocumentsListItem.h
fourplusone/SubEthaEdit
ec5f5f2a14d803a5fcfd35df282d2822a7009cdc
[ "MIT" ]
1,240
2018-10-25T21:22:38.000Z
2022-03-26T14:13:52.000Z
SubEthaEdit-Mac/Source/SEEMoreRecentDocumentsListItem.h
fourplusone/SubEthaEdit
ec5f5f2a14d803a5fcfd35df282d2822a7009cdc
[ "MIT" ]
200
2018-11-21T11:44:57.000Z
2022-03-28T19:51:41.000Z
SubEthaEdit-Mac/Source/SEEMoreRecentDocumentsListItem.h
fourplusone/SubEthaEdit
ec5f5f2a14d803a5fcfd35df282d2822a7009cdc
[ "MIT" ]
115
2018-11-28T09:49:01.000Z
2022-03-31T03:26:05.000Z
// SEEMoreRecentDocumentsListItem.h // SubEthaEdit // // Created by Michael Ehrmann on 22.05.14. #import <Foundation/Foundation.h> #import "SEEDocumentListItemProtocol.h" @interface SEEMoreRecentDocumentsListItem : NSObject <SEEDocumentListItem> @property (nonatomic, weak) NSMenu *moreMenu; @end
21.714286
74
0.782895
154716fd677e7ef98b6f08751e8607703ea16363
1,059
c
C
src/args.c
MinaSaad47/project
1e281e3c07381f6899abf710603d56b8c09c20bd
[ "Unlicense" ]
4
2021-12-28T13:33:26.000Z
2022-01-04T13:59:27.000Z
src/args.c
MinaSaad47/project
1e281e3c07381f6899abf710603d56b8c09c20bd
[ "Unlicense" ]
null
null
null
src/args.c
MinaSaad47/project
1e281e3c07381f6899abf710603d56b8c09c20bd
[ "Unlicense" ]
null
null
null
#include "args.h" Args args; void handle_args(int argc, char **argv) { int c, longIndex; struct option longOpts[] = { { "address", required_argument, 0, 'a' }, { "port", required_argument, 0, 'p' }, { "daemon", no_argument, 0, 'd' } }; for (;;) { c = getopt_long(argc, argv, "apd", longOpts, &longIndex); if (c < 0) break; switch (c) { case 'a': strncpy((char*) args.addr, optarg, sizeof(args.addr)); args.mask |= ArgAddrMask; break; case 'p': args.port = strtol(optarg, NULL, 0); args.mask |= ArgPortMask; break; case 'd': args.mask |= ArgDaemonMask; break; } } }
30.257143
102
0.342776
29e2bf9604d925ecf233a6510665e8056303d62c
3,473
c
C
d/antioch/valley/obj/sea_dagger.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/antioch/valley/obj/sea_dagger.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
4
2021-03-15T18:56:39.000Z
2021-08-17T17:08:22.000Z
d/antioch/valley/obj/sea_dagger.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> #include "../valley.h" inherit "/d/common/obj/weapon/dagger.c"; void create() { ::create(); set_name("sea dagger"); set_id(({"dagger","sprite dagger","tiny dagger","nixie dagger","sea roar dagger","coral dagger"})); set_short("%^BOLD%^%^BLUE%^S%^RESET%^%^BLUE%^e%^CYAN%^a"+ " %^BOLD%^R%^BLUE%^o%^RESET%^%^CYAN%^a%^BLUE%^r dagger%^RESET%^"); set_obvious_short("%^BOLD%^%^BLUE%^A %^WHITE%^white coral%^BLUE%^"+ " handle dagger%^RESET%^"); set_long("%^CYAN%^This curved %^BOLD%^%^BLUE%^metal dagger%^RESET%^"+ " %^CYAN%^is forged from a pale %^BOLD%^%^WHITE%^silver%^RESET%^"+ "%^CYAN%^ metal. Swirling along the length of the blade is "+ "ripples of %^BOLD%^%^BLUE%^b%^CYAN%^l%^RESET%^%^BLUE%^u%^CYAN%^e"+ ", giving the dagger a watery appearance. Lengths of "+ "%^BOLD%^%^WHITE%^white coral%^RESET%^%^CYAN%^ encircle the "+ "lower part of the blade and create the pommel of this dagger."+ " Embedded into the pommel are tiny %^BOLD%^%^WHITE%^pearls%^RESET%^%^CYAN%^."); set_lore("The Sea Roar Dagger is crafted by the nixies to use in"+ " defense against the threats of the forest around their "+ "waterfall in the Moonstone Valley. The creation of each "+ "dagger is said to take three months, for the nixie "+ "priestesses imbue the strength of the sea into each one. "+ "The daggers among the faith of Istishia are seens a lucky "+ "relics to carry with them, for they feel its like having a "+ "piece of the sea with you where ever you go. Needless to say"+ " the follower of Kossuth abhor the daggers and wish nothing "+ "more to melt them all."); set_property("lore",11); //set_size(1); set_type("piercing"); //set_weight3); //set_wc(1,4); //set_large_wc(1,3); set_value(400); set_property("enchantment",2+random(2)); set_wield((:TO,"wieldme":)); set_unwield((:TO,"removeme":)); set_hit((:TO,"hitme":)); } int wieldme(){ if((string)ETO->query_diety() == "kossuth") { tell_object(ETO,"%^CYAN%^Wield this dagger?!? Have you gone mad?"); return 0; } if((string)ETO->query_diety() == "istishia") { tell_object(ETO,"%^CYAN%^The shades of blue begin to crest and"+ " fall across the dagger, as the sound of the sea fills your ears."); tell_room(environment(ETO),"%^CYAN%^Odd..is that the ocean I hear?",ETO); return 1; } else{ tell_object(ETO,"%^BOLD%^%^BLUE%^The sound of the sea fills your ears"+ " as you grasp the dagger."); tell_room(environment(ETO),"%^BOLD%^%^BLUE%^Odd..is that the sea I hear?",ETO); return 1; } } int removeme(){ tell_object(ETO,"%^CYAN%^The shades of blue quell to a quiet ripple as"+ " you unwield the dagger."); return 1; } int hitme(object targ) { if(!objectp(targ)) return 1; if(!random(12)) { tell_object(ETO,"%^BOLD%^%^CYAN%^The dagger in your hand "+ "begins to roar like the surf as you speed in towards"+ " "+targ->QCN+", granting you the strength of the sea."); tell_room(environment(ETO),"%^BOLD%^%^CYAN%^"+ETO->QCN+" "+ "speeds towards "+targ->QCN+" with "+ETO->QP+" dagger."+ " The roar of the sea follows the dagger's path before it "+ "comes crashing into "+targ->QCN+".",({ETO,targ})); tell_object(targ,"%^BOLD%^%^CYAN%^"+ETO->QCN+""+ " speeds towards you with "+ETO->QP+" dagger. The"+ " roar of the sea follows the dagger's path until it comes "+ "crashing into you with the strength of a mighty wave!"); targ->do_damage("torso",random(5)+3); return 1; } }
39.465909
100
0.647567
17acde81b2ba89b4f8853256f4359a1e9e1ee109
1,511
c
C
ece2140_cnn_theta/software/CNN_C/CNN_C/src/batch_input_conv.c
wew55/ece2140
ea7da0222d496582b746df3ba83f734c2439efa6
[ "Unlicense" ]
1
2020-03-31T10:00:19.000Z
2020-03-31T10:00:19.000Z
ece2140_cnn_theta/software/CNN_C/CNN_C/src/batch_input_conv.c
wew55/ece2140
ea7da0222d496582b746df3ba83f734c2439efa6
[ "Unlicense" ]
null
null
null
ece2140_cnn_theta/software/CNN_C/CNN_C/src/batch_input_conv.c
wew55/ece2140
ea7da0222d496582b746df3ba83f734c2439efa6
[ "Unlicense" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int batch_input_conv(float*** input, int size_input, int features_input, int numberOfSlice, int size_kernel, int counter, float*** batch, int* PreviousnumberOfLine) { int size_output = size_input - size_kernel + 1; int numberOfCalculation = pow(size_output,2); int numberOfLine = floor(numberOfSlice / size_output); int numberOfBatch = floor(numberOfCalculation / numberOfSlice) + 1; int size = 0; int begin_batch = 0; int end_batch; if ((numberOfBatch == 1) && (PreviousnumberOfLine[0] == 0)) { for (int i = 0; i < size_input; i++) { for (int j = 0; j < size_input; j++) { memcpy(batch[i][j], input[i][j], sizeof(input)*features_input); } } size = size_output; PreviousnumberOfLine[0] = 0; } else if(size_input < numberOfSlice) { for (int i = 0; i < (counter - 1); i++) { begin_batch += PreviousnumberOfLine[i]; } end_batch = begin_batch + numberOfLine + size_kernel - 1; if (end_batch > size_input) { end_batch = size_input; size = end_batch - begin_batch - size_kernel + 1 ; } else { size = numberOfLine; } for (int i = begin_batch; i < end_batch; i++) { for (int j = 0; j < size_input; j++) { memcpy(batch[i-begin_batch][j], input[i][j], sizeof(input)*features_input); } } PreviousnumberOfLine[counter - 1] = numberOfLine; } else { printf("this function is not yet implemented \n"); size = 0; } return size; }
24.370968
164
0.643283
6f1aa5ba35b672477635d30e20ff1a196f83edc1
968
c
C
ZZZ_OtherDemo/00-dyld-832.7.3/testing/test-cases/dylib-static-weak-link.dtest/present.c
1079278593/TreasureChest
8b1ebe04ed7c2ed399c4ecf3b75b3fee0a1aced8
[ "MIT" ]
null
null
null
ZZZ_OtherDemo/00-dyld-832.7.3/testing/test-cases/dylib-static-weak-link.dtest/present.c
1079278593/TreasureChest
8b1ebe04ed7c2ed399c4ecf3b75b3fee0a1aced8
[ "MIT" ]
null
null
null
ZZZ_OtherDemo/00-dyld-832.7.3/testing/test-cases/dylib-static-weak-link.dtest/present.c
1079278593/TreasureChest
8b1ebe04ed7c2ed399c4ecf3b75b3fee0a1aced8
[ "MIT" ]
null
null
null
// BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib // BUILD: $CC present.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/dylib-static-weak-present.exe // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo2.dylib -install_name $RUN_DIR/libfoomissing.dylib // BUILD: $CC missing.c $BUILD_DIR/libfoo2.dylib -o $BUILD_DIR/dylib-static-weak-missing.exe // BUILD: $SKIP_INSTALL $BUILD_DIR/libfoo2.dylib // RUN: ./dylib-static-weak-present.exe // RUN: ./dylib-static-weak-missing.exe #include <stddef.h> #include <stdio.h> #include "test_support.h" extern int foo __attribute__((weak_import)); int main(int argc, const char* argv[], const char* envp[], const char* apple[]) { // dylib will be found at runtime, so &foo should never be NULL if ( &foo != NULL ) { if ( foo == 42 ) PASS("Success"); else FAIL("Wrong value"); } else { FAIL("&foo == NULL"); } }
28.470588
103
0.65186
1762dd38853b5387524d3bff44702d43564099b0
289
h
C
Pods/Headers/Private/libsodium/poly1305_sse2.h
hboon/web3swift
183b97078b9f98dbc7e6029db08c0cd1247829fc
[ "Apache-2.0" ]
269
2017-11-18T13:28:33.000Z
2022-03-22T15:11:27.000Z
Pods/Headers/Private/libsodium/poly1305_sse2.h
ZhangxiaoHuangfu/shadowsocks-iOS
5a1b8cc79abbcbf1b3fa91d44e2bba47d52c2e23
[ "Apache-2.0" ]
13
2018-03-15T10:06:08.000Z
2022-02-08T17:57:08.000Z
Pods/Headers/Private/libsodium/poly1305_sse2.h
ZhangxiaoHuangfu/shadowsocks-iOS
5a1b8cc79abbcbf1b3fa91d44e2bba47d52c2e23
[ "Apache-2.0" ]
379
2017-10-23T11:43:16.000Z
2022-03-21T12:13:24.000Z
#ifndef poly1305_sse2_H #define poly1305_sse2_H #include <stddef.h> #include "../onetimeauth_poly1305.h" #include "crypto_onetimeauth_poly1305.h" extern struct crypto_onetimeauth_poly1305_implementation crypto_onetimeauth_poly1305_sse2_implementation; #endif /* poly1305_sse2_H */
22.230769
56
0.83045
c0ef3e23ca33442c50db1a46687ed76d710f99a5
473
h
C
Theremin2/PatchBank.h
dcherednikov/Theremin2
544232f56ed9d624c9cedcaab966be184f884451
[ "MIT" ]
null
null
null
Theremin2/PatchBank.h
dcherednikov/Theremin2
544232f56ed9d624c9cedcaab966be184f884451
[ "MIT" ]
null
null
null
Theremin2/PatchBank.h
dcherednikov/Theremin2
544232f56ed9d624c9cedcaab966be184f884451
[ "MIT" ]
null
null
null
// // PatchBank.h // Theremin2 // // Created by Admin on 03/07/2017. // Copyright © 2017 MacBookPro. All rights reserved. // #import <Foundation/Foundation.h> #import "Patch.h" @interface PatchBank : NSObject @property (nonatomic, readonly, assign) BOOL isReadyToSave; @property (nonatomic, assign) NSInteger selectedPatchIndex; - (void)prepareForSaving; - (void)abortSaving; - (void)savePatchAtSelectedIndex:(Patch *)patch; - (Patch *)patchAtSelectedIndex; @end
19.708333
59
0.733615
77d57b9e77da670896b8ca2c0ef367955d4e93a0
496
h
C
MVVMTest/View/MVVMCell.h
feiyanghe/MVVMTest
73425e07995ebc2178b25712eee308e34e908462
[ "MIT" ]
null
null
null
MVVMTest/View/MVVMCell.h
feiyanghe/MVVMTest
73425e07995ebc2178b25712eee308e34e908462
[ "MIT" ]
null
null
null
MVVMTest/View/MVVMCell.h
feiyanghe/MVVMTest
73425e07995ebc2178b25712eee308e34e908462
[ "MIT" ]
null
null
null
// // MVVMCell.h // MVVMTest // // Created by feiyanghe on 2018/4/25. // Copyright © 2018年 feiyanghe. All rights reserved. // #import <UIKit/UIKit.h> @class MVVMCellModel; @interface MVVMCell : UITableViewCell @property (weak, nonatomic) IBOutlet UIImageView *icon; @property (weak, nonatomic) IBOutlet UILabel *title; @property (weak, nonatomic) IBOutlet UILabel *subTitle; @property (nonatomic,strong) MVVMCellModel *model; + (instancetype)cellWithTableView:(UITableView *)tableView; @end
27.555556
59
0.752016
4f72107f49be6d1d12e33ded9e57e84bcb503d6e
580
h
C
mem-axc-64/apps/macsim.r.d.b.s/macsim-mem-axc-64/gems-lib-ooo/simics/src/include/simics/alloc.h
vnaveen0/nachos
99933b0da5474bf43bd167d2540438375237b2d9
[ "MIT" ]
1
2018-02-28T10:00:00.000Z
2018-02-28T10:00:00.000Z
mem-axc-64/apps/macsim.r.d.b.s/macsim-mem-axc-64/gems-lib-ooo/simics/src/include/simics/alloc.h
vnaveen0/nachos
99933b0da5474bf43bd167d2540438375237b2d9
[ "MIT" ]
1
2020-04-06T22:30:00.000Z
2020-04-06T22:30:00.000Z
mem-axc-64/apps/macsim.r.d.b.s/macsim-mem-axc-64/gems-lib-ooo/simics/src/include/simics/alloc.h
vnaveen0/nachos
99933b0da5474bf43bd167d2540438375237b2d9
[ "MIT" ]
null
null
null
/* * simics/alloc.h * * This file is part of Virtutech Simics * * Copyright (C) 1998-2005 Virtutech AB, All Rights Reserved * * The Virtutech Simics API is distributed under license. Please refer to * the 'LICENSE' file for details. * * For documentation on the Virtutech Simics API, please refer to the * Simics Reference Manual. Please report any difficulties you encounter * with this API through the Virtutech Simics website at www.simics.com * * */ #ifndef _SIMICS_ALLOC_H #define _SIMICS_ALLOC_H #include <simics/util/alloc.h> #endif /* _SIMICS_ALLOC_H */
24.166667
73
0.739655
ae528a648e4d9fe76b573ae703ccb2be5e23fa35
916
c
C
Task/Amicable-pairs/C/amicable-pairs.c
djgoku/RosettaCodeData
91df62d46142e921b3eacdb52b0316c39ee236bc
[ "Info-ZIP" ]
null
null
null
Task/Amicable-pairs/C/amicable-pairs.c
djgoku/RosettaCodeData
91df62d46142e921b3eacdb52b0316c39ee236bc
[ "Info-ZIP" ]
null
null
null
Task/Amicable-pairs/C/amicable-pairs.c
djgoku/RosettaCodeData
91df62d46142e921b3eacdb52b0316c39ee236bc
[ "Info-ZIP" ]
null
null
null
#include <stdio.h> #include <stdlib.h> typedef unsigned int uint; int main(int argc, char **argv) { uint top = atoi(argv[1]); uint *divsum = malloc((top + 1) * sizeof(*divsum)); uint pows[32] = {1, 0}; for (uint i = 0; i <= top; i++) divsum[i] = 1; // sieve for (uint p = 2; p <= top; p++) { if (divsum[p] > 1) continue; // p not prime uint x; // highest power of p we need // checking x <= top/y instead of x*y <= top to avoid overflow for (x = 1; pows[x - 1] <= top/p; x++) pows[x] = p*pows[x - 1]; for (uint n = p; n <= top; n += p) { uint s; for (uint i = s = 1; i < x && !(n%pows[i]); s += pows[i++]); divsum[n] *= s; } } // subtract number itself from divisor sum ('proper') for (uint i = 0; i <= top; i++) divsum[i] -= i; for (uint a = 1; a <= top; a++) { uint b = divsum[a]; if (b > a && b <= top && divsum[b] == a) printf("%u %u\n", a, b); } return 0; }
21.809524
64
0.512009
53d2e9210439eb31e2349a9e139c8d210cb33703
362
h
C
yituiyun/yituiyun/Controllers/MainVC/Controller/HomeMiddleLabelVc.h
HJXIcon/YiTuiYun
b6d700d8905f8929e180f662392058d8f349906d
[ "MIT" ]
1
2018-08-31T03:37:42.000Z
2018-08-31T03:37:42.000Z
yituiyun/yituiyun/Controllers/MainVC/Controller/HomeMiddleLabelVc.h
HJXIcon/YiTuiYun
b6d700d8905f8929e180f662392058d8f349906d
[ "MIT" ]
null
null
null
yituiyun/yituiyun/Controllers/MainVC/Controller/HomeMiddleLabelVc.h
HJXIcon/YiTuiYun
b6d700d8905f8929e180f662392058d8f349906d
[ "MIT" ]
null
null
null
// // HomeMiddleLabelVc.h // yituiyun // // Created by yituiyun on 2017/6/6. // Copyright © 2017年 张强. All rights reserved. // #import <UIKit/UIKit.h> #import "HomeTableViewCell.h" #import "KongKongViewVc.h" @interface HomeMiddleLabelVc : KongKongViewVc /**leixing */ @property(nonatomic,strong) NSDictionary * dict; // {@“linkageid”:@"",@"name":@""} @end
19.052632
48
0.685083
12ef472ff1b388d01d199b5d584cd489907b4e4b
2,740
h
C
BaiduWalletSDK/SAPI/Headers/SAPILib.h
wzy911229/ZYBaiduWalletSDK
89e27f8564aaf40665001ade397181ee18ba97c6
[ "Apache-2.0" ]
null
null
null
BaiduWalletSDK/SAPI/Headers/SAPILib.h
wzy911229/ZYBaiduWalletSDK
89e27f8564aaf40665001ade397181ee18ba97c6
[ "Apache-2.0" ]
null
null
null
BaiduWalletSDK/SAPI/Headers/SAPILib.h
wzy911229/ZYBaiduWalletSDK
89e27f8564aaf40665001ade397181ee18ba97c6
[ "Apache-2.0" ]
null
null
null
// // SAPILib.h // SAPILib // // Created by Vinson.D.Warm on 13-9-6. // Copyright (c) 2013年 baidu. All rights reserved. // // v6.15.10 2016.05.20 // 增加H5与NABDUSS同步策略,可参考[SAPIMainManager sharedManager].naH5SyncStrategy配置项。 // // v6.15.8 2016.05.10 // 适配IPv6-only // // v6.15.6 2016.05.06 // 获取stoken接口增加同步返回值 // // v6.15.5 2016.05.03 // 兼容钱包SDK使用ptoken,stoken情况 // // v6.15.4 2016.04.28 // 增加旧版升级新版时,更新存量cookie标记 // // v6.15.3 2016.04.26 // 优化Native和H5登录态同步(文档地址:http://wiki.baidu.com/pages/viewpage.action?pageId=187600212 ) // // v6.15.0 2016.04.12 // 新增分散认证(文档地址:http://wiki.baidu.com/pages/viewpage.action?pageId=184370957) // // v6.14.12 2016.03.25 // 配置文件支持HTTPS // 增加线下测试环境HTTPS开关 // 人人网已下线,移除相关配置项和接口 // // v6.14.11 2016.03.11 // 调整第三方登录绑定策略:删除暗绑和选择绑定方式;增加注册(首次登录)时强制绑定手机方式。 // 调整HTTPS:删除HTTPS开关配置;增加由于设备时间不对导致HTTPS证书过期的处理。 // 调整静默登录策略,优先静默高价值帐号。 // 写Cookie增加httponly属性。 // // v6.14.8 2016.01.15 // 增加不互通半帐号 // // v6.14.5 2015.12.22 // 支持QQ SSO登录 // // v6.14.4 2015.12.02 // wappass.baidu.com域支持HTTPS // // v6.14.2 2015.11.23 // 短信登录接口支持图片验证码 // 增加飞凡第三方登录 // // v6.14.1 2015.11.03 // 修复Archive时不支持Bitcode错误 // 增加包含额外信息的登录成功回调 // // v6.14.0 2015.10.23 // 增加应用内Native和H5的登录状态同步 // 部分接口支持HTTPS通信(参考SAPIMainManager的shouldEnableHTTPSIfPossible属性) // 支持语音验证码(参考SAPIMainManager的supportVoiceVerifyOnSMSLogin属性) // 支持海外手机号登录注册(参考SAPIMainManager的supportForeignMobile属性) // 支持Bitcode // // v6.12.2 2015.9.18 // 支持OnePassword // 人人网用户登录增加引导绑定流程,后续将下线人人网登录 // 增加登录成功前回调 // 增加修改密码完成后更新登录态 // 增加第三方登录绑定方式 // // v6.12.1 2015.7.30 // 优化代码,修复SAPIMainWebViewDelegate与optional关键字不一致的问题。 // // v6.12.0 2015.7.24 // 新增声纹开关,验证接口 // 新增人脸登录(人脸登录的授权和bundle id有关,如需体验,可用手机访问https://passport.rdtest.baidu.com/export/app/download/Passport_iOS.html) // 注册接口增加统计项 // 优化代码 // // v6.11.4 2015.7.20 // 修复绑定操作页面webview自带的导航栏消失的问题 // // v6.11.3 2015.7.15 // 修复QQ用户昵称包含特殊字符时无法登录的问题 // // v6.11.2 2015.06.01 // 取消导入登录态时ptoken不能为nil的限制;新增一个获取登录界面URL的方法;优化代码 // // v6.11.1 2015.05.18 // 支持线下环境SDK版本号检测;修复声纹登录帐号无法互通的问题 // // v6.11.0 2015.05.12 // 声纹登录带*方案 // // v6.8.5 2015.05.05 // SAPIMainManagerDelegate新增成功登录前的回调 // // v6.8.4 2015.04.30 // 短信登录增加第三方登录入口;优化手机绑定逻辑 // // v6.8.3 2015.04.27 // 优化bduss、cookie的处理策略 // // v6.8.2 2015.04.21 // 新增错误码定义;优化帐号正常化逻辑 #ifndef SAPILib_SAPILib_h #define SAPILib_SAPILib_h // 工具 & 框架 #import "SAPIJSONUtility.h" #import "SAPIInvokeCommand.h" #import "SAPIPlugin.h" #import "SAPIWebView.h" #import "SAPIMainWebView.h" #import "SapiUIDManager.h" // SAPI基本类型定义 #import "SAPIDefine.h" // SAPI通用模型 #import "SAPILoginModel.h" // SAPI管理组件 #import "SapiError.h" #import "SAPILoginService.h" #import "SAPIRegisterService.h" #import "SAPIMainManager.h" #endif
20.916031
114
0.702555
3f5f94b13daaceed85d3c5c902833a3ef89ef107
17,902
c
C
xen-4.6.0/tools/qemu-xen-traditional/hw/pt-msi.c
StanPlatinum/VMI-as-a-Service
5828a9c73815ad7e043428e7e56dc0715aaa60a1
[ "MIT" ]
185
2017-12-14T08:18:15.000Z
2022-03-30T02:58:36.000Z
xen-4.6.0/tools/qemu-xen-traditional/hw/pt-msi.c
StanPlatinum/VMI-as-a-Service
5828a9c73815ad7e043428e7e56dc0715aaa60a1
[ "MIT" ]
11
2018-01-30T23:31:20.000Z
2022-01-17T05:03:56.000Z
xen-4.6.0/tools/qemu-xen-traditional/hw/pt-msi.c
StanPlatinum/ROP-detection-inside-VMs
7b39298dd0791711cbd78fd0730b819b755cc995
[ "MIT" ]
87
2018-01-10T08:12:32.000Z
2022-02-19T10:29:31.000Z
/* * Copyright (c) 2007, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307 USA. * * Jiang Yunhong <yunhong.jiang@intel.com> * * This file implements direct PCI assignment to a HVM guest */ #include "pt-msi.h" #include <sys/mman.h> void msi_set_enable(struct pt_dev *dev, int en) { uint16_t val = 0; uint32_t address = 0; if (!dev->msi) return; address = dev->msi->ctrl_offset; if (!address) return; val = pci_read_word(dev->pci_dev, address); val &= ~PCI_MSI_FLAGS_ENABLE; val |= en & PCI_MSI_FLAGS_ENABLE; pci_write_word(dev->pci_dev, address, val); } static void msix_set_enable(struct pt_dev *dev, int en) { uint16_t val = 0; uint32_t address = 0; if (!dev->msix) return; address = dev->msix->ctrl_offset; if (!address) return; val = pci_read_word(dev->pci_dev, address); val &= ~PCI_MSIX_ENABLE; if (en) val |= PCI_MSIX_ENABLE; pci_write_word(dev->pci_dev, address, val); } /* MSI virtuailization functions */ /* * setup physical msi, but didn't enable it */ int pt_msi_setup(struct pt_dev *dev) { int pirq = -1; uint8_t gvec = 0; if ( !(dev->msi->flags & MSI_FLAG_UNINIT) ) { PT_LOG("Error: setup physical after initialized?? \n"); return -1; } gvec = dev->msi->data & 0xFF; if (!gvec) { /* if gvec is 0, the guest is asking for a particular pirq that * is passed as dest_id */ pirq = (dev->msi->addr_hi & 0xffffff00) | ((dev->msi->addr_lo >> MSI_TARGET_CPU_SHIFT) & 0xff); if (!pirq) /* this probably identifies an misconfiguration of the guest, * try the emulated path */ pirq = -1; else PT_LOG("pt_msi_setup requested pirq = %d\n", pirq); } if ( xc_physdev_map_pirq_msi(xc_handle, domid, AUTO_ASSIGN, &pirq, PCI_DEVFN(dev->pci_dev->dev, dev->pci_dev->func), dev->pci_dev->bus, 0, 0) ) { PT_LOG("Error: Mapping of MSI failed.\n"); return -1; } if ( pirq < 0 ) { PT_LOG("Error: Invalid pirq number\n"); return -1; } dev->msi->pirq = pirq; PT_LOG("msi mapped with pirq %x\n", pirq); return 0; } uint32_t __get_msi_gflags(uint32_t data, uint64_t addr) { uint32_t result = 0; int rh, dm, dest_id, deliv_mode, trig_mode; rh = (addr >> MSI_ADDR_REDIRECTION_SHIFT) & 0x1; dm = (addr >> MSI_ADDR_DESTMODE_SHIFT) & 0x1; dest_id = (addr >> MSI_TARGET_CPU_SHIFT) & 0xff; deliv_mode = (data >> MSI_DATA_DELIVERY_SHIFT) & 0x7; trig_mode = (data >> MSI_DATA_TRIGGER_SHIFT) & 0x1; result |= dest_id | (rh << GFLAGS_SHIFT_RH) | (dm << GFLAGS_SHIFT_DM) | \ (deliv_mode << GLFAGS_SHIFT_DELIV_MODE) | (trig_mode << GLFAGS_SHIFT_TRG_MODE); return result; } int pt_msi_update(struct pt_dev *d) { uint8_t gvec = 0; uint32_t gflags = 0; uint64_t addr = 0; int ret = 0; /* get vector, address, flags info, etc. */ gvec = d->msi->data & 0xFF; addr = (uint64_t)d->msi->addr_hi << 32 | d->msi->addr_lo; gflags = __get_msi_gflags(d->msi->data, addr); PT_LOG("Update msi with pirq %x gvec %x gflags %x\n", d->msi->pirq, gvec, gflags); ret = xc_domain_update_msi_irq(xc_handle, domid, gvec, d->msi->pirq, gflags, 0); if (ret) { PT_LOG("Error: Binding of MSI failed.\n"); if (xc_physdev_unmap_pirq(xc_handle, domid, d->msi->pirq)) PT_LOG("Error: Unmapping of MSI failed.\n"); d->msi->pirq = -1; return ret; } return 0; } void pt_msi_disable(struct pt_dev *dev) { PCIDevice *d = &dev->dev; uint8_t gvec = 0; uint32_t gflags = 0; uint64_t addr = 0; uint8_t e_device = 0; uint8_t e_intx = 0; msi_set_enable(dev, 0); e_device = PCI_SLOT(dev->dev.devfn); e_intx = pci_intx(dev); if (dev->msi_trans_en) { if (xc_domain_unbind_pt_irq(xc_handle, domid, dev->msi->pirq, PT_IRQ_TYPE_MSI_TRANSLATE, 0, e_device, e_intx, 0)) { PT_LOG("Error: Unbinding pt irq for MSI-INTx failed!\n"); goto out; } } else if (!(dev->msi->flags & MSI_FLAG_UNINIT)) { /* get vector, address, flags info, etc. */ gvec = dev->msi->data & 0xFF; addr = (uint64_t)dev->msi->addr_hi << 32 | dev->msi->addr_lo; gflags = __get_msi_gflags(dev->msi->data, addr); PT_LOG("Unbind msi with pirq %x, gvec %x\n", dev->msi->pirq, gvec); if (xc_domain_unbind_msi_irq(xc_handle, domid, gvec, dev->msi->pirq, gflags)) { PT_LOG("Error: Unbinding of MSI failed. [%02x:%02x.%x]\n", pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); goto out; } } if (dev->msi->pirq != -1) { PT_LOG("Unmap msi with pirq %x\n", dev->msi->pirq); if (xc_physdev_unmap_pirq(xc_handle, domid, dev->msi->pirq)) { PT_LOG("Error: Unmapping of MSI failed. [%02x:%02x.%x]\n", pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); goto out; } } out: /* clear msi info */ dev->msi->flags &= ~(PT_MSI_MAPPED | PCI_MSI_FLAGS_ENABLE); dev->msi->flags |= MSI_FLAG_UNINIT; dev->msi->pirq = -1; dev->msi_trans_en = 0; } /* MSI-INTx translation virtulization functions */ int pt_enable_msi_translate(struct pt_dev* dev) { uint8_t e_device = 0; uint8_t e_intx = 0; if (!(dev->msi && dev->msi_trans_cap)) return -1; msi_set_enable(dev, 0); dev->msi_trans_en = 0; if (pt_msi_setup(dev)) { PT_LOG("Error: MSI-INTx translation MSI setup failed, fallback\n"); return -1; } e_device = PCI_SLOT(dev->dev.devfn); /* fix virtual interrupt pin to INTA# */ e_intx = pci_intx(dev); if (xc_domain_bind_pt_irq(xc_handle, domid, dev->msi->pirq, PT_IRQ_TYPE_MSI_TRANSLATE, 0, e_device, e_intx, 0)) { PT_LOG("Error: MSI-INTx translation bind failed, fallback\n"); if (xc_physdev_unmap_pirq(xc_handle, domid, dev->msi->pirq)) PT_LOG("Error: Unmapping of MSI failed.\n"); dev->msi->pirq = -1; return -1; } msi_set_enable(dev, 1); dev->msi_trans_en = 1; return 0; } void pt_disable_msi_translate(struct pt_dev *dev) { uint8_t e_device = 0; uint8_t e_intx = 0; pt_msi_disable(dev); dev->msi->flags |= MSI_FLAG_UNINIT; if (dev->machine_irq) { if (xc_domain_bind_pt_pci_irq(xc_handle, domid, dev->machine_irq, 0, e_device, e_intx)) PT_LOG("Error: Rebinding of interrupt failed!\n"); } } static int pt_msix_update_one(struct pt_dev *dev, int entry_nr) { struct msix_entry_info *entry = &dev->msix->msix_entry[entry_nr]; int pirq = entry->pirq; int gvec = entry->io_mem[2] & 0xff; uint64_t gaddr = *(uint64_t *)&entry->io_mem[0]; uint32_t gflags = __get_msi_gflags(entry->io_mem[2], gaddr); int ret; if ( !entry->flags ) return 0; if (!gvec) { /* if gvec is 0, the guest is asking for a particular pirq that * is passed as dest_id */ pirq = ((gaddr >> 32) & 0xffffff00) | (((gaddr & 0xffffffff) >> MSI_TARGET_CPU_SHIFT) & 0xff); if (!pirq) /* this probably identifies an misconfiguration of the guest, * try the emulated path */ pirq = -1; else PT_LOG("pt_msix_update_one requested pirq = %d\n", pirq); } /* Check if this entry is already mapped */ if ( entry->pirq == -1 ) { ret = xc_physdev_map_pirq_msi(xc_handle, domid, AUTO_ASSIGN, &pirq, PCI_DEVFN(dev->pci_dev->dev, dev->pci_dev->func), dev->pci_dev->bus, entry_nr, dev->msix->table_base); if ( ret ) { PT_LOG("Error: Mapping msix entry %x\n", entry_nr); return ret; } entry->pirq = pirq; } PT_LOG("Update msix entry %x with pirq %x gvec %x\n", entry_nr, pirq, gvec); ret = xc_domain_update_msi_irq(xc_handle, domid, gvec, pirq, gflags, dev->msix->mmio_base_addr); if ( ret ) { PT_LOG("Error: Updating msix irq info for entry %d\n", entry_nr); if (xc_physdev_unmap_pirq(xc_handle, domid, entry->pirq)) PT_LOG("Error: Unmapping of MSI-X failed.\n"); entry->pirq = -1; return ret; } entry->flags = 0; return 0; } int pt_msix_update(struct pt_dev *dev) { struct pt_msix_info *msix = dev->msix; int i; for ( i = 0; i < msix->total_entries; i++ ) { pt_msix_update_one(dev, i); } return 0; } void pt_msix_disable(struct pt_dev *dev) { PCIDevice *d = &dev->dev; uint8_t gvec = 0; uint32_t gflags = 0; uint64_t addr = 0; int i = 0; struct msix_entry_info *entry = NULL; msix_set_enable(dev, 0); for ( i = 0; i < dev->msix->total_entries; i++ ) { entry = &dev->msix->msix_entry[i]; if (entry->pirq == -1) continue; gvec = entry->io_mem[2] & 0xff; addr = *(uint64_t *)&entry->io_mem[0]; gflags = __get_msi_gflags(entry->io_mem[2], addr); PT_LOG("Unbind msix with pirq %x, gvec %x\n", entry->pirq, gvec); if (xc_domain_unbind_msi_irq(xc_handle, domid, gvec, entry->pirq, gflags)) PT_LOG("Error: Unbinding of MSI-X failed. [%02x:%02x.%x]\n", pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); else { PT_LOG("Unmap msix with pirq %x\n", entry->pirq); if (xc_physdev_unmap_pirq(xc_handle, domid, entry->pirq)) PT_LOG("Error: Unmapping of MSI-X failed. [%02x:%02x.%x]\n", pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); } /* clear msi-x info */ entry->pirq = -1; entry->flags = 0; } } int pt_msix_update_remap(struct pt_dev *dev, int bar_index) { struct msix_entry_info *entry; int i, ret; if ( !(dev->msix && dev->msix->bar_index == bar_index) ) return 0; for ( i = 0; i < dev->msix->total_entries; i++ ) { entry = &dev->msix->msix_entry[i]; if ( entry->pirq != -1 ) { ret = xc_domain_unbind_pt_irq(xc_handle, domid, entry->pirq, PT_IRQ_TYPE_MSI, 0, 0, 0, 0); if ( ret ) PT_LOG("Error: unbind MSI-X entry %d failed\n", entry->pirq); entry->flags = 1; } } pt_msix_update(dev); return 0; } static void pci_msix_invalid_write(void *opaque, target_phys_addr_t addr, uint32_t val) { PT_LOG("Error: Invalid write to MSI-X table, addr %016"PRIx64";" " only dword access is allowed\n", addr); } static void pci_msix_writel(void *opaque, target_phys_addr_t addr, uint32_t val) { struct pt_dev *dev = (struct pt_dev *)opaque; struct pt_msix_info *msix = dev->msix; struct msix_entry_info *entry; int entry_nr, offset; if ( addr % 4 ) { PT_LOG("Error: Unaligned dword write to MSI-X table," " addr %016"PRIx64"\n", addr); return; } entry_nr = (addr - msix->mmio_base_addr) / 16; entry = &msix->msix_entry[entry_nr]; offset = ((addr - msix->mmio_base_addr) % 16) / 4; if ( offset != 3 ) { const volatile uint32_t *vec_ctrl; if ( entry->io_mem[offset] == val && entry->pirq != -1) return; /* * If Xen intercepts the mask bit access, io_mem[3] may not be * up-to-date. Read from hardware directly. */ vec_ctrl = msix->phys_iomem_base + 16 * entry_nr + 12; if ( msix->enabled && !(*vec_ctrl & 0x1) ) { PT_LOG("Can't update entry %d since MSI-X is already enabled" " (%08"PRIx32" -> %08"PRIx32")\n", entry_nr, entry->io_mem[offset], val); return; } entry->flags = 1; } entry->io_mem[offset] = val; if ( offset == 3 ) { if ( msix->enabled && !(val & 0x1) ) pt_msix_update_one(dev, entry_nr); } } static CPUWriteMemoryFunc *pci_msix_write[] = { pci_msix_invalid_write, pci_msix_invalid_write, pci_msix_writel }; static uint32_t pci_msix_invalid_read(void *opaque, target_phys_addr_t addr) { PT_LOG("Error: Invalid read >from MSI-X table, addr %016"PRIx64";" " only dword access is allowed\n", addr); return 0; } static uint32_t pci_msix_readl(void *opaque, target_phys_addr_t addr) { struct pt_dev *dev = (struct pt_dev *)opaque; struct pt_msix_info *msix = dev->msix; int entry_nr, offset; if ( addr % 4 ) { PT_LOG("Error: Unaligned dword read from MSI-X table," " addr %016"PRIx64"\n", addr); return 0; } entry_nr = (addr - msix->mmio_base_addr) / 16; offset = ((addr - msix->mmio_base_addr) % 16) / 4; if ( addr - msix->mmio_base_addr < msix->total_entries * 16 ) return msix->msix_entry[entry_nr].io_mem[offset]; else return *(uint32_t *)(msix->phys_iomem_base + (addr - msix->mmio_base_addr)); } static CPUReadMemoryFunc *pci_msix_read[] = { pci_msix_invalid_read, pci_msix_invalid_read, pci_msix_readl }; int has_msix_mapping(struct pt_dev *dev, int bar_index) { if ( !(dev->msix && dev->msix->bar_index == bar_index) ) return 0; return 1; } int pt_msix_init(struct pt_dev *dev, int pos) { uint8_t id; uint16_t control; int i, total_entries, table_off, bar_index; struct pci_dev *pd = dev->pci_dev; int fd; id = pci_read_byte(pd, pos + PCI_CAP_LIST_ID); if ( id != PCI_CAP_ID_MSIX ) { PT_LOG("Error: Invalid id %x pos %x\n", id, pos); return -1; } control = pci_read_word(pd, pos + 2); total_entries = control & 0x7ff; total_entries += 1; dev->msix = malloc(sizeof(struct pt_msix_info) + total_entries*sizeof(struct msix_entry_info)); if ( !dev->msix ) { PT_LOG("Error: Allocating pt_msix_info failed.\n"); return -1; } memset(dev->msix, 0, sizeof(struct pt_msix_info) + total_entries*sizeof(struct msix_entry_info)); dev->msix->total_entries = total_entries; for ( i = 0; i < total_entries; i++ ) dev->msix->msix_entry[i].pirq = -1; dev->msix->mmio_index = cpu_register_io_memory(0, pci_msix_read, pci_msix_write, dev); table_off = pci_read_long(pd, pos + PCI_MSIX_TABLE); bar_index = dev->msix->bar_index = table_off & PCI_MSIX_BIR; table_off = dev->msix->table_off = table_off & ~PCI_MSIX_BIR; dev->msix->table_base = pt_pci_base_addr(dev->pci_dev->base_addr[bar_index]); PT_LOG("get MSI-X table bar base %llx\n", (unsigned long long)dev->msix->table_base); fd = open("/dev/mem", O_RDWR); if ( fd == -1 ) { PT_LOG("Error: Can't open /dev/mem: %s\n", strerror(errno)); goto error_out; } PT_LOG("table_off = %x, total_entries = %d\n", table_off, total_entries); dev->msix->table_offset_adjust = table_off & 0x0fff; dev->msix->phys_iomem_base = mmap(0, total_entries * 16 + dev->msix->table_offset_adjust, PROT_READ, MAP_SHARED | MAP_LOCKED, fd, dev->msix->table_base + table_off - dev->msix->table_offset_adjust); close(fd); if ( dev->msix->phys_iomem_base == MAP_FAILED ) { PT_LOG("Error: Can't map physical MSI-X table: %s\n", strerror(errno)); goto error_out; } dev->msix->phys_iomem_base += dev->msix->table_offset_adjust; PT_LOG("mapping physical MSI-X table to %lx\n", (unsigned long)dev->msix->phys_iomem_base); return 0; error_out: free(dev->msix); dev->msix = NULL; return -1; } void pt_msix_delete(struct pt_dev *dev) { /* unmap the MSI-X memory mapped register area */ if (dev->msix->phys_iomem_base) { PT_LOG("unmapping physical MSI-X table from %lx\n", (unsigned long)dev->msix->phys_iomem_base); munmap(dev->msix->phys_iomem_base, dev->msix->total_entries * 16 + dev->msix->table_offset_adjust); } if (dev->msix->mmio_index > 0) { cpu_unregister_io_memory(dev->msix->mmio_index); } free(dev->msix); dev->msix = NULL; }
28.735152
98
0.568652
e986589d0b8c8cfb6cc205ed1b4325aeed2ed154
4,255
h
C
src/envoy/mixer/grpc_transport.h
douglas-reid/proxy
fc43bcbbc78577f86ed8ae90fbe334a31875ee8a
[ "Apache-2.0" ]
null
null
null
src/envoy/mixer/grpc_transport.h
douglas-reid/proxy
fc43bcbbc78577f86ed8ae90fbe334a31875ee8a
[ "Apache-2.0" ]
null
null
null
src/envoy/mixer/grpc_transport.h
douglas-reid/proxy
fc43bcbbc78577f86ed8ae90fbe334a31875ee8a
[ "Apache-2.0" ]
null
null
null
/* Copyright 2017 Istio Authors. All Rights Reserved. * * 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 <memory> #include "common/common/logger.h" #include "envoy/event/dispatcher.h" #include "envoy/grpc/rpc_channel.h" #include "envoy/upstream/cluster_manager.h" #include "include/client.h" namespace Envoy { namespace Http { namespace Mixer { // An object to use Envoy async_client to make grpc call. class GrpcTransport : public Grpc::RpcChannelCallbacks, public Logger::Loggable<Logger::Id::http> { public: GrpcTransport(Upstream::ClusterManager& cm); void onPreRequestCustomizeHeaders(Http::HeaderMap& headers) override {} void onSuccess() override; void onFailure(const Optional<uint64_t>& grpc_status, const std::string& message) override; // Check if mixer server cluster configured in cluster_manager. static bool IsMixerServerConfigured(Upstream::ClusterManager& cm); protected: // Create a new grpc channel. Grpc::RpcChannelPtr NewChannel(Upstream::ClusterManager& cm); // The on_done callback function. ::istio::mixer_client::DoneFunc on_done_; // the grpc channel. Grpc::RpcChannelPtr channel_; // The generated mixer client stub. ::istio::mixer::v1::Mixer::Stub stub_; }; // A helper class to pass Upstream::ClusterManager& in the lambda capture // If passing Upstream::ClusterManager& directly in the capture, it assumes // const Upstream::ClusterManager&. class ClusterManagerStore { public: ClusterManagerStore(Upstream::ClusterManager& cm) : cm_(cm) {} Upstream::ClusterManager& cm() { return cm_; } private: Upstream::ClusterManager& cm_; }; class CheckGrpcTransport : public GrpcTransport { public: CheckGrpcTransport(Upstream::ClusterManager& cm) : GrpcTransport(cm) {} static ::istio::mixer_client::TransportCheckFunc GetFunc( std::shared_ptr<ClusterManagerStore> cms) { return [cms](const ::istio::mixer::v1::CheckRequest& request, ::istio::mixer::v1::CheckResponse* response, ::istio::mixer_client::DoneFunc on_done) { CheckGrpcTransport* transport = new CheckGrpcTransport(cms->cm()); transport->Call(request, response, on_done); }; } void Call(const ::istio::mixer::v1::CheckRequest& request, ::istio::mixer::v1::CheckResponse* response, ::istio::mixer_client::DoneFunc on_done) { on_done_ = [this, response, on_done](const ::google::protobuf::util::Status& status) { if (status.ok()) { log().debug("Check response: {}", response->DebugString()); } on_done(status); }; log().debug("Call grpc check: {}", request.DebugString()); stub_.Check(nullptr, &request, response, nullptr); } }; class ReportGrpcTransport : public GrpcTransport { public: ReportGrpcTransport(Upstream::ClusterManager& cm) : GrpcTransport(cm) {} static ::istio::mixer_client::TransportReportFunc GetFunc( std::shared_ptr<ClusterManagerStore> cms) { return [cms](const ::istio::mixer::v1::ReportRequest& request, ::istio::mixer::v1::ReportResponse* response, ::istio::mixer_client::DoneFunc on_done) { ReportGrpcTransport* transport = new ReportGrpcTransport(cms->cm()); transport->Call(request, response, on_done); }; } void Call(const ::istio::mixer::v1::ReportRequest& request, ::istio::mixer::v1::ReportResponse* response, ::istio::mixer_client::DoneFunc on_done) { on_done_ = on_done; log().debug("Call grpc report: {}", request.DebugString()); stub_.Report(nullptr, &request, response, nullptr); } }; } // namespace Mixer } // namespace Http } // namespace Envoy
34.314516
75
0.693067
b9ec498decf78f5fe0597b824e62fb97c3d037f3
1,344
h
C
impactKiosk/src/chartdir/memblock.h
aaga/impact-kiosk
19474edbbac8c7b7328b07f31b447fb14d413e29
[ "MIT" ]
3
2021-06-22T18:36:14.000Z
2021-11-07T20:26:16.000Z
impactKiosk/src/chartdir/memblock.h
aaga/impact-kiosk
19474edbbac8c7b7328b07f31b447fb14d413e29
[ "MIT" ]
1
2017-08-30T03:11:30.000Z
2017-08-30T03:11:30.000Z
libecg-test/ChartDirector/include/memblock.h
kamyar-nemati/libecg-test
14f2344bc02fea957ab6805351edb5aa88664451
[ "MIT" ]
2
2019-05-20T09:51:59.000Z
2021-03-24T19:35:01.000Z
/* * Copyright (C) 2013 Advanced Software Engineering Limited. * * This file is part of the ChartDirector software. Usage of this file is * subjected to the ChartDirector license agreement. See the LICENSE.TXT * file that comes with the ChartDirector software release, or visit * Advanced Software Engineering's web site at www.advsofteng.com or * email to support@advsofteng.com for information. * */ #ifndef MEMBLOCK_HDR #define MEMBLOCK_HDR class MemBlock { public : int len; const char *data; MemBlock() : len(0), data(0) {} MemBlock(const char *_data, int _len) : len(_len), data(_data) {} char operator[](int i) const { return data[i]; } }; class StringArray { public : int len; const char * const *data; StringArray() : len(0), data(0) {} StringArray(const char * const *_data, int _len) : len(_len), data(_data) {} const char *operator[](int i) const { return data[i]; } }; class DoubleArray { public : int len; const double *data; DoubleArray() : len(0), data(0) {} DoubleArray(const double *_data, int _len) : len(_len), data(_data) {} double operator[](int i) const { return data[i]; } }; class IntArray { public : int len; const int *data; IntArray() : len(0), data(0) {} IntArray(const int *_data, int _len) : len(_len), data(_data) {} int operator[](int i) const { return data[i]; } }; #endif
24
77
0.684524
2704551e1c6cba3ca58f8ffe057c6e2cdcdb3f51
1,440
h
C
OutPutHeaders/LView.h
cocos543/WeChatTimeLineRobot
1e93480e502e36ca9a21a506f481aa1fcb70ac4b
[ "MIT" ]
106
2016-04-09T01:16:14.000Z
2021-06-04T00:20:24.000Z
OutPutHeaders/LView.h
cocos543/WeChatTimeLineRobot
1e93480e502e36ca9a21a506f481aa1fcb70ac4b
[ "MIT" ]
2
2017-06-13T09:41:29.000Z
2018-03-26T03:32:07.000Z
OutPutHeaders/LView.h
cocos543/WeChatTimeLineRobot
1e93480e502e36ca9a21a506f481aa1fcb70ac4b
[ "MIT" ]
58
2016-04-28T09:52:08.000Z
2021-12-25T06:42:14.000Z
/** * This header is generated by class-dump-z 0.2a. * class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3. * * Source: (null) */ #import <XXUnknownSuperclass.h> // Unknown library #import "WeChat-Structs.h" @class UIView, AVCaptureVideoPreviewLayer; @protocol NSObject; @interface LView : XXUnknownSuperclass { BOOL mIsCameraFront; AVCaptureVideoPreviewLayer* localLayer; UIView* m_defaultView; SEL selector; id<NSObject> targetor; } @property(assign, nonatomic) BOOL mIsCameraFront; @property(assign, nonatomic) SEL selector; @property(retain, nonatomic) id<NSObject> targetor; @property(retain, nonatomic) UIView* m_defaultView; @property(retain, nonatomic) AVCaptureVideoPreviewLayer* localLayer; -(void).cxx_destruct; -(void)resetSmallRect; -(void)randerDefaultView:(id)view; -(void)switchLocalView:(BOOL)view; -(void)dealloc; -(void)changeFrame:(CGRect)frame; -(void)renderImage:(char*)image Width:(unsigned long)width Height:(unsigned long)height; -(void)stopRender; -(void)restartRender; -(void)transformFrontImage; -(void)transformBackImage; -(void)addSingleTapTarget:(id)target action:(SEL)action; -(id)initWithView:(id)view Layer:(id)layer; -(id)initWithFrame:(CGRect)frame; -(void)touchesEnded:(id)ended withEvent:(id)event; -(void)touchesCancelled:(id)cancelled withEvent:(id)event; -(void)touchesBegan:(id)began withEvent:(id)event; -(BOOL)checkTouchPoint:(CGPoint)point IfInView:(id)view; @end
31.304348
88
0.771528
5bdaf65c36d519ddbbd69813feea812a9138c2ca
84
h
C
os/darwin/SetupLogging.h
kovdan01/libtgvoip
6fec40ea1acd40fddba927b049f78962507d4922
[ "Unlicense" ]
null
null
null
os/darwin/SetupLogging.h
kovdan01/libtgvoip
6fec40ea1acd40fddba927b049f78962507d4922
[ "Unlicense" ]
null
null
null
os/darwin/SetupLogging.h
kovdan01/libtgvoip
6fec40ea1acd40fddba927b049f78962507d4922
[ "Unlicense" ]
null
null
null
#import <Foundation/Foundation.h> extern void (*TGVoipLoggingFunction)(NSString*);
21
48
0.785714
1d04af9a68e06a88b12be37601662f0c627bf4a2
487
h
C
src/sandbox/io/File.h
OpenSpace-VisLink/sandbox
cb8a42facc3afe73794e2e4405aab13531ccbcb2
[ "MIT" ]
null
null
null
src/sandbox/io/File.h
OpenSpace-VisLink/sandbox
cb8a42facc3afe73794e2e4405aab13531ccbcb2
[ "MIT" ]
null
null
null
src/sandbox/io/File.h
OpenSpace-VisLink/sandbox
cb8a42facc3afe73794e2e4405aab13531ccbcb2
[ "MIT" ]
1
2020-12-01T18:17:58.000Z
2020-12-01T18:17:58.000Z
#ifndef SANDBOX_IO_FILE_H_ #define SANDBOX_IO_FILE_H_ #include <string> #include "sandbox/Component.h" namespace sandbox { class File : public Component { public: File(const std::string& path) : path(path) { addType<File>(); lastModifiedTime = getFileModifiedTime(); } virtual ~File() {} const std::string& getPath() const { return path; } long long getFileModifiedTime() const; bool checkForUpdate(); private: std::string path; long long lastModifiedTime; }; } #endif
17.392857
52
0.724846
df6a63b51e7b35c864f2a591c2e1cf03aa94c972
1,804
h
C
deps/common/metrics/histogram_snapshot.h
wangqiim/miniob
f5d8b716f8449c9d9df3622231237e2438f8849a
[ "Apache-2.0" ]
null
null
null
deps/common/metrics/histogram_snapshot.h
wangqiim/miniob
f5d8b716f8449c9d9df3622231237e2438f8849a
[ "Apache-2.0" ]
null
null
null
deps/common/metrics/histogram_snapshot.h
wangqiim/miniob
f5d8b716f8449c9d9df3622231237e2438f8849a
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. miniob is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. */ // // Created by Longda on 2021/4/20. // #ifndef __COMMON_METRICS_HISTOGRAM_SNAPSHOT_H_ #define __COMMON_METRICS_HISTOGRAM_SNAPSHOT_H_ #include <stddef.h> #include <stdint.h> #include <string> #include <vector> #include "common/metrics/snapshot.h" namespace common { class HistogramSnapShot : public Snapshot { public: HistogramSnapShot(); explicit HistogramSnapShot(const std::vector<double> &collection); virtual ~HistogramSnapShot(); public: void set_collection(const std::vector<double> &collection); /** * Returns the value at the given quantile * * @param quantile a given quantile, in {@code [0..1]} * @return the value in the distribute */ double get_value(double quantile); /** * Returns the size of collection in the snapshot */ size_t size() const; /** * Returns 50th_percentile. */ double get_median(); double get_75th(); double get_90th(); double get_95th(); double get_99th(); double get_999th(); double get_max(); double get_min(); double get_mean(); const std::vector<double> &get_values(); std::string to_string(); protected: std::vector<double> data_; }; } // namespace common #endif /* __COMMON_METRICS_HISTOGRAM_SNAPSHOT_H_ */
23.736842
111
0.723392
ce5dc7f941aaf8c245313411d68d957cc6ddf16c
361
h
C
src/map/EnemyGenerator.h
LiquidityC/deadgaem
3d970ce09e26115e002b391524584eab0583af37
[ "WTFPL" ]
1
2016-02-18T23:05:13.000Z
2016-02-18T23:05:13.000Z
src/map/EnemyGenerator.h
LiquidityC/deadgaem
3d970ce09e26115e002b391524584eab0583af37
[ "WTFPL" ]
null
null
null
src/map/EnemyGenerator.h
LiquidityC/deadgaem
3d970ce09e26115e002b391524584eab0583af37
[ "WTFPL" ]
1
2020-05-13T09:39:51.000Z
2020-05-13T09:39:51.000Z
#ifndef MAP_ENEMYGENERATOR_H_ #define MAP_ENEMYGENERATOR_H_ #include <flat/flat.h> #include "EntityGenerator.h" class MapTileObject; class EnemyGenerator : public EntityGenerator { protected: virtual bool timeToSpawn() = 0; public: virtual void preMove(const flat2d::GameData *gameData, const MapTileObject *tile); }; #endif // MAP_ENEMYGENERATOR_H_
19
84
0.781163
3807efd787f112d5671ffd9105923c4d01f7df22
5,596
c
C
demo/conclusion.c
henrikh/posix_ipc
46eae821f56f364a3afd6d68b3562adeced3794a
[ "BSD-3-Clause" ]
73
2018-01-17T01:29:28.000Z
2022-03-06T18:16:48.000Z
demo/conclusion.c
henrikh/posix_ipc
46eae821f56f364a3afd6d68b3562adeced3794a
[ "BSD-3-Clause" ]
27
2018-01-11T01:42:24.000Z
2021-09-03T21:52:14.000Z
demo/conclusion.c
henrikh/posix_ipc
46eae821f56f364a3afd6d68b3562adeced3794a
[ "BSD-3-Clause" ]
14
2018-02-20T14:52:53.000Z
2021-11-25T01:44:07.000Z
#include <stdio.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <time.h> #include <semaphore.h> #include <sys/types.h> #include <sys/mman.h> #include <fcntl.h> #include "md5.h" #include "utils.h" static const char MY_NAME[] = "Mrs. Conclusion"; // Set up a Mrs. Premise & Mrs. Conclusion conversation. int main() { sem_t *the_semaphore = NULL; int rc; char s[1024]; int i; int done; int fd; void *pSharedMemory = NULL; char last_message_i_wrote[256]; char md5ified_message[256]; struct param_struct params; say(MY_NAME, "Oooo 'ello, I'm Mrs. Conclusion!"); read_params(&params); // Mrs. Premise has already created the semaphore and shared memory. // I just need to get handles to them. the_semaphore = sem_open(params.semaphore_name, 0); if (the_semaphore == SEM_FAILED) { the_semaphore = NULL; sprintf(s, "Getting a handle to the semaphore failed; errno is %d", errno); say(MY_NAME, s); } else { // get a handle to the shared memory fd = shm_open(params.shared_memory_name, O_RDWR, params.permissions); if (fd == -1) { sprintf(s, "Couldn't get a handle to the shared memory; errno is %d", errno); say(MY_NAME, s); } else { // mmap it. pSharedMemory = mmap((void *)0, (size_t)params.size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (pSharedMemory == MAP_FAILED) { sprintf(s, "MMapping the shared memory failed; errno is %d", errno); say(MY_NAME, s); } else { sprintf(s, "pSharedMemory = %p", pSharedMemory); say(MY_NAME, s); i = 0; done = 0; last_message_i_wrote[0] = '\0'; while (!done) { sprintf(s, "iteration %d", i); say(MY_NAME, s); // Wait for Mrs. Premise to free up the semaphore. rc = acquire_semaphore(MY_NAME, the_semaphore, params.live_dangerously); if (rc) done = 1; else { while ( (!rc) && \ (!strcmp((char *)pSharedMemory, last_message_i_wrote)) ) { // Nothing new; give Mrs. Premise another change to respond. sprintf(s, "Read %zu characters '%s'", strlen((char *)pSharedMemory), (char *)pSharedMemory); say(MY_NAME, s); say(MY_NAME, "Releasing the semaphore"); rc = release_semaphore(MY_NAME, the_semaphore, params.live_dangerously); if (!rc) { say(MY_NAME, "Waiting to acquire the semaphore"); rc = acquire_semaphore(MY_NAME, the_semaphore, params.live_dangerously); } } md5ify(last_message_i_wrote, md5ified_message); // I always accept the first message (when i == 0) if ( (i == 0) || (!strcmp(md5ified_message, (char *)pSharedMemory)) ) { // All is well i++; if (i == params.iterations) done = 1; // MD5 the reply and write back to Mrs. Premise. md5ify((char *)pSharedMemory, md5ified_message); // Write back to Mrs. Premise. sprintf(s, "Writing %zu characters '%s'", strlen(md5ified_message), md5ified_message); say(MY_NAME, s); strcpy((char *)pSharedMemory, md5ified_message); strcpy(last_message_i_wrote, md5ified_message); } else { sprintf(s, "Shared memory corruption after %d iterations.", i); say(MY_NAME, s); sprintf(s, "Mismatch; rc = %d, new message is '%s', expected '%s'.", rc, (char *)pSharedMemory, md5ified_message); say(MY_NAME, s); done = 1; } } // Release the semaphore. rc = release_semaphore(MY_NAME, the_semaphore, params.live_dangerously); if (rc) done = 1; } } // Un-mmap the memory rc = munmap(pSharedMemory, (size_t)params.size); if (rc) { sprintf(s, "Unmapping the memory failed; errno is %d", errno); say(MY_NAME, s); } // Close the shared memory segment's file descriptor if (-1 == close(fd)) { sprintf(s, "Closing memory's file descriptor failed; errno is %d", errno); say(MY_NAME, s); } } rc = sem_close(the_semaphore); if (rc) { sprintf(s, "Closing the semaphore failed; errno is %d", errno); say(MY_NAME, s); } } return 0; }
38.068027
142
0.456397
38723e56ed13dfe29585b00be5f05c1206a4effb
11,511
c
C
src/lib/pubsub/pubsub_check.c
Hyodar/tor
6342a347b3bddc42fe925b943146253c0bc426c1
[ "BSD-2-Clause-NetBSD" ]
1
2020-01-09T22:46:28.000Z
2020-01-09T22:46:28.000Z
src/lib/pubsub/pubsub_check.c
Hyodar/tor
6342a347b3bddc42fe925b943146253c0bc426c1
[ "BSD-2-Clause-NetBSD" ]
null
null
null
src/lib/pubsub/pubsub_check.c
Hyodar/tor
6342a347b3bddc42fe925b943146253c0bc426c1
[ "BSD-2-Clause-NetBSD" ]
null
null
null
/* Copyright (c) 2001, Matej Pfajfar. * Copyright (c) 2001-2004, Roger Dingledine. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. * Copyright (c) 2007-2018, The Tor Project, Inc. */ /* See LICENSE for licensing information */ /** * @file pubsub_check.c * @brief Enforce various requirements on a pubsub_builder. **/ /** @{ */ #define PUBSUB_PRIVATE /** @} */ #include "lib/dispatch/dispatch_naming.h" #include "lib/dispatch/msgtypes.h" #include "lib/pubsub/pubsub_flags.h" #include "lib/pubsub/pubsub_builder_st.h" #include "lib/pubsub/pubsub_build.h" #include "lib/container/bitarray.h" #include "lib/container/smartlist.h" #include "lib/log/util_bug.h" #include "lib/malloc/malloc.h" #include "lib/string/compat_string.h" #include <string.h> static void pubsub_adjmap_add(pubsub_adjmap_t *map, const pubsub_cfg_t *item); /** * Helper: contruct and return a new pubsub_adjacency_map from <b>cfg</b>. * Return NULL on error. **/ static pubsub_adjmap_t * pubsub_build_adjacency_map(const pubsub_items_t *cfg) { pubsub_adjmap_t *map = tor_malloc_zero(sizeof(*map)); const size_t n_subsystems = get_num_subsys_ids(); const size_t n_msgs = get_num_message_ids(); map->n_subsystems = n_subsystems; map->n_msgs = n_msgs; map->pub_by_subsys = tor_calloc(n_subsystems, sizeof(smartlist_t*)); map->sub_by_subsys = tor_calloc(n_subsystems, sizeof(smartlist_t*)); map->pub_by_msg = tor_calloc(n_msgs, sizeof(smartlist_t*)); map->sub_by_msg = tor_calloc(n_msgs, sizeof(smartlist_t*)); SMARTLIST_FOREACH_BEGIN(cfg->items, const pubsub_cfg_t *, item) { pubsub_adjmap_add(map, item); } SMARTLIST_FOREACH_END(item); return map; } /** * Helper: add a single pubsub_cfg_t to an adjacency map. **/ static void pubsub_adjmap_add(pubsub_adjmap_t *map, const pubsub_cfg_t *item) { smartlist_t **by_subsys; smartlist_t **by_msg; tor_assert(item->subsys < map->n_subsystems); tor_assert(item->msg < map->n_msgs); if (item->is_publish) { by_subsys = &map->pub_by_subsys[item->subsys]; by_msg = &map->pub_by_msg[item->msg]; } else { by_subsys = &map->sub_by_subsys[item->subsys]; by_msg = &map->sub_by_msg[item->msg]; } if (! *by_subsys) *by_subsys = smartlist_new(); if (! *by_msg) *by_msg = smartlist_new(); smartlist_add(*by_subsys, (void*) item); smartlist_add(*by_msg, (void *) item); } /** * Release all storage held by m and set m to NULL. **/ #define pubsub_adjmap_free(m) \ FREE_AND_NULL(pubsub_adjmap_t, pubsub_adjmap_free_, m) /** * Free every element of an <b>n</b>-element array of smartlists, then * free the array itself. **/ static void pubsub_adjmap_free_helper(smartlist_t **lsts, size_t n) { if (!lsts) return; for (unsigned i = 0; i < n; ++i) { smartlist_free(lsts[i]); } tor_free(lsts); } /** * Release all storage held by <b>map</b>. **/ static void pubsub_adjmap_free_(pubsub_adjmap_t *map) { if (!map) return; pubsub_adjmap_free_helper(map->pub_by_subsys, map->n_subsystems); pubsub_adjmap_free_helper(map->sub_by_subsys, map->n_subsystems); pubsub_adjmap_free_helper(map->pub_by_msg, map->n_msgs); pubsub_adjmap_free_helper(map->sub_by_msg, map->n_msgs); tor_free(map); } /** * Helper: return the length of <b>sl</b>, or 0 if sl is NULL. **/ static int smartlist_len_opt(const smartlist_t *sl) { if (sl) return smartlist_len(sl); else return 0; } /** Return a pointer to a statically allocated string encoding the * dispatcher flags in <b>flags</b>. */ static const char * format_flags(unsigned flags) { static char buf[32]; buf[0] = 0; if (flags & DISP_FLAG_EXCL) { strlcat(buf, " EXCL", sizeof(buf)); } if (flags & DISP_FLAG_STUB) { strlcat(buf, " STUB", sizeof(buf)); } return buf[0] ? buf+1 : buf; } /** * Log a message containing a description of <b>cfg</b> at severity, prefixed * by the string <b>prefix</b>. */ static void pubsub_cfg_dump(const pubsub_cfg_t *cfg, int severity, const char *prefix) { tor_assert(prefix); tor_log(severity, LD_MESG, "%s%s %s: %s{%s} on %s (%s) <%u %u %u %u %x> [%s:%d]", prefix, get_subsys_id_name(cfg->subsys), cfg->is_publish ? "PUB" : "SUB", get_message_id_name(cfg->msg), get_msg_type_id_name(cfg->type), get_channel_id_name(cfg->channel), format_flags(cfg->flags), cfg->subsys, cfg->msg, cfg->type, cfg->channel, cfg->flags, cfg->added_by_file, cfg->added_by_line); } /** * Helper: fill a bitarray <b>out</b> with entries corresponding to the * subsystems listed in <b>items</b>. **/ static void get_message_bitarray(const pubsub_adjmap_t *map, const smartlist_t *items, bitarray_t **out) { *out = bitarray_init_zero((unsigned)map->n_subsystems); if (! items) return; SMARTLIST_FOREACH_BEGIN(items, const pubsub_cfg_t *, cfg) { bitarray_set(*out, cfg->subsys); } SMARTLIST_FOREACH_END(cfg); } /** * Helper for lint_message: check that all the pubsub_cfg_t items in the two * respective smartlists obey our local graph topology rules. * * (Right now this is just a matter of "each subsystem only * publishes/subscribes once; no subsystem is a publisher and subscriber for * the same message.") * * Return 0 on success, -1 on failure. **/ static int lint_message_graph(const pubsub_adjmap_t *map, message_id_t msg, const smartlist_t *pub, const smartlist_t *sub) { bitarray_t *published_by = NULL; bitarray_t *subscribed_by = NULL; bool ok = true; get_message_bitarray(map, pub, &published_by); get_message_bitarray(map, sub, &subscribed_by); /* Check whether any subsystem is publishing and subscribing the same * message. [??] */ for (unsigned i = 0; i < map->n_subsystems; ++i) { if (bitarray_is_set(published_by, i) && bitarray_is_set(subscribed_by, i)) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" is published and subscribed by the same " "subsystem \"%s\".", get_message_id_name(msg), get_subsys_id_name(i)); ok = false; } } bitarray_free(published_by); bitarray_free(subscribed_by); return ok ? 0 : -1; } /** * Helper for lint_message: check that all the pubsub_cfg_t items in the two * respective smartlists have compatible flags, channels, and types. **/ static int lint_message_consistency(message_id_t msg, const smartlist_t *pub, const smartlist_t *sub) { if (!smartlist_len_opt(pub) && !smartlist_len_opt(sub)) return 0; // LCOV_EXCL_LINE -- this was already checked. /* The 'all' list has the publishers and the subscribers. */ smartlist_t *all = smartlist_new(); if (pub) smartlist_add_all(all, pub); if (sub) smartlist_add_all(all, sub); const pubsub_cfg_t *item0 = smartlist_get(all, 0); /* Indicates which subsystems we've found publishing/subscribing here. */ bool pub_excl = false, sub_excl = false, chan_same = true, type_same = true; /* Simple message consistency properties across messages. */ SMARTLIST_FOREACH_BEGIN(all, const pubsub_cfg_t *, cfg) { chan_same &= (cfg->channel == item0->channel); type_same &= (cfg->type == item0->type); if (cfg->is_publish) pub_excl |= (cfg->flags & DISP_FLAG_EXCL) != 0; else sub_excl |= (cfg->flags & DISP_FLAG_EXCL) != 0; } SMARTLIST_FOREACH_END(cfg); bool ok = true; if (! chan_same) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" is associated with multiple inconsistent " "channels.", get_message_id_name(msg)); ok = false; } if (! type_same) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" is associated with multiple inconsistent " "message types.", get_message_id_name(msg)); ok = false; } /* Enforce exclusive-ness for publishers and subscribers that have asked for * it. */ if (pub_excl && smartlist_len_opt(pub) > 1) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" has multiple publishers, but at least one is " "marked as exclusive.", get_message_id_name(msg)); ok = false; } if (sub_excl && smartlist_len_opt(sub) > 1) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" has multiple subscribers, but at least one is " "marked as exclusive.", get_message_id_name(msg)); ok = false; } smartlist_free(all); return ok ? 0 : -1; } /** * Check whether there are any errors or inconsistencies for the message * described by <b>msg</b> in <b>map</b>. If there are problems, log about * them, and return -1. Otherwise return 0. **/ static int lint_message(const pubsub_adjmap_t *map, message_id_t msg) { /* NOTE: Some of the checks in this function are maybe over-zealous, and we * might not want to have them forever. I've marked them with [?] below. */ if (BUG(msg >= map->n_msgs)) return 0; // LCOV_EXCL_LINE const smartlist_t *pub = map->pub_by_msg[msg]; const smartlist_t *sub = map->sub_by_msg[msg]; const size_t n_pub = smartlist_len_opt(pub); const size_t n_sub = smartlist_len_opt(sub); if (n_pub == 0 && n_sub == 0) { log_info(LD_MESG, "Nobody is publishing or subscribing to message " "\"%s\".", get_message_id_name(msg)); return 0; // No publishers or subscribers: nothing to do. } /* We'll set this to false if there are any problems. */ bool ok = true; /* First make sure that if there are publishers, there are subscribers. */ if (n_pub == 0) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" has subscribers, but no publishers.", get_message_id_name(msg)); ok = false; } else if (n_sub == 0) { log_warn(LD_MESG|LD_BUG, "Message \"%s\" has publishers, but no subscribers.", get_message_id_name(msg)); ok = false; } /* Check the message graph topology. */ if (lint_message_graph(map, msg, pub, sub) < 0) ok = false; /* Check whether the messages have the same fields set on them. */ if (lint_message_consistency(msg, pub, sub) < 0) ok = false; if (!ok) { /* There was a problem -- let's log all the publishers and subscribers on * this message */ if (pub) { SMARTLIST_FOREACH(pub, pubsub_cfg_t *, cfg, pubsub_cfg_dump(cfg, LOG_WARN, " ")); } if (sub) { SMARTLIST_FOREACH(sub, pubsub_cfg_t *, cfg, pubsub_cfg_dump(cfg, LOG_WARN, " ")); } } return ok ? 0 : -1; } /** * Check all the messages in <b>map</b> for consistency. Return 0 on success, * -1 on problems. **/ static int pubsub_adjmap_check(const pubsub_adjmap_t *map) { bool all_ok = true; for (unsigned i = 0; i < map->n_msgs; ++i) { if (lint_message(map, i) < 0) { all_ok = false; } } return all_ok ? 0 : -1; } /** * Check builder for consistency and various constraints. Return 0 on success, * -1 on failure. **/ int pubsub_builder_check(pubsub_builder_t *builder) { pubsub_adjmap_t *map = pubsub_build_adjacency_map(builder->items); int rv = -1; if (!map) goto err; // should be impossible if (pubsub_adjmap_check(map) < 0) goto err; rv = 0; err: pubsub_adjmap_free(map); return rv; }
27.737349
78
0.64712
e06dc06dc2aba79d4ce5e6a0ca26816254b1c501
2,979
h
C
rootex/vendor/Effekseer/effekseer/src/Effekseer/Effekseer/Renderer/Effekseer.RingRenderer.h
ChronicallySerious/Rootex
bf2a0997b6aa5be84dbfc0e7826c31ff693ca0f1
[ "MIT" ]
166
2019-06-19T19:51:45.000Z
2022-03-24T13:03:29.000Z
rootex/vendor/Effekseer/effekseer/src/Effekseer/Effekseer/Renderer/Effekseer.RingRenderer.h
rahil627/Rootex
44f827d469bddc7167b34dedf80d7a8b984fdf20
[ "MIT" ]
312
2019-06-13T19:39:25.000Z
2022-03-02T18:37:22.000Z
rootex/vendor/Effekseer/effekseer/src/Effekseer/Effekseer/Renderer/Effekseer.RingRenderer.h
rahil627/Rootex
44f827d469bddc7167b34dedf80d7a8b984fdf20
[ "MIT" ]
23
2019-10-04T11:02:21.000Z
2021-12-24T16:34:52.000Z
 #ifndef __EFFEKSEER_RING_RENDERER_H__ #define __EFFEKSEER_RING_RENDERER_H__ //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- #include "../Effekseer.Base.h" #include "../Effekseer.Color.h" #include "../Effekseer.Matrix43.h" #include "../Effekseer.Vector2D.h" #include "../Effekseer.Vector3D.h" #include "../SIMD/Effekseer.Mat43f.h" #include "../SIMD/Effekseer.Vec2f.h" #include "../SIMD/Effekseer.Vec3f.h" //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace Effekseer { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class RingRenderer { public: struct NodeParameter { Effect* EffectPointer; //int32_t ColorTextureIndex; //AlphaBlendType AlphaBlend; //TextureFilterType TextureFilter; //TextureWrapType TextureWrap; bool ZTest; bool ZWrite; BillboardType Billboard; int32_t VertexCount; bool IsRightHand; float StartingFade = 0.0f; float EndingFade = 0.0f; //bool Distortion; //float DistortionIntensity; NodeRendererDepthParameter* DepthParameterPtr = nullptr; NodeRendererBasicParameter* BasicParameterPtr = nullptr; //RendererMaterialType MaterialType = RendererMaterialType::Default; //MaterialParameter* MaterialParameterPtr = nullptr; //float DepthOffset; //bool IsDepthOffsetScaledWithCamera; //bool IsDepthOffsetScaledWithParticleScale; NodeRendererBasicParameter BasicParameter; }; struct InstanceParameter { Mat43f SRTMatrix43; Vec2f OuterLocation; Vec2f InnerLocation; float ViewingAngleStart; float ViewingAngleEnd; float CenterRatio; Color OuterColor; Color CenterColor; Color InnerColor; RectF UV; #ifdef __EFFEKSEER_BUILD_VERSION16__ RectF AlphaUV; float FlipbookIndexAndNextRate; float AlphaThreshold; #endif std::array<float, 4> CustomData1; std::array<float, 4> CustomData2; }; public: RingRenderer() { } virtual ~RingRenderer() { } virtual void BeginRendering(const NodeParameter& parameter, int32_t count, void* userData) { } virtual void Rendering(const NodeParameter& parameter, const InstanceParameter& instanceParameter, void* userData) { } virtual void EndRendering(const NodeParameter& parameter, void* userData) { } }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } // namespace Effekseer //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #endif // __EFFEKSEER_RING_RENDERER_H__
26.362832
115
0.537093
0d293a4b4722c69f195a8cb7c776748922ac86eb
3,237
h
C
CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/FTSWebSearchBaseResultTableViewCell.h
ceekay1991/CallTraceForWeChat
5767cb6f781821b6bf9facc8c87e58e15fa88541
[ "MIT" ]
30
2020-03-22T12:30:21.000Z
2022-02-09T08:49:13.000Z
CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/FTSWebSearchBaseResultTableViewCell.h
ceekay1991/CallTraceForWeChat
5767cb6f781821b6bf9facc8c87e58e15fa88541
[ "MIT" ]
null
null
null
CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/FTSWebSearchBaseResultTableViewCell.h
ceekay1991/CallTraceForWeChat
5767cb6f781821b6bf9facc8c87e58e15fa88541
[ "MIT" ]
8
2020-03-22T12:30:23.000Z
2020-09-22T04:01:47.000Z
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import "MMTableViewCell.h" @class AttributeLabel, MMUIImageView, MMUILabel, MMWebImageView, UIView; @protocol FTSWebSearchBaseResultTableViewCellDelegate; @interface FTSWebSearchBaseResultTableViewCell : MMTableViewCell { UIView *_cardContentView; UIView *_titleArea; MMUIImageView *_wsLogoView; MMUILabel *_wsWordingView; MMUILabel *_moreLabel; MMUIImageView *_moreArrowView; UIView *_gapLine; UIView *_infoView; AttributeLabel *_titleView; AttributeLabel *_subTitleView; AttributeLabel *_descView; MMWebImageView *_thumbView; id <FTSWebSearchBaseResultTableViewCellDelegate> _delegate; } + (_Bool)isDescDoubleLine:(id)arg1; + (_Bool)checkLabelDoubleLineWithMaxWidth:(double)arg1 fontSize:(double)arg2 text:(id)arg3; + (id)getAttributeText:(id)arg1; @property(nonatomic) __weak id <FTSWebSearchBaseResultTableViewCellDelegate> delegate; // @synthesize delegate=_delegate; @property(retain, nonatomic) MMWebImageView *thumbView; // @synthesize thumbView=_thumbView; @property(retain, nonatomic) AttributeLabel *descView; // @synthesize descView=_descView; @property(retain, nonatomic) AttributeLabel *subTitleView; // @synthesize subTitleView=_subTitleView; @property(retain, nonatomic) AttributeLabel *titleView; // @synthesize titleView=_titleView; @property(retain, nonatomic) UIView *infoView; // @synthesize infoView=_infoView; @property(retain, nonatomic) UIView *gapLine; // @synthesize gapLine=_gapLine; @property(retain, nonatomic) MMUIImageView *moreArrowView; // @synthesize moreArrowView=_moreArrowView; @property(retain, nonatomic) MMUILabel *moreLabel; // @synthesize moreLabel=_moreLabel; @property(retain, nonatomic) MMUILabel *wsWordingView; // @synthesize wsWordingView=_wsWordingView; @property(retain, nonatomic) MMUIImageView *wsLogoView; // @synthesize wsLogoView=_wsLogoView; @property(retain, nonatomic) UIView *titleArea; // @synthesize titleArea=_titleArea; @property(retain, nonatomic) UIView *cardContentView; // @synthesize cardContentView=_cardContentView; - (void).cxx_destruct; - (void)triggerClickCardArea:(id)arg1; - (void)onClickCardArea:(id)arg1; - (void)triggerClickMoreArea:(id)arg1; - (void)onClickMoreArea:(id)arg1; - (_Bool)gestureRecognizer:(id)arg1 shouldReceiveTouch:(id)arg2; - (void)addTouchEvent:(SEL)arg1 toView:(id)arg2; - (void)setLineSpace:(double)arg1 forLabel:(id)arg2; - (void)updateSubviewWithBasePardusShowInfo:(id)arg1; - (void)updateSubviewWithBaseContent:(id)arg1; - (void)layoutCardInfoRightArea:(double)arg1 rightMidGap:(double)arg2; - (void)layoutCardInfoView; - (void)layoutTitleArea; - (void)layoutSubviews; - (id)attachImageViewWithLocalIcon:(id)arg1 toView:(id)arg2; - (id)attachLabelWithFontSize:(double)arg1 color:(id)arg2 lineBreakMode:(long long)arg3 numberOfLines:(unsigned long long)arg4 toView:(id)arg5; - (id)attachNormalLabelWithFontSize:(double)arg1 color:(id)arg2 lineBreakMode:(long long)arg3 numberOfLines:(unsigned long long)arg4 toView:(id)arg5; - (id)initWithStyle:(long long)arg1 reuseIdentifier:(id)arg2; @end
49.045455
149
0.785604
33d70c85f59e5cc01c2fb90c5d1964c99e4cadc3
3,681
h
C
modules/webbrowser/properties/templatepropertywidgetcef.h
leaveitout/inviwo
a623c6bdf3fd9cc6b7cfb253dd492c38c2ef5797
[ "BSD-2-Clause" ]
null
null
null
modules/webbrowser/properties/templatepropertywidgetcef.h
leaveitout/inviwo
a623c6bdf3fd9cc6b7cfb253dd492c38c2ef5797
[ "BSD-2-Clause" ]
null
null
null
modules/webbrowser/properties/templatepropertywidgetcef.h
leaveitout/inviwo
a623c6bdf3fd9cc6b7cfb253dd492c38c2ef5797
[ "BSD-2-Clause" ]
1
2020-07-17T10:27:57.000Z
2020-07-17T10:27:57.000Z
/********************************************************************************* * * Inviwo - Interactive Visualization Workshop * * Copyright (c) 2018 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. * *********************************************************************************/ #ifndef IVW_TEMPLATEPROPERTYWIDGETCEF_H #define IVW_TEMPLATEPROPERTYWIDGETCEF_H #include <modules/webbrowser/webbrowsermoduledefine.h> #include <modules/webbrowser/properties/propertywidgetcef.h> #include <inviwo/core/properties/templateproperty.h> namespace inviwo { /** * \class TemplatePropertyWidgetCEF * \brief CEF property widget for TemplateProperty<T> * Parses request and sets property value. */ template <typename T> class TemplatePropertyWidgetCEF: public PropertyWidgetCEF { public: typedef T value_type; TemplatePropertyWidgetCEF() = default; TemplatePropertyWidgetCEF(TemplateProperty<T>* prop, CefRefPtr<CefFrame> frame = nullptr, std::string htmlId = "") : PropertyWidgetCEF(prop, frame, htmlId){}; virtual bool onQuery(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int64 /*query_id*/, const CefString& request, bool /*persistent*/, CefRefPtr<CefMessageRouterBrowserSide::Handler::Callback> callback) override { // Check if we are blocking queries if (onQueryBlocker_ > 0) { onQueryBlocker_--; callback->Success(""); return true; } value_type value; const std::string& requestStr = request; auto key = std::string(R"("value":")"); auto start = requestStr.find(key, 0) + key.length(); auto end = requestStr.find(R"("})", start); if (end == std::string::npos) { callback->Failure(0, "Failed to parse value " + requestStr); return true; } auto stream = std::stringstream(requestStr.substr(start, end)); if (stream >> value) { getProperty()->setInitiatingWidget(this); static_cast< TemplateProperty<T>* >(getProperty())->set(value); callback->Success(""); getProperty()->clearInitiatingWidget(); } else { callback->Failure(0, "Failed to parse value " + requestStr); } return true; } }; } // namespace inviwo #endif // IVW_TEMPLATEPROPERTYWIDGETCEF_H
42.802326
162
0.665308
4bd28acc565e2ead4ed80d0bcb45e8de99fff7e4
224
c
C
Sprint09/t06/mx_timer.c
LoveNek0/UCode-Connect-Marathone
d80e0c1e6719dd5069d2a065fe529fd09a1dad40
[ "MIT" ]
null
null
null
Sprint09/t06/mx_timer.c
LoveNek0/UCode-Connect-Marathone
d80e0c1e6719dd5069d2a065fe529fd09a1dad40
[ "MIT" ]
null
null
null
Sprint09/t06/mx_timer.c
LoveNek0/UCode-Connect-Marathone
d80e0c1e6719dd5069d2a065fe529fd09a1dad40
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <time.h> double mx_timer(void(*f)()); double mx_timer(void(*f)()){ clock_t begin = clock(); f(); clock_t end = clock(); return (double)(end - begin) / (double)CLOCKS_PER_SEC; }
20.363636
58
0.611607
ef1d7a3687fd89d934dfdb6a180641184181ffaf
498
h
C
net/cookies/CookieJarMgr.h
gergul/MiniBlink
7a11c52f141d54d5f8e1a9af31867cd120a2c3c4
[ "Apache-2.0" ]
8
2019-05-05T16:38:05.000Z
2021-11-09T11:45:38.000Z
net/cookies/CookieJarMgr.h
gergul/MiniBlink
7a11c52f141d54d5f8e1a9af31867cd120a2c3c4
[ "Apache-2.0" ]
null
null
null
net/cookies/CookieJarMgr.h
gergul/MiniBlink
7a11c52f141d54d5f8e1a9af31867cd120a2c3c4
[ "Apache-2.0" ]
4
2018-12-14T07:52:46.000Z
2021-06-11T18:06:09.000Z
#ifndef net_CookieJarMgr_h #define net_CookieJarMgr_h #include <string> #include <map> namespace net { class WebCookieJarImpl; class CookieJarMgr { public: static CookieJarMgr* getInst() { if (!m_inst) m_inst = new CookieJarMgr(); return m_inst; } WebCookieJarImpl* createOrGet(const std::string& fullPath); private: static CookieJarMgr* m_inst; std::map<std::string, WebCookieJarImpl*> m_pathToCookies; }; } #endif // net_CookieJarMgr_h
16.6
63
0.686747
0d0e74871504f541a8924cc5a0282c2942f6e3e3
1,559
h
C
esp32_blekbd/kc.h
oha-Ohashi/ESP-32-likeQMK
e23de63b4c0d04e8b91aa2473a0b0b3c58f53332
[ "MIT" ]
null
null
null
esp32_blekbd/kc.h
oha-Ohashi/ESP-32-likeQMK
e23de63b4c0d04e8b91aa2473a0b0b3c58f53332
[ "MIT" ]
null
null
null
esp32_blekbd/kc.h
oha-Ohashi/ESP-32-likeQMK
e23de63b4c0d04e8b91aa2473a0b0b3c58f53332
[ "MIT" ]
null
null
null
const uint8_t KEY_LEFT_CTRL = 0x80; const uint8_t KEY_LEFT_SHIFT = 0x81; const uint8_t KEY_LEFT_ALT = 0x82; const uint8_t KEY_LEFT_GUI = 0x83; const uint8_t KEY_RIGHT_CTRL = 0x84; const uint8_t KEY_RIGHT_SHIFT = 0x85; const uint8_t KEY_RIGHT_ALT = 0x86; const uint8_t KEY_RIGHT_GUI = 0x87; const uint8_t KEY_UP_ARROW = 0xDA; const uint8_t KEY_DOWN_ARROW = 0xD9; const uint8_t KEY_LEFT_ARROW = 0xD8; const uint8_t KEY_RIGHT_ARROW = 0xD7; const uint8_t KEY_BACKSPACE = 0xB2; const uint8_t KEY_TAB = 0xB3; const uint8_t KEY_RETURN = 0xB0; const uint8_t KEY_ESC = 0xB1; const uint8_t KEY_INSERT = 0xD1; const uint8_t KEY_DELETE = 0xD4; const uint8_t KEY_PAGE_UP = 0xD3; const uint8_t KEY_PAGE_DOWN = 0xD6; const uint8_t KEY_HOME = 0xD2; const uint8_t KEY_END = 0xD5; const uint8_t KEY_CAPS_LOCK = 0xC1; const uint8_t KEY_F1 = 0xC2; const uint8_t KEY_F2 = 0xC3; const uint8_t KEY_F3 = 0xC4; const uint8_t KEY_F4 = 0xC5; const uint8_t KEY_F5 = 0xC6; const uint8_t KEY_F6 = 0xC7; const uint8_t KEY_F7 = 0xC8; const uint8_t KEY_F8 = 0xC9; const uint8_t KEY_F9 = 0xCA; const uint8_t KEY_F10 = 0xCB; const uint8_t KEY_F11 = 0xCC; const uint8_t KEY_F12 = 0xCD; const uint8_t KEY_F13 = 0xF0; const uint8_t KEY_F14 = 0xF1; const uint8_t KEY_F15 = 0xF2; const uint8_t KEY_F16 = 0xF3; const uint8_t KEY_F17 = 0xF4; const uint8_t KEY_F18 = 0xF5; const uint8_t KEY_F19 = 0xF6; const uint8_t KEY_F20 = 0xF7; const uint8_t KEY_F21 = 0xF8; const uint8_t KEY_F22 = 0xF9; const uint8_t KEY_F23 = 0xFA; const uint8_t KEY_F24 = 0xFB;
31.816327
38
0.757537
6090ea21c70ad0e7f3b2d56798c4d17d318d4746
865
c
C
11.c
ednl/aoc2017
429cec4e8e89bed375bc40989d7c8bab609cc4b1
[ "MIT" ]
null
null
null
11.c
ednl/aoc2017
429cec4e8e89bed375bc40989d7c8bab609cc4b1
[ "MIT" ]
null
null
null
11.c
ednl/aoc2017
429cec4e8e89bed375bc40989d7c8bab609cc4b1
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> static inline int dist(int q, int r) { return (abs(q) + abs(q + r) + abs(r)) / 2; } int main(void) { // Axial coordinates (q,r) // ref.: https://www.redblobgames.com/grids/hexagons/ int q = 0, r = 0, d = 0, dmax = 0; FILE *f = fopen("11.txt", "r"); if (f != NULL) { int c, p = 0; while ((c = fgetc(f)) != EOF) { switch (c) { case 'n': --r; break; case 's': ++r; break; case 'w': --q; if (p == 'n') ++r; break; case 'e': ++q; if (p == 's') --r; break; } p = c; d = dist(q, r); if (d > dmax) { dmax = d; } } fclose(f); } printf("Part 1: %d\n", d); printf("Part 2: %d\n", dmax); return 0; }
23.378378
57
0.378035
e6f144d9f458acc21054f41c1c8915d5a0c7392a
6,709
h
C
stlsoft/stlsoft_proxy_ptr.h
masscry/dmc
c7638f7c524a65bc2af0876c76621d8a11da42bb
[ "BSL-1.0" ]
86
2018-05-24T12:03:44.000Z
2022-03-13T03:01:25.000Z
stlsoft/stlsoft_proxy_ptr.h
masscry/dmc
c7638f7c524a65bc2af0876c76621d8a11da42bb
[ "BSL-1.0" ]
1
2019-05-30T01:38:40.000Z
2019-10-26T07:15:01.000Z
stlsoft/stlsoft_proxy_ptr.h
masscry/dmc
c7638f7c524a65bc2af0876c76621d8a11da42bb
[ "BSL-1.0" ]
14
2018-07-16T08:29:12.000Z
2021-08-23T06:21:30.000Z
/* ///////////////////////////////////////////////////////////////////////////// * File: stlsoft_proxy_ptr.h (originally MLBrwPtr.h, ::SynesisStd) * * Purpose: Contains the proxy_ptr template class. * * Created: 17th January 1999 * Updated: 11th September 2004 * * Home: http://stlsoft.org/ * * Copyright (c) 1999-2004, Matthew Wilson and Synesis Software * 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(s) of Matthew Wilson and Synesis Software nor the names of * any contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * ////////////////////////////////////////////////////////////////////////// */ /// \file stlsoft_proxy_ptr.h /// /// Contains the proxy_ptr template class. #ifndef STLSOFT_INCL_H_STLSOFT_PROXY_PTR #define STLSOFT_INCL_H_STLSOFT_PROXY_PTR #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_H_STLSOFT_PROXY_PTR_MAJOR 2 # define STLSOFT_VER_H_STLSOFT_PROXY_PTR_MINOR 0 # define STLSOFT_VER_H_STLSOFT_PROXY_PTR_REVISION 1 # define STLSOFT_VER_H_STLSOFT_PROXY_PTR_EDIT 48 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////////// * Includes */ #ifndef STLSOFT_INCL_H_STLSOFT # include "stlsoft.h" // Include the STLSoft root header #endif /* !STLSOFT_INCL_H_STLSOFT */ /* ///////////////////////////////////////////////////////////////////////////// * Namespace */ #ifndef _STLSOFT_NO_NAMESPACE namespace stlsoft { #endif /* _STLSOFT_NO_NAMESPACE */ /* ///////////////////////////////////////////////////////////////////////////// * Forward declarations */ #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION template <ss_typename_param_k T> class proxy_ptr; #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////////// * Classes */ // class proxy_ptr /// This class emulates a pointer in all respects, and is simply an aid to /// self-documentation. /// /// \param T The value type template <ss_typename_param_k T> class proxy_ptr { public: /// The value type typedef T value_type; /// The current parameterisation of the type typedef proxy_ptr<T> class_type; // Construction public: /// Construct from a pointer to "borrow" ss_explicit_k proxy_ptr(value_type *t) : m_value(t) {} /// Assignment from a new pointer proxy_ptr &operator =(value_type *t) { m_value = t; return *this; } // Conversion public: /// Implicit conversion to pointer to the underlying pointer operator value_type *() { return m_value; } /// Implicit conversion to pointer-to-const to the underlying pointer operator const value_type *() const { return m_value; } /// Indirection operator /// /// \note This method does a debug-time assertion that the underlying pointer is non-null value_type &operator *() // indirection { stlsoft_message_assert("Dereferencing a null pointer!", NULL != m_value); return *m_value; } /// Indirection operator /// /// \note This method does a debug-time assertion that the underlying pointer is non-null value_type const &operator *() const // indirection { stlsoft_message_assert("Dereferencing a null pointer!", NULL != m_value); return *m_value; } /// Member-selection operator /// /// \note This method does a debug-time assertion that the underlying pointer is non-null value_type *operator ->() // member-selection { stlsoft_message_assert("Dereferencing a null pointer!", NULL != m_value); return m_value; } /// Member-selection operator /// /// \note This method does a debug-time assertion that the underlying pointer is non-null value_type const *operator ->() const // member-selection { stlsoft_message_assert("Dereferencing a null pointer!", NULL != m_value); return m_value; } /// Returns the underlying pointer value value_type *get_ptr() { return m_value; } /// Returns the underlying pointer value value_type const *get_ptr() const { return m_value; } /// Returns the underlying pointer value /// /// \deprecated value_type *GetPointer() { return m_value; } /// Returns the underlying pointer value /// /// \deprecated value_type const *GetPointer() const { return m_value; } /// Sets the underlying pointer value to null void clear() { m_value = NULL; } // Members private: value_type *m_value; }; /* ////////////////////////////////////////////////////////////////////////// */ #ifndef _STLSOFT_NO_NAMESPACE } // namespace stlsoft #endif /* _STLSOFT_NO_NAMESPACE */ /* ////////////////////////////////////////////////////////////////////////// */ #endif /* !STLSOFT_INCL_H_STLSOFT_PROXY_PTR */ /* ////////////////////////////////////////////////////////////////////////// */
31.497653
94
0.596661
fc8c286db35217bc5950df99316aa26a1d520438
843
h
C
inetsrv/iis/svcs/nntp/server/server/tomaster.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
inetsrv/iis/svcs/nntp/server/server/tomaster.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
inetsrv/iis/svcs/nntp/server/server/tomaster.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*++ Copyright (c) 1995 Microsoft Corporation Module Name: fromclnt.h Abstract: This module contains class declarations/definitions for !!! **** Overview **** !!! Author: Carl Kadie (CarlK) 05-Dec-1995 Revision History: --*/ #ifndef _TOMASTER_H_ #define _TOMASTER_H_ // // // // CToMasterFeed - for processing article to master (from slaves) // class CToMasterFeed: public CInFeed { // // Public Members // public : // // Constructor // CToMasterFeed(void){}; // // Destructor // virtual ~CToMasterFeed(void) {}; // // Return a string that can be used to log errors indicating // what type of feed was processing the articles etc... // LPSTR FeedType() { return "To Master" ; } protected: }; #endif
11.547945
66
0.581257
cccf3a4506f9aadd75e9f2dac43026d8db971b32
1,329
c
C
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
dan-zheng/llvm-project
6b792850da0345274758c9260fda5df5e57ab486
[ "Apache-2.0" ]
409
2015-01-03T23:52:34.000Z
2022-03-09T11:32:18.000Z
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
dan-zheng/llvm-project
6b792850da0345274758c9260fda5df5e57ab486
[ "Apache-2.0" ]
15
2015-08-31T13:35:00.000Z
2018-11-23T12:34:50.000Z
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
dan-zheng/llvm-project
6b792850da0345274758c9260fda5df5e57ab486
[ "Apache-2.0" ]
374
2015-02-02T05:23:26.000Z
2022-03-31T10:53:25.000Z
// RUN: %check_clang_tidy %s misc-misplaced-const %t typedef int plain_i; typedef int *ip; typedef const int *cip; typedef void (*func_ptr)(void); void func(void) { // ok const int *i0 = 0; const plain_i *i1 = 0; const cip i2 = 0; // const applies to both pointer and pointee. // Not ok const ip i3 = 0; // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *' ip const i4 = 0; // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i4' declared with a const-qualified const volatile ip i5 = 0; // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i5' declared with a const-qualified typedef type; results in the type being 'int *const volatile' instead of 'const int *volatile' } void func2(const plain_i *i1, const cip i2, const ip i3, // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i3' declared with a const-qualified const int *i4) { } struct S { const int *i0; const plain_i *i1; const cip i2; const ip i3; // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified }; // Function pointers should not be diagnosed because a function // pointer type can never be const. void func3(const func_ptr fp) { const func_ptr fp2 = fp; }
28.891304
178
0.654628
0a9737cdb9fa0d731faae25f7befe8c8c3e0bba6
12,333
h
C
lib/scipoptsuite-5.0.1/zimpl/src/zimpl/code.h
npwebste/UPS_Controller
a90ce2229108197fd48f956310ae2929e0fa5d9a
[ "AFL-1.1" ]
null
null
null
lib/scipoptsuite-5.0.1/zimpl/src/zimpl/code.h
npwebste/UPS_Controller
a90ce2229108197fd48f956310ae2929e0fa5d9a
[ "AFL-1.1" ]
null
null
null
lib/scipoptsuite-5.0.1/zimpl/src/zimpl/code.h
npwebste/UPS_Controller
a90ce2229108197fd48f956310ae2929e0fa5d9a
[ "AFL-1.1" ]
null
null
null
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* File....: code.h */ /* Name....: Code Functions */ /* Author..: Thorsten Koch */ /* Copyright by Author, All rights reserved */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Copyright (C) 2001-2018 by Thorsten Koch <koch@zib.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _CODE_H_ #define _CODE_H_ #ifndef _RATLPTYPES_H_ #error "Need to include ratlptypes.h before code.h" #endif #ifndef _MME_H_ #error "Need to include mme.h before code.h" #endif #ifdef __cplusplus extern "C" { #endif /*lint -sem( code_new_inst, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern CodeNode* code_new_inst(Inst inst, int childs, ...); /*lint -sem( code_new_numb, custodial(1), 1p == 1, @P > malloc(1P)) */ extern CodeNode* code_new_numb(Numb* numb); /*lint -sem( code_new_strg, nulterm(1), 1p, @P > malloc(1P)) */ extern CodeNode* code_new_strg(const char* strg); /*lint -sem( code_new_name, nulterm(1), 1p, @P > malloc(1P)) */ extern CodeNode* code_new_name(const char* name); /*lint -sem( code_new_size, @P > malloc(1P)) */ extern CodeNode* code_new_size(int size); /*lint -sem( code_new_varclass, @P > malloc(1P)) */ extern CodeNode* code_new_varclass(VarClass varclass); /*lint -sem( code_new_contype, @P > malloc(1P)) */ extern CodeNode* code_new_contype(ConType contype); /*lint -sem( code_new_bits, @P > malloc(1P)) */ extern CodeNode* code_new_bits(unsigned int bits); /*lint -sem( code_new_symbol, @P > malloc(1P)) */ extern CodeNode* code_new_symbol(Symbol* sym); /*lint -sem( code_new_define, @P > malloc(1P)) */ extern CodeNode* code_new_define(Define* def); /*lint -sem( code_new_bound, @P > malloc(1P)) */ extern CodeNode* code_new_bound(BoundType type); /*lint -sem( code_free, custodial(1), 1p == 1) */ extern void code_free(CodeNode* node); /*lint -sem( code_free_value, @P > malloc(1P)) */ extern void code_free_value(CodeNode* node); /*lint -sem( code_is_valid, 1p == 1) */ extern bool code_is_valid(const CodeNode* node); /*lint -sem( code_get_type, 1p == 1) */ extern CodeType code_get_type(const CodeNode* node); /*lint -sem( code_get_inst, 1p == 1, @p) */ extern Inst code_get_inst(const CodeNode* node); /*lint -sem( code_set_root, custodial(1), 1p == 1) */ extern void code_set_root(CodeNode* node); /*lint -sem( code_get_root, @P > malloc(1P)) */ extern CodeNode* code_get_root(void); /*lint -sem( code_set_child, custodial(3), 1p == 1 && 2n >= 0 && 3p == 1) */ extern void code_set_child(CodeNode* node, int idx, CodeNode* child); /*lint -sem( code_errmsg, 1p == 1) */ extern void code_errmsg(const CodeNode* node); #if 0 /*lint -sem( code_check_type, 1p == 1, @P > malloc(1P)p) */ extern CodeNode* code_check_type(CodeNode* node, CodeType expected); #endif /*lint -sem( code_eval, 1p == 1, @P > malloc(1P)p) */ extern CodeNode* code_eval(CodeNode* node); /*lint -sem( code_prune_tree, 1p == 1) */ extern bool code_prune_tree(CodeNode* node); /*lint -sem( code_get_child, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern CodeNode* code_get_child(const CodeNode* node, int no); /*lint -sem( code_get_numb, 1p == 1) */ extern const Numb* code_get_numb(CodeNode* node); /*lint -sem( code_get_strg, 1p == 1, @p && nulterm(@)) */ extern const char* code_get_strg(CodeNode* node); /*lint -sem( code_get_name, 1p == 1, @p && nulterm(@)) */ extern const char* code_get_name(CodeNode* node); extern unsigned int code_get_inst_count(void); /*lint -sem( code_get_tuple, 1p == 1, @P > malloc(1P)) */ extern void code_clear_inst_count(void); extern const Tuple* code_get_tuple(CodeNode* node); /*lint -sem( code_get_set, 1p == 1, @P > malloc(1P)) */ extern const Set* code_get_set(CodeNode* node); /*lint -sem( code_get_idxset, 1p == 1, @P > malloc(1P)) */ extern const IdxSet* code_get_idxset(CodeNode* node); /*lint -sem( code_get_entry, 1p == 1, @P > malloc(1P)) */ extern const Entry* code_get_entry(CodeNode* node); /*lint -sem( code_get_term, 1p == 1, @P > malloc(1P)) */ extern const Term* code_get_term(CodeNode* node); /*lint -sem( code_get_size, 1p == 1) */ extern int code_get_size(CodeNode* node); /*lint -sem( code_get_bool, 1p == 1) */ extern bool code_get_bool(CodeNode* node); /*lint -sem( code_get_list, 1p == 1, @P > malloc(1P)) */ extern const List* code_get_list(CodeNode* node); /*lint -sem( code_get_varclass, 1p == 1) */ extern VarClass code_get_varclass(CodeNode* node); /*lint -sem( code_get_contype, 1p == 1) */ extern ConType code_get_contype(CodeNode* node); /*lint -sem( code_get_rdef, 1p == 1, @P > malloc(1P)) */ extern const RDef* code_get_rdef(CodeNode* node); /*lint -sem( code_get_rpar, 1p == 1, @P > malloc(1P)) */ extern const RPar* code_get_rpar(CodeNode* node); /*lint -sem( code_get_bits, 1p == 1) */ extern unsigned int code_get_bits(CodeNode* node); /*lint -sem( code_get_symbol, 1p == 1) */ extern Symbol* code_get_symbol(CodeNode* node); /*lint -sem( code_get_define, 1p == 1) */ extern Define* code_get_define(CodeNode* node); /*lint -sem( code_get_bound, 1p == 1) */ extern const Bound* code_get_bound(CodeNode* node); /*lint -sem( code_value_numb, custodial(2), 1p == 1) */ extern void code_value_numb(CodeNode* node, Numb* numb); /*lint -sem( code_value_strg, nulterm(2), 1p == 1 && 2p) */ extern void code_value_strg(CodeNode* node, const char* strg); /*lint -sem( code_value_name, nulterm(2), 1p == 1 && 2p) */ extern void code_value_name(CodeNode* node, const char* name); /*lint -sem( code_value_tuple, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_tuple(CodeNode* node, Tuple* tuple); /*lint -sem( code_value_set, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_set(CodeNode* node, Set* set); /*lint -sem( code_value_idxset, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_idxset(CodeNode* node, IdxSet* idxset); /*lint -sem( code_value_entry, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_entry(CodeNode* node, Entry* entry); /*lint -sem( code_value_term, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_term(CodeNode* node, Term* term); /*lint -sem( code_value_steal_child_term, 1p == 1 && 2n >= 0, @P > malloc(1P)p) */ extern Term* code_value_steal_term(CodeNode* node, int no); /*lint -sem( code_value_bool, 1p == 1) */ extern void code_value_bool(CodeNode* node, bool bvalue); /*lint -sem( code_value_size, 1p == 1) */ extern void code_value_size(CodeNode* node, int size); /*lint -sem( code_value_list, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_list(CodeNode* node, List* list); /*lint -sem( code_value_varclass, 1p == 1) */ extern void code_value_varclass(CodeNode* node, VarClass varclass); /*lint -sem( code_value_contype, 1p == 1) */ extern void code_value_contype(CodeNode* node, ConType contype); /*lint -sem( code_value_rdef, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_rdef(CodeNode* node, RDef* rdef); /*lint -sem( code_value_rpar, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_rpar(CodeNode* node, RPar* rpar); /*lint -sem( code_value_bits, 1p == 1) */ extern void code_value_bits(CodeNode* node, unsigned int bits); /*lint -sem( code_value_bound, custodial(2), 1p == 1 && 2p == 1) */ extern void code_value_bound(CodeNode* node, Bound* bound); /*lint -sem( code_value_void, 1p == 1) */ extern void code_value_void(CodeNode* node); /*lint -sem( code_copy_value, 1p == 1 && 2p == 1) */ extern void code_copy_value(CodeNode* dst, const CodeNode* src); /*lint -sem( code_eval_child, 1p == 1 && 2n >= 0, @P > malloc(1P)p) */ extern CodeNode* code_eval_child(const CodeNode* node, int no); /*lint -sem( code_eval_child_numb, 1p == 1 && 2n >= 0) */ extern const Numb* code_eval_child_numb(const CodeNode* node, int no); /*lint -sem( char* code_eval_child_strg, 1p == 1 && 2n >= 0, @p && nulterm(@)) */ extern const char* code_eval_child_strg(const CodeNode* node, int no); /*lint -sem( code_eval_child_name, 1p == 1 && 2n >= 0, @p && nulterm(@)) */ extern const char* code_eval_child_name(const CodeNode* node, int no); /*lint -sem( code_eval_child_tuple, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const Tuple* code_eval_child_tuple(const CodeNode* node, int no); /*lint -sem( code_eval_child_set, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const Set* code_eval_child_set(const CodeNode* node, int no); /*lint -sem( code_eval_child_idxset, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const IdxSet* code_eval_child_idxset(const CodeNode* node, int no); /*lint -sem( code_eval_child_entry, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const Entry* code_eval_child_entry(const CodeNode* node, int no); /*lint -sem( code_eval_child_term, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const Term* code_eval_child_term(const CodeNode* node, int no); /*lint -sem( code_eval_child_size, 1p == 1 && 2n >= 0, @n >= 0) */ extern int code_eval_child_size(const CodeNode* node, int no); /*lint -sem( code_eval_child_bool, 1p == 1 && 2n >= 0) */ extern bool code_eval_child_bool(const CodeNode* node, int no); /*lint -sem( code_eval_child_list, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const List* code_eval_child_list(const CodeNode* node, int no); /*lint -sem( code_eval_child_varclass, 1p == 1 && 2n >= 0) */ extern VarClass code_eval_child_varclass(const CodeNode* node, int no); /*lint -sem( code_eval_child_contype, 1p == 1 && 2n >= 0) */ extern ConType code_eval_child_contype(const CodeNode* node, int no); /*lint -sem( code_eval_child_rdef, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const RDef* code_eval_child_rdef(const CodeNode* node, int no); /*lint -sem( code_eval_child_rpar, 1p == 1 && 2n >= 0, @P > malloc(1P)) */ extern const RPar* code_eval_child_rpar(const CodeNode* node, int no); /*lint -sem( code_eval_child_bits, 1p == 1 && 2n >= 0) */ extern unsigned int code_eval_child_bits(const CodeNode* node, int no); /*lint -sem( code_eval_child_symbol, 1p == 1 && 2n >= 0) */ extern Symbol* code_eval_child_symbol(const CodeNode* node, int no); /*lint -sem( code_eval_child_define, 1p == 1 && 2n >= 0) */ extern Define* code_eval_child_define(const CodeNode* node, int no); /*lint -sem( code_eval_child_bound, 1p == 1 && 2n >= 0) */ extern const Bound* code_eval_child_bound(const CodeNode* node, int no); #ifdef __cplusplus } #endif #endif /* _CODE_H_ */
56.315068
89
0.610962
112878ddb1ef53919deba4c16f242f3bf3e16468
2,886
h
C
include/global.h
Eezy-Inc/norminette
c711b184ac9cf9467e380fb5b9dc694f1690ce5d
[ "MIT" ]
82
2017-12-14T22:39:49.000Z
2021-01-07T20:33:45.000Z
include/global.h
Eezy-Inc/norminette
c711b184ac9cf9467e380fb5b9dc694f1690ce5d
[ "MIT" ]
18
2018-02-09T12:01:26.000Z
2019-11-27T10:03:12.000Z
include/global.h
Eezy-Inc/norminette
c711b184ac9cf9467e380fb5b9dc694f1690ce5d
[ "MIT" ]
25
2018-05-09T09:15:23.000Z
2021-11-27T13:17:00.000Z
/* ** EPITECH PROJECT, 2017 ** global ** File description: ** My globals vars */ #include "structs.h" const char *key_words[] = { "while", "return", "if", "else", "for", "switch", 0 }; const style_error coding_style[] = { /*garbage files*/ { "O1", "content of the delivery folder should contain only files required for compilation", 2 }, /*5 fcts*/ { "O3", "more than 5 function in a single file", 2 }, /*files names*/ { "O4", "your file name must follow the snake_case convention, be clear, precise, explicit, and unambiguous", 2 }, /*epi header*/ { "G1", "you must start your source code with a correctly formatted Epitech standard header", 2 }, /*empty lines between fcts*/ { "G2", "one and only one empty line should separate the implementations of functions", 1 }, /*function's name invalid*/ { "F2", "function should be in english, according to the snake_case convention", 2 }, /*too long line*/ { "F3", "too long line", 2 }, /*too long function*/ { "F4", "too long function", 2 }, /*fct > 4 args*/ { "F5", "a function should not need more than 4 arguments and taking no parameters should take void as argument in the function declaration.", 2 }, /*comment in fct*/ { "F6", "comment inside a function.", 1 }, /*+1 action per line*/ { "L1", "a line correspond to more than one statement", 2 }, /*indentation*/ { "L2", "bad indentation on start of a line", 1 }, /*space after key words and operators*/ { "L3", "misplaced space(s)", 1 }, /*brackets*/ { "L4", "curly brackets misplaced", 1 }, /*x vars declared on 1 line or in prog*/ { "L5", "severals variables declared on the same line", 1 }, //line break after vars declarations { "L6", "", 1 }, //nom de types { "V1", "structures and typedef names should be in english and follow the snake_case convention", 2 }, //pointers declaration { "V3", "", 1 }, //if depth > 3 or if forest { "C1", "nested conditonal branchings with a depth of 3 or more should be avoided and an if block should not contain more than 3 branchings", 1 }, /*goto*/ { "C3", "goto keyword is forbidden", 1 }, //bad seperation between header and source { "H1", "bad separation between source file and header file", 2 }, /*trailing space*/ { "implicit_L001", "trailing space", 0 }, //trailing empty line { "implicit_L003", "leading or trailing empty line", 0 }, /*semicolon isolated*/ { "implicit_T007", "semicolon is isolated from other tokens", 0 }, /*l and o*/ { "implicit_T010", "identifier should not be composed of only 'l' and 'o'", 0 }, /*banned fct*/ { "explicit_F001", "banned functions used", 2 }, //too long file name ? { "implicit_F002", "bad file or directory name", 0 }, { 0, 0, 0 } };
15.269841
136
0.612613
f7780e002a83291f99a03e91900ee2f601b1aa24
156
h
C
gmod_launcher/HtmlSystemLoader.h
ChurchOfMiku/gmod-html
4c3490c88a10692d1538681f8621a7feed8109fc
[ "MIT" ]
1
2022-01-12T20:45:28.000Z
2022-01-12T20:45:28.000Z
gmod_launcher/HtmlSystemLoader.h
ChurchOfMiku/gmod-html
4c3490c88a10692d1538681f8621a7feed8109fc
[ "MIT" ]
null
null
null
gmod_launcher/HtmlSystemLoader.h
ChurchOfMiku/gmod-html
4c3490c88a10692d1538681f8621a7feed8109fc
[ "MIT" ]
1
2021-12-14T22:54:08.000Z
2021-12-14T22:54:08.000Z
#pragma once #include "html/IHtmlSystem.h" extern IHtmlSystem* g_pHtmlSystem; bool HtmlSystem_Init(); void HtmlSystem_Tick(); void HtmlSystem_Shutdown();
17.333333
34
0.794872
9293c319124f0c66ed12920552e02c272baade02
164
h
C
Pods/Target Support Files/Pods-Evil InsultTests/Pods-Evil InsultTests-umbrella.h
EvilInsultGenerator/ios
2322c9502a789d081aee73f0c22a225782e1ba94
[ "Unlicense" ]
59
2016-11-03T18:47:28.000Z
2022-01-20T22:55:09.000Z
Pods/Target Support Files/Pods-Evil InsultTests/Pods-Evil InsultTests-umbrella.h
lggg123/eviliosapp1
009ec86d8ee32be22a4ba8017eea952aa7e4f619
[ "Unlicense" ]
null
null
null
Pods/Target Support Files/Pods-Evil InsultTests/Pods-Evil InsultTests-umbrella.h
lggg123/eviliosapp1
009ec86d8ee32be22a4ba8017eea952aa7e4f619
[ "Unlicense" ]
25
2016-10-29T18:22:59.000Z
2022-01-16T01:20:55.000Z
#import <UIKit/UIKit.h> FOUNDATION_EXPORT double Pods_Evil_InsultTestsVersionNumber; FOUNDATION_EXPORT const unsigned char Pods_Evil_InsultTestsVersionString[];
23.428571
75
0.865854
a1d0e39d553c765919cb8717ae6decb3bca64381
2,419
h
C
src/Application/WalletApplication.h
BitcoinNero/REPO1
dfa3e667bfd4b8f051173b2c113ab51095f54212
[ "MIT" ]
null
null
null
src/Application/WalletApplication.h
BitcoinNero/REPO1
dfa3e667bfd4b8f051173b2c113ab51095f54212
[ "MIT" ]
null
null
null
src/Application/WalletApplication.h
BitcoinNero/REPO1
dfa3e667bfd4b8f051173b2c113ab51095f54212
[ "MIT" ]
null
null
null
// Copyright (c) 2015-2017, The Bytecoin developers // // This file is part of Bytecoin. // // Bytecoin is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Bytecoin is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with Bytecoin. If not, see <http://www.gnu.org/licenses/>. #pragma once #include <QApplication> #include <QSystemTrayIcon> #include "Settings/Settings.h" class QLockFile; class QMainWindow; class QSplashScreen; namespace WalletGui { class CommandLineParser; class IAddressBookManager; class IApplicationEventHandler; class ICryptoNoteAdapter; class IDonationManager; class IOptimizationManager; class IMiningManager; class INewsReader; class LogFileWatcher; class WalletApplication : public QApplication, public ISettingsObserver { Q_OBJECT Q_DISABLE_COPY(WalletApplication) public: WalletApplication(int& _argc, char** _argv); ~WalletApplication(); bool init(); void dockClickHandler(); // ISettingsObserver virtual void settingsUpdated() override; private: QLockFile* m_lockFile; QSystemTrayIcon* m_systemTrayIcon; CommandLineParser* m_commandLineParser; IApplicationEventHandler* m_applicationEventHandler; ICryptoNoteAdapter* m_cryptoNoteAdapter; IAddressBookManager* m_addressBookManager; IDonationManager* m_donationManager; IOptimizationManager* m_optimizationManager; IMiningManager* m_miningManager; QMainWindow* m_mainWindow; QSplashScreen* m_splash; LogFileWatcher* m_logWatcher; bool m_isAboutToQuit; void loadFonts(); void makeDataDir(); void setupTheme(); bool initCryptoNoteAdapter(); void deinitCryptoNoteAdapter(); void reinitCryptoNoteAdapter(); void initUi(); void initSystemTrayIcon(); void showCoreInitError(); bool askForRemoveDb(); void trayActivated(QSystemTrayIcon::ActivationReason _reason); void prepareToQuit(); void newLogString(const QString& _string); #ifdef Q_OS_MAC private: void installDockHandler(); #endif }; }
26.582418
78
0.781728
1f11ce129f6afbce3e64bf14ab3d56d5936f4218
107
h
C
advent_of_code/advent/advent11.h
arkadye/advent_of_code_framework
767378a625ca6f9defbf76e9fb6ddb7258934001
[ "CC0-1.0" ]
6
2020-11-28T00:58:39.000Z
2021-02-19T21:03:00.000Z
advent_of_code/advent/advent11.h
arkadye/advent_of_code_framework
767378a625ca6f9defbf76e9fb6ddb7258934001
[ "CC0-1.0" ]
null
null
null
advent_of_code/advent/advent11.h
arkadye/advent_of_code_framework
767378a625ca6f9defbf76e9fb6ddb7258934001
[ "CC0-1.0" ]
1
2021-08-22T04:45:43.000Z
2021-08-22T04:45:43.000Z
#pragma once #include "advent_types.h" ResultType advent_eleven_p1(); ResultType advent_eleven_p2();
17.833333
31
0.766355
de305902afb2b5a8f50658fbff80563a822c1d65
769
h
C
Template/Minimal_Threadx/modules/uart/uart_interrupt.h
krish2487/STM32-Repo
3a9df18e405337feab84221f639d3a6064eb4044
[ "MIT" ]
null
null
null
Template/Minimal_Threadx/modules/uart/uart_interrupt.h
krish2487/STM32-Repo
3a9df18e405337feab84221f639d3a6064eb4044
[ "MIT" ]
null
null
null
Template/Minimal_Threadx/modules/uart/uart_interrupt.h
krish2487/STM32-Repo
3a9df18e405337feab84221f639d3a6064eb4044
[ "MIT" ]
null
null
null
#ifndef MODULES_UART_INTERRUPT_H #define MODULES_UART_INTERRUPT_H #include <stdint.h> #include "stm32l4xx.h" typedef struct { USART_TypeDef *usart; uint8_t *rx_buffer; uint32_t rx_buffer_length; uint32_t rx_buffer_count; uint8_t *tx_buffer; uint32_t tx_buffer_length; uint32_t tx_buffer_count; } UART_interrupt_s; // Initializes the UART Interrupt driver void uart_interrupt__init(UART_interrupt_s *interrupt_config); // Writes string to UART Driver void uart_interrupt__write_string(UART_interrupt_s *interrupt_config, char *data); // TODO, Read Function (Implement using FreeRTOS Queue or RingBuffer) // Used by Interrupt Function void uart_interrupt__process(const UART_interrupt_s *interrupt_config); #endif
24.03125
71
0.775033
544e4e541741d430f07768b89a10ed65a6317d1a
644
h
C
client/iOS/Views/BookmarkTableCell.h
zouhirzz/FreeRDP
d51958205298123ce83a5c349c08fc1859be7de9
[ "Apache-2.0" ]
5,941
2015-01-01T13:25:03.000Z
2022-03-30T11:31:00.000Z
client/iOS/Views/BookmarkTableCell.h
zouhirzz/FreeRDP
d51958205298123ce83a5c349c08fc1859be7de9
[ "Apache-2.0" ]
5,801
2015-01-01T22:35:16.000Z
2022-03-31T13:54:50.000Z
client/iOS/Views/BookmarkTableCell.h
zouhirzz/FreeRDP
d51958205298123ce83a5c349c08fc1859be7de9
[ "Apache-2.0" ]
12,644
2015-01-01T14:59:26.000Z
2022-03-31T22:31:34.000Z
/* Custom bookmark table cell Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #import <UIKit/UIKit.h> @interface BookmarkTableCell : UITableViewCell { IBOutlet UILabel *_title; IBOutlet UILabel *_sub_title; IBOutlet UIImageView *_connection_state_icon; } @property(retain, nonatomic) UILabel *title; @property(retain, nonatomic) UILabel *subTitle; @property(retain, nonatomic) UIImageView *connectionStateIcon; @end
25.76
85
0.771739
dc6374102a5152d2a929ebaa37edff363548d4fc
2,316
c
C
kubernetes/unit-test/test_io_k8s_api_core_v1_binding.c
zouxiaoliang/nerv-kubernetes-client-c
07528948c643270fd757d38edc68da8c9628ee7a
[ "Apache-2.0" ]
null
null
null
kubernetes/unit-test/test_io_k8s_api_core_v1_binding.c
zouxiaoliang/nerv-kubernetes-client-c
07528948c643270fd757d38edc68da8c9628ee7a
[ "Apache-2.0" ]
null
null
null
kubernetes/unit-test/test_io_k8s_api_core_v1_binding.c
zouxiaoliang/nerv-kubernetes-client-c
07528948c643270fd757d38edc68da8c9628ee7a
[ "Apache-2.0" ]
null
null
null
#ifndef io_k8s_api_core_v1_binding_TEST #define io_k8s_api_core_v1_binding_TEST // the following is to include only the main from the first c file #ifndef TEST_MAIN #define TEST_MAIN #define io_k8s_api_core_v1_binding_MAIN #endif // TEST_MAIN #include <stdlib.h> #include <string.h> #include <stdio.h> #include <stdbool.h> #include "../external/cJSON.h" #include "../model/io_k8s_api_core_v1_binding.h" io_k8s_api_core_v1_binding_t* instantiate_io_k8s_api_core_v1_binding(int include_optional); #include "test_io_k8s_apimachinery_pkg_apis_meta_v1_object_meta.c" #include "test_io_k8s_api_core_v1_object_reference.c" io_k8s_api_core_v1_binding_t* instantiate_io_k8s_api_core_v1_binding(int include_optional) { io_k8s_api_core_v1_binding_t* io_k8s_api_core_v1_binding = NULL; if (include_optional) { io_k8s_api_core_v1_binding = io_k8s_api_core_v1_binding_create( "0", "0", // false, not to have infinite recursion instantiate_io_k8s_apimachinery_pkg_apis_meta_v1_object_meta(0), // false, not to have infinite recursion instantiate_io_k8s_api_core_v1_object_reference(0) ); } else { io_k8s_api_core_v1_binding = io_k8s_api_core_v1_binding_create( "0", "0", NULL, NULL ); } return io_k8s_api_core_v1_binding; } #ifdef io_k8s_api_core_v1_binding_MAIN void test_io_k8s_api_core_v1_binding(int include_optional) { io_k8s_api_core_v1_binding_t* io_k8s_api_core_v1_binding_1 = instantiate_io_k8s_api_core_v1_binding(include_optional); cJSON* jsonio_k8s_api_core_v1_binding_1 = io_k8s_api_core_v1_binding_convertToJSON(io_k8s_api_core_v1_binding_1); printf("io_k8s_api_core_v1_binding :\n%s\n", cJSON_Print(jsonio_k8s_api_core_v1_binding_1)); io_k8s_api_core_v1_binding_t* io_k8s_api_core_v1_binding_2 = io_k8s_api_core_v1_binding_parseFromJSON(jsonio_k8s_api_core_v1_binding_1); cJSON* jsonio_k8s_api_core_v1_binding_2 = io_k8s_api_core_v1_binding_convertToJSON(io_k8s_api_core_v1_binding_2); printf("repeating io_k8s_api_core_v1_binding:\n%s\n", cJSON_Print(jsonio_k8s_api_core_v1_binding_2)); } int main() { test_io_k8s_api_core_v1_binding(1); test_io_k8s_api_core_v1_binding(0); printf("Hello world \n"); return 0; } #endif // io_k8s_api_core_v1_binding_MAIN #endif // io_k8s_api_core_v1_binding_TEST
33.565217
137
0.813472
9136c4e4f16f48973e7304ed54b144b042034822
4,058
c
C
B2G/hardware/ti/wlan/wl1271/Test/connDebug.c
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-08-31T15:24:31.000Z
2020-04-24T20:31:29.000Z
B2G/hardware/ti/wlan/wl1271/Test/connDebug.c
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
null
null
null
B2G/hardware/ti/wlan/wl1271/Test/connDebug.c
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-07-29T07:17:15.000Z
2020-11-04T06:55:37.000Z
/* * connDebug.c * * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. * 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 Texas Instruments 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 * 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. */ /** \file reportReplvl.c * \brief Report level implementation * * \see reportReplvl.h */ /***************************************************************************/ /* */ /* MODULE: reportReplvl.c */ /* PURPOSE: Report level implementation */ /* */ /***************************************************************************/ #include "tidef.h" #include "osApi.h" #include "paramOut.h" #include "connDebug.h" #include "conn.h" #include "connApi.h" #include "report.h" #ifdef REPORT_LOG void printConnDbgFunctions(void); #endif void connDebugSetParam(TI_HANDLE hConn, TI_UINT32 paramType, TI_UINT32 *value) { #ifdef REPORT_LOG conn_t *pConn = (conn_t *)hConn; switch (paramType) { default: WLAN_OS_REPORT(("Invalid param type in Set Debug Connection command: %d, curr state %d\n\n", value, pConn->state)); break; } #endif } void connDebugGetParam(TI_HANDLE hConn, TI_UINT32 paramType, TI_UINT32 *value) { #ifdef REPORT_LOG conn_t *pConn = (conn_t *)hConn; switch (paramType) { default: WLAN_OS_REPORT(("Invalid param type in Get Debug Connection command: %d, curr state %d\n\n", value, pConn->state)); break; } #endif } void connDebugFunction(TI_HANDLE hConn, TI_UINT32 funcType, void *pParam) { #ifdef REPORT_LOG conn_t *pConn = (conn_t *)hConn; switch (funcType) { case CONN_PRINT_TEST_FUNCTIONS: printConnDbgFunctions(); break; case CONN_PRINT_TEST: WLAN_OS_REPORT(("Connection Print Test, param = %d , curr state %d\n\n", *((TI_UINT32 *)pParam), pConn->state)); break; default: WLAN_OS_REPORT(("Invalid function type in Debug Connection Function Command: %d\n\n", funcType)); break; } #endif } void printConnDbgFunctions(void) { #ifdef REPORT_LOG WLAN_OS_REPORT((" Conn Dbg Functions \n")); WLAN_OS_REPORT(("----------------------\n")); WLAN_OS_REPORT(("601 - Connection Print Test.\n")); #endif }
34.10084
117
0.600789
7bcb0b86bebf214f181828bf3c067941bc81accc
8,264
h
C
src/Menge/MengeCore/BFSM/VelocityComponents/VelCompNavMesh.h
mfprado/Menge
75b1ebe91989c2a58073444fb2d5908644856372
[ "Apache-2.0" ]
null
null
null
src/Menge/MengeCore/BFSM/VelocityComponents/VelCompNavMesh.h
mfprado/Menge
75b1ebe91989c2a58073444fb2d5908644856372
[ "Apache-2.0" ]
null
null
null
src/Menge/MengeCore/BFSM/VelocityComponents/VelCompNavMesh.h
mfprado/Menge
75b1ebe91989c2a58073444fb2d5908644856372
[ "Apache-2.0" ]
null
null
null
/* Menge Crowd Simulation Framework Copyright and trademark 2012-17 University of North Carolina at Chapel Hill 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 or LICENSE.txt in the root of the Menge repository. Any questions or comments should be sent to the authors menge@cs.unc.edu <http://gamma.cs.unc.edu/Menge/> */ /*! * @file VelCompNavMesh.h * @brief Provides the definition of the navigation mesh velocity component. * The preferred velocity is defined for each agent based on a * polygonal mesh representation of the free space (a navigation mesh) * and searches on that graph. */ #ifndef __VEL_COMP_NAV_MESH_H__ #define __VEL_COMP_NAV_MESH_H__ #include "MengeCore/CoreConfig.h" #include "MengeCore/Agents/PrefVelocity.h" #include "MengeCore/BFSM/VelocityComponents/VelComponent.h" #include "MengeCore/BFSM/VelocityComponents/VelComponentFactory.h" #include "MengeCore/resources/NavMesh.h" #include "MengeCore/resources/NavMeshLocalizer.h" // forward declaration namespace Menge { namespace BFSM { // forward declaration class NavMeshVCContext; /*! * @brief A velocity component that returns a preferred velocity whose direction * and preferred speed are computed from a navigation mesh. * * A navigation mesh is a representation of the traversalbe space. The traversable space * is represented as a polygonal mesh. Graph searches through the mesh are performed to * find paths through arbitrarily complex environments. */ class MENGE_API NavMeshVelComponent : public VelComponent { public: /*! * @brief Default constructor. */ NavMeshVelComponent(); /*! * @brief Called when the agent exits the state that uses this velocity * component. * * @param agent The agent exiting the state. */ virtual void onExit( Agents::BaseAgent * agent ); /*! * @brief Sets the navigation mesh pointer. * * @param nm The managed pointer to the navigation mesh. */ void setNavMesh( const NavMeshPtr & nm ) { _navMesh = nm; } /*! * @brief Returns a resource pointer to the underlying navigation mesh. * * @returns The navigation mesh. */ const NavMeshPtr getNavMesh() const { return _navMesh; } /*! * @brief Returns a resource pointer to the underlying navigation mesh localizer * * @returns The navigation mesh localizer. */ const NavMeshLocalizerPtr getLocalizer() const { return _localizer; } /*! * @brief Sets the navigation mesh localizer pointer. * * @param nml The managed pointer to the navigation mesh localizer. */ void setNavMeshLocalizer( const NavMeshLocalizerPtr & nml ) { _localizer = nml; } /*! * @brief Sets the angular deviation which triggers replanning. * * @param angle The angle of deviation in radians. */ void setHeadingDeviation( float angle ); /*! * @brief Computes and sets the agent's preferred velocity. * * The velocity component directly sets preferred velocity values in the * the provided preferred velocity instance. See Agents::PrefVelocity for details. * Rather than setting the agent's preferred velocity value directly, a reference * to a preferred velocity instance is passed in to make the use more general. * This allows the computation of the preferred velocity for the agent, without * necessarily making changes to it. * * @param agent The agent for which a preferred velocity is computed. * @param goal The agent's goal (although this may be ignored). * @param pVel The instance of Agents::PrefVelocity to set. */ virtual void setPrefVelocity( const Agents::BaseAgent * agent, const Goal * goal, Agents::PrefVelocity & pVel ) const; /*! * @brief Used by the plugin system to know what artifacts to associate with * agents of this type. Every sub-class of must return a globally * unique value if it should be associated with unique artifacts. */ virtual std::string getStringId() const { return NAME; } /*! The unique identifier used to register this type with run-time components. */ static const std::string NAME; /*! * @brief Returns a pointer to the nav mesh localizer task. * * @returns A pointer to the nav mesh localizer task. It is the responsibility * of the caller to free the memory of the provided task by * calling its destroy method. */ virtual Task * getTask(); protected: /*! * @brief The cosine of the heading deviation angular threshold. This detects * when the angle of approach deviates beyond a threshold and the agent * needs to replan. */ float _headingDevCos; /*! * @brief The navigation mesh. */ NavMeshPtr _navMesh; /*! * @brief The localizer for the navigation mesh. */ NavMeshLocalizerPtr _localizer; }; ////////////////////////////////////////////////////////////////////////////// /*! * @brief Factory for the NavMeshVelComponent. */ class MENGE_API NavMeshVCFactory : public VelCompFactory { public: /*! * @brief Constructor. */ NavMeshVCFactory(); /*! * @brief The name of the velocity component. * * The velocity component's name must be unique among all registered * velocity components. Each velocity component factory must override this function. * * @returns A string containing the unique velocity component name. */ virtual const char * name() const { return NavMeshVelComponent::NAME.c_str(); } /*! * @brief A description of the velocity component. * * Each velocity component factory must override this function. * * @returns A string containing the velocity component description. */ virtual const char * description() const { return "Provides a preferred velocity which is derived from a path along a " "polygonally decomposed representation of the traversable space (a " "navigaiton mesh)."; }; protected: /*! * @brief Create an instance of this class's velocity component. * * All VelCompFactory sub-classes must override this by creating (on the heap) * a new instance of its corresponding velocity component type. The various field * values of the instance will be set in a subsequent call to * VelCompFactory::setFromXML. The caller of this function takes ownership of the * memory. * * @returns A pointer to a newly instantiated VelComponent class. */ VelComponent * instance() const { return new NavMeshVelComponent(); } /*! * @brief Given a pointer to an VelComponent instance, sets the appropriate fields * from the provided XML node. * * It is assumed that the value of the `type` attribute is this VelComponent's type. * (i.e. VelCompFactory::thisFactory has already been called and returned true.) * If sub-classes of VelCompFactory introduce *new* VelComponent parameters, then the * sub-class should override this method but explicitly call the parent class's * version. * * @param vc A pointer to the velocity component whose attributes are to * be set. * @param node The XML node containing the velocity component attributes. * @param behaveFldr The path to the behavior file. If the velocity component * references resources in the file system, it should be * defined relative to the behavior file location. This is * the folder containing that path. * @returns A boolean reporting success (true) or failure (false). */ virtual bool setFromXML( VelComponent * vc, TiXmlElement * node, const std::string & behaveFldr ) const; /*! * @brief The identifier for the "file_name" string attribute. */ size_t _fileNameID; /*! * @brief The identifier for the "heading_threshold" float attribute. */ size_t _headingID; }; } // namespace BFSM } // namespace Menge #endif // __VEL_COMP_NAV_MESH_H__
34.14876
91
0.684293
72ec63fd2db2d4e489f5dd69ab0c66dce8052ddd
1,156
c
C
src/watchdog_fd.c
ChrisNisbet01/watchdogd
ad99b23139a37ecb17c588ecb42aafe0a4d4a5c9
[ "MIT" ]
null
null
null
src/watchdog_fd.c
ChrisNisbet01/watchdogd
ad99b23139a37ecb17c588ecb42aafe0a4d4a5c9
[ "MIT" ]
null
null
null
src/watchdog_fd.c
ChrisNisbet01/watchdogd
ad99b23139a37ecb17c588ecb42aafe0a4d4a5c9
[ "MIT" ]
null
null
null
#include "watchdog_fd.h" #include <ubus_utils/ubus_utils.h> #include <fcntl.h> #include <linux/watchdog.h> #include <sys/ioctl.h> void disable_watchdog(int const fd) { if (fd >= 0) { char const V = 'V'; TEMP_FAILURE_RETRY(write(fd, &V, sizeof V)); } } void stroke_watchdog(int const fd) { if (fd >= 0) { int dummy; ioctl(fd, WDIOC_KEEPALIVE, &dummy); } } bool set_watchdog_secs(int const fd, int const secs) { bool const success = fd >= 0 && ioctl(fd, WDIOC_SETTIMEOUT, &secs) == 0; return success; } int get_watchdog_secs(int const fd) { int watchdog_secs; if (fd >= 0) { int const err = ioctl(fd, WDIOC_GETTIMEOUT, &watchdog_secs); if (err != 0) { watchdog_secs = err; } } else { watchdog_secs = -1; } return watchdog_secs; } int watchdog_open(void) { return open("/dev/watchdog", O_WRONLY | O_CLOEXEC); } void watchdog_close(int const fd, bool const disable) { if (fd >= 0) { if (disable) { disable_watchdog(fd); } close(fd); } }
14.45
76
0.558824
3c95d1068da81a2be1f6593e9968a73288de7001
2,096
h
C
parser/vexs_header.h
fshriver/VEXS
d4850fb3c30fef9cb8f417c44d850a2136b8e787
[ "MIT" ]
null
null
null
parser/vexs_header.h
fshriver/VEXS
d4850fb3c30fef9cb8f417c44d850a2136b8e787
[ "MIT" ]
null
null
null
parser/vexs_header.h
fshriver/VEXS
d4850fb3c30fef9cb8f417c44d850a2136b8e787
[ "MIT" ]
1
2020-09-25T12:29:06.000Z
2020-09-25T12:29:06.000Z
/* VEXS header file; declares common functions and also defines the available data types */ #ifndef __VEXS_HEADER_H__ #define __VEXS_HEADER_H__ #include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> #include <sys/stat.h> #include <fstream> #include <algorithm> #include <cmath> //Standard namespaces using namespace std; //VEXS data structures definitions #include "problem_data.h" //Common IO functions; we give them their own separate header file so we can expose them to CUDA kernels, which can actually use them extern "C" { #include "vexs_io_functions.h" } //VEXS exposed data structure definitions //I don't think we need this anymore, let's comment it out and see what happens! /* #define IGAOS 1 //Individual grid, array of structs #define IGFA 2 //Individual grid, flat array (one single large array) #define IGFAI 3 //Individual grids, flat arrays, each nuclide has its xs values interleaved after the energy grid [DEFAULT] #define UGAOS 4 //Unionized grid, array of structs #define UGFA 5 //Unionized grid, flat array #define ALL 6 //All above data types */ //Define flag values for reading in binary files #define FALSE 0 #define TRUE 1 //Command-line parsing functions void parse_cli(problem_data &problem, int ac, char* av[]); //Library reading functions void read_library(problem_data &problem); void read_metadata(problem_data &problem); void read_material(problem_data &problem, int material); void read_nuclide(problem_data &problem, int nuclide); //Random data assignment functions void assign_random_data(problem_data &problem); void assign_random_xs(problem_data &problem, unsigned long &seed); void assign_random_concentrations(problem_data &problem, unsigned long &seed); //Generation of random numbers long double random_number(unsigned long &seed); //VEXS functions to binary file I/O void write_binary_data(problem_data problem); void read_binary_data(problem_data &problem); void print_problem_data(problem_data problem); void call_kernels(problem_data problem); /* Just prints the VEXS logo */ void print_vexs_logo(); #endif
26.531646
133
0.781489
a70806b92b1c3bd36b5aa542cc280420d73f3831
558
h
C
NS2 HLSL Parser/Engine/String.h
WhoBrokeTheBuild/Water-and-Oil-Engine
aaaed0664a394dd1f670524832b5ca3ec065512e
[ "MIT" ]
133
2015-01-03T16:43:57.000Z
2022-02-22T17:54:48.000Z
src/Engine/String.h
mcanthony/hlslparser
104a53d01f057ba2970511331462bec6d37ae34d
[ "MIT" ]
2
2015-02-13T03:45:54.000Z
2015-02-14T10:04:15.000Z
src/Engine/String.h
mcanthony/hlslparser
104a53d01f057ba2970511331462bec6d37ae34d
[ "MIT" ]
26
2015-01-21T15:59:48.000Z
2021-03-08T00:28:07.000Z
#ifndef ENGINE_STRING_H #define ENGINE_STRING_H #include <cstdarg> namespace M4 { int String_Printf(char* buffer, int bufferSize, const char* format, va_list args); int String_Printf(char* buffer, int bufferSize, const char* format, ...); bool String_Equal(const char* first, const char* second); bool String_EqualNoCase(const char* first, const char* second); double String_ToDouble(const char* buffer, char** end); int String_ToInteger(const char* buffer, char** end); int String_FormatFloat(char* buffer, int bufferSize, float value); } #endif
21.461538
82
0.761649
5678450816e061a2e84defba79bf1bb600a02dfa
352
c
C
src/do_fflush.c
Wodan58/DUPLO
aa19a0cb9e9ac85e990b12a707d802531190af6a
[ "BSD-3-Clause" ]
null
null
null
src/do_fflush.c
Wodan58/DUPLO
aa19a0cb9e9ac85e990b12a707d802531190af6a
[ "BSD-3-Clause" ]
null
null
null
src/do_fflush.c
Wodan58/DUPLO
aa19a0cb9e9ac85e990b12a707d802531190af6a
[ "BSD-3-Clause" ]
null
null
null
/* module : do_fflush.c version : 1.2 date : 10/26/20 */ #include <stdio.h> #include <assert.h> #include "data.h" #include "ident.h" /* fflush : S -> S Flush stream S, forcing all buffered output to be written. */ void do_fflush() { DEBUG(__FUNCTION__); assert(stack->op == typ_file && stack->fp); fflush(stack->fp); }
16.761905
58
0.605114
f09c1c624eaef29b7fc4f9bd5858c634be4d2bde
2,769
h
C
s32v234_sdk/libs/apex/acf_offline/include/acf_report.h
intesight/Panorama4AIWAYS
46e1988e54a5155be3b3b47c486b3f722be00b5c
[ "WTFPL" ]
null
null
null
s32v234_sdk/libs/apex/acf_offline/include/acf_report.h
intesight/Panorama4AIWAYS
46e1988e54a5155be3b3b47c486b3f722be00b5c
[ "WTFPL" ]
null
null
null
s32v234_sdk/libs/apex/acf_offline/include/acf_report.h
intesight/Panorama4AIWAYS
46e1988e54a5155be3b3b47c486b3f722be00b5c
[ "WTFPL" ]
2
2021-01-21T02:06:16.000Z
2021-01-28T10:47:37.000Z
/***************************************************************************** * * NXP Confidential Proprietary * * Copyright (c) 2014-2016 Freescale Semiconductor * Copyright 2017 NXP * All Rights Reserved * ****************************************************************************** * * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ #ifndef ACFREPORT_H #define ACFREPORT_H #include <stdio.h> #include <time.h> #include <cstring> #ifndef TEST_LOG_DIR #define TEST_LOG_DIR ("C:/__Traceability/APEXCV/") #endif //////////////////////////////////////////////////////////////////////// /// \defgroup CGV_TOOLS S/W Verification Tools //////////////////////////////////////////////////////////////////////// ///@{ //////////////////////////////////////////////////////////////////////// /// \defgroup CGV_TOOLS_REPORT S/W Tools - Test Cases Report //////////////////////////////////////////////////////////////////////// ///@{ //! Get time. time_t CGV_LOG_GetTime(); // disable report to stdout #define CGV_REPORT_STDOUT (0) #define CGV_REPORT_TC_NAME_SIZE (128) #define CGV_REPORT_SIM_NAME_SIZE (128) #define CGV_REPORT_PATH_NAME_SIZE (128) #define CGV_REPORT_FILE_NAME_SIZE (128) #ifndef gCGV_RPT_DBASE #define CGV_REPORT_INIT(_PATH, _TC) #define CGV_REPORT_START(_SIM) #define CGV_REPORT_END(_NB) #define CGV_REPORT_CLOSE() #define CGV_REPORT_FILE_XML_STR(_HANDLE, _STR, _EOL, _TAB) #define CGV_REPORT_FILE_XML_INT(_HANDLE, _STR, _EOL, _TAB) #define CGV_REPORT_FILE(_R) #define CGV_REPORT_LOG(...) #define CGV_REPORT_GRAPH(_R) //! Report Function Database (Functions) extern char* gCGV_RPT_TC_NAME; extern char* gCGV_RPT_SIM_NAME; extern char* gCGV_RPT_PATH_NAME; extern char* gCGV_RPT_FILE_NAME; extern FILE* gCGV_RPT_FILE_HANDLE; extern time_t gCGV_TIME; extern unsigned int gCGV_ERROR; #else #define CGV_REPORT_LOG(...) #endif #endif /* ACFREPORT_H */
32.576471
78
0.592633
f0c9943c9c22b8e101c2f1a83034e73897707278
17,755
h
C
ipa.h
ispras/lingvodoc-ext-oslon
bd2a04175534bf654c9172e68513723f9428ee3c
[ "Apache-2.0" ]
null
null
null
ipa.h
ispras/lingvodoc-ext-oslon
bd2a04175534bf654c9172e68513723f9428ee3c
[ "Apache-2.0" ]
null
null
null
ipa.h
ispras/lingvodoc-ext-oslon
bd2a04175534bf654c9172e68513723f9428ee3c
[ "Apache-2.0" ]
1
2018-09-25T14:37:10.000Z
2018-09-25T14:37:10.000Z
#pragma once #include "stringfunctions.h" #include "parser.h" #include "pool.h" #include "btree.h" #include "datastructures.h" #include "ipatables.h" enum { FT_VOWEL = 1, FT_CONSONANT, FT_MODIFIER, FT_UNKNOWNSOUND, FT_NSOUNDCLASSES, }; enum { FT_CLASS = 0, FT_MANNER, FT_PLACE, FT_COARTICULATION, FT_NFEATURETYPES, FT_NONE, FT_SOUND, }; class Feature : public BNode { public: int iClass; int iType; int value; LPTSTR abbr; Feature(LPTSTR _abbr, int _iClass = FT_NONE, int _iType = FT_NONE, int _value = 0) { iClass = _iClass; iType = _iType; abbr = _abbr; value = _value; } }; int CompareFeaturesAnd(int* f1, int* f2) { for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { if (f1[iFType] > f2[iFType]) return 1; if (f1[iFType] < f2[iFType]) return -1; } return 0; } int CompareFeaturesNumberOfDifferences___(int* f1, int* f2) { int nDiff = 0; for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { if (f1[iFType] > f2[iFType]) nDiff++; if (f1[iFType] < f2[iFType]) nDiff++; } return nDiff; } int CompareFeaturesOr(int* f1, int* f2, int max = FT_NFEATURETYPES - 1) { for (int iFType = 0; iFType <= max; iFType++) { if (f2[iFType]) { if (!(f1[iFType] & f2[iFType])) return 1; } } return 0; } class FeatureTree : public BTree { public: int CompareNodes(BNode* _nd1, BNode* _nd2, void*_) { Feature* nd1 = (Feature*)_nd1;//поэтому надо шаблонно!! Feature* nd2 = (Feature*)_nd2; return wcscmp(nd1->abbr, nd2->abbr); } }; #define FT_PREV 0x100 #define FT_SET 0x200 #define FT_UNSET 0x400 class SoundTable { public: class Row;//надо без этого!!! class Row : public LinkedElement<Row>, public OwnNew { public: bool isEmpty; int valBase; int valMod; int i; int iIPA; Row(Row* rowPrev = NULL) { next = prev = NULL;// можно это в LinkedElement()? i = 0; isEmpty = true; valBase = valMod = 0; if (rowPrev) iIPA = rowPrev->iIPA; } }; //сделать SoundRef class Sound : public BNode { public: TCHAR Symbol[8]; //bool canExist; bool exists; bool used; void* dataExtra; Sound* nextModified; Row* row[FT_NFEATURETYPES]; int feature[FT_NFEATURETYPES]; Sound(TCHAR* _symbol, int* _feature = NULL) { if (_symbol) { lstrcpy(Symbol, _symbol); //canExist = true; } else { //int i=9;i/=0; //canExist = false; } exists = used = false; dataExtra = nextModified = NULL; for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { row[iFType] = NULL; if (_feature) feature[iFType] = _feature[iFType]; else feature[iFType] = 0; } } Sound(int _code, Row** rows = NULL)//, bool _isPreModifier = false, bool _isPostModifier = false) { Symbol[0] = _code; Symbol[1] = L'\0'; dataExtra = nextModified = NULL; exists = false; if (rows) { for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { row[iFType] = rows[iFType]; if (rows[iFType]) { if (iFType == FT_COARTICULATION) feature[iFType] = rows[iFType]->valMod; else feature[iFType] = rows[iFType]->valBase; } else feature[iFType] = 0; } } else { for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { row[iFType] = NULL; feature[iFType] = 0; } } } int Ordinal(int iFType) { if (!row[iFType]) return -1; return row[iFType]->i; } int OrdinalInIPA(int iFType) { if (!row[iFType]) return -1; return row[iFType]->iIPA; } }; class SoundTree : public BTree { public: int CompareNodes(BNode* _nd1, BNode* _nd2, void*_) { return CompareFeaturesAnd(((Sound*)_nd1)->feature, ((Sound*)_nd2)->feature); } }; public: SoundTree tSounds; Sound** ipaAll; int nipaAll; LinkedList<Row> llRows[FT_NFEATURETYPES]; Row* rowCurrent[FT_NFEATURETYPES]; Pool<Row> pRows; Pool<Sound> pSounds; class Iterator { BTree* tree; BTree::Walker walker; public: Iterator(BTree* _tree) : walker(_tree) { } Sound* Next() { return (Sound*)walker.Next(); } void Done() { delete this; } }; SoundTable() : pRows(50), pSounds(100) { ipaAll = NULL; for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) rowCurrent[iFType] = NULL; } // ~SoundTable() // { // } bool InitIPAMemory(Sound*** _pipaAll) { nipaAll = 0xffff; if (!*_pipaAll) { int sz = sizeof(Sound*)*nipaAll; if (!(*_pipaAll = (Sound**)malloc(sz))) return false;//не new, чтоб избежать к-ра в цикле memset(*_pipaAll, 0, sz); } ipaAll = *_pipaAll; return true; } Sound* AddUnknownSound(int iChr) { Sound* sound = ipaAll[iChr] = new (pSounds.New()) Sound(iChr); sound->feature[FT_CLASS] = FT_UNKNOWNSOUND; sound->feature[FT_MANNER] = iChr; sound->exists = true; tSounds.Add(sound); return sound; } void ConfirmSound(Sound* sound, int iClass = -1) { sound->exists = true; tSounds.Add(sound); if (iClass == FT_MODIFIER) { Sound* sdMain = ipaAll[sound->Symbol[0]]; for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) sound->row[iFType] = sdMain->row[iFType]; for (int iFType = FT_PLACE; ; iFType = FT_MANNER) { Row* row; Row* rowPrev = NULL; for (row = llRows[iFType].first; row; row = row->next) { if (row->valBase == sound->feature[iFType]) { if (iFType == FT_PLACE) { if (row->valMod == sound->feature[FT_COARTICULATION]) goto FoundRow; if (row->valMod > sound->feature[FT_COARTICULATION]) goto AddRow; } else goto FoundRow; } else if (row->valBase > sound->feature[iFType]) { goto AddRow; } rowPrev = row; } AddRow: row = new (pRows.New()) Row(rowPrev); llRows[iFType].Add(row, rowPrev); AddRowValue(iFType, sound->feature[iFType], FT_SET, row); AddRowValue(FT_COARTICULATION, sound->feature[FT_COARTICULATION], FT_SET, row); FoundRow: sound->row[iFType] = row; row->isEmpty = false; if (iFType == FT_MANNER) break; } sound->nextModified = sdMain->nextModified; sdMain->nextModified = sound; } for (int iFType = FT_PLACE; ; iFType = FT_MANNER) //for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { if (sound->row[iFType]) sound->row[iFType]->isEmpty = false; if (iFType == FT_MANNER) break; } } /* Sound* Get(int iChr) { if (!ipaAll[iChr].exists) return NULL; return &ipaAll[iChr]; } */ void AddRowValue(int iFType, int toAdd, int flag, Row* row = NULL) { /* if ((flag & FT_PREV) && rowCurrent[iFType]) { if (rowCurrent[iFType]->prev) toAdd = rowCurrent[iFType]->prev->value; } */ if (!row) row = rowCurrent[iFType]; int* val; switch (iFType) { case FT_COARTICULATION: val = &row->valMod; break; default: val = &row->valBase; } switch (flag & (FT_SET | FT_UNSET)) { case FT_SET: *val |= toAdd; break; case FT_UNSET: *val &= ~toAdd; } } Row* GetRow(int iFType, int iRow) { if (!llRows[iFType].first) return NULL; int i = 0; for (Row* row = llRows[iFType].first; row; row = row->next) { if (i == iRow) return row; i++; } return NULL; } void UnsetRow(int iFType) { rowCurrent[iFType] = NULL;//llRows[iFType].first; } void NextRow(int iFType) { int iCur; if (!llRows[iFType].first) { iCur = -1; goto AddNewRow; } else if (!rowCurrent[iFType]) { rowCurrent[iFType] = llRows[iFType].first; } else if (!rowCurrent[iFType]->next) { iCur = rowCurrent[iFType]->iIPA; AddNewRow: rowCurrent[iFType] = new (pRows.New()) Row; llRows[iFType].Add(rowCurrent[iFType]); rowCurrent[iFType]->iIPA = iCur + 1; } else { rowCurrent[iFType] = rowCurrent[iFType]->next; } } bool PutSoundInIPATable(int iChr, bool doConfirm) { if (!IsSoundCodeOK(iChr)) return false; //else if (ipaAll[iChr].canExist) // return false; //Sound* sound = //new (&ipaAll[iChr]) Sound(iChr, rowCurrent);//, iRow, iCol, _isPreModifier, _isPostModifier); ipaAll[iChr] = new (pSounds.New()) Sound(iChr, rowCurrent); if (doConfirm) { ipaAll[iChr]->exists = true; tSounds.Add(ipaAll[iChr]); } return true; } void CountRows() { for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { int i = 0; Row* nxt; for (Row* row = llRows[iFType].first; row; row = nxt) { nxt = row->next; if (row->isEmpty) llRows[iFType].Delete(row, false); else { row->i = i; i++; } } } } bool IsSoundCodeOK(int iChr) { return (iChr < nipaAll); } }; /////////////////////////////////////////////////////////////// typedef SoundTable::Sound Sound; /////////////////////////////////////////////////////////////// class IPA { // friend Segmentizer; public://временно вм. friend Sound** ipaAll; Pool<Sound> pSounds; Pool<Feature> pFeatures; FeatureTree tFeatures; int curFeatureValue[FT_NSOUNDCLASSES]; SoundTable tblSounds[FT_NSOUNDCLASSES]; Pool<TCHAR> pString; LPTSTR nameFeature[FT_NSOUNDCLASSES]; public: LPTSTR tblPostModifiers, tblConsonants, tblVowels;//, tblReplaceLat, tblReplaceCyr; IPA(bool doConfirmAllSounds = false) : pString(3000), pSounds(100) { ipaAll = NULL; Feature* f; f = new (pFeatures.New()) Feature(L"С", FT_CONSONANT, FT_CLASS, FT_CONSONANT); tFeatures.Add(f); f = new (pFeatures.New()) Feature(L"Г", FT_VOWEL, FT_CLASS, FT_VOWEL); tFeatures.Add(f); //копируем пока просто из глобальных литералов, потом как-то иначе будет tblPostModifiers = pString.New(_tblPostModifiers, wcslen(_tblPostModifiers) + 1); tblConsonants = pString.New(_tblConsonants, wcslen(_tblConsonants) + 1); tblVowels = pString.New(_tblVowels, wcslen(_tblVowels) + 1); BuildPotentialSoundTable(FT_MODIFIER, tblPostModifiers, FT_COARTICULATION, doConfirmAllSounds); BuildPotentialSoundTable(FT_CONSONANT, tblConsonants, FT_PLACE, doConfirmAllSounds); BuildPotentialSoundTable(FT_VOWEL, tblVowels, FT_PLACE, doConfirmAllSounds); tblSounds[FT_UNKNOWNSOUND].InitIPAMemory(&ipaAll);//плохо, что надо явно вызывать!!! nameFeature[FT_CLASS] = L"класс"; nameFeature[FT_MANNER] = L"способ"; nameFeature[FT_PLACE] = L"место"; nameFeature[FT_COARTICULATION] = L"ко-ция"; } ~IPA() { free(ipaAll); } bool CompareSoundsByText(Sound* s1, Sound* s2) { return !!wcscmp(s1->Symbol, s2->Symbol); } Sound* FindModifiedSound(Sound* sndBase, int* feature) { for (Sound* soundMod = sndBase->nextModified; soundMod; soundMod = soundMod->nextModified) { Sound sdForCompare(NULL, feature); if (!tblSounds[sndBase->feature[FT_CLASS]].tSounds.CompareNodes(soundMod, &sdForCompare, NULL)) return soundMod; } return NULL; } int GetPostModifiers(LPTSTR pInWord, LPTSTR chrWithMod, int* feature) { Sound* soundBase = ipaAll[*pInWord]; int nPostModifiers = 0; while (true) { Sound* soundMod = ipaAll[pInWord[1]]; if (!soundMod) break; if (soundMod->feature[FT_CLASS] == FT_MODIFIER) { if (nPostModifiers == 0)//т.е. это первый { chrWithMod[0] = soundBase->Symbol[0]; CopyFeatures(feature, soundBase->feature); } //if (nPostModifiers > ...)//чтоб не было больше 5, например nPostModifiers++; feature[FT_COARTICULATION] |= soundMod->feature[FT_COARTICULATION]; chrWithMod[nPostModifiers] = pInWord[1]; } else break; pInWord++; } chrWithMod[nPostModifiers + 1] = L'\0'; return nPostModifiers; } Sound* GetSound(TCHAR pChr) { if (pChr == 0) return NULL; Sound* sd = ipaAll[pChr]; //if (!sd) // sd = tblSounds[FT_UNKNOWNSOUND].AddUnknownSound(pChr); return sd; } Sound* GetBaseSound(Sound* sound) { return GetSound(sound->Symbol[0]); } Sound* SubmitWordForm(LPTSTR word)//будет меняться подстановками! { Sound* sdCur; for (LPTSTR pInWord = word; *pInWord; pInWord++) { Sound* soundBase = sdCur = ipaAll[*pInWord];//GetSoundWithReplacement(pInWord); TCHAR chr = *pInWord; bool isSoundOK = SoundIsInIPA(chr); if (!isSoundOK) { if (!SoundExists(chr)) tblSounds[FT_UNKNOWNSOUND].AddUnknownSound(chr); } int feature[FT_NFEATURETYPES]; TCHAR chrWithMod[9]; int nPostModifiers = GetPostModifiers(pInWord, chrWithMod, feature); pInWord += nPostModifiers; if (isSoundOK) { int iClass = soundBase->feature[FT_CLASS]; if (nPostModifiers) { //SoundTable::Sound sdForSearch(NULL, feature); //SoundTable::Sound* sdFound = (SoundTable::Sound*)tblSounds[iClass].tSounds.Find(&sdForSearch); if (!(sdCur = FindModifiedSound(soundBase, feature))) { Sound* soundWithMod = sdCur = new (pSounds.New()) Sound(chrWithMod, feature); tblSounds[iClass].ConfirmSound(soundWithMod, FT_MODIFIER);//со вставкой столбца } } else if (!SoundExists(chr)) { tblSounds[iClass].ConfirmSound(soundBase); } } } return sdCur; } void EndSubmitWordForms() { for (int i = 0; i < FT_NSOUNDCLASSES; i++) { tblSounds[i].CountRows(); } } SoundTable::Iterator* Iterator(int iClass) { return new SoundTable::Iterator(&tblSounds[iClass].tSounds); } //private: void CopyFeatures(int* fTo, int* fFrom) { for (int iFType = 0; iFType < FT_NFEATURETYPES; iFType++) { if (!fFrom) fTo[iFType] = 1; else fTo[iFType] = fFrom[iFType]; } } LPTSTR GetFeatureNames(int* ftrs, int iFType, LPTSTR buf) { buf[0] = '\0'; Feature* f; for (BTree::Walker w(&tFeatures); f = (Feature*)w.Next();) { if (f->iType == iFType && (f->iClass == ftrs[FT_CLASS] || f->iClass == FT_COARTICULATION)) //FT_COARTICULATION — общее для С и Г? { if (f->value & ftrs[iFType]) { lstrcat(buf, f->abbr); lstrcat(buf, L" "); } } } return buf; } bool SoundExists(int iChr) { if (!tblSounds[FT_CONSONANT].IsSoundCodeOK(iChr)) //если согласных нет, то сломается, поэтому надо делать класс IPAAll return false; else if (ipaAll[iChr]) return ipaAll[iChr]->exists; return false; } bool SoundIsInIPA(int iChr) { if (!tblSounds[FT_CONSONANT].IsSoundCodeOK(iChr)) //если согласных нет, то сломается, поэтому надо делать класс IPAAll return false; else return !!ipaAll[iChr]; } bool BuildPotentialSoundTable(int iClass, LPTSTR txtTable, int iHorFType, bool doConfirmAllSounds) { SoundTable* table = &tblSounds[iClass]; if (!table->InitIPAMemory(&ipaAll)) return false; Parser parser(txtTable, L"\t\r\n", PARSER_SKIPNEWLINE); LPTSTR word; CopyFeatures(curFeatureValue, NULL); Feature* feature, *ftLast = NULL; table->UnsetRow(FT_CLASS); table->NextRow(FT_CLASS); table->AddRowValue(FT_CLASS, iClass, FT_SET); table->UnsetRow(iHorFType); table->UnsetRow(FT_MANNER); int iFtType = FT_NONE; while (word = parser.Next()) { if (parser.IsItemFirstInLine()) { table->UnsetRow(iHorFType); ftLast = NULL; if (parser.IsItemEmpty()) { switch (iFtType) { case FT_NONE: //curFeatureValue = 1; break; case FT_PLACE: case FT_COARTICULATION: iFtType = FT_NONE; break; } } else { table->NextRow(FT_MANNER); switch (iFtType) { case FT_NONE: iFtType = FT_MANNER; break; case FT_PLACE: case FT_COARTICULATION: iFtType = FT_MANNER; //curFeatureValue[iFtType] = modFeatureValue[iFtType]; break; case FT_SOUND: iFtType = FT_MANNER; } } } else { switch (iFtType) { case FT_NONE: iFtType = iHorFType; break; case FT_MANNER: iFtType = FT_SOUND; break; } table->NextRow(iHorFType); } switch (iFtType) { case FT_PLACE: case FT_MANNER: case FT_COARTICULATION: if (parser.IsItemEmpty()) { if (ftLast) table->AddRowValue(iFtType, ftLast->value, FT_SET); } else { if (ftLast) table->AddRowValue(iFtType, ftLast->value, FT_UNSET); if (word[0] != '-') { Feature ftForSearch(word, iClass, iFtType); if (!(feature = (Feature*)tFeatures.Find(&ftForSearch)))//ужас: (Feature*), поэтому надо шаблонно, но тоже тяжко { feature = new (pFeatures.New()) Feature(ftForSearch.abbr, iClass, iFtType, curFeatureValue[iFtType]); curFeatureValue[iFtType] = curFeatureValue[iFtType] * 2; //curFeatureValue *= 2;//НЕ ПАШЕТ tFeatures.Add(feature); } table->AddRowValue(iFtType, feature->value, FT_SET); ftLast = feature; } } break; case FT_SOUND: if (!parser.IsItemEmpty()) { table->PutSoundInIPATable(word[0], doConfirmAllSounds); } //ругаться, если есть! break; } } return true; } }; #include "segmentizer.h" #include "ipaquery.h" #include "replacer.h"
21.469166
133
0.59786
091119c1b19a11a92a63998b7471d201deaed21c
1,960
h
C
src/OutputManagerFactory.h
wilseypa/warped
8842cf88b11213b6b69e53de5e969c4e3c2c8bd5
[ "MIT" ]
12
2015-03-13T09:58:25.000Z
2021-09-23T11:48:42.000Z
src/OutputManagerFactory.h
wilseypa/warped
8842cf88b11213b6b69e53de5e969c4e3c2c8bd5
[ "MIT" ]
1
2015-12-09T05:21:44.000Z
2015-12-17T19:37:12.000Z
src/OutputManagerFactory.h
wilseypa/warped
8842cf88b11213b6b69e53de5e969c4e3c2c8bd5
[ "MIT" ]
null
null
null
#ifndef OUTPUT_MANAGER_FACTORY_H #define OUTPUT_MANAGER_FACTORY_H #include "Configurer.h" // for Configurer #include "warped.h" class Configurable; class Event; class OutputManager; class SimulationConfiguration; class SimulationObject; /** The OutputManagerFactory class. This is the class interface for the various output events manager implementations that are available in the Simulation kernel. The specific output events manager implementation is hidden from the other components of the simulation kernel by the aggregation of the output manager implemetations in this class interface ( factory pattern). All output events manager implementations must be derived from the OutputManager abstract base class. The choices are: AggressiveOutputManager, LazyOutputManager, and AdaptiveOutputManager. */ class OutputManagerFactory : virtual public Configurer { public: /**@name Public Class Methods of OutputManagerFactory. */ //@{ /** Constructor. @param SimulationManager Handle to the sim. mgr. @param numObjects Number of simulation objects. */ OutputManagerFactory(); /// Destructor. virtual ~OutputManagerFactory(); /** Set the configured output manager implementation. Function to attach the particular output manager implementation in the kernel. Will be called by the configuration step to set the appropriate output manager implementation. @param configurationMap Configuration options. */ Configurable* allocate(SimulationConfiguration& configuration, Configurable* parent) const; static const OutputManagerFactory* instance(); //@} // End of Public Class Methods of OutputManagerFactory. protected: /**@name Private Class Attributes of OutputManagerFactory. */ //@{ //@} // End of Private Class Attributes of OutputManagerFactory. }; #endif
29.253731
74
0.727041
3479cb20f863f24e09f6c20ce01eb0ccbf1f7040
439
h
C
ios/Model/Message.h
yswor/react-native-netease-im
857837c3ce94d4f93d28e9db8e728bbef689f181
[ "MIT" ]
1
2020-08-27T04:18:41.000Z
2020-08-27T04:18:41.000Z
ios/Model/Message.h
yswor/react-native-netease-im
857837c3ce94d4f93d28e9db8e728bbef689f181
[ "MIT" ]
null
null
null
ios/Model/Message.h
yswor/react-native-netease-im
857837c3ce94d4f93d28e9db8e728bbef689f181
[ "MIT" ]
1
2020-09-30T02:01:45.000Z
2020-09-30T02:01:45.000Z
#import <NIMSDK/NIMSDK.h> #import "NimConstant.h" #import "Contact.h" @interface Message: NSObject { @public NSString *messageId; @public NSString *account; @public NIMSessionType sessionType; @public NIMMessage *message; } -(instancetype)initWithParams:(NSString *)id :(NSString *)account :(NIMSessionType)sessionType; -(instancetype)initWithMessage:(NIMMessage *)message; -(NSDictionary *)getMessage; -(NIMMessage *)getImMessage; @end
24.388889
95
0.774487
4291d5f1bccba5de9bac0c483ba2440eb48bea70
1,521
h
C
applications/physbam/physbam-lib/Public_Library/PhysBAM_Dynamics/Coupled_Evolution/LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
20
2017-07-03T19:09:09.000Z
2021-09-10T02:53:56.000Z
applications/physbam/physbam-lib/Public_Library/PhysBAM_Dynamics/Coupled_Evolution/LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
null
null
null
applications/physbam/physbam-lib/Public_Library/PhysBAM_Dynamics/Coupled_Evolution/LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR.h
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
9
2017-09-17T02:05:06.000Z
2020-01-31T00:12:01.000Z
//##################################################################### // Copyright 2009, Avi Robinson-Mosher. // This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt. //##################################################################### // Class LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR //##################################################################### #ifndef __LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR__ #define __LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR__ #include <PhysBAM_Tools/Krylov_Solvers/KRYLOV_VECTOR_BASE.h> namespace PhysBAM{ template<class T> class VECTOR_ND; template<class TV> class GENERALIZED_VELOCITY; template<class TV> class LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR : public KRYLOV_VECTOR_BASE<typename TV::SCALAR> { typedef typename TV::SCALAR T; typedef KRYLOV_VECTOR_BASE<T> BASE; public: VECTOR_ND<T>& lagrange_multipliers; GENERALIZED_VELOCITY<TV>& solid_velocity; LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR(VECTOR_ND<T>& lagrange_multipliers_input,GENERALIZED_VELOCITY<TV>& solid_velocity_input); LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR& operator=(const LAGRANGE_MULTIPLIERS_VELOCITY_VECTOR& v); BASE& operator+=(const BASE& bv) PHYSBAM_OVERRIDE; BASE& operator-=(const BASE& bv) PHYSBAM_OVERRIDE; BASE& operator*=(const T a) PHYSBAM_OVERRIDE; void Copy(const T c,const BASE& bv) PHYSBAM_OVERRIDE; void Copy(const T c1,const BASE& bv1,const BASE& bv2) PHYSBAM_OVERRIDE; }; } #endif
43.457143
135
0.690335
550796e9bfd77f595668864c43b70faf4f4f9b15
657
h
C
iOS/VZ/VZ/VZProgressView.h
aadebuger/leancloud-demo
0a4915366f32dd9d1c7498f7a1c82e4b903a781e
[ "MIT" ]
3
2015-07-07T09:10:37.000Z
2015-07-23T13:23:48.000Z
iOS/VZ/VZ/VZProgressView.h
EmoryLee/avoscloud-demo
52fd3df86d7785f6d7fedca18a0e1020edd2f62a
[ "MIT" ]
null
null
null
iOS/VZ/VZ/VZProgressView.h
EmoryLee/avoscloud-demo
52fd3df86d7785f6d7fedca18a0e1020edd2f62a
[ "MIT" ]
null
null
null
// // VZProgressView.h // VZ // // Created by Travis on 13-10-31. // Copyright (c) 2013年 Plumn LLC. All rights reserved. // #import <UIKit/UIKit.h> @interface VZProgressView : UIView @property(nonatomic,assign) BOOL autoCenter; @property(nonatomic,retain) UIBezierPath *path; @property(nonatomic,retain) UIColor *bgLineColor; @property(nonatomic,retain) UIColor *fgLineColor; @property(nonatomic,assign) BOOL infinite; @property(nonatomic,assign) BOOL dashBgLine; @property(nonatomic,assign) float progress; @property(nonatomic,assign) float lineWidth; - (id)initWithWidth:(float)width; -(void)setProgress:(float)p animated:(BOOL)animated; @end
22.655172
55
0.757991
b64ada4912185a2a8b00819dc053638a1e7c5be9
10,143
h
C
config.h
axelcalixte/mon_dwm
9e457c9577eff922673545005940cc9306517156
[ "MIT" ]
null
null
null
config.h
axelcalixte/mon_dwm
9e457c9577eff922673545005940cc9306517156
[ "MIT" ]
null
null
null
config.h
axelcalixte/mon_dwm
9e457c9577eff922673545005940cc9306517156
[ "MIT" ]
null
null
null
/* See LICENSE file for copyright and license details. */ /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int gappx = 3; /* gaps between windows */ static const unsigned int snap = 32; /* snap pixel */ static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { "Iosevka:style=Regular:pixelsize=17:autohint=true:antialias=true", "Font Awesome 5 Free " "Regular:style=Regular:pixelsize=17:antialias=true:autohint=true", "Noto Color Emoji:style=Regular:pixelsize=17:antialias=true:autohint=true"}; static const char dmenufont[] = "Iosevka:style=Regular:size=13"; static const char col_gray1[] = "#1F1F28"; // default background static const char col_gray2[] = "#2A2A37"; // lighter background static const char col_gray3[] = "#DCD7BA"; // default foreground static const char col_gray4[] = "#DCD7BA"; // default foreground static const char col_cyan[] = "#223249"; // waveBlue1 static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = {col_gray3, col_gray1, col_gray2}, [SchemeSel] = {col_gray4, col_cyan, col_cyan}, }; static const char *const autostart[] = { //"nirogen", "--restore", NULL, setting wallpaper through // lightdm-gtk-greeyer-settings "aslstatus", NULL, //"xcompmgr", "-c", "-C", "-t-5", "-l-5", "-r4.2", "-o.55", "-f", "-I.15", "-O.17", "-D3", NULL, "dunst", "-c", "/home/axel/.config/dunst/dunstrc", NULL, "picom", "--experimental-backends", NULL, "xrdb", "-merge", "/home/axel/.config/x11/.Xresources", NULL, "xautolock", "-locker", "slock", "-time", "5", "-corners", "----", NULL, NULL /* terminate */ }; /* tagging */ static const char *tags[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; static const Rule rules[] = { /* xprop(1): * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ /* class instance title tags mask isfloating isterminal noswallow monitor */ {"KeePassXC", "keepassxc", NULL, 1 << 8, 0, 0, 1, -1}, {"Claws-mail", "claws-mail", NULL, 1 << 7, 0, 0, 1, -1}, {"KeePassXC", "keepassxc", "Unlock Database - KeePassXC", 1 << 8, 1, 0, 1, -1}, {NULL, NULL, "xdg-su: /sbin/yast2", 0, 1, 1, 1, -1}, {NULL, NULL, "xdg-su: /sbin/yast2 sw_single ", 0, 1, 1, 1, -1}, {"kitty", NULL, NULL, 0, 0, 1, 0, -1}, {"St", NULL, NULL, 0, 0, 1, 0, -1}, {NULL, NULL, "Event Tester", 0, 0, 0, 1, -1}, /* xev */ }; /* layout(s) */ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const Layout layouts[] = { /* symbol arrange function */ {"[]=", tile}, /* first entry is default */ {"><>", NULL}, /* no layout function means floating behavior */ {"[M]", monocle}, }; /* key definitions */ #define MODKEY Mod4Mask #define TAGKEYS(KEY, TAG) \ {MODKEY, KEY, view, {.ui = 1 << TAG}}, \ {MODKEY | ControlMask, KEY, toggleview, {.ui = 1 << TAG}}, \ {MODKEY | ShiftMask, KEY, tag, {.ui = 1 << TAG}}, \ {MODKEY | ControlMask | ShiftMask, KEY, toggletag, {.ui = 1 << TAG}}, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) \ { \ .v = (const char *[]) { "/bin/sh", "-c", cmd, NULL } \ } /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL}; static const char *termcmd[] = {"st", "-e", "tmux", NULL}; static const char *web[] = {"firefox", NULL}; static const char *filemanager[] = {"st", "-e", "nnn", "-C", NULL}; static const char *htop[] = {"st", "-e", "htop", NULL}; static const char *keepass[] = {"keepassxc", NULL}; static const char *musicplayer[] = {"st", "-e", "cmus", NULL}; static const char *mixer[] = {"st", "-e", "pulsemixer", NULL}; static const char *mail[] = {"claws-mail", "--alternate-config-dir", "/home/axel/.config/claws-mail", NULL}; static const char *bluetoothctl[] = {"st", "-e", "bluetoothctl", NULL}; /* commands spawned when clicking statusbar, the mouse button pressed is * exported as BUTTON */ static const StatusCmd statuscmds[] = { {"sudo zypper dup", 1}, {"/home/axel/.local/bin/scripts/weather.sh", 2}, {"pulsemixer", 3}, {"pamixer --source $(pamixer --list-sources | tail -1 | cut -d' ' -f1) -t", 4}, {"sudo nmtui", 5}, {"cal", 6}, }; static const char *statuscmd[] = {"/bin/sh", "-c", NULL, NULL}; #include <X11/XF86keysym.h> static Key keys[] = { /* modifier key function argument */ {MODKEY, XK_p, spawn, {.v = dmenucmd}}, {MODKEY | ShiftMask, XK_Return, spawn, {.v = termcmd}}, {Mod1Mask | ShiftMask, XK_w, spawn, {.v = web}}, {Mod1Mask | ShiftMask, XK_f, spawn, {.v = filemanager}}, {Mod1Mask | ShiftMask, XK_h, spawn, {.v = htop}}, {Mod1Mask | ShiftMask, XK_k, spawn, {.v = keepass}}, {Mod1Mask | ShiftMask, XK_m, spawn, {.v = musicplayer}}, {Mod1Mask | ShiftMask, XK_p, spawn, {.v = mixer}}, {Mod1Mask | ShiftMask, XK_c, spawn, {.v = mail}}, {MODKEY, XK_b, togglebar, {0}}, {MODKEY, XK_j, focusstack, {.i = +1}}, {MODKEY, XK_k, focusstack, {.i = -1}}, {MODKEY, XK_i, incnmaster, {.i = +1}}, {MODKEY, XK_d, incnmaster, {.i = -1}}, {MODKEY, XK_h, setmfact, {.f = -0.05}}, {MODKEY, XK_l, setmfact, {.f = +0.05}}, {MODKEY, XK_Return, zoom, {0}}, {MODKEY, XK_Tab, view, {0}}, {MODKEY | ShiftMask, XK_c, killclient, {0}}, {MODKEY, XK_t, setlayout, {.v = &layouts[0]}}, {MODKEY, XK_f, setlayout, {.v = &layouts[1]}}, {MODKEY, XK_m, setlayout, {.v = &layouts[2]}}, {MODKEY, XK_space, setlayout, {0}}, {MODKEY | ShiftMask, XK_space, togglefloating, {0}}, {MODKEY, XK_agrave, view, {.ui = ~0}}, {MODKEY | ShiftMask, XK_agrave, tag, {.ui = ~0}}, {MODKEY, XK_ugrave, focusmon, {.i = -1}}, {MODKEY, XK_asterisk, focusmon, {.i = +1}}, {MODKEY | ShiftMask, XK_ugrave, tagmon, {.i = -1}}, {MODKEY | ShiftMask, XK_asterisk, tagmon, {.i = +1}}, TAGKEYS(XK_ampersand, 0) TAGKEYS(XK_eacute, 1) TAGKEYS(XK_quotedbl, 2) TAGKEYS(XK_apostrophe, 3) TAGKEYS(XK_parenleft, 4) TAGKEYS(XK_minus, 5) TAGKEYS(XK_egrave, 6) TAGKEYS(XK_underscore, 7) TAGKEYS( XK_ccedilla, 8){MODKEY | ShiftMask, XK_q, spawn, SHCMD("~/.local/bin/scripts/poweroff.sh")}, {MODKEY, XK_a, spawn, SHCMD("~/.local/bin/scripts/switch")}, {MODKEY | ShiftMask, XK_Delete, quit, {0}}, /* Function keys */ {0, XF86XK_AudioMute, spawn, SHCMD("pamixer -t")}, {0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer -i5")}, {0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer -d5")}, {0, XF86XK_AudioMicMute, spawn, SHCMD("pamixer --source $(pamixer --list-sources | tail -1 | cut -d' ' " "-f1) -t")}, {0, XF86XK_MonBrightnessUp, spawn, SHCMD("brightnessctl -e s +5%")}, {0, XF86XK_MonBrightnessDown, spawn, SHCMD("brightnessctl -e s 5%-")}, {0, XF86XK_Display, spawn, SHCMD("~/.local/bin/scripts/screens.sh")}, //{ 0, XF86XK_Tools, spawn, SHCMD("") }, {0, XF86XK_Bluetooth, spawn, {.v = bluetoothctl}}, //{ 0, XF86XK_Wakeup, spawn, SHCMD("") }, {0, XF86XK_Favorites, spawn, SHCMD("~/.local/bin/scripts/weather.sh")}, {Mod1Mask | ShiftMask, XK_t, spawn, SHCMD("tmux list-session | dmenu -l 5 | cut -d':' -f1 | xargs tmux " "kill-session -t")}, //{Mod1Mask | ShiftMask, XK_a, spawn,SHCMD("t=$(tmux list-session | dmenu -l // 5 | cut -d':' -f1); st -e 'tmux attach-session -t $t'")}, /* CMUS music control */ {MODKEY, XK_Right, spawn, SHCMD("cmus-remote --next")}, {MODKEY, XK_Left, spawn, SHCMD("cmus-remote --prev")}, {MODKEY, XK_Up, spawn, SHCMD("cmus-remote --pause")}, {MODKEY, XK_Down, spawn, SHCMD("cmus-remote --stop")}, /* Screenshots */ {MODKEY, XK_Print, spawn, SHCMD("maim -s | xclip -selection clipboard -t image/png")}, {MODKEY | ShiftMask, XK_Print, spawn, SHCMD("maim ~/pics/maim-$(date +%s).png -s | xclip -selection clipboard " "-t image/png")}, }; /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, * ClkClientWin, or ClkRootWin */ static Button buttons[] = { /* click event mask button function argument */ {ClkLtSymbol, 0, Button1, setlayout, {0}}, {ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]}}, {ClkWinTitle, 0, Button2, zoom, {0}}, {ClkStatusText, 0, Button1, spawn, {.v = statuscmd}}, {ClkStatusText, 0, Button2, spawn, {.v = statuscmd}}, {ClkStatusText, 0, Button3, spawn, {.v = statuscmd}}, {ClkClientWin, MODKEY, Button1, movemouse, {0}}, {ClkClientWin, MODKEY, Button2, togglefloating, {0}}, {ClkClientWin, MODKEY, Button3, resizemouse, {0}}, {ClkTagBar, 0, Button1, view, {0}}, {ClkTagBar, 0, Button3, toggleview, {0}}, {ClkTagBar, MODKEY, Button1, tag, {0}}, {ClkTagBar, MODKEY, Button3, toggletag, {0}}, {ClkRootWin, 0, Button3, spawn, SHCMD("~/.local/bin/scripts/xdg-xmenu.sh > ~/.cache/menu; xmenu < " "~/.cache/menu | sh &")}, };
46.527523
80
0.571823
99f252a33b5ee6aec01feca7dc627bad9e70b8bf
514
c
C
lib/wizards/irmeli/ent/monsters/ent.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/irmeli/ent/monsters/ent.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/irmeli/ent/monsters/ent.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
inherit "obj/monster"; reset(arg) { ::reset(arg); if (arg) { return; } set_level(random(5)*5+12); set_name("ent"); set_alias("ent"); set_short("A moss covered ent"); set_long("It's hard to say, what this thing is, because it's covered with moss. Undoubtedly it's some sort of a tree, but it's not a regular tree. You can perceive its strange face, its soft hands and its big brown feets.\n"); set_al(40); set_gender(0); set_race("ent"); set_aggressive(0); }
19.037037
230
0.632296
e8e9af7a9939814d2104306b132939bf96b9ab97
14,242
c
C
neon/src/core/wavefront.c
m1nuz/neon-core
171ccb939387d5f8cce55f3911451530b6bba58e
[ "MIT" ]
null
null
null
neon/src/core/wavefront.c
m1nuz/neon-core
171ccb939387d5f8cce55f3911451530b6bba58e
[ "MIT" ]
null
null
null
neon/src/core/wavefront.c
m1nuz/neon-core
171ccb939387d5f8cce55f3911451530b6bba58e
[ "MIT" ]
null
null
null
#include <stdio.h> #include <assert.h> #include <string.h> #include <locale.h> #include <memtrack.h> #include "core/common.h" #include "core/wavefront.h" #include "core/logerr.h" #include "core/rwtext.h" //#define WAVEFRONT_DEBUG #ifdef WAVEFRONT_DEBUG #define wavefront_print(fmt, ...) printf(fmt, __VA_ARGS__) #else #define wavefront_print(fmt, ...) #endif typedef float float2[2]; typedef float float3[3]; typedef float float4[4]; typedef int int2[2]; typedef int int3[3]; typedef int int4[4]; struct Face { int3 positions; int3 normals; int3 uvs; }; struct Wavefront { float3 *positions; float3 *normals; float2 *uvs; struct Face *faces; size_t num_positions; size_t num_normals; size_t num_uvs; size_t num_faces; int vf; }; static void update_wavefront_info(struct Wavefront *wavefront, SDL_RWops *fp) { assert(wavefront != NULL); assert(wavefront != NULL); wavefront->vf = -1; char buf[WAVEFRONT_READ_BUFFER_SIZE]; while (!rweof(fp)) { memset(buf, 0, sizeof(buf)); rwgets(buf, sizeof(buf), fp); char *ptr; char *p = NULL; int v[3] = {0}, n[3] = {0}, t[3] = {0}; switch (buf[0]) { case 'v': switch (buf[1]) { case ' ': wavefront->num_positions++; break; case 'n': wavefront->num_normals++; break; case 't': wavefront->num_uvs++; break; } break; case 'f': p = strtok_r(buf + 1, " \n", &ptr); if (sscanf(p, "%d/%d/%d", &v[0], &t[0], &n[0]) == 3) { wavefront->vf = VF_V3T2N3; } else if (strstr(p, "//")) { wavefront->vf = VF_V3N3; } else if (sscanf(p, "%d/%d", &v[0], &t[0]) == 2) { wavefront->vf = VF_V3T2; } else { wavefront->vf = VF_V3; } wavefront->num_faces++; break; } } SDL_RWseek(fp, 0, RW_SEEK_SET); #ifdef WAVEFRONT_DEBUG switch (wavefront->vf) { case VF_V3: puts("format V3"); break; case VF_V3N3: puts("format V3N3"); break; case VF_V3T2: puts("format V3T2"); break; case VF_V3T2N3: puts("format V3T2N3"); break; default: fprintf(stderr, "ERROR: unknown vertex format\n"); exit(1); break; } printf("positions %d\n", wavefront->num_positions); printf("uv %d\n", wavefront->num_uvs); printf("normals %d\n", wavefront->num_normals); printf("faces %d\n", wavefront->num_faces); #else // NO WAVEFRONT_DEBUG if (wavefront->vf == -1) { LOG_CRITICAL("unknown vertex format %d\n", wavefront->vf); exit(EXIT_FAILURE); } #endif // NO WAVEFRONT_DEBUG } static void alloc_wavefront(struct Wavefront *wavefront) { assert(wavefront != NULL); wavefront->positions = malloc(sizeof(float3) * wavefront->num_positions); wavefront->uvs = malloc(sizeof(float2) * wavefront->num_uvs); wavefront->normals = malloc(sizeof(float3) * wavefront->num_normals); wavefront->faces = malloc(sizeof(struct Face) * wavefront->num_faces); } static void free_wavefront(struct Wavefront *wavefront) { assert(wavefront != NULL); free(wavefront->positions); wavefront->positions = NULL; free(wavefront->uvs); wavefront->uvs = NULL; free(wavefront->normals); wavefront->normals = NULL; free(wavefront->faces); wavefront->faces = NULL; wavefront->num_positions = 0; wavefront->num_uvs = 0; wavefront->num_normals = 0; wavefront->num_faces = 0; } static v3_t * build_v3(const struct Wavefront *wavefront) { assert(wavefront != NULL); int count = (wavefront->num_faces); v3_t *vertices = malloc(sizeof(v3_t) * count * 3); memset(vertices, 0, sizeof(v3_t) * count * 3); for (int i = 0; i < count; i++) { memcpy(vertices[i * 3 + 0].position, wavefront->positions[wavefront->faces[i].positions[0] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 1].position, wavefront->positions[wavefront->faces[i].positions[1] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 2].position, wavefront->positions[wavefront->faces[i].positions[2] - 1], sizeof(float3)); } return vertices; } static v3n3_t * build_v3n3(const struct Wavefront *wavefront) { assert(wavefront != NULL); int count = (wavefront->num_faces); v3n3_t *vertices = malloc(sizeof(v3n3_t) * count * 3); memset(vertices, 0, sizeof(v3n3_t) * count * 3); for (int i = 0; i < count; i++) { memcpy(vertices[i * 3 + 0].position, wavefront->positions[wavefront->faces[i].positions[0] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 1].position, wavefront->positions[wavefront->faces[i].positions[1] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 2].position, wavefront->positions[wavefront->faces[i].positions[2] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 0].normal, wavefront->positions[wavefront->faces[i].normals[0] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 1].normal, wavefront->positions[wavefront->faces[i].normals[1] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 2].normal, wavefront->positions[wavefront->faces[i].normals[2] - 1], sizeof(float3)); } return vertices; } static v3t2_t * build_v3t2(const struct Wavefront *wavefront) { assert(wavefront != NULL); int count = (wavefront->num_faces); v3t2_t *vertices = malloc(sizeof(v3t2_t) * count * 3); memset(vertices, 0, sizeof(v3t2_t) * count * 3); for (int i = 0; i < count; i++) { memcpy(vertices[i * 3 + 0].position, wavefront->positions[wavefront->faces[i].positions[0] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 1].position, wavefront->positions[wavefront->faces[i].positions[1] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 2].position, wavefront->positions[wavefront->faces[i].positions[2] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 0].texcoord, wavefront->positions[wavefront->faces[i].uvs[0] - 1], sizeof(float2)); memcpy(vertices[i * 3 + 1].texcoord, wavefront->positions[wavefront->faces[i].uvs[1] - 1], sizeof(float2)); memcpy(vertices[i * 3 + 2].texcoord, wavefront->positions[wavefront->faces[i].uvs[2] - 1], sizeof(float2)); } return vertices; } static v3t2n3_t * build_v3t2n3(const struct Wavefront *wavefront) { assert(wavefront != NULL); int count = (wavefront->num_faces); v3t2n3_t *vertices = malloc(sizeof(v3t2n3_t) * count * 3); memset(vertices, 0, sizeof(v3t2n3_t) * count * 3); for (int i = 0; i < count; i++) { memcpy(vertices[i * 3 + 0].position, wavefront->positions[wavefront->faces[i].positions[0] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 1].position, wavefront->positions[wavefront->faces[i].positions[1] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 2].position, wavefront->positions[wavefront->faces[i].positions[2] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 0].texcoord, wavefront->positions[wavefront->faces[i].uvs[0] - 1], sizeof(float2)); memcpy(vertices[i * 3 + 1].texcoord, wavefront->positions[wavefront->faces[i].uvs[1] - 1], sizeof(float2)); memcpy(vertices[i * 3 + 2].texcoord, wavefront->positions[wavefront->faces[i].uvs[2] - 1], sizeof(float2)); memcpy(vertices[i * 3 + 0].normal, wavefront->positions[wavefront->faces[i].normals[0] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 1].normal, wavefront->positions[wavefront->faces[i].normals[1] - 1], sizeof(float3)); memcpy(vertices[i * 3 + 2].normal, wavefront->positions[wavefront->faces[i].normals[2] - 1], sizeof(float3)); } return vertices; } static unsigned short * build_indices(struct Wavefront *wavefront) { assert(wavefront != NULL); int count = (wavefront->num_faces); unsigned short *indices = malloc(sizeof(unsigned short) * count * 3); for (int i = 0; i < count * 3; i++) { indices[i] = i; } return indices; } extern int load_wavefront(SDL_RWops *rw, void **_vertices, int *_vertices_num, void **_indices, int *_indices_num) { assert(rw != NULL); assert(_vertices != NULL); assert(_vertices_num != NULL); assert(_indices != NULL); assert(_indices_num != NULL); if(!rw) { LOG_ERROR("Can't open file %p\n", (void*)rw); return -1; } setlocale(LC_ALL, "C"); struct Wavefront wavefront = {0}; update_wavefront_info(&wavefront, rw); alloc_wavefront(&wavefront); char buf[WAVEFRONT_READ_BUFFER_SIZE]; size_t positions_count = 0; size_t normals_count = 0; size_t uvs_count = 0; size_t faces_count = 0; while(!rweof(rw)) { memset(buf, 0, sizeof(buf)); rwgets(buf, sizeof(buf), rw); char *ptr; char *p = NULL; int v[3] = {0}, n[3] = {0}, t[3] = {0}; struct Face f = {{0}, {0}, {0}}; switch (buf[0]) { case 'v': switch (buf[1]) { case ' ': p = strtok_r(buf, " \n", &ptr); p = strtok_r(0, " \n", &ptr); wavefront.positions[positions_count][0] = atof(p); p = strtok_r(0, " \n", &ptr); wavefront.positions[positions_count][1] = atof(p); p = strtok_r(0, " \n", &ptr); wavefront.positions[positions_count][2] = atof(p); wavefront_print("v %f %f %f\n", wavefront.positions[positions_count][0], wavefront.positions[positions_count][1], wavefront.positions[positions_count][2]); positions_count++; break; case 'n': p = strtok_r(buf, " \n", &ptr); p = strtok_r(0, " \n", &ptr); wavefront.normals[normals_count][0] = atof(p); p = strtok_r(0, " \n", &ptr); wavefront.normals[normals_count][1] = atof(p); p = strtok_r(0, " \n", &ptr); wavefront.normals[normals_count][2] = atof(p); wavefront_print("vn %f %f %f\n", wavefront.normals[normals_count][0], wavefront.normals[normals_count][1], wavefront.normals[normals_count][2]); normals_count++; break; case 't': p = strtok_r(buf, " \n", &ptr); p = strtok_r(0, " \n", &ptr); wavefront.uvs[uvs_count][0] = atof(p); p = strtok_r(0, " \n", &ptr); wavefront.uvs[uvs_count][1] = atof(p); wavefront_print("vt %f %f\n", wavefront.uvs[uvs_count][0], wavefront.uvs[uvs_count][1]); uvs_count++; break; } break; case 'f': p = strtok_r(buf + 1, " \n", &ptr); if (sscanf(p, "%d/%d/%d", &v[0], &t[0], &n[0]) == 3) { wavefront_print("%d/%d/%d ", v[0], t[0], n[0]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d/%d/%d", &v[1], &t[1], &n[1]); wavefront_print("%d/%d/%d ", v[1], t[1], n[1]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d/%d/%d", &v[2], &t[2], &n[2]); wavefront_print("%d/%d/%d\n", v[2], t[2], n[2]); } else if (strstr(p, "//")) { sscanf(p, "%d//%d", &v[0], &n[0]); wavefront_print("%d//%d ", v[0], n[0]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d//%d", &v[1], &n[1]); wavefront_print("%d//%d ", v[1], n[1]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d//%d", &v[2], &n[2]); wavefront_print("%d//%d\n", v[2], n[2]); } else if (sscanf(p, "%d/%d", &v[0], &t[0]) == 2) { sscanf(p, "%d/%d", &v[0], &t[0]); wavefront_print("%d/%d ", v[0], t[0]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d/%d", &v[1], &t[1]); wavefront_print("%d/%d ", v[1], t[1]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d/%d", &v[2], &t[2]); wavefront_print("%d/%d\n", v[2], t[2]); } else { sscanf(p, "%d", &v[0]); wavefront_print("%d ", v[0]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d", &v[1]); wavefront_print("%d ", v[1]); p = strtok_r(0, " \n", &ptr); sscanf(p, "%d", &v[2]); wavefront_print("%d\n", v[2]); } memcpy(f.positions, v, sizeof(v)); memcpy(f.uvs, t, sizeof(t)); memcpy(f.normals, n, sizeof(n)); memcpy(&wavefront.faces[faces_count], &f, sizeof(f)); faces_count++; break; } } switch (wavefront.vf) { case VF_V3: *_vertices = build_v3(&wavefront); *_indices = build_indices(&wavefront); *_vertices_num = faces_count * 3; *_indices_num = faces_count * 3; break; case VF_V3N3: *_vertices = build_v3n3(&wavefront); *_indices = build_indices(&wavefront); *_vertices_num = faces_count * 3; *_indices_num = faces_count * 3; break; case VF_V3T2: *_vertices = build_v3t2(&wavefront); *_indices = build_indices(&wavefront); *_vertices_num = faces_count * 3; *_indices_num = faces_count * 3; break; case VF_V3T2N3: *_vertices = build_v3t2n3(&wavefront); *_indices = build_indices(&wavefront); *_vertices_num = faces_count * 3; *_indices_num = faces_count * 3; break; default: LOG_ERROR("%s\n", "Unknown vertex format"); } free_wavefront(&wavefront); SDL_RWclose(rw); setlocale(LC_ALL, ""); return wavefront.vf; }
31.09607
121
0.537354
d785a7a5395a1c3fcc165054d989c2cf71d01ef6
5,897
h
C
src/net/listener.h
ddxy18/xyco
7682652f17b82e2370fa7af17635c5d0c470efe0
[ "MIT" ]
null
null
null
src/net/listener.h
ddxy18/xyco
7682652f17b82e2370fa7af17635c5d0c470efe0
[ "MIT" ]
17
2021-10-30T06:10:46.000Z
2022-03-18T06:16:15.000Z
src/net/listener.h
ddxy18/xyco
7682652f17b82e2370fa7af17635c5d0c470efe0
[ "MIT" ]
null
null
null
#ifndef XYCO_NET_LISTENER_H_ #define XYCO_NET_LISTENER_H_ #include <unistd.h> #include "io/mod.h" #include "net/socket.h" #include "runtime/future.h" #include "runtime/registry.h" namespace xyco::net { class TcpStream; class TcpListener; class TcpSocket { template <typename T> using Future = runtime::Future<T>; friend struct fmt::formatter<TcpSocket>; public: auto bind(SocketAddr addr) -> Future<io::IoResult<void>>; auto connect(SocketAddr addr) -> Future<io::IoResult<TcpStream>>; auto listen(int backlog) -> Future<io::IoResult<TcpListener>>; auto set_reuseaddr(bool reuseaddr) -> io::IoResult<void>; auto set_reuseport(bool reuseport) -> io::IoResult<void>; static auto new_v4() -> io::IoResult<TcpSocket>; static auto new_v6() -> io::IoResult<TcpSocket>; private: TcpSocket(Socket &&socket); Socket socket_; }; class TcpStream { template <typename T> using Future = runtime::Future<T>; friend struct fmt::formatter<TcpStream>; friend class TcpSocket; friend class TcpListener; public: static auto connect(SocketAddr addr) -> Future<io::IoResult<TcpStream>>; template <typename Iterator> auto read(Iterator begin, Iterator end) -> Future<io::IoResult<uintptr_t>> { using CoOutput = io::IoResult<uintptr_t>; class Future : public runtime::Future<CoOutput> { public: Future(Iterator begin, Iterator end, net::TcpStream *self) : runtime::Future<CoOutput>(nullptr), begin_(begin), end_(end), self_(self) {} auto poll(runtime::Handle<void> self) -> runtime::Poll<CoOutput> override { auto extra = std::get<runtime::IoExtra>(self_->event_->extra_); if (extra.readable()) { auto n = ::read(self_->socket_.into_c_fd(), &*begin_, std::distance(begin_, end_)); if (n != -1) { INFO("read {} bytes from {}", n, self_->socket_); return runtime::Ready<CoOutput>{CoOutput::ok(n)}; } if (errno != EAGAIN && errno != EWOULDBLOCK) { return runtime::Ready<CoOutput>{ CoOutput::err(io::into_sys_result(-1).unwrap_err())}; } } extra.clear_readable(); self_->event_->future_ = this; return runtime::Pending(); } private: net::TcpStream *self_; Iterator begin_; Iterator end_; }; auto result = co_await Future(begin, end, this); event_->future_ = nullptr; co_return result; } template <typename Iterator> auto write(Iterator begin, Iterator end) -> Future<io::IoResult<uintptr_t>> { using CoOutput = io::IoResult<uintptr_t>; class Future : public runtime::Future<CoOutput> { public: Future(Iterator begin, Iterator end, TcpStream *self) : runtime::Future<CoOutput>(nullptr), begin_(begin), end_(end), self_(self) {} auto poll(runtime::Handle<void> self) -> runtime::Poll<CoOutput> override { auto extra = std::get<runtime::IoExtra>(self_->event_->extra_); if (extra.writeable()) { auto n = ::write(self_->socket_.into_c_fd(), &*begin_, std::distance(begin_, end_)); auto nbytes = io::into_sys_result(n).map( [](auto n) -> uintptr_t { return static_cast<uintptr_t>(n); }); INFO("write {} bytes to {}", n, self_->socket_); return runtime::Ready<CoOutput>{nbytes}; } extra.clear_writeable(); self_->event_->future_ = this; return runtime::Pending(); } private: TcpStream *self_; Iterator begin_; Iterator end_; }; auto result = co_await Future(begin, end, this); event_->future_ = nullptr; co_return result; } static auto flush() -> Future<io::IoResult<void>>; [[nodiscard]] auto shutdown(io::Shutdown shutdown) const -> Future<io::IoResult<void>>; TcpStream(const TcpStream &tcp_stream) = delete; TcpStream(TcpStream &&tcp_stream) noexcept = default; auto operator=(const TcpStream &tcp_stream) -> TcpStream & = delete; auto operator=(TcpStream &&tcp_stream) noexcept -> TcpStream & = default; ~TcpStream(); private: explicit TcpStream(Socket &&socket, runtime::IoExtra::State state); Socket socket_; std::unique_ptr<runtime::Event> event_; }; class TcpListener { friend class TcpSocket; friend struct fmt::formatter<TcpListener>; template <typename T> using Future = runtime::Future<T>; public: static auto bind(SocketAddr addr) -> Future<io::IoResult<TcpListener>>; auto accept() -> Future<io::IoResult<std::pair<TcpStream, SocketAddr>>>; TcpListener(const TcpListener &tcp_stream) = delete; TcpListener(TcpListener &&tcp_stream) noexcept = default; auto operator=(const TcpListener &tcp_stream) -> TcpListener & = delete; auto operator=(TcpListener &&tcp_stream) noexcept -> TcpListener & = default; ~TcpListener(); private: TcpListener(Socket &&socket); Socket socket_; std::unique_ptr<runtime::Event> event_; }; } // namespace xyco::net template <> struct fmt::formatter<xyco::net::TcpSocket> : public fmt::formatter<bool> { template <typename FormatContext> auto format(const xyco::net::TcpSocket &tcp_socket, FormatContext &ctx) const -> decltype(ctx.out()); }; template <> struct fmt::formatter<xyco::net::TcpStream> : public fmt::formatter<bool> { template <typename FormatContext> auto format(const xyco::net::TcpStream &tcp_stream, FormatContext &ctx) const -> decltype(ctx.out()); }; template <> struct fmt::formatter<xyco::net::TcpListener> : public fmt::formatter<bool> { template <typename FormatContext> auto format(const xyco::net::TcpListener &tcp_listener, FormatContext &ctx) const -> decltype(ctx.out()); }; #endif // XYCO_NET_LISTENER_H_
28.350962
79
0.645243
ba9c38387dcafcb290870258151243dcf0681abc
312
h
C
include/escape.h
HanwGeek/tiger-cc
0c7787470d5ec7d4029c639a6a80e5be19aeeabe
[ "MIT" ]
3
2020-05-31T09:05:59.000Z
2021-12-19T14:52:26.000Z
include/escape.h
HanwGeek/tiger-cc
0c7787470d5ec7d4029c639a6a80e5be19aeeabe
[ "MIT" ]
null
null
null
include/escape.h
HanwGeek/tiger-cc
0c7787470d5ec7d4029c639a6a80e5be19aeeabe
[ "MIT" ]
null
null
null
/* * @Author: HanwGeek * @Github: https://github.com/HanwGeek * @Description: Escape variable search module header file. * @Date: 2019-11-01 21:40:10 * @Last Modified: 2020-02-25 20:11:56 */ #ifndef T_ESCAPE_H_ #define T_ESCAPE_H_ #include "absyn.h" #include "env.h" void ESC_findEscape(A_exp e); #endif
19.5
59
0.705128
c9260f0e27fd3bc896dc63a3a1f899b5d51f8c3d
2,652
h
C
source/names.h
dos-games/vanilla-shadow_warrior
bf781c586c7e9cda0cfb0b3bc56983f535cb75c4
[ "Unlicense" ]
18
2015-07-21T03:53:29.000Z
2021-12-20T18:42:56.000Z
source/names.h
Azarien/shadow-warrior
bf781c586c7e9cda0cfb0b3bc56983f535cb75c4
[ "Unlicense" ]
null
null
null
source/names.h
Azarien/shadow-warrior
bf781c586c7e9cda0cfb0b3bc56983f535cb75c4
[ "Unlicense" ]
6
2016-10-17T09:06:22.000Z
2022-02-11T10:02:17.000Z
//------------------------------------------------------------------------- /* Copyright (C) 1997, 2005 - 3D Realms Entertainment This file is part of Shadow Warrior version 1.2 Shadow Warrior is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Original Source: 1997 - Frank Maddin and Jim Norwood Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- //Be careful when changing this file - it is parsed by Editart and Build. #define ALPHABET 85 #define MENU_MAIN 295 #define MENU_OPTION 296 #define MENU_WHICH 297 #define MENU_CURSOR 298 #define DART1 2000 #define DART2 2001 #define DART3 2002 #define DART4 2003 #define DART 2004 #define FIRE1 2005 #define FIRE2 2006 #define FIRE3 2007 #define FIRE4 2008 #define FIRE5 2009 #define FIREBALL1 2010 #define FIREBALL2 2011 #define FIREBALL3 2012 #define FIREBALL4 2013 #define FLAMES1 2014 #define FLAMES2 2015 #define FLAMES3 2016 #define FLAMES4 2017 #define FLAMES5 2018 #define GAS1 2019 #define GAS2 2020 #define GAS3 2021 #define GAS4 2022 #define GAS5 2023 #define GAS6 2024 #define GAS7 2025 #define GASCLOUD1 2026 #define GASCLOUD2 2027 #define GASCLOUD3 2028 #define GASCLOUD4 2029 #define GASCLOUD5 2030 #define GASCLOUD6 2031 #define GASCLOUD7 2032 #define GASCLOUD8 2033 #define GASCLOUD9 2034 #define LIGHT1 2035 #define LIGHT2 2036 #define LIGHT3 2037 #define LIGHT4 2038 #define LIGHT5 2039 #define LIGHT6 2040 #define ELECTRO1 2041 #define ELECTRO2 2042 #define ELECTRO3 2043 #define RIFLE1 2044 #define RIFLE2 2045 #define RIFLE3 2046 #define DON'TUSE...EXTRA 2047 #define RIFLE4 2048 #define CARTRIGE3 2053 #define STATUE1 2054 #define STATUE2 2055 #define STATUE3 2056 #define STATUE4 2057 #define SWORD3 2065 #define SWORD4 2066 #define SWORD1 2067 #define SWORD2 2068 #define SWORD5 2069 #define BLACK!!!!!!!!!!! 2306 #define FragBarErase 2375 #define FragBarErase2 2376
27.915789
76
0.71908
2a0e7eb0a513a69798a49cc53de968149181c402
532
h
C
RHPReviewCell/RHPReviewCell.h
robertherdzik/RHPreviewCell
c8c2a75905e250c84836bcc736fe40e4cc3cb3eb
[ "MIT" ]
417
2016-09-25T06:53:18.000Z
2022-02-06T10:03:54.000Z
RHPReviewCell/RHPReviewCell.h
robertherdzik/RHPreviewCell
c8c2a75905e250c84836bcc736fe40e4cc3cb3eb
[ "MIT" ]
3
2016-11-03T19:33:47.000Z
2019-06-01T08:04:22.000Z
RHPReviewCell/RHPReviewCell.h
robertherdzik/RHPreviewCell
c8c2a75905e250c84836bcc736fe40e4cc3cb3eb
[ "MIT" ]
20
2016-10-29T13:11:26.000Z
2019-11-13T19:21:32.000Z
// // RHPreviewCell.h // RHPreviewCell // // Created by Robert Herdzik on 11/01/2018. // Copyright © 2018 Robert Herdzik. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for RHPreviewCell. FOUNDATION_EXPORT double RHPreviewCellVersionNumber; //! Project version string for RHPreviewCell. FOUNDATION_EXPORT const unsigned char RHPreviewCellVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <RHPreviewCell/PublicHeader.h>
26.6
138
0.774436
ba6cd31f14ce221c33d413ff3160e4a556eb7292
366
h
C
Example/Pods/Target Support Files/EHLoaders/EHLoaders-umbrella.h
waterflowseast/EHLoaders
361cca57570f9cf1512c88aba6f7c600687b7085
[ "MIT" ]
null
null
null
Example/Pods/Target Support Files/EHLoaders/EHLoaders-umbrella.h
waterflowseast/EHLoaders
361cca57570f9cf1512c88aba6f7c600687b7085
[ "MIT" ]
null
null
null
Example/Pods/Target Support Files/EHLoaders/EHLoaders-umbrella.h
waterflowseast/EHLoaders
361cca57570f9cf1512c88aba6f7c600687b7085
[ "MIT" ]
null
null
null
#import <UIKit/UIKit.h> #import "EHFootLoader.h" #import "EHHeadLoader.h" #import "EHLoaders.h" #import "EHLoadersDefs.h" #import "EHLoaderView.h" #import "UIScrollView+EHExtension.h" #import "UIScrollView+EHLoaders.h" #import "UIView+EHExtension.h" FOUNDATION_EXPORT double EHLoadersVersionNumber; FOUNDATION_EXPORT const unsigned char EHLoadersVersionString[];
24.4
63
0.800546
688aca23cdeb85ff0a35e94a53ae6c82d115f737
796
c
C
msp430f5529lp/board_ext.c
callalilychen/TIOT
af67f783600789d21cdd96d6a3dc07c475bbb3c8
[ "BSD-2-Clause" ]
null
null
null
msp430f5529lp/board_ext.c
callalilychen/TIOT
af67f783600789d21cdd96d6a3dc07c475bbb3c8
[ "BSD-2-Clause" ]
null
null
null
msp430f5529lp/board_ext.c
callalilychen/TIOT
af67f783600789d21cdd96d6a3dc07c475bbb3c8
[ "BSD-2-Clause" ]
null
null
null
#include "board_ext.h" /*! * \brief Set all pins as output pin * * Make sure there are no floating input I/Os. * */ void ports_init(void){ P1SEL = 0; P1DIR = 0xFF; P1OUT = 0; /* Port1 Output: 00000000 = 0x00 */ P2SEL = 0; P2DIR = 0xFF; P2OUT = 0; /* Port2 Output: 00000000 = 0x00 */ P3SEL = 0; P3DIR = 0xFF; P3OUT = 0; /* Port3 Output: 00000000 = 0x00 */ P4SEL = 0; P4DIR = 0xFF; P4OUT = 0; /* Port4 Output: 00000000 = 0x00 */ P5SEL = 0; P5DIR = 0xFF; P5OUT = 0; /* Port5 Output: 00000000 = 0x00 */ P6SEL = 0; P6DIR = 0xFF; P6OUT = 0; /* Port6 Output: 00000000 = 0x00 */ P7SEL = 0; P7DIR = 0xFF; P7OUT = 0; /* Port7 Output: 00000000 = 0x00 */ P8SEL = 0; P8DIR = 0xFF; P8OUT = 0; /* Port8 Output: 00000000 = 0x00 */ }
22.742857
51
0.561558
71e59cc8c052f138fc41dfea7438eb585f0845b1
1,463
h
C
FindSecret/Classes/Native/SimpleGif_SimpleGif_Gif_e844532692.h
GodIsWord/NewFindSecret
4f98f316d29936380f9665d6a6d89962d9ee5478
[ "MIT" ]
null
null
null
FindSecret/Classes/Native/SimpleGif_SimpleGif_Gif_e844532692.h
GodIsWord/NewFindSecret
4f98f316d29936380f9665d6a6d89962d9ee5478
[ "MIT" ]
null
null
null
FindSecret/Classes/Native/SimpleGif_SimpleGif_Gif_e844532692.h
GodIsWord/NewFindSecret
4f98f316d29936380f9665d6a6d89962d9ee5478
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_Object3080106164.h" // SimpleGif.Data.GifFrame struct GifFrame_t1833165212; // SimpleGif.Gif/E struct E_t3714578548; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // SimpleGif.Gif/e struct e_t844532692 : public Il2CppObject { public: // SimpleGif.Data.GifFrame SimpleGif.Gif/e::A GifFrame_t1833165212 * ___A_0; // SimpleGif.Gif/E SimpleGif.Gif/e::A E_t3714578548 * ___A_1; public: inline static int32_t get_offset_of_A_0() { return static_cast<int32_t>(offsetof(e_t844532692, ___A_0)); } inline GifFrame_t1833165212 * get_A_0() const { return ___A_0; } inline GifFrame_t1833165212 ** get_address_of_A_0() { return &___A_0; } inline void set_A_0(GifFrame_t1833165212 * value) { ___A_0 = value; Il2CppCodeGenWriteBarrier(&___A_0, value); } inline static int32_t get_offset_of_A_1() { return static_cast<int32_t>(offsetof(e_t844532692, ___A_1)); } inline E_t3714578548 * get_A_1() const { return ___A_1; } inline E_t3714578548 ** get_address_of_A_1() { return &___A_1; } inline void set_A_1(E_t3714578548 * value) { ___A_1 = value; Il2CppCodeGenWriteBarrier(&___A_1, value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
23.983607
107
0.749829
d5b1d55ce8ef386ed44a92efcab352bb6e18b82b
15,902
c
C
src/server/Server.c
riemann89/SSLv3.0
8280b6827a9fc7670ec48a4b4b75017e0e863005
[ "Apache-2.0" ]
3
2016-02-19T12:34:02.000Z
2016-11-25T20:05:36.000Z
src/server/Server.c
riemann89/SSLv3.0-filebased
8280b6827a9fc7670ec48a4b4b75017e0e863005
[ "Apache-2.0" ]
2
2019-11-24T13:16:13.000Z
2019-11-24T13:16:41.000Z
src/server/Server.c
riemann89/SSLv3.0-filebased
8280b6827a9fc7670ec48a4b4b75017e0e863005
[ "Apache-2.0" ]
null
null
null
// // Server.c // SSLv3.0 // // Created by Giuseppe Giffone on 16/02/16. // Copyright © 2016 Giuseppe Giffone. All rights reserved. // #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <openssl/rand.h> #include <openssl/md5.h> #include <openssl/dh.h> #include <openssl/bn.h> #include "SSL_functions.h" #include "networking.h" #include "crypto_binding.h" #include "utilities.h" int main(int argc, const char *argv[]){ //Declaration ClientServerHello *server_hello, *client_hello; Handshake *handshake, *client_handshake; RecordLayer *record, *client_message, *temp_record; ClientKeyExchange *client_key_exchange; ServerKeyExchange *server_key_exchange; Certificate *certificate; Finished finished; CipherSuite *ciphersuite_choosen; Talker sender; int phase, key_block_size, len_parameters,dec_message_len, enc_message_len, pre_master_secret_size; uint8_t ciphersuite_code; uint8_t *key_block,*dec_message,*enc_message, *mac, *mac_test, *pre_master_secret, *master_secret,*sha_1, *md5_1, *sha_fin, *md5_fin, *client_write_MAC_secret, session_Id[4]; MD5_CTX md5; SHA_CTX sha; DH *dh, **dhp; BIGNUM *pub_key_client; EVP_PKEY *private_key; //Initialization server_hello = NULL; client_hello = NULL; handshake = NULL; client_handshake = NULL; record = NULL; client_message = NULL; temp_record = NULL; client_key_exchange = NULL; server_key_exchange = NULL; certificate = NULL; ciphersuite_choosen = NULL; sender = server; phase = 0; key_block_size = 0; len_parameters = 0; dec_message_len = 0; enc_message_len = 0; pre_master_secret_size = 0; ciphersuite_code = 0; key_block = NULL; dec_message = NULL; enc_message = NULL; mac = NULL; mac_test = NULL; pre_master_secret = NULL; sha_1 = NULL; md5_1 = NULL; sha_fin = NULL; md5_fin = NULL; master_secret = NULL; SHA1_Init(&sha); MD5_Init(&md5); dh = NULL; dhp = &dh; pub_key_client = NULL; private_key = NULL; ///////////////////////////////////////////////////////////////PHASE 1////////////////////////////////////////////////////////// while(CheckCommunication() == client){} client_message = readchannel(); printRecordLayer(client_message); SHA1_Update(&sha, client_message->message, sizeof(uint8_t)*(client_message->length-5)); MD5_Update(&md5, client_message->message, sizeof(uint8_t)*(client_message->length-5)); client_handshake = RecordToHandshake(client_message); client_hello = HandshakeToClientServerHello(client_handshake); FreeRecordLayer(client_message); FreeHandshake(client_handshake); //Construction Server Hello RAND_bytes(session_Id, 4); ciphersuite_code = chooseChipher(client_hello, "ServerConfig/All"); server_hello = ClientServerHello_init(SERVER_HELLO, Bytes_To_Int(4, session_Id), &ciphersuite_code, 1); //Wrapping handshake = ClientServerHelloToHandshake(server_hello); record = HandshakeToRecordLayer(handshake); SHA1_Update(&sha,record->message, sizeof(uint8_t)*(record->length-5)); MD5_Update(&md5,record->message, sizeof(uint8_t)*(record->length-5)); ciphersuite_choosen = CodeToCipherSuite(ciphersuite_code); //TODO: eliminare la riga dopo usata per i test //ciphersuite_choosen = CodeToCipherSuite(0x14); //TODO: riga su... //Sending server hello and open the communication to the client. sendPacketByte(record); printRecordLayer(record); FreeHandshake(handshake); FreeRecordLayer(record); OpenCommunication(client); ///////////////////////////////////////////////////////////////PHASE 2////////////////////////////////////////////////////////// while(CheckCommunication() == client){} certificate = Certificate_init(ciphersuite_choosen); handshake = CertificateToHandshake(certificate); record = HandshakeToRecordLayer(handshake); SHA1_Update(&sha,record->message,sizeof(uint8_t)*(record->length-5)); MD5_Update(&md5,record->message,sizeof(uint8_t)*(record->length-5)); sendPacketByte(record); printRecordLayer(record); FreeCertificate(certificate); FreeHandshake(handshake); FreeRecordLayer(record); OpenCommunication(client); while(CheckCommunication() == client){} //SERVER KEY EXCHANGE if (ciphersuite_choosen->key_exchange_algorithm == DH_){ server_key_exchange = ServerKeyExchange_init(ciphersuite_choosen, private_key, client_hello, server_hello,dhp); handshake = ServerKeyExchangeToHandshake(server_key_exchange); //free(dhp); record = HandshakeToRecordLayer(handshake); SHA1_Update(&sha,record->message,sizeof(uint8_t)*(record->length-5)); MD5_Update(&md5,record->message,sizeof(uint8_t)*(record->length-5)); sendPacketByte(record); printRecordLayer(record); FreeServerKeyExchange(server_key_exchange); FreeHandshake(handshake); FreeRecordLayer(record); OpenCommunication(client); while(CheckCommunication() == client){} } //CERTIFICATE REQUEST //SERVER HELLO DONE handshake = ServerDoneToHandshake(); record = HandshakeToRecordLayer(handshake); SHA1_Update(&sha,record->message,sizeof(uint8_t)*(record->length-5)); MD5_Update(&md5,record->message,sizeof(uint8_t)*(record->length-5)); sendPacketByte(record); printRecordLayer(record); FreeHandshake(handshake); FreeRecordLayer(record); OpenCommunication(client); ///////////////////////////////////////////////////////////////PHASE 3////////////////////////////////////////////////////////// phase = 3; while(phase == 3){ while(CheckCommunication() == client){} client_message = readchannel(); printRecordLayer(client_message); client_handshake = RecordToHandshake(client_message); switch (client_handshake->msg_type) { case CERTIFICATE: certificate = HandshakeToCertificate(client_handshake); OpenCommunication(client); break; case CLIENT_KEY_EXCHANGE: len_parameters = client_handshake->length - 4; client_key_exchange = HandshakeToClientKeyExchange(client_handshake); switch (ciphersuite_choosen->key_exchange_algorithm){ case RSA_: private_key = EVP_PKEY_new(); FILE *key_file; key_file = NULL; key_file = fopen("private_keys/RSA_server.key","rb"); private_key = PEM_read_PrivateKey(key_file, &private_key, NULL, NULL); pre_master_secret = AsymDec(EVP_PKEY_RSA, client_key_exchange->parameters, len_parameters, (size_t*)&pre_master_secret_size, private_key); EVP_PKEY_free(private_key); break; case DH_: pub_key_client = BN_bin2bn(client_key_exchange->parameters, DH_size(dh), NULL); pre_master_secret = (uint8_t*)calloc(DH_size(dh), sizeof(uint8_t)); pre_master_secret_size = DH_compute_key(pre_master_secret, pub_key_client, dh); DH_free(dh); BN_clear_free(pub_key_client); break; default: perror("Client Key Exchange not supported"); exit(1); break; } FreeClientKeyExchange(client_key_exchange); printf("PRE MASTER:\n"); for (int i = 0; i<pre_master_secret_size; i++) { printf("%02X ",pre_master_secret[i]); } printf("\n"); master_secret = MasterSecretGen(pre_master_secret, pre_master_secret_size, client_hello, server_hello); free(pre_master_secret); SHA1_Update(&sha,client_message->message, sizeof(uint8_t)*(client_message->length-5)); MD5_Update(&md5,client_message->message, sizeof(uint8_t)*(client_message->length-5)); printf("MASTER KEY:generated\n"); for (int i=0; i< 48; i++){ printf("%02X ", master_secret[i]); } printf("\n"); //KEYBLOCK GENERATION key_block = KeyBlockGen(master_secret, ciphersuite_choosen, &key_block_size, client_hello, server_hello); FreeClientServerHello(client_hello); FreeClientServerHello(server_hello); printf("\nKEY BLOCK\n"); for (int i=0; i< key_block_size; i++){ printf("%02X ", key_block[i]); } printf("\n\n"); OpenCommunication(client); phase = 4; break; default: perror("ERROR: Unattended message in phase 3.\n"); exit(1); break; } FreeRecordLayer(client_message); FreeHandshake(client_handshake); } ///////////////////////////////////////////////////////////////PHASE 4////////////////////////////////////////////////////////// //CHANGE CIPHER SPEC read while(CheckCommunication() == client){} client_message = readchannel(); printRecordLayer(client_message); FreeRecordLayer(client_message); //FINISHED read OpenCommunication(client); while(CheckCommunication() == client){} client_message = readchannel(); uint8_t length_bytes[4]; int_To_Bytes(client_message->length, length_bytes); printf("ENCRYPED FINISHED: received\n"); printf("%02X ", client_message->type); printf("%02X ", client_message->version.major); printf("%02X ", client_message->version.minor); printf("%02X ", length_bytes[2]); printf("%02X ", length_bytes[3]); for(int i=0; i<client_message->length - 5; i++){ printf("%02X ", client_message->message[i]); } printf("\n\n"); dec_message = DecEncryptPacket(client_message->message, client_message->length - 5, &dec_message_len, ciphersuite_choosen, key_block, client, 0); free(client_message->message); int_To_Bytes(dec_message_len + 5, length_bytes); printf("DECRYPTED FINISHED:\n"); printf("%02X ", client_message->type); printf("%02X ", client_message->version.major); printf("%02X ", client_message->version.minor); printf("%02X ", length_bytes[2]); printf("%02X ", length_bytes[3]); for(int i = 0; i < dec_message_len; i++){ printf("%02X ", dec_message[i]); } printf("\n\n"); //MAC verification client_message->message = dec_message; handshake = RecordToHandshake(client_message); handshake->length = dec_message_len; mac_test = NULL; handshake->length = handshake->length - ciphersuite_choosen->hash_size; client_write_MAC_secret = NULL; client_write_MAC_secret = key_block; mac = dec_message + (dec_message_len - ciphersuite_choosen->hash_size); mac_test = MAC(ciphersuite_choosen, handshake, client_write_MAC_secret); if(ByteCompare(mac, mac_test, ciphersuite_choosen->hash_size)==0){ printf("\nmac verified\n"); } else{ printf("\nmac not verified\n"); exit(1); } free(mac_test); FreeHandshake(handshake); FreeRecordLayer(client_message); //CHANGE CIPHER SPEC send record = ChangeCipherSpecRecord(); sendPacketByte(record); printRecordLayer(record); FreeRecordLayer(record); OpenCommunication(client); while(CheckCommunication() == client){} //FINISHED send SHA1_Update(&sha, &sender, sizeof(uint32_t)); MD5_Update(&md5, &sender, sizeof(uint32_t)); SHA1_Update(&sha,master_secret,sizeof(uint8_t)*48); MD5_Update(&md5,master_secret,sizeof(uint8_t)*48); SHA1_Update(&sha, pad_1,sizeof(uint8_t)*40); MD5_Update(&md5, pad_1,sizeof(uint8_t)*48); md5_1 = calloc(16, sizeof(uint8_t)); sha_1 = calloc(20, sizeof(uint8_t)); SHA1_Final(sha_1,&sha); MD5_Final(md5_1,&md5); SHA1_Init(&sha); MD5_Init(&md5); SHA1_Update(&sha, master_secret,sizeof(uint8_t)*48); SHA1_Update(&sha, pad_2,sizeof(uint8_t)*40); SHA1_Update(&sha, sha_1,sizeof(uint8_t)*20); MD5_Update(&md5, master_secret,sizeof(uint8_t)*48); MD5_Update(&md5, pad_2,sizeof(uint8_t)*48); MD5_Update(&md5, md5_1,sizeof(uint8_t)*16); md5_fin = calloc(16, sizeof(uint8_t)); sha_fin = calloc(20, sizeof(uint8_t)); SHA1_Final(sha_fin, &sha); MD5_Final(md5_fin, &md5); finished.hash = (uint8_t*)calloc(36, sizeof(uint8_t)); memcpy(finished.hash, md5_fin, 16*sizeof(uint8_t)); memcpy(finished.hash + 16, sha_fin, 20*sizeof(uint8_t)); free(md5_1); free(sha_1); free(md5_fin); free(sha_fin); free(master_secret); /* MAC and ENCRYPTION*/ handshake = FinishedToHandshake(&finished); free(finished.hash); temp_record = HandshakeToRecordLayer(handshake); //compute MAC mac = MAC(ciphersuite_choosen, handshake, key_block + ciphersuite_choosen->hash_size); FreeHandshake(handshake); //append MAC and free uint8_t* message_with_mac = (uint8_t*)calloc(temp_record->length + ciphersuite_choosen->hash_size, sizeof(uint8_t)); memcpy(message_with_mac, temp_record->message, temp_record->length - 5); memcpy(message_with_mac + temp_record->length - 5, mac, ciphersuite_choosen->hash_size); free(mac); // update temp_record temp_record->length = temp_record->length + ciphersuite_choosen->hash_size; free(temp_record->message); temp_record->message = message_with_mac; int_To_Bytes(temp_record->length, length_bytes); printf("FINISHED:to sent\n"); printf("%02X ", temp_record->type); printf("%02X ", temp_record->version.major); printf("%02X ", temp_record->version.minor); printf("%02X ", length_bytes[2]); printf("%02X ", length_bytes[3]); for(int i=0; i<temp_record->length - 5; i++){ printf("%02X ", temp_record->message[i]); } printf("\n\n"); enc_message = DecEncryptPacket(temp_record->message, temp_record->length - 5, &enc_message_len, ciphersuite_choosen, key_block, server, 1); free(key_block); // update temp_record free(temp_record->message); temp_record->message = enc_message; temp_record->length = enc_message_len + 5; sendPacketByte(temp_record); int_To_Bytes(temp_record->length, length_bytes); printf("ENCRYPED FINISHED: sent\n"); printf("%02X ", temp_record->type); printf("%02X ", temp_record->version.major); printf("%02X ", temp_record->version.minor); printf("%02X ", length_bytes[2]); printf("%02X ", length_bytes[3]); for(int i=0; i<temp_record->length - 5; i++){ printf("%02X ", temp_record->message[i]); } printf("\n\n"); free(ciphersuite_choosen); FreeRecordLayer(temp_record); OpenCommunication(client); return 0; }
34.872807
178
0.60332
02fa4ae7eb98b4de7dcd9334625bc1aa1926218b
702
h
C
OddEngine/SpriteConfiguration.h
oddpersons/OddEngine
cdd4cc78b713dcb186a8f4ff7cdc3d605990558b
[ "MIT" ]
null
null
null
OddEngine/SpriteConfiguration.h
oddpersons/OddEngine
cdd4cc78b713dcb186a8f4ff7cdc3d605990558b
[ "MIT" ]
null
null
null
OddEngine/SpriteConfiguration.h
oddpersons/OddEngine
cdd4cc78b713dcb186a8f4ff7cdc3d605990558b
[ "MIT" ]
null
null
null
#pragma once #include "pch.h" class DllExport SpriteConfiguration { public: SpriteConfiguration(std::wstring, IWICImagingFactory*); ~SpriteConfiguration(); void CreateDeviceDependentBitmap(ID2D1DeviceContext*); ID2D1Bitmap* GetBitmap(); ID2D1Bitmap* NextSprite(); private: winrt::hstring _ConfigJSON; int SpritesPerRow = 0; int SpritesPerColumn = 0; int UnusedSprites = 0; int SpriteCount = 0; int SpriteWidth = 0; int SpriteHeight = 0; int ParentBitmapX; int ParentBitmapY; int CurrentSprite = 0; winrt::com_ptr<IWICFormatConverter> converter; winrt::com_ptr<IWICBitmapFrameDecode> pBitmapFrame; std::wstring Path; std::vector<winrt::com_ptr<ID2D1Bitmap>> FrameList; };
18.972973
56
0.762108
bee376ac985a5ad37035bd31628f6152bc0e324a
6,040
h
C
common/tcp_connection_serialized.h
btabibian/EdiLogger
02aa2438fad93cffc328b574106be5a5fd74fc90
[ "MIT" ]
null
null
null
common/tcp_connection_serialized.h
btabibian/EdiLogger
02aa2438fad93cffc328b574106be5a5fd74fc90
[ "MIT" ]
null
null
null
common/tcp_connection_serialized.h
btabibian/EdiLogger
02aa2438fad93cffc328b574106be5a5fd74fc90
[ "MIT" ]
null
null
null
#include <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/asio.hpp> #include <vector> #include <boost/thread.hpp> #include <boost/tuple/tuple.hpp> #include <boost/bind.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #ifndef TCP_CONNECTION_SERIALIZED_H_ #define TCP_CONNECTION_SERIALIZED_H_ class tcp_connection_serialized { public: typedef boost::shared_ptr<tcp_connection_serialized> connection_serialized_ptr; /// Constructor. tcp_connection_serialized(boost::asio::io_service& io_service) : socket_(io_service) { } /// Get the underlying socket. Used for making a connection or for accepting /// an incoming connection. boost::asio::ip::tcp::socket& socket() { return socket_; } /// Asynchronously write a data structure to the socket. template <typename T, typename Handler> void async_write(const T& t, Handler handler) { // Serialize the data first so we know how large it is. std::ostringstream archive_stream; boost::archive::text_oarchive archive(archive_stream); archive << t; outbound_data_ = archive_stream.str(); // Format the header. std::ostringstream header_stream; header_stream << std::setw(header_length) << std::hex << outbound_data_.size(); if (!header_stream || header_stream.str().size() != header_length) { // Something went wrong, inform the caller. boost::system::error_code error(boost::asio::error::invalid_argument); socket_.io_service().post(boost::bind(handler, error)); return; } outbound_header_ = header_stream.str(); // Write the serialized data to the socket. We use "gather-write" to send // both the header and the data in a single write operation. std::vector<boost::asio::const_buffer> buffers; buffers.push_back(boost::asio::buffer(outbound_header_)); buffers.push_back(boost::asio::buffer(outbound_data_)); boost::asio::async_write(socket_, buffers, handler); } /// Asynchronously read a data structure from the socket. template <typename T, typename Handler> void async_read(T& t, Handler handler) { // Issue a read operation to read exactly the number of bytes in a header. void (tcp_connection_serialized::*f)( const boost::system::error_code&, T&, boost::tuple<Handler>) = &tcp_connection_serialized::handle_read_header<T, Handler>; boost::asio::async_read(socket_, boost::asio::buffer(inbound_header_), boost::bind(f, this, boost::asio::placeholders::error, boost::ref(t), boost::make_tuple(handler))); } /// Handle a completed read of a message header. The handler is passed using /// a tuple since boost::bind seems to have trouble binding a function object /// created using boost::bind as a parameter. template <typename T, typename Handler> void handle_read_header(const boost::system::error_code& e, T& t, boost::tuple<Handler> handler) { if (e) { boost::get<0>(handler)(e); } else { // Determine the length of the serialized data. std::istringstream is(std::string(inbound_header_, header_length)); std::size_t inbound_data_size = 0; if (!(is >> std::hex >> inbound_data_size)) { // Header doesn't seem to be valid. Inform the caller. boost::system::error_code error(boost::asio::error::invalid_argument); boost::get<0>(handler)(error); return; } // Start an asynchronous call to receive the data. inbound_data_.resize(inbound_data_size); void (tcp_connection_serialized::*f)( const boost::system::error_code&, T&, boost::tuple<Handler>) = &tcp_connection_serialized::handle_read_data<T, Handler>; boost::asio::async_read(socket_, boost::asio::buffer(inbound_data_), boost::bind(f, this, boost::asio::placeholders::error, boost::ref(t), handler)); } } /// Handle a completed read of message data. template <typename T, typename Handler> void handle_read_data(const boost::system::error_code& e, T& t, boost::tuple<Handler> handler) { if (e) { boost::get<0>(handler)(e); } else { // Extract the data structure from the data just received. try { std::string archive_data(&inbound_data_[0], inbound_data_.size()); std::istringstream archive_stream(archive_data); boost::archive::text_iarchive archive(archive_stream); archive >> t; } catch (std::exception& e) { // Unable to decode data. boost::system::error_code error(boost::asio::error::invalid_argument); boost::get<0>(handler)(error); return; } // Inform caller that data has been received ok. boost::get<0>(handler)(e); } } private: /// The underlying socket. boost::asio::ip::tcp::socket socket_; /// The size of a fixed length header. enum { header_length = 8 }; /// Holds an outbound header. std::string outbound_header_; /// Holds the outbound data. std::string outbound_data_; /// Holds an inbound header. char inbound_header_[header_length]; /// Holds the inbound data. std::vector<char> inbound_data_; }; #endif
36.606061
107
0.592715
7dd73d29a713e5bd87e750bb0d1616632103db2b
8,270
c
C
src/instructions_data_transfer.c
h3nnn4n/space_invaders_emulator
f94d7a57d2cb23ed4a4f5b873c2e38708612bef2
[ "Zlib" ]
null
null
null
src/instructions_data_transfer.c
h3nnn4n/space_invaders_emulator
f94d7a57d2cb23ed4a4f5b873c2e38708612bef2
[ "Zlib" ]
1
2016-12-15T20:38:27.000Z
2016-12-15T22:38:16.000Z
src/instructions_data_transfer.c
h3nnn4n/space_invaders_emulator
f94d7a57d2cb23ed4a4f5b873c2e38708612bef2
[ "Zlib" ]
2
2017-11-15T13:13:17.000Z
2018-02-27T17:54:04.000Z
#include <stdint.h> #include <assert.h> #include <stdlib.h> #include "types.h" #include "instructions_data_transfer.h" uint8_t *get_reg_ref ( _cpu_info *cpu, uint8_t opcode ) { switch ( opcode ) { case 0x00: // B return &(cpu->b); case 0x01: // C return &(cpu->c); case 0x02: // D return &(cpu->d); case 0x03: // E return &(cpu->e); case 0x04: // H return &(cpu->h); case 0x05: // L return &(cpu->l); case 0x07: // A return &(cpu->a); default: assert( 0 && "Invalid OPCODE for MOV"); } return NULL; } void emulate_XCHG ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; uint8_t t = 0; switch ( *opcode ) { case 0xeb: // XCHG t = cpu->d; cpu->d = cpu->h; cpu->h = t; t = cpu->e; cpu->e = cpu->l; cpu->l = t; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 4 ; // FIXME THis is 5 cpu->pc += 1 ; } void emulate_LDAX ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; uint16_t addr = 0; switch ( *opcode ) { case 0x0a: // LDAX B addr = cpu->b << 8 | cpu->c; cpu->a = cpu->memory[addr]; break; case 0x1a: // LDAX D addr = cpu->d << 8 | cpu->e; cpu->a = cpu->memory[addr]; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 7 ; cpu->pc += 1 ; } void emulate_STAX ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; switch ( *opcode ) { case 0x02: // STAX B cpu->memory[ ( cpu->b << 8 ) | cpu->c ] = cpu->a; break; case 0x12: // STAX D cpu->memory[ ( cpu->d << 8 ) | cpu->e ] = cpu->a; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 7 ; cpu->pc += 1 ; } void emulate_SHLD ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; switch ( *opcode ) { case 0x22: // SHLD D16 { uint16_t addr = opcode[2] << 8 | opcode[1]; cpu->memory[addr+0] = cpu->l; cpu->memory[addr+1] = cpu->h; } break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 16; cpu->pc += 3 ; } void emulate_LHLD ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; switch ( *opcode ) { case 0x2a: // LHLD B cpu->l = cpu->memory[(opcode[2] << 8 | opcode[1]) + 0]; cpu->h = cpu->memory[(opcode[2] << 8 | opcode[1]) + 1]; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 16; cpu->pc += 3 ; } void emulate_LDA ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; uint16_t addr = 0; switch ( *opcode ) { case 0x3a: addr = opcode[2] << 8 | opcode[1]; cpu->a = cpu->memory[addr]; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 13; cpu->pc += 3; } void emulate_STA ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; uint16_t addr = 0; switch ( *opcode ) { case 0x32: addr = opcode[2] << 8 | opcode[1]; cpu->memory[addr] = cpu->a; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 13; cpu->pc += 3 ; } void emulate_LXI ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; switch ( *opcode ) { case 0x01: // LXI B cpu->b = opcode[2]; cpu->c = opcode[1]; break; case 0x11: // LXI D cpu->d = opcode[2]; cpu->e = opcode[1]; break; case 0x21: // LXI H cpu->h = opcode[2]; cpu->l = opcode[1]; break; case 0x31: // LXI SP cpu->sp = opcode[2] << 8 | opcode[1]; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 10; cpu->pc += 3 ; } void emulate_MVI ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; switch ( *opcode ) { case 0x06: // MVI B, D8 cpu->b = opcode[1]; break; case 0x0e: // MVI C, D8 cpu->c = opcode[1]; break; case 0x16: // MVI D, D8 cpu->d = opcode[1]; break; case 0x1e: // MVI E, D8 cpu->e = opcode[1]; break; case 0x26: // MVI H, D8 cpu->h = opcode[1]; break; case 0x2e: // MVI L, D8 cpu->l = opcode[1]; break; case 0x36: // MVI M, D8 cpu->memory[cpu->h << 8 | cpu->l] = opcode[1]; cpu->cycles += 3; break; case 0x3e: // MVI A, D8 cpu->a = opcode[1]; break; default: assert( 0 && "Code should not get here\n" ); } cpu->cycles += 7 ; cpu->pc += 2 ; } void emulate_MOV ( _cpu_info *cpu ) { unsigned char *opcode = &cpu->memory[cpu->pc]; uint16_t addr; switch ( *opcode ) { case 0x46: // MOV B, M addr = cpu->h << 8 | cpu->l; cpu->b = cpu->memory[addr]; cpu->cycles += 2; break; case 0x56: // MOV D, M addr = cpu->h << 8 | cpu->l; cpu->d = cpu->memory[addr]; cpu->cycles += 2; break; case 0x66: // MOV H, M addr = cpu->h << 8 | cpu->l; cpu->h = cpu->memory[addr]; cpu->cycles += 2; break; case 0x70: // MOV M, B addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->b; cpu->cycles += 2; break; case 0x71: // MOV M, C addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->c; cpu->cycles += 2; break; case 0x72: // MOV M, D addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->d; cpu->cycles += 2; break; case 0x73: // MOV M, E addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->e; cpu->cycles += 2; break; case 0x74: // MOV M, H addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->h; cpu->cycles += 2; break; case 0x75: // MOV M, L addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->l; cpu->cycles += 2; break; /*case 0x76: // HLT*/ case 0x77: // MOV M, A addr = cpu->h << 8 | cpu->l; cpu->memory[addr] = cpu->a; cpu->cycles += 2; break; case 0x4e: // MOV C, M addr = cpu->h << 8 | cpu->l; cpu->c = cpu->memory[addr]; cpu->cycles += 2; break; case 0x5e: // MOV E, M addr = cpu->h << 8 | cpu->l; cpu->e = cpu->memory[addr]; cpu->cycles += 2; break; case 0x6e: // MOV L, M addr = cpu->h << 8 | cpu->l; cpu->l = cpu->memory[addr]; cpu->cycles += 2; break; case 0x7e: // MOV A, M addr = cpu->h << 8 | cpu->l; cpu->a = cpu->memory[addr]; cpu->cycles += 2; break; default: { /*printf("dst = ");*/ uint8_t *dst = get_reg_ref( cpu, ( *opcode & 0x38 ) >> 3 ); /*printf("src = ");*/ uint8_t *src = get_reg_ref( cpu, ( *opcode & 0x07 ) >> 0 ); *dst = *src; } break; } cpu->cycles += 5 ; cpu->pc += 1 ; }
26.088328
75
0.413664
702db12b35e4557bfca7cb6920b1b2e38992dcfb
1,448
c
C
src/ape_log.c
nidium/libapenetwork
d011cf41402b3936cbaef1c07b5086a1a0eab265
[ "MIT" ]
22
2016-06-28T18:12:34.000Z
2020-12-10T05:05:54.000Z
src/ape_log.c
paraboul/libapenetwork
6e5acac08467b818914ba600a9985e04ccfd32c6
[ "MIT" ]
14
2016-10-15T19:45:00.000Z
2017-04-24T11:07:01.000Z
src/ape_log.c
nidium/libapenetwork
d011cf41402b3936cbaef1c07b5086a1a0eab265
[ "MIT" ]
8
2016-12-08T02:40:56.000Z
2020-12-11T00:27:14.000Z
/* Copyright 2016 Nidium Inc. All rights reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file. */ #include <string.h> #include <stdio.h> #include <stdlib.h> #include "ape_log.h" #include "ape_netlib.h" void APE_setlogger(const ape_log_lvl_t lvl, const ape_log_init_callback_t init, const ape_log_log_callback_t log, const ape_log_cleanup_callback_t cleanup, void *ctx) { ape_logger_t *logger = &APE_get()->logger; if (logger->cleanup) { logger->cleanup(logger->ctx, logger->cb_args); } logger->lvl = lvl; logger->init = init; logger->log = log; logger->cleanup = cleanup; logger->ctx = ctx; if (logger->init) { logger->cb_args = logger->init(ctx); } } const char *APE_getloglabel(ape_log_lvl_t lvl) { return ape_log_levellabels[lvl]; } int APE_log(const ape_log_lvl_t lvl, const char *tag, const char *buffer) { ape_logger_t *logger = &APE_get()->logger; if (logger->log && lvl <= logger->lvl) { logger->log(logger->ctx, logger->cb_args, lvl, tag, buffer); return 1; } return 0; } int APE_logf(const ape_log_lvl_t lvl, const char *tag, const char * fmt, ...) { int logged; va_list args; char* buff; va_start(args, fmt); vasprintf(&buff, fmt, args); va_end(args); logged = APE_log(lvl, tag, buff); free(buff); return logged; }
20.111111
73
0.640884
6240acb273add1d975a42e8fbaf6b13ccfdbe0c9
83
h
C
security/unhash/files/strnlen.h
davidlrichmond/macports-ports
c79eda419c3963c074e4e9ce31a95296636bd500
[ "BSD-3-Clause" ]
1,199
2016-10-16T01:55:27.000Z
2022-03-28T17:07:12.000Z
security/unhash/files/strnlen.h
davidlrichmond/macports-ports
c79eda419c3963c074e4e9ce31a95296636bd500
[ "BSD-3-Clause" ]
11,428
2016-10-31T16:54:32.000Z
2022-03-31T22:58:45.000Z
security/unhash/files/strnlen.h
davidlrichmond/macports-ports
c79eda419c3963c074e4e9ce31a95296636bd500
[ "BSD-3-Clause" ]
1,772
2016-10-16T22:28:33.000Z
2022-03-31T08:52:24.000Z
#ifndef STRLEN_H #define STRLEN_H size_t strnlen(const char *s, size_t n); #endif
13.833333
40
0.759036
2b9ae3a3f1e8b4c169122c2e3b6777469d7c1fe0
266
c
C
traslate_py_C/example5.c
lmokto/ilovec
27efcc8b60533a1fc7685abda21a48977353e6cc
[ "MIT" ]
null
null
null
traslate_py_C/example5.c
lmokto/ilovec
27efcc8b60533a1fc7685abda21a48977353e6cc
[ "MIT" ]
null
null
null
traslate_py_C/example5.c
lmokto/ilovec
27efcc8b60533a1fc7685abda21a48977353e6cc
[ "MIT" ]
null
null
null
#include <stdio.h> int main(void){ int n, i, r; n = 1; while(n<6){ i=1; while(i<6){ r = n*i; printf("%d\n", r); i=i+1; printf("\n"); } n=n+1; } return 0; }
14
30
0.300752
75f8261e4e27fed34d6b03823f4c9271460491b0
396
h
C
c/read_file_with_mmap.h
i-usalko/torri
4e533d8e13cd9db7694c9983c73f874856e4cd69
[ "Apache-2.0" ]
null
null
null
c/read_file_with_mmap.h
i-usalko/torri
4e533d8e13cd9db7694c9983c73f874856e4cd69
[ "Apache-2.0" ]
null
null
null
c/read_file_with_mmap.h
i-usalko/torri
4e533d8e13cd9db7694c9983c73f874856e4cd69
[ "Apache-2.0" ]
null
null
null
#ifndef READ_FILE_WITH_MMAP_H #define READ_FILE_WITH_MMAP_H #include <stdlib.h> #include <stdint.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/errno.h> #include <fcntl.h> #include <string.h> typedef struct READING_RESULT_T { void* data; int32_t length; char* errors; } READING_RESULT_T; READING_RESULT_T* read_file(char *file_path); #endif // READ_FILE_WITH_MMAP_H
19.8
45
0.744949
fae0d993ac682060308909ffc29367568ee4f720
6,308
h
C
extensions/basic/bit_field/bit_field.h
blockspacer/chromium_base_conan
b4749433cf34f54d2edff52e2f0465fec8cb9bad
[ "Apache-2.0", "BSD-3-Clause" ]
6
2020-12-22T05:48:31.000Z
2022-02-08T19:49:49.000Z
extensions/basic/bit_field/bit_field.h
blockspacer/chromium_base_conan
b4749433cf34f54d2edff52e2f0465fec8cb9bad
[ "Apache-2.0", "BSD-3-Clause" ]
4
2020-05-22T18:36:43.000Z
2021-05-19T10:20:23.000Z
extensions/basic/bit_field/bit_field.h
blockspacer/chromium_base_conan
b4749433cf34f54d2edff52e2f0465fec8cb9bad
[ "Apache-2.0", "BSD-3-Clause" ]
2
2019-12-06T11:48:16.000Z
2021-09-16T04:44:47.000Z
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #pragma once #include <base/logging.h> #include <base/macros.h> #include <base/compiler_specific.h> #include <base/check.h> #include <atomic> // Bit fields are used to pack more variables into a smaller data space. // /// \note `BitField` can store only primitive types // // You must pass size of each field using `DefineFirstValue` and `DefineNextValue`. // // For example if you want to store 2 byte unsigned integer field // with type `uint16_t`: // `BitField::DefineFirstValue<uint16_t, 16>;`. // /// \note If you search for bit masks - see `typed_enum.h`. /// Unlike `BitField` bit masks can not store arbitrary data. // namespace basic { namespace internal { /// \todo replace these casts with std::atomic_ref (C++20) once it /// becomes available template <typename T> ALWAYS_INLINE std::atomic<T>* AsAtomicPtr(T* t) { return reinterpret_cast<std::atomic<T>*>(t); } template <typename T> ALWAYS_INLINE const std::atomic<T>* AsAtomicPtr(const T* t) { return reinterpret_cast<const std::atomic<T>*>(t); } } // namespace internal enum class BitFieldValueConstness { kNonConst, kConst, }; namespace internal { template <class BitFieldType> class BitFieldBase; // Helper class for defining values in a bit field. This helper provides // utilities to read, write and update the value in the bit field. // /// \note size in bits // template <class ValueType, size_t offset, size_t size, class BitFieldType, BitFieldValueConstness is_const = BitFieldValueConstness::kNonConst> class BitFieldValue final { static_assert(std::is_fundamental<ValueType>::value, "Fields in a bit field must be of a primitive type."); static_assert(std::is_fundamental<BitFieldType>::value, "Bit fields must be of a primitive type."); static_assert(std::is_unsigned<BitFieldType>::value, "Bit field must be of an unsigned type"); static_assert(sizeof(ValueType) <= sizeof(BitFieldType), "Value in bit field cannot be bigger than the bit field"); // sizeof in bytes, but `offset` and `size` in bits, so multiply bits by 8 static_assert( offset < 8 * sizeof(BitFieldType), "Field offset in bit field must be smaller than the bit field size"); static_assert( size < 8 * sizeof(BitFieldType), "Field size in bit field must be smaller than the bit field size"); static_assert(offset + size <= 8 * sizeof(BitFieldType), "Field in bit field cannot overflow the bit field"); static_assert(size > 0, "Bit field fields cannot have 0 size."); public: using Type = ValueType; using BitType = BitFieldType; template <class OtherValueType, int other_size, BitFieldValueConstness other_is_const = BitFieldValueConstness::kNonConst> using DefineNextValue = BitFieldValue<OtherValueType, offset + size, other_size, BitFieldType, other_is_const>; // Create a bit field with the given value. static constexpr BitFieldType encode(ValueType value) { DCHECK(is_valid(value)); return static_cast<BitFieldType>(value) << offset; } // Update a bit field with the given value. static constexpr BitFieldType update(BitFieldType previous, ValueType value) { return (previous & ~kMask) | encode(value); } // Read the value from the bit field. static constexpr ValueType decode(BitFieldType value) { return static_cast<ValueType>((value & kMask) >> offset); } private: static constexpr BitFieldValueConstness kIsConst = is_const; static constexpr BitFieldType kValidationMask = (BitFieldType{1} << size) - BitFieldType{1}; static constexpr BitFieldType kMask = (kValidationMask) << offset; static_assert(kMask != 0, "Mask in which all bits are 0 is not allowed."); static_assert(~kMask != 0, "Mask in which all bits are 1 is not allowed."); // Confirm that the provided value fits into the bit field. static constexpr bool is_valid(ValueType value) { return (static_cast<BitFieldType>(value) & ~kValidationMask) == 0; } friend class BitFieldBase<BitFieldType>; }; } // namespace internal // BitField intended to be used by a single thread. template <class BitFieldType> class BASE_EXPORT SingleThreadedBitField { static_assert(std::is_fundamental<BitFieldType>::value, "Bit fields must be of a primitive type."); static_assert(std::is_unsigned<BitFieldType>::value, "Bit field must be of an unsigned type"); public: /// \note size in bits // template <class Type, int size, BitFieldValueConstness is_const = BitFieldValueConstness::kNonConst> using DefineFirstValue = internal::BitFieldValue<Type, /* offset */ 0, size, BitFieldType, is_const>; explicit SingleThreadedBitField() : SingleThreadedBitField(0) {} explicit SingleThreadedBitField(BitFieldType bits) : bits_(bits) {} template <typename Value> typename Value::Type get() const { return Value::decode(bits_); } template <typename Value> void set(typename Value::Type value) { bits_ = Value::update(bits_, value); } protected: BitFieldType bits_; }; // BitField that can be written by a single thread but read by multiple threads. template <class BitFieldType> class BASE_EXPORT ConcurrentlyReadBitField : public SingleThreadedBitField<BitFieldType> { using Base = SingleThreadedBitField<BitFieldType>; using Base::bits_; public: explicit ConcurrentlyReadBitField() : Base(0) {} explicit ConcurrentlyReadBitField(BitFieldType bits) : Base(bits) {} template <typename Value> typename Value::Type get_concurrently() const { return Value::decode(internal::AsAtomicPtr(&bits_)->load(std::memory_order_relaxed)); } template <typename Value> void set(typename Value::Type value) { internal::AsAtomicPtr(&bits_)->store(Value::update(bits_, value), std::memory_order_relaxed); } }; } // namespace basic
33.026178
89
0.688491
2b16bc85bd478bc67d1ab3f01c850334fe08fbee
6,925
h
C
as6502/symbols.h
RyuKojiro/v6502
39e80f3fbf9c401429311abbb6693465be486b69
[ "MIT" ]
4
2017-02-27T21:50:27.000Z
2021-09-10T21:07:07.000Z
as6502/symbols.h
RyuKojiro/v6502
39e80f3fbf9c401429311abbb6693465be486b69
[ "MIT" ]
1
2020-11-07T06:02:31.000Z
2020-11-07T06:02:31.000Z
as6502/symbols.h
RyuKojiro/v6502
39e80f3fbf9c401429311abbb6693465be486b69
[ "MIT" ]
null
null
null
/** @brief Symbol table management */ /** @file symbols.h */ /* * Copyright (c) 2013 Daniel Loffgren * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef as6502_symbols_h #define as6502_symbols_h #include <stdint.h> #include <as6502/token.h> /** @defgroup sym_type_macros Symbol Type Test Macros */ /**@{*/ /** @brief Return YES if a given as6502_symbol_type has a low link bit */ #define as6502_symbolTypeIsLinked(_type) (_type == as6502_symbol_type_label || _type == as6502_symbol_type_variable) /** @brief Return YES if a given as6502_symbol_type is a label type, regardless of linkage */ #define as6502_symbolTypeIsLabel(_type) (_type == as6502_symbol_type_label || _type == as6502_symbol_type_label_unlinked) /** @brief Return YES if a given as6502_symbol_type is a variable type, regardless of linkage */ #define as6502_symbolTypeIsVariable(_type) (_type == as6502_symbol_type_variable || _type == as6502_symbol_type_variable_unlinked) /**@}*/ /** @enum */ /** @brief as6502_symbol Type */ /** <B>If you need to test type or linkage, use the provided @ref sym_type_macros.</B> If for some reason you need to do more advanced manipulation of the type field: Label types are odd, variable types are even, so symbol type (regardless of linkage) can be tested with a simple or mask against the unlinked type that you want. For example: @code (type | as6502_symbol_type_variable_unlinked) == as6502_symbol_type_variable_unlinked @endcode Linkage can be tested by masking against the linkage you want, always using label, as it carries a type bit of zero. */ typedef enum { as6502_symbol_type_unknown = 0, as6502_symbol_type_label = 2, as6502_symbol_type_variable = 3, as6502_symbol_type_label_unlinked = 4, as6502_symbol_type_variable_unlinked = 5 } as6502_symbol_type; /** @struct */ /** @brief An individual symbol in a symbol table */ typedef struct /** @cond STRUCT_FORWARD_DECLS */ _as6502_symbol /** @endcond */ { /** @brief The next variable in the linked list */ struct _as6502_symbol *next; /** @brief The line number of the symbol in the source file */ unsigned long line; /** @brief The symbol name */ char *name; /** @brief The symbol's address */ uint16_t address; /** @brief The symbol type */ as6502_symbol_type type; } as6502_symbol; /** @struct */ /** @brief The assembler's per-object symbol table structure, which holds all symbols. */ typedef struct { /** @brief The head of the linked list of labels */ as6502_symbol *first_symbol; } as6502_symbol_table; /** @defgroup sym_lifecycle Symbol Table Lifecycle Functions */ /**@{*/ /** @brief Creates a new symbol table object */ as6502_symbol_table *as6502_createSymbolTable(void); /** @brief Destroys a symbol table object */ void as6502_destroySymbolTable(as6502_symbol_table *table); /** @brief Prints a human readable representation of a as6502_symbol_table for debugging */ void as6502_printSymbolTable(as6502_symbol_table *table); /** @brief Generates a debugger script containing all of the commands necessary for loading the symbol table generated during assembly into the debugger */ void as6502_printSymbolScript(as6502_symbol_table *table, FILE *out); /**@}*/ /** @defgroup sym_access Symbol Table Accessors */ /**@{*/ /** @brief Finds a as6502_symbol in a given as6502_symbol_table by name */ as6502_symbol *as6502_symbolForString(as6502_symbol_table *table, const char *name); /** @brief Finds a as6502_symbol in a given as6502_symbol_table by address */ as6502_symbol *as6502_symbolForAddress(as6502_symbol_table *table, uint16_t address); /** @brief Looks up a symbol by name to retrieve its address */ uint16_t as6502_addressForSymbolByName(as6502_symbol_table *table, const char *name); /** @brief Creates and adds a as6502_symbol to a as6502_symbol_table */ void as6502_addSymbolToTable(as6502_symbol_table *table, unsigned long line, const char *name, uint16_t address, as6502_symbol_type type); /** @brief Removes a as6502_symbol from a as6502_symbol_table */ void as6502_removeSymbolFromTable(as6502_symbol_table *table, as6502_symbol *symbol); /** @brief Remove all as6502_symbol's that lie outside the address region specified. */ void as6502_truncateTableToAddressSpace(as6502_symbol_table *table, uint16_t start, uint16_t len); /**@}*/ /** @defgroup sym_ez Easy Symbol Table Interaction */ /**@{*/ /** @brief Automatically detects symbols in a given line, then dereferences them and replaces them with their actual addresses @param table The as6502_symbol_table to search @param head The as6502_token list to desymbolicate @param offset Address of current line @param caseSensitive Symbol search case sensitivity (This argument is currently ignored, and it's always case sensitive) @return A freshly malloc'ed, null terminated, string of length outLen, containing the desymbolicated line */ as6502_token *as6502_desymbolicateExpression(as6502_symbol_table *table, as6502_token *head, uint16_t offset, int caseSensitive); /** @brief Searches for addresses in a given line and replaces them with their symbols in a given symbol table @param table The as6502_symbol_table to search @param line The string to desymbolicate @param len Useable length of the line in chars @param offset Address of current line */ void as6502_symbolicateLine(as6502_symbol_table *table, char *line, size_t len, uint16_t offset); /**@}*/ /** @defgroup sym_rep Symbol Replacement */ /**@{*/ /** @brief Convenience function to replace a given string in another string, with its location already specified for performance */ void as6502_replaceSymbolInLineAtLocationWithText(char *line, size_t len, char *loc, const char * restrict symbol, const char * restrict text); /** @brief This indicates if a symbol following an instruction should be replaced with a relative or absolute address */ int as6502_symbolShouldBeReplacedDoubleWidth(as6502_token *instruction); /**@}*/ #endif
51.679104
562
0.772419
d88b321cdcc0e83c9da489adccda194d430217a3
516
h
C
project/functions/Scheduler.h
opatiny/S1-INFO1
5cd3eb850057a002d1fa0feaa24633cac2e03d1a
[ "MIT" ]
null
null
null
project/functions/Scheduler.h
opatiny/S1-INFO1
5cd3eb850057a002d1fa0feaa24633cac2e03d1a
[ "MIT" ]
null
null
null
project/functions/Scheduler.h
opatiny/S1-INFO1
5cd3eb850057a002d1fa0feaa24633cac2e03d1a
[ "MIT" ]
null
null
null
#ifndef SCHEDULER_H #define SCHEDULER_H #include <stdbool.h> // STRUCTURES typedef struct user_options { const int nbTics; // defines the simulation length const int ticLength; // in seconds -> accuracy of the simulation const int weather; // can be LAUSANNE_SUMMER or LAUSANNE_WINTER const bool showOutputData; // 0 or 1 const bool showControlValues; // 0 or 1 } USER_OPTIONS; // PUBLIC FUNCTIONS int Scheduler(void); #endif // SCHEDULER_H
25.8
78
0.660853
946afd6fa58c5170b5cd4ec16a6584f8d2f98e9a
9,132
c
C
src/GaIA/pkgs/postfix/postfix-3.0.2/src/postscreen/postscreen_state.c
uninth/UNItools
c8b1fbfd5d3753b5b14fa19033e39737dedefc00
[ "BSD-3-Clause" ]
null
null
null
src/GaIA/pkgs/postfix/postfix-3.0.2/src/postscreen/postscreen_state.c
uninth/UNItools
c8b1fbfd5d3753b5b14fa19033e39737dedefc00
[ "BSD-3-Clause" ]
null
null
null
src/GaIA/pkgs/postfix/postfix-3.0.2/src/postscreen/postscreen_state.c
uninth/UNItools
c8b1fbfd5d3753b5b14fa19033e39737dedefc00
[ "BSD-3-Clause" ]
1
2021-06-08T15:59:26.000Z
2021-06-08T15:59:26.000Z
/*++ /* NAME /* postscreen_state 3 /* SUMMARY /* postscreen session state and queue length management /* SYNOPSIS /* #include <postscreen.h> /* /* PSC_STATE *psc_new_session_state(stream, client_addr, client_port, /* server_addr, server_port) /* VSTREAM *stream; /* const char *client_addr; /* const char *client_port; /* const char *server_addr; /* const char *server_port; /* /* void psc_free_session_state(state) /* PSC_STATE *state; /* /* char *psc_print_state_flags(flags, context) /* int flags; /* const char *context; /* /* void PSC_ADD_SERVER_STATE(state, server_fd) /* PSC_STATE *state; /* int server_fd; /* /* void PSC_DEL_CLIENT_STATE(state) /* PSC_STATE *state; /* /* void PSC_DROP_SESSION_STATE(state, final_reply) /* PSC_STATE *state; /* const char *final_reply; /* /* void PSC_ENFORCE_SESSION_STATE(state, rcpt_reply) /* PSC_STATE *state; /* const char *rcpt_reply; /* /* void PSC_PASS_SESSION_STATE(state, testname, pass_flag) /* PSC_STATE *state; /* const char *testname; /* int pass_flag; /* /* void PSC_FAIL_SESSION_STATE(state, fail_flag) /* PSC_STATE *state; /* int fail_flag; /* /* void PSC_UNFAIL_SESSION_STATE(state, fail_flag) /* PSC_STATE *state; /* int fail_flag; /* DESCRIPTION /* This module maintains per-client session state, and two /* global file descriptor counters: /* .IP psc_check_queue_length /* The total number of remote SMTP client sockets. /* .IP psc_post_queue_length /* The total number of server file descriptors that are currently /* in use for client file descriptor passing. This number /* equals the number of client file descriptors in transit. /* .PP /* psc_new_session_state() creates a new session state object /* for the specified client stream, and increments the /* psc_check_queue_length counter. The flags and per-test time /* stamps are initialized with PSC_INIT_TESTS(). The addr and /* port arguments are null-terminated strings with the remote /* SMTP client endpoint. The _reply members are set to /* polite "try again" SMTP replies. The protocol member is set /* to "SMTP". /* /* The psc_stress variable is set to non-zero when /* psc_check_queue_length passes over a high-water mark. /* /* psc_free_session_state() destroys the specified session state /* object, closes the applicable I/O channels, and decrements /* the applicable file descriptor counters: psc_check_queue_length /* and psc_post_queue_length. /* /* The psc_stress variable is reset to zero when psc_check_queue_length /* passes under a low-water mark. /* /* psc_print_state_flags() converts per-session flags into /* human-readable form. The context is for error reporting. /* The result is overwritten upon each call. /* /* PSC_ADD_SERVER_STATE() updates the specified session state /* object with the specified server file descriptor, and /* increments the global psc_post_queue_length file descriptor /* counter. /* /* PSC_DEL_CLIENT_STATE() updates the specified session state /* object, closes the client stream, and decrements the global /* psc_check_queue_length file descriptor counter. /* /* PSC_DROP_SESSION_STATE() updates the specified session state /* object and closes the client stream after sending the /* specified SMTP reply. /* /* PSC_ENFORCE_SESSION_STATE() updates the specified session /* state object. It arranges that the built-in SMTP engine /* logs sender/recipient information and rejects all RCPT TO /* commands with the specified SMTP reply. /* /* PSC_PASS_SESSION_STATE() sets the specified "pass" flag. /* The testname is used for debug logging. /* /* PSC_FAIL_SESSION_STATE() sets the specified "fail" flag. /* /* PSC_UNFAIL_SESSION_STATE() unsets the specified "fail" flag. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /*--*/ /* System library. */ #include <sys_defs.h> /* Utility library. */ #include <msg.h> #include <mymalloc.h> #include <name_mask.h> #include <htable.h> /* Global library. */ #include <mail_proto.h> /* Master server protocols. */ #include <mail_server.h> /* Application-specific. */ #include <postscreen.h> /* psc_new_session_state - fill in connection state for event processing */ PSC_STATE *psc_new_session_state(VSTREAM *stream, const char *client_addr, const char *client_port, const char *server_addr, const char *server_port) { PSC_STATE *state; HTABLE_INFO *ht; state = (PSC_STATE *) mymalloc(sizeof(*state)); PSC_INIT_TESTS(state); if ((state->smtp_client_stream = stream) != 0) psc_check_queue_length++; state->smtp_server_fd = (-1); state->smtp_client_addr = mystrdup(client_addr); state->smtp_client_port = mystrdup(client_port); state->smtp_server_addr = mystrdup(server_addr); state->smtp_server_port = mystrdup(server_port); state->send_buf = vstring_alloc(100); state->test_name = "TEST NAME HERE"; state->dnsbl_reply = 0; state->final_reply = "421 4.3.2 Service currently unavailable\r\n"; state->rcpt_reply = "450 4.3.2 Service currently unavailable\r\n"; state->command_count = 0; state->protocol = MAIL_PROTO_SMTP; state->helo_name = 0; state->sender = 0; state->cmd_buffer = 0; state->read_state = 0; state->ehlo_discard_mask = 0; /* XXX Should be ~0 */ state->expand_buf = 0; state->where = PSC_SMTPD_CMD_CONNECT; /* * Update the stress level. */ if (psc_stress == 0 && psc_check_queue_length >= psc_hiwat_check_queue_length) { psc_stress = 1; msg_info("entering STRESS mode with %d connections", psc_check_queue_length); } /* * Update the per-client session count. */ if ((ht = htable_locate(psc_client_concurrency, client_addr)) == 0) ht = htable_enter(psc_client_concurrency, client_addr, (void *) 0); ht->value += 1; state->client_concurrency = CAST_ANY_PTR_TO_INT(ht->value); return (state); } /* psc_free_session_state - destroy connection state including connections */ void psc_free_session_state(PSC_STATE *state) { const char *myname = "psc_free_session_state"; HTABLE_INFO *ht; /* * Update the per-client session count. */ if ((ht = htable_locate(psc_client_concurrency, state->smtp_client_addr)) == 0) msg_panic("%s: unknown client address: %s", myname, state->smtp_client_addr); if (--(ht->value) == 0) htable_delete(psc_client_concurrency, state->smtp_client_addr, (void (*) (void *)) 0); if (state->smtp_client_stream != 0) { event_server_disconnect(state->smtp_client_stream); psc_check_queue_length--; } if (state->smtp_server_fd >= 0) { close(state->smtp_server_fd); psc_post_queue_length--; } if (state->send_buf != 0) state->send_buf = vstring_free(state->send_buf); myfree(state->smtp_client_addr); myfree(state->smtp_client_port); myfree(state->smtp_server_addr); myfree(state->smtp_server_port); if (state->dnsbl_reply) vstring_free(state->dnsbl_reply); if (state->helo_name) myfree(state->helo_name); if (state->sender) myfree(state->sender); if (state->cmd_buffer) vstring_free(state->cmd_buffer); if (state->expand_buf) vstring_free(state->expand_buf); myfree((void *) state); if (psc_check_queue_length < 0 || psc_post_queue_length < 0) msg_panic("bad queue length: check_queue=%d, post_queue=%d", psc_check_queue_length, psc_post_queue_length); /* * Update the stress level. */ if (psc_stress != 0 && psc_check_queue_length <= psc_lowat_check_queue_length) { psc_stress = 0; msg_info("leaving STRESS mode with %d connections", psc_check_queue_length); } } /* psc_print_state_flags - format state flags */ const char *psc_print_state_flags(int flags, const char *context) { static const NAME_MASK flags_mask[] = { "NOFORWARD", PSC_STATE_FLAG_NOFORWARD, "USING_TLS", PSC_STATE_FLAG_USING_TLS, "NEW", PSC_STATE_FLAG_NEW, "BLIST_FAIL", PSC_STATE_FLAG_BLIST_FAIL, "HANGUP", PSC_STATE_FLAG_HANGUP, /* unused */ "WLIST_FAIL", PSC_STATE_FLAG_WLIST_FAIL, "PREGR_FAIL", PSC_STATE_FLAG_PREGR_FAIL, "PREGR_PASS", PSC_STATE_FLAG_PREGR_PASS, "PREGR_TODO", PSC_STATE_FLAG_PREGR_TODO, "PREGR_DONE", PSC_STATE_FLAG_PREGR_DONE, "DNSBL_FAIL", PSC_STATE_FLAG_DNSBL_FAIL, "DNSBL_PASS", PSC_STATE_FLAG_DNSBL_PASS, "DNSBL_TODO", PSC_STATE_FLAG_DNSBL_TODO, "DNSBL_DONE", PSC_STATE_FLAG_DNSBL_DONE, "PIPEL_FAIL", PSC_STATE_FLAG_PIPEL_FAIL, "PIPEL_PASS", PSC_STATE_FLAG_PIPEL_PASS, "PIPEL_TODO", PSC_STATE_FLAG_PIPEL_TODO, "PIPEL_SKIP", PSC_STATE_FLAG_PIPEL_SKIP, "NSMTP_FAIL", PSC_STATE_FLAG_NSMTP_FAIL, "NSMTP_PASS", PSC_STATE_FLAG_NSMTP_PASS, "NSMTP_TODO", PSC_STATE_FLAG_NSMTP_TODO, "NSMTP_SKIP", PSC_STATE_FLAG_NSMTP_SKIP, "BARLF_FAIL", PSC_STATE_FLAG_BARLF_FAIL, "BARLF_PASS", PSC_STATE_FLAG_BARLF_PASS, "BARLF_TODO", PSC_STATE_FLAG_BARLF_TODO, "BARLF_SKIP", PSC_STATE_FLAG_BARLF_SKIP, 0, }; return (str_name_mask_opt((VSTRING *) 0, context, flags_mask, flags, NAME_MASK_PIPE | NAME_MASK_NUMBER)); }
30.33887
77
0.726347
a20e9a9abf321ec7f77af85297b30628c15985c6
275
h
C
SOLID/MUAppDelegate.h
muncman/SOLID
a28edcc1a63f794b528c6a9722640f25b12fa94c
[ "MIT" ]
null
null
null
SOLID/MUAppDelegate.h
muncman/SOLID
a28edcc1a63f794b528c6a9722640f25b12fa94c
[ "MIT" ]
null
null
null
SOLID/MUAppDelegate.h
muncman/SOLID
a28edcc1a63f794b528c6a9722640f25b12fa94c
[ "MIT" ]
null
null
null
// // MUAppDelegate.h // SOLID // // Created by Kevin Munc on 7/8/12. // Copyright (c) 2012 Method Up. All rights reserved. // #import <UIKit/UIKit.h> @interface MUAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
17.1875
62
0.701818
fa269760e5f32adc8827b07278f3fb8eff741b81
2,895
c
C
src/rmutil/periodic.c
abrookins/RediSearch
773a04106e4f0cfbad3a75a84ce69f3a36fd16e1
[ "Apache-2.0", "Ruby", "BSD-3-Clause", "MIT" ]
2,098
2019-05-13T09:11:54.000Z
2022-03-31T06:24:50.000Z
src/rmutil/periodic.c
abrookins/RediSearch
773a04106e4f0cfbad3a75a84ce69f3a36fd16e1
[ "Apache-2.0", "Ruby", "BSD-3-Clause", "MIT" ]
1,659
2019-05-13T07:55:29.000Z
2022-03-31T02:42:57.000Z
src/rmutil/periodic.c
abrookins/RediSearch
773a04106e4f0cfbad3a75a84ce69f3a36fd16e1
[ "Apache-2.0", "Ruby", "BSD-3-Clause", "MIT" ]
227
2019-05-17T07:54:49.000Z
2022-03-28T03:50:19.000Z
#include "periodic.h" #include "rmalloc.h" #include <pthread.h> #include <stdlib.h> #include <errno.h> typedef struct RMUtilTimer { RMutilTimerFunc cb; RMUtilTimerTerminationFunc onTerm; void *privdata; struct timespec interval; pthread_t thread; pthread_mutex_t lock; pthread_cond_t cond; volatile bool isCanceled; } RMUtilTimer; static struct timespec timespecAdd(struct timespec *a, struct timespec *b) { struct timespec ret; ret.tv_sec = a->tv_sec + b->tv_sec; long long ns = a->tv_nsec + b->tv_nsec; ret.tv_sec += ns / 1000000000; ret.tv_nsec = ns % 1000000000; return ret; } static void *rmutilTimer_Loop(void *ctx) { RMUtilTimer *tm = ctx; int rc = ETIMEDOUT; struct timespec ts; pthread_mutex_lock(&tm->lock); while (true) { clock_gettime(CLOCK_REALTIME, &ts); struct timespec timeout = timespecAdd(&ts, &tm->interval); rc = pthread_cond_timedwait(&tm->cond, &tm->lock, &timeout); if (rc == EINVAL) { perror("Error waiting for condition"); break; } if (tm->isCanceled) { break; } // Create a thread safe context if we're running inside redis RedisModuleCtx *rctx = NULL; if (RedisModule_GetThreadSafeContext) rctx = RedisModule_GetThreadSafeContext(NULL); // call our callback... if (!tm->cb(rctx, tm->privdata)) { if (rctx) RedisModule_FreeThreadSafeContext(rctx); break; } // If needed - free the thread safe context. // It's up to the user to decide whether automemory is active there if (rctx) RedisModule_FreeThreadSafeContext(rctx); } // call the termination callback if needed if (tm->onTerm != NULL) { tm->onTerm(tm->privdata); } // free resources associated with the timer pthread_cond_destroy(&tm->cond); pthread_mutex_unlock(&tm->lock); rm_free(tm); return NULL; } /* set a new frequency for the timer. This will take effect AFTER the next trigger */ void RMUtilTimer_SetInterval(struct RMUtilTimer *t, struct timespec newInterval) { t->interval = newInterval; } RMUtilTimer *RMUtil_NewPeriodicTimer(RMutilTimerFunc cb, RMUtilTimerTerminationFunc onTerm, void *privdata, struct timespec interval) { RMUtilTimer *ret = rm_malloc(sizeof(*ret)); *ret = (RMUtilTimer){ .privdata = privdata, .interval = interval, .cb = cb, .onTerm = onTerm, .isCanceled = false, }; pthread_cond_init(&ret->cond, NULL); pthread_mutex_init(&ret->lock, NULL); pthread_create(&ret->thread, NULL, rmutilTimer_Loop, ret); pthread_detach(ret->thread); return ret; } void RMUtilTimer_ForceInvoke(struct RMUtilTimer *t) { RMUtilTimer_Signal(t); } int RMUtilTimer_Signal(struct RMUtilTimer *t) { return pthread_cond_signal(&t->cond); } int RMUtilTimer_Terminate(struct RMUtilTimer *t) { t->isCanceled = true; return RMUtilTimer_Signal(t); }
26.081081
91
0.688083
36669cadee16c260d36677b05da2bf1d643e1484
1,753
c
C
SLIP_LU/Source/slip_sparse_alloc.c
cjh10644/SLIP_LU
7e376f214867a72c4150cfdf681e4a44de35b023
[ "Apache-2.0" ]
null
null
null
SLIP_LU/Source/slip_sparse_alloc.c
cjh10644/SLIP_LU
7e376f214867a72c4150cfdf681e4a44de35b023
[ "Apache-2.0" ]
null
null
null
SLIP_LU/Source/slip_sparse_alloc.c
cjh10644/SLIP_LU
7e376f214867a72c4150cfdf681e4a44de35b023
[ "Apache-2.0" ]
null
null
null
//------------------------------------------------------------------------------ // SLIP_LU/slip_sparse_alloc: allocate a sparse mpz matrix //------------------------------------------------------------------------------ // SLIP_LU: (c) 2019, Chris Lourenco, Jinhao Chen, Erick Moreno-Centeno, // Timothy A. Davis, Texas A&M University. All Rights Reserved. See // SLIP_LU/License for the license. //------------------------------------------------------------------------------ # include "SLIP_LU_internal.h" /* * Purpose: This function allocates a SLIP LU matrix of size n*m with array * size nzmax. This function initializes each entry in A->x therefore they are * immediately ready to be operated on. This is less efficient but more user * friendly. * * See also slip_sparse_alloc2. */ SLIP_info slip_sparse_alloc ( SLIP_sparse* A,// sparse matrix data structure to be allocated int32_t n, // number of columns int32_t m, // number of rows (recall m=n assumed) int32_t nzmax // size of allocated i and x arrays ) { // Check input if (n <= 0 || m <= 0 || nzmax <= 0 || !A) {return SLIP_INCORRECT_INPUT;} A->m = m; // Rows of the matrix A->n = n; // Columns of the matrix A->nz = 0; // Currently 0 nonzeros A->nzmax = nzmax; // Size of the vectors A->x = SLIP_create_mpz_array(nzmax); // Create and initialize A->x A->p = (int32_t*) SLIP_calloc(n+1, sizeof(int32_t));// Initialize p A->i = (int32_t*) SLIP_calloc(nzmax, sizeof(int32_t));// Initialize i if (!A->x || !A->p || !A->i) {return SLIP_OUT_OF_MEMORY;} return SLIP_OK; }
42.756098
80
0.520251
3687b669cdb33fb9c27a76d1db931a2f6615189c
3,635
c
C
1-24/kushblazingjudah.c
k-and-r-study-group/chapter-one
24482218cc219b5727f142ca6d58dcddcfdf627b
[ "Unlicense" ]
1
2021-03-28T19:17:49.000Z
2021-03-28T19:17:49.000Z
1-24/kushblazingjudah.c
k-and-r-study-group/chapter-one
24482218cc219b5727f142ca6d58dcddcfdf627b
[ "Unlicense" ]
null
null
null
1-24/kushblazingjudah.c
k-and-r-study-group/chapter-one
24482218cc219b5727f142ca6d58dcddcfdf627b
[ "Unlicense" ]
1
2021-03-29T21:19:08.000Z
2021-03-29T21:19:08.000Z
// compile with -std=c99 // RETURN OF getline(3) // too bad it's not to standard // either way, this is probably written horribly and you'll like it #include <stdio.h> #define MAXLINE 1000 #define MAXSTACK 1000 int getline(char line[], int maxline); void copy(char to[], char from[]); int main() { int len; char line[MAXLINE]; int ln = 0; // state machine time int stack_curlybrace[MAXSTACK]; int stack_bracket[MAXSTACK]; int stack_parenthesis[MAXSTACK]; int level_curlybrace = 0; // {{{these}}} int level_bracket = 0; /// [[[this]]] int level_parenthesis = 0; // (((them))) int in_literal = 0; int in_string = 0; int in_comment = 0; int in_multicomment = 0; while ((len = getline(line, MAXLINE)) > 0) { ln++; for (int i = 0; line[i]; ++i) { char c = line[i]; // didn't feel like writing line[i] many times putchar(c); if (c == '/' && line[i + 1] == '/') in_comment = 1; else if (c == '/' && line[i + 1] == '*') in_multicomment = ln; else if (c == '*' && line[i + 1] == '/') in_multicomment = 0; if (in_comment || in_multicomment) continue; if (c == '\\') { ++i; continue; } if (!in_string && !in_literal) { // PLEASE LET ME USE switch(c) ALREADY if (c == '{') stack_curlybrace[level_curlybrace++] = ln; else if (c == '}') --level_curlybrace; else if (c == '[') stack_bracket[level_bracket++] = ln; else if (c == ']') --level_bracket; else if (c == '(') stack_parenthesis[level_parenthesis++] = ln; else if (c == ')') --level_parenthesis; else if (c == '\"') { in_string = 1; } else if (c == '\'') { in_literal = 1; } } else if (in_string && c == '\"') { in_string = 0; } else if (in_literal && c == '\'') { in_literal = 0; } } in_comment = 0; // string stuff if (in_string == 1) { fprintf(stderr, "on line %d: line ends, still in string\n", ln); in_string = 0; } if (in_literal == 1) { fprintf(stderr, "on line %d: line ends, still in literal\n", ln); in_literal = 0; } // {} [] () if (level_curlybrace < 0) { fprintf(stderr, "on line %d: %d too many end curly braces\n", ln, -level_curlybrace); } if (level_bracket < 0) { fprintf(stderr, "on line %d: %d too many end brackets\n", ln, -level_curlybrace); } if (level_parenthesis < 0) { fprintf(stderr, "on line %d: %d too many end parenthesis\n", ln, -level_curlybrace); } } // i was going to do something here and say "hey, you ended (parenthesis|bracket) early // but i decided not to if (in_multicomment) fprintf(stderr, "on line %d: multiline comment never ended\n", in_multicomment); if (level_curlybrace > 0) { for(int i = 0; i < level_curlybrace; i++) fprintf(stderr, "on line %d: curly brace never ended\n", stack_curlybrace[i]); } if (level_bracket > 0) { for(int i = 0; i < level_bracket; i++) fprintf(stderr, "on line %d: bracket never ended\n", stack_bracket[i]); } if (level_parenthesis > 0) { for(int i = 0; i < level_parenthesis; i++) fprintf(stderr, "on line %d: parenthesis never ended\n", stack_bracket[i]); } printf("statistics:\n%d curly, %d bracket, %d paren\n", level_curlybrace, level_bracket, level_parenthesis); return 0; } int getline(char s[], int lim) { int c, i; for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i) s[i] = c; if (i == lim - 1) while((c = getchar()) != EOF && c != '\n') ++i; if (c == '\n') { s[i] = c; ++i; } s[i] = 0; return i; } void copy(char to[], char from[]) { int i = 0; while ((to[i] = from[i]) != '\0') ++i; }
22.438272
109
0.573865
36c04c46589aafa50fd762c6886a3503e01ea039
5,615
c
C
zone.c
andydiba/fomite_sim2
f5de8c00bcccbe7760087c4dcc7187c793cd7df7
[ "Apache-2.0" ]
null
null
null
zone.c
andydiba/fomite_sim2
f5de8c00bcccbe7760087c4dcc7187c793cd7df7
[ "Apache-2.0" ]
null
null
null
zone.c
andydiba/fomite_sim2
f5de8c00bcccbe7760087c4dcc7187c793cd7df7
[ "Apache-2.0" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include "utilities.h" #include "zone.h" #include "person.h" bool zone_config(Zone* zone, Hash_t* H, unsigned int n, unsigned int N ) { char type[40]; char buff[40]; int i=0; //init all pointers to null ... zone->_mc.prb = NULL; zone->bioburden = NULL; zone->A = NULL; zone->D = NULL; zone->INTERACTION_RATE = 1; //default (not really in use) or option to change using config file..? //Fomite 'type' is specified by trunGauss + a rate parameter if(!hash_lookup_csv(H,"FOMITE_TYPE",n,type)) return errorMsg("location config: FOMITE_TYPE not specified"); if(!hash_lookup_csv(H,type,0,buff)) return errorMsg("location config: FOMITE_TYPE[0] not specified"); zone->fomType.md = atof(buff); if(!hash_lookup_csv(H,type,1,buff)) return errorMsg("location config: FOMITE_TYPE[1] not specified"); zone->fomType.sd = atof(buff); if(!hash_lookup_csv(H,type,2,buff)) return errorMsg("location config: FOMITE_TYPE[2] not specified"); zone->fomType.mn = atof(buff); if(!hash_lookup_csv(H,type,3,buff)) return errorMsg("location config: FOMITE_TYPE[3] not specified"); zone->fomType.mx = atof(buff); if(!hash_lookup_csv(H,type,4,buff)) return errorMsg("location config: FOMITE_TYPE[4] not specified"); zone->fomL = atof(buff); //Number of identical fomites in this zone if(!hash_lookup_csv(H,"FOMITES",n,buff)) return errorMsg("location config: FOMITES not specified"); zone->numFomites = atoi(buff); //init bioburden counters zone->bioburden = (unsigned long*)calloc(zone->numFomites,sizeof(unsigned long)); //Rate at which people leave this zone/ how long do they stick around if(!hash_lookup_csv(H,"ZONE_L",n,buff)) return errorMsg("location config: ZONE_L not specified"); zone->L = atof(buff); //Fomite cleaning/disinfecting rate if(!hash_lookup_csv(H,"CLEAN_RATE_HR",n,buff)) return errorMsg("location config: CLEAN_RATE_HR not specified"); zone->CR = atof(buff)/60; //Note: config file=per hour, but utilized as per min in sim //Markov chain init zone->_mc.num_states = N; zone->_mc.prb = malloc(N*sizeof(double)); if(!hash_lookup_csv(H,"ZONE_MC",n,type)) return errorMsg("location config: ZONE_MC not specified"); for(i=0;i<N;i++) { if(!hash_lookup_csv(H,type,i,buff)) return false; zone->_mc.prb[i] = atof(buff); } zone->A = new_queue(sizeof(Person)); zone->D = new_queue(sizeof(Person)); return true; } bool pool_config(Zone* pool, Hash_t* H, unsigned int n,unsigned int N) { //Pools and Zones are essentially the same (but different params in use) char buff[40]; char type[40]; int i=0; unsigned int num_people,num_jumps; //init all pointers to null ... pool->_mc.prb = NULL; pool->bioburden = NULL; //pools have no fomites pool->A = NULL; pool->D = NULL; //Rate of emptying pool if(!hash_lookup_csv(H,"POOL_L",n,buff)) return errorMsg("location config: POOL_L not specified"); pool->L = atof(buff); //Number of people in pool (make use of numFomites parameter to store value) if(!hash_lookup_csv(H,"PEOPLE",n,buff)) return errorMsg("location config: PEOPLE not specified"); num_people = atoi(buff); pool->numFomites = num_people; //Markov chain: Number of jumps i.e. total number of zones that will be visited by individuals in sim if(!hash_lookup_csv(H,"JUMPS",n,buff)) return errorMsg("location config: JUMPS not specified"); num_jumps = atoi(buff); pool->_mc.num_states = N; pool->_mc.prb = malloc(N*sizeof(double)); if(!hash_lookup_csv(H,"POOL_MC",n,type)) return errorMsg("location config: POOL_MC not specified"); for(i=0;i<N;i++) { if(!hash_lookup_csv(H,type,i,buff)) return errorMsg("pool config: POOL_MC[i] not specified"); pool->_mc.prb[i] = atof(buff); } pool->A = new_queue(sizeof(Person)); pool->D = new_queue(sizeof(Person)); Person dummy; //load pool with (default) people for(i=0;i<num_people;i++) { dummy.status = SUSCEPTIBLE; dummy.fdose = 0; dummy.mdose = 0.0; dummy.pool = n; dummy.jumps = num_jumps; enqueue(pool->D,&dummy); } return true; } void zone_close(Zone* zn) { //delete queues and mc free(zn->_mc.prb); free(zn->bioburden); delete_queue(zn->A); delete_queue(zn->D); } //Markov Chains: given a person at Zone[current], where to go next? unsigned int zone_mc(Zone* zone){ double r,sum; unsigned int i,states; states = zone->_mc.num_states; // >0 (may be ==1) //jump to a new location/zone according to MC parameters? r = uniform(); sum = 0; for(i=0; i<states;i++) { sum=sum+(zone->_mc.prb[i]); if(r<sum) return i; } errorMsg("zone_mc error: should never reach this point! Check your MC values!"); return 0; } /*seeds a zone's fomites with initial contamination level; num_pathogens will be generated from pathogen_shed function*/ void zone_contaminated(Zone* zone, unsigned long num_pathogens) { int i; for (i=0;i<zone->numFomites;i++) zone->bioburden[i] = num_pathogens; } //clean particular fomites at that zone void zone_clean(Zone* zone, unsigned int cfom) { /*from ref paper: geo mean reduction of 94.1 95%CI = [71.4 , 98.8] * therefore fraction left over 0.059 CI [0.012 , 0.286] * equals a logNorm: mu = -3.0187 sd = 0.614 */ double fraction_alive = samplelogNorm(-3.0187,0.614,1); zone->bioburden[cfom] = (unsigned long) ( (zone->bioburden[cfom])*fraction_alive ); //implicit rounding; use cast anyways }
22.193676
126
0.671594
32158adab3403fa394f1406d40961692ad19425d
3,501
c
C
proxmark3-master/client/util_posix.c
UCLA-ECE209AS-2018W/Hui-Wenxuan-Yifan
87cb1dbe2d219974b04cefcec5088d3ac6d5fe6f
[ "BSD-2-Clause" ]
17
2018-04-19T08:29:01.000Z
2022-03-01T07:39:32.000Z
proxmark3-master/client/util_posix.c
UCLA-ECE209AS-2018W/Hui-Wenxuan-Yifan
87cb1dbe2d219974b04cefcec5088d3ac6d5fe6f
[ "BSD-2-Clause" ]
null
null
null
proxmark3-master/client/util_posix.c
UCLA-ECE209AS-2018W/Hui-Wenxuan-Yifan
87cb1dbe2d219974b04cefcec5088d3ac6d5fe6f
[ "BSD-2-Clause" ]
4
2018-12-23T22:57:07.000Z
2020-09-23T05:14:19.000Z
//----------------------------------------------------------------------------- // Copyright (C) 2010 iZsh <izsh at fail0verflow.com> // // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. //----------------------------------------------------------------------------- // utilities requiring Posix library functions //----------------------------------------------------------------------------- #if !defined(_WIN32) #define _POSIX_C_SOURCE 199309L // need nanosleep() #else #include <windows.h> #endif #include "util_posix.h" #include <stdint.h> #include <time.h> // Timer functions #if !defined (_WIN32) #include <errno.h> static void nsleep(uint64_t n) { struct timespec timeout; timeout.tv_sec = n/1000000000; timeout.tv_nsec = n%1000000000; while (nanosleep(&timeout, &timeout) && errno == EINTR); } void msleep(uint32_t n) { nsleep(1000000 * (uint64_t)n); } #endif // _WIN32 #ifdef __APPLE__ #ifndef CLOCK_MONOTONIC #define CLOCK_MONOTONIC (1) #endif #ifndef CLOCK_REALTIME #define CLOCK_REALTIME (2) #endif #include <sys/time.h> #include <mach/clock.h> #include <mach/mach.h> #include <mach/mach_time.h> /* clock_gettime is not implemented on OSX prior to 10.12 */ int _civet_clock_gettime(int clk_id, struct timespec *t); int _civet_clock_gettime(int clk_id, struct timespec *t) { memset(t, 0, sizeof(*t)); if (clk_id == CLOCK_REALTIME) { struct timeval now; int rv = gettimeofday(&now, NULL); if (rv) { return rv; } t->tv_sec = now.tv_sec; t->tv_nsec = now.tv_usec * 1000; return 0; } else if (clk_id == CLOCK_MONOTONIC) { static uint64_t clock_start_time = 0; static mach_timebase_info_data_t timebase_info = {0, 0}; uint64_t now = mach_absolute_time(); if (clock_start_time == 0) { mach_timebase_info(&timebase_info); clock_start_time = now; } now = (uint64_t)((double)(now - clock_start_time) * (double)timebase_info.numer / (double)timebase_info.denom); t->tv_sec = now / 1000000000; t->tv_nsec = now % 1000000000; return 0; } return -1; // EINVAL - Clock ID is unknown } /* if clock_gettime is declared, then __CLOCK_AVAILABILITY will be defined */ #ifdef __CLOCK_AVAILABILITY /* If we compiled with Mac OSX 10.12 or later, then clock_gettime will be declared * but it may be NULL at runtime. So we need to check before using it. */ int _civet_safe_clock_gettime(int clk_id, struct timespec *t); int _civet_safe_clock_gettime(int clk_id, struct timespec *t) { if( clock_gettime ) { return clock_gettime(clk_id, t); } return _civet_clock_gettime(clk_id, t); } #define clock_gettime _civet_safe_clock_gettime #else #define clock_gettime _civet_clock_gettime #endif #endif // a milliseconds timer for performance measurement uint64_t msclock() { #if defined(_WIN32) #include <sys/types.h> // WORKAROUND FOR MinGW (some versions - use if normal code does not compile) // It has no _ftime_s and needs explicit inclusion of timeb.h #include <sys/timeb.h> struct _timeb t; _ftime(&t); return 1000 * t.time + t.millitm; // NORMAL CODE (use _ftime_s) //struct _timeb t; //if (_ftime_s(&t)) { // return 0; //} else { // return 1000 * t.time + t.millitm; //} #else struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (t.tv_sec * 1000 + t.tv_nsec / 1000000); #endif }
25.742647
84
0.646672
9a6e12956798f22b01c4703b5863b433a9a6a768
3,252
h
C
lsp_shiloh/third_party/devices/wifi/878x/sigma/inc/wfa_utils.h
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/third_party/devices/wifi/878x/sigma/inc/wfa_utils.h
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/third_party/devices/wifi/878x/sigma/inc/wfa_utils.h
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
/**************************************************************************** * (c) Copyright 2007 Wi-Fi Alliance. All Rights Reserved * * * LICENSE * * License is granted only to Wi-Fi Alliance members and designated * contractors ($B!H(BAuthorized Licensees$B!I(B)..AN Authorized Licensees are granted * the non-exclusive, worldwide, limited right to use, copy, import, export * and distribute this software: * (i) solely for noncommercial applications and solely for testing Wi-Fi * equipment; and * (ii) solely for the purpose of embedding the software into Authorized * Licensee$B!G(Bs proprietary equipment and software products for distribution to * its customers under a license with at least the same restrictions as * contained in this License, including, without limitation, the disclaimer of * warranty and limitation of liability, below..AN The distribution rights * granted in clause * (ii), above, include distribution to third party companies who will * redistribute the Authorized Licensee$B!G(Bs product to their customers with or * without such third party$B!G(Bs private label. Other than expressly granted * herein, this License is not transferable or sublicensable, and it does not * extend to and may not be used with non-Wi-Fi applications..AN Wi-Fi Alliance * reserves all rights not expressly granted herein..AN *.AN * Except as specifically set forth above, commercial derivative works of * this software or applications that use the Wi-Fi scripts generated by this * software are NOT AUTHORIZED without specific prior written permission from * Wi-Fi Alliance. *.AN * Non-Commercial derivative works of this software for internal use are * authorized and are limited by the same restrictions; provided, however, * that the Authorized Licensee shall provide Wi-Fi Alliance with a copy of * such derivative works under a perpetual, payment-free license to use, * modify, and distribute such derivative works for purposes of testing Wi-Fi * equipment. *.AN * Neither the name of the author nor "Wi-Fi Alliance" may be used to endorse * or promote products that are derived from or that use this software without * specific prior written permission from Wi-Fi Alliance. * * THIS SOFTWARE IS PROVIDED BY WI-FI ALLIANCE "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A.AN PARTICULAR PURPOSE, * ARE DISCLAIMED. IN NO EVENT SHALL WI-FI ALLIANCE BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, THE COST OF 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) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************** */ #ifndef _WFA_UTILS_H #define _WFA_UTILS_H #define WFA_RET_ENV "WFA_UTIL_RET" #endif
52.451613
159
0.714945
3c37bce4d82fd2d810d78bb57c9961cd4923fa5a
1,784
h
C
src/cbson-misc.h
andrejlevkovitch/lua-cbson
49a892382cb45f87f4564d7830ddad70cd027ce7
[ "WTFPL" ]
18
2015-10-21T13:20:49.000Z
2021-02-22T21:26:02.000Z
src/cbson-misc.h
andrejlevkovitch/lua-cbson
49a892382cb45f87f4564d7830ddad70cd027ce7
[ "WTFPL" ]
6
2018-11-08T21:19:03.000Z
2019-08-19T19:10:14.000Z
src/cbson-misc.h
andrejlevkovitch/lua-cbson
49a892382cb45f87f4564d7830ddad70cd027ce7
[ "WTFPL" ]
12
2016-11-20T02:16:10.000Z
2022-01-27T09:49:43.000Z
#ifndef __CBSON_MINMAX_H__ #define __CBSON_MINMAX_H__ #include <lauxlib.h> #include <lua.h> #define UNDEFINED_METATABLE "bson-undef metatable" #define CBNULL_METATABLE "bson-null metatable" #define ARRAY_METATABLE "bson-array metatable" #define MINKEY_METATABLE "bson-minkey metatable" #define MAXKEY_METATABLE "bson-maxkey metatable" typedef struct { char unused; } cbson_undefined_t; typedef cbson_undefined_t cbson_minkey_t; typedef cbson_undefined_t cbson_maxkey_t; typedef cbson_undefined_t cbson_null_t; typedef cbson_undefined_t cbson_array_t; int cbson_undefined_create(lua_State* L); int cbson_undefined_new(lua_State* L); cbson_undefined_t* check_cbson_undefined(lua_State *L, int index); int cbson_null_create(lua_State* L); int cbson_null_new(lua_State* L); cbson_null_t* check_cbson_null(lua_State *L, int index); int cbson_array_create(lua_State* L); int cbson_array_new(lua_State* L); cbson_array_t* check_cbson_array(lua_State *L, int index); extern const struct luaL_Reg cbson_undefined_meta[]; extern const struct luaL_Reg cbson_undefined_methods[]; extern const struct luaL_Reg cbson_null_meta[]; extern const struct luaL_Reg cbson_null_methods[]; extern const struct luaL_Reg cbson_array_meta[]; extern const struct luaL_Reg cbson_array_methods[]; int cbson_minkey_create(lua_State* L); int cbson_minkey_new(lua_State* L); cbson_minkey_t* check_cbson_minkey(lua_State *L, int index); extern const struct luaL_Reg cbson_minkey_meta[]; extern const struct luaL_Reg cbson_minkey_methods[]; int cbson_maxkey_create(lua_State* L); int cbson_maxkey_new(lua_State* L); cbson_maxkey_t* check_cbson_maxkey(lua_State *L, int index); extern const struct luaL_Reg cbson_maxkey_meta[]; extern const struct luaL_Reg cbson_maxkey_methods[]; #endif
30.237288
66
0.818946
aa2c8abfd2685f2e8ff6636463903392b22cf87c
1,974
h
C
plugins/zimg/src/Common/align.h
darcyg/vapoursynth-plugins
5aaf090d3523cb8c53841949f2da286688ba33bb
[ "BSD-2-Clause" ]
null
null
null
plugins/zimg/src/Common/align.h
darcyg/vapoursynth-plugins
5aaf090d3523cb8c53841949f2da286688ba33bb
[ "BSD-2-Clause" ]
null
null
null
plugins/zimg/src/Common/align.h
darcyg/vapoursynth-plugins
5aaf090d3523cb8c53841949f2da286688ba33bb
[ "BSD-2-Clause" ]
1
2020-04-06T16:52:59.000Z
2020-04-06T16:52:59.000Z
#pragma once #ifndef ZIMG_ALIGN_H_ #define ZIMG_ALIGN_H_ #include <vector> #ifdef _WIN32 #include <malloc.h> inline void *zimg_aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); } inline void zimg_aligned_free(void *ptr) { _aligned_free(ptr); } #else #include <stdlib.h> inline void *zimg_aligned_malloc(size_t size, int alignment) { void *p; if (posix_memalign(&p, alignment, size)) return nullptr; else return p; } inline void zimg_aligned_free(void *ptr) { free(ptr); } #endif namespace zimg {; /** * 32-byte alignment allows the use of instructions up to AVX. */ const int ALIGNMENT = 32; /** * Round up the argument x to the nearest multiple of n. * x must be non-negative and n must be positive. */ template <class T, class U> inline T align(T x, U n) { return x % n ? x + n - (x % n) : x; } /** * Round down the argument x to the nearest multiple of n. * x must be non-negative and n must be positive. */ template <class T, class U> inline T mod(T x, U n) { return x - (x % n); } /** * Helper struct that computes alignment in units of object count. * * @param T type of object */ template <class T> struct AlignmentOf { static const int value = ALIGNMENT / sizeof(T); }; /** * STL allocator class which returns aligned buffers. * * @param T type of object to allocate */ template <class T> struct AlignedAllocator { typedef T value_type; T *allocate(size_t n) const { T *ptr = (T *)zimg_aligned_malloc(n * sizeof(T), ALIGNMENT); if (!ptr) throw std::bad_alloc{}; return ptr; } void deallocate(void *ptr, size_t) const { zimg_aligned_free(ptr); } bool operator==(const AlignedAllocator &) const { return true; } bool operator!=(const AlignedAllocator &) const { return false; } }; /** * std::vector specialization using AlignedAllocator. */ template <class T> using AlignedVector = std::vector<T, AlignedAllocator<T>>; } // namespace zimg #endif // ZIMG_ALIGN_H_
23.5
147
0.691996
aa5520aed7067d648f07f8cf654a382c30796cec
1,328
c
C
basics/fixed_xor.c
aeroc7/crypto_misc
abdaff1209aa8f1c40605dd5ff98ef5a42b3dc59
[ "MIT" ]
null
null
null
basics/fixed_xor.c
aeroc7/crypto_misc
abdaff1209aa8f1c40605dd5ff98ef5a42b3dc59
[ "MIT" ]
null
null
null
basics/fixed_xor.c
aeroc7/crypto_misc
abdaff1209aa8f1c40605dd5ff98ef5a42b3dc59
[ "MIT" ]
null
null
null
#include <assert.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "../crypt_helpers.h" static struct DecodedData *xor_with( const struct DecodedData *data1, const struct DecodedData *data2) { assert(data1->size == data2->size); struct DecodedData *xord_data = NULL; xord_data = malloc(sizeof(struct DecodedData)); xord_data->size = data1->size; xord_data->data = malloc(xord_data->size + 1); for (size_t i = 0; i < xord_data->size; ++i) { xord_data->data[i] = (data1->data[i] ^ data2->data[i]); } xord_data->data[xord_data->size] = '\0'; return xord_data; } int main() { const char data[] = "1c0111001f010100061a024b53535009181c"; const char xor_data[] = "686974207468652062756c6c277320657965"; struct DecodedData *decoded_data = hex_decode(data, strlen(data)); struct DecodedData *decoded_xor_data = hex_decode(xor_data, strlen(xor_data)); struct DecodedData *result = xor_with(decoded_data, decoded_xor_data); for (size_t i = 0; i < result->size; ++i) { printf("%x", result->data[i]); } putchar('\n'); decoded_data = free_hex_decode(decoded_data); decoded_xor_data = free_hex_decode(decoded_xor_data); result = free_hex_decode(result); return EXIT_SUCCESS; }
27.102041
74
0.670181
e78901ca62d319809dd63a4339bcdca971637715
5,669
c
C
src/arch/riscv64/mach-d1/sys-hash.c
HareGun/xboot
4cc7db09c622d45c42774d5cbedcfef683c9b735
[ "MIT" ]
null
null
null
src/arch/riscv64/mach-d1/sys-hash.c
HareGun/xboot
4cc7db09c622d45c42774d5cbedcfef683c9b735
[ "MIT" ]
null
null
null
src/arch/riscv64/mach-d1/sys-hash.c
HareGun/xboot
4cc7db09c622d45c42774d5cbedcfef683c9b735
[ "MIT" ]
null
null
null
/* * sys-hash.c * * Copyright(c) 2007-2021 Jianjun Jiang <8192542@qq.com> * Official site: http://xboot.org * Mobile phone: +86-18665388956 * QQ: 8192542 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ #include <xboot.h> #define ror(v, n) (((v) >> (n)) | ((v) << (32 - (n)))) #define shr(v, n) ((v) >> (n)) struct sha256_ctx_t { uint32_t K[64]; uint64_t count; uint8_t buf[64]; uint32_t state[8]; }; static void sha256_transform(struct sha256_ctx_t * ctx) { uint32_t W[64]; uint32_t A, B, C, D, E, F, G, H; uint32_t s0, s1, t1, t2, ch, maj; uint32_t tmp; uint32_t * K; uint8_t * p; int t; K = ctx->K; p = ctx->buf; for(t = 0; t < 16; ++t) { tmp = *p++ << 24; tmp |= *p++ << 16; tmp |= *p++ << 8; tmp |= *p++; W[t] = tmp; } for(; t < 64; t++) { s0 = ror(W[t-15], 7) ^ ror(W[t-15], 18) ^ shr(W[t-15], 3); s1 = ror(W[t-2], 17) ^ ror(W[t-2], 19) ^ shr(W[t-2], 10); W[t] = W[t-16] + s0 + W[t-7] + s1; } A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; E = ctx->state[4]; F = ctx->state[5]; G = ctx->state[6]; H = ctx->state[7]; for(t = 0; t < 64; t++) { s0 = ror(A, 2) ^ ror(A, 13) ^ ror(A, 22); maj = (A & B) ^ (A & C) ^ (B & C); t2 = s0 + maj; s1 = ror(E, 6) ^ ror(E, 11) ^ ror(E, 25); ch = (E & F) ^ ((~E) & G); t1 = H + s1 + ch + K[t] + W[t]; H = G; G = F; F = E; E = D + t1; D = C; C = B; B = A; A = t1 + t2; } ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; ctx->state[4] += E; ctx->state[5] += F; ctx->state[6] += G; ctx->state[7] += H; } static void sha256_init(struct sha256_ctx_t * ctx) { uint32_t * K; K = ctx->K; K[ 0] = 0x428a2f98; K[ 1] = 0x71374491; K[ 2] = 0xb5c0fbcf; K[ 3] = 0xe9b5dba5; K[ 4] = 0x3956c25b; K[ 5] = 0x59f111f1; K[ 6] = 0x923f82a4; K[ 7] = 0xab1c5ed5; K[ 8] = 0xd807aa98; K[ 9] = 0x12835b01; K[10] = 0x243185be; K[11] = 0x550c7dc3; K[12] = 0x72be5d74; K[13] = 0x80deb1fe; K[14] = 0x9bdc06a7; K[15] = 0xc19bf174; K[16] = 0xe49b69c1; K[17] = 0xefbe4786; K[18] = 0x0fc19dc6; K[19] = 0x240ca1cc; K[20] = 0x2de92c6f; K[21] = 0x4a7484aa; K[22] = 0x5cb0a9dc; K[23] = 0x76f988da; K[24] = 0x983e5152; K[25] = 0xa831c66d; K[26] = 0xb00327c8; K[27] = 0xbf597fc7; K[28] = 0xc6e00bf3; K[29] = 0xd5a79147; K[30] = 0x06ca6351; K[31] = 0x14292967; K[32] = 0x27b70a85; K[33] = 0x2e1b2138; K[34] = 0x4d2c6dfc; K[35] = 0x53380d13; K[36] = 0x650a7354; K[37] = 0x766a0abb; K[38] = 0x81c2c92e; K[39] = 0x92722c85; K[40] = 0xa2bfe8a1; K[41] = 0xa81a664b; K[42] = 0xc24b8b70; K[43] = 0xc76c51a3; K[44] = 0xd192e819; K[45] = 0xd6990624; K[46] = 0xf40e3585; K[47] = 0x106aa070; K[48] = 0x19a4c116; K[49] = 0x1e376c08; K[50] = 0x2748774c; K[51] = 0x34b0bcb5; K[52] = 0x391c0cb3; K[53] = 0x4ed8aa4a; K[54] = 0x5b9cca4f; K[55] = 0x682e6ff3; K[56] = 0x748f82ee; K[57] = 0x78a5636f; K[58] = 0x84c87814; K[59] = 0x8cc70208; K[60] = 0x90befffa; K[61] = 0xa4506ceb; K[62] = 0xbef9a3f7; K[63] = 0xc67178f2; ctx->state[0] = 0x6a09e667; ctx->state[1] = 0xbb67ae85; ctx->state[2] = 0x3c6ef372; ctx->state[3] = 0xa54ff53a; ctx->state[4] = 0x510e527f; ctx->state[5] = 0x9b05688c; ctx->state[6] = 0x1f83d9ab; ctx->state[7] = 0x5be0cd19; ctx->count = 0; } static void sha256_update(struct sha256_ctx_t * ctx, char * buf, int len) { uint8_t * p; int i; p = (uint8_t *)buf; i = (int)(ctx->count & 63); ctx->count += len; while(len--) { ctx->buf[i++] = *p++; if(i == 64) { sha256_transform(ctx); i = 0; } } } static void sha256_final(struct sha256_ctx_t * ctx) { uint64_t cnt; uint32_t tmp; uint8_t * p; char c80, c0, c; int i; cnt = ctx->count << 3; p = ctx->buf; c80 = 0x80; c0 = 0x0; sha256_update(ctx, &c80, 1); while((ctx->count & 63) != 56) sha256_update(ctx, &c0, 1); for(i = 0; i < 8; ++i) { c = (uint8_t)(cnt >> ((7 - i) << 3)); sha256_update(ctx, &c, 1); } for(i = 0; i < 8; i++) { tmp = ctx->state[i]; *p++ = tmp >> 24; *p++ = tmp >> 16; *p++ = tmp >> 8; *p++ = tmp >> 0; } } int sys_hash_keygen(char * msg, void * key) { struct sha256_ctx_t ctx; char * p; if(msg && key) { sha256_init(&ctx); for(p = msg; *p != '\0'; ++p); sha256_update(&ctx, msg, p - msg); sha256_final(&ctx); memcpy(key, ctx.buf, 32); return 1; } return 0; } int sys_hash(char * id, char * buf, int len, char * sha256) { struct sha256_ctx_t ctx; char * p; int i; sha256_init(&ctx); if(id) { for(p = id; *p != '\0'; ++p); sha256_update(&ctx, id, p - id); } sha256_update(&ctx, buf, len); sha256_final(&ctx); for(i = 0; i < 32; i++) { if(ctx.buf[i] != sha256[i]) return 0; } return 1; }
25.536036
81
0.590404
43c88428e099574084e67c77a5829b763309e7ff
7,665
h
C
pow_accel_soc/software/u-boot-socfpga/include/configs/EXBITGEN.h
ajblane/iota_fpga
2ec78e89bf263a84905aba92437da5ec091ab621
[ "MIT" ]
13
2018-05-24T07:02:26.000Z
2021-04-13T12:48:24.000Z
pow_accel_soc/software/u-boot-socfpga/include/configs/EXBITGEN.h
ajblane/iota_fpga
2ec78e89bf263a84905aba92437da5ec091ab621
[ "MIT" ]
null
null
null
pow_accel_soc/software/u-boot-socfpga/include/configs/EXBITGEN.h
ajblane/iota_fpga
2ec78e89bf263a84905aba92437da5ec091ab621
[ "MIT" ]
14
2018-05-08T23:40:47.000Z
2022-02-12T00:12:06.000Z
/* * (C) Copyright 2000-2004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * board/config.h - configuration options, board specific */ #ifndef __CONFIG_H #define __CONFIG_H /* * High Level Configuration Options * (easy to change) */ #define CONFIG_405GP 1 /* This is a PPC405GP CPU */ #define CONFIG_4xx 1 /* ...member of PPC4xx family */ #define CONFIG_EXBITGEN 1 /* on a Exbit Generic board */ #define CONFIG_BOARD_EARLY_INIT_F 1 /* Call board_early_init_f */ #define CONFIG_SYS_CLK_FREQ 25000000 /* external frequency to pll */ /* I2C configuration */ #define CONFIG_HARD_I2C 1 /* I2C with hardware support */ #define CONFIG_SYS_I2C_SPEED 40000 /* I2C speed */ #define CONFIG_SYS_I2C_SLAVE 0x7F /* I2C slave address */ /* environment is in EEPROM */ #define CONFIG_ENV_IS_IN_EEPROM 1 #undef CONFIG_ENV_IS_IN_FLASH #undef CONFIG_ENV_IS_IN_NVRAM #ifdef CONFIG_ENV_IS_IN_EEPROM #define CONFIG_SYS_I2C_EEPROM_ADDR 0x56 /* 1010110 */ #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* 8-bit internal addressing */ #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW 1 /* ... and 1 bit in I2C address */ #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3 /* 4 bytes per page */ #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 40 /* write takes up to 40 msec */ #define CONFIG_ENV_OFFSET 4 /* Offset of Environment Sector */ #define CONFIG_ENV_SIZE 350 /* that is 350 bytes only! */ #endif #define CONFIG_BOOTDELAY 10 /* autoboot after 10 seconds */ /* Explanation: autbooting is altogether disabled and cannot be enabled if CONFIG_BOOTDELAY is negative. If you want shorter bootdelay, then - "setenv bootdelay <delay>" to the proper value */ #define CONFIG_BOOTCOMMAND "bootm 20400000 20800000" #define CONFIG_BOOTARGS "root=/dev/ram " \ "ramdisk_size=32768 " \ "console=ttyS0,115200 " \ "ram=128M debug" #define CONFIG_LOADS_ECHO 1 /* echo on for serial download */ #define CONFIG_SYS_LOADS_BAUD_CHANGE 1 /* allow baudrate change */ #define CONFIG_MII 1 /* MII PHY management */ #define CONFIG_PHY_ADDR 0 /* PHY address */ /* * BOOTP options */ #define CONFIG_BOOTP_BOOTFILESIZE #define CONFIG_BOOTP_BOOTPATH #define CONFIG_PPC4xx_EMAC #define CONFIG_BOOTP_GATEWAY #define CONFIG_BOOTP_HOSTNAME /* * Command line configuration. */ #include <config_cmd_default.h> #undef CONFIG_WATCHDOG /* watchdog disabled */ /* * Miscellaneous configurable options */ #define CONFIG_SYS_LONGHELP /* undef to save memory */ #define CONFIG_SYS_PROMPT "=> " /* Monitor Command Prompt */ #if defined(CONFIG_CMD_KGDB) #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ #else #define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */ #endif #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */ #define CONFIG_SYS_MAXARGS 16 /* max number of command args */ #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */ #define CONFIG_SYS_MEMTEST_START 0x0400000 /* memtest works on */ #define CONFIG_SYS_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ /* UART configuration */ #define CONFIG_SYS_BASE_BAUD 691200 /* Default baud rate */ #define CONFIG_BAUDRATE 115200 /* The following table includes the supported baudrates */ #define CONFIG_SYS_BAUDRATE_TABLE \ { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, \ 57600, 115200, 230400, 460800, 921600 } #define CONFIG_SYS_LOAD_ADDR 0x100000 /* default load address */ #define CONFIG_SYS_EXTBDINFO 1 /* To use extended board_into (bd_t) */ #define CONFIG_SYS_HZ 1000 /* decrementer freq: 1 ms ticks */ /*----------------------------------------------------------------------- * PCI stuff *----------------------------------------------------------------------- */ #undef CONFIG_PCI /* no pci support */ /*----------------------------------------------------------------------- * External peripheral base address *----------------------------------------------------------------------- */ #undef CONFIG_IDE_PCMCIA /* no pcmcia interface required */ #undef CONFIG_IDE_LED /* no led for ide supported */ #undef CONFIG_IDE_RESET /* no reset for ide supported */ #define CONFIG_SYS_KEY_REG_BASE_ADDR 0xF0100000 #define CONFIG_SYS_IR_REG_BASE_ADDR 0xF0200000 #define CONFIG_SYS_FPGA_REG_BASE_ADDR 0xF0300000 /*----------------------------------------------------------------------- * Start addresses for the final memory configuration * (Set up by the startup code) * Please note that CONFIG_SYS_SDRAM_BASE _must_ start at 0 */ #define CONFIG_SYS_SDRAM_BASE 0x00000000 #define CONFIG_SYS_FLASH0_BASE 0xFFF80000 #define CONFIG_SYS_FLASH0_SIZE 0x00080000 #define CONFIG_SYS_FLASH1_BASE 0x20000000 #define CONFIG_SYS_FLASH1_SIZE 0x02000000 #define CONFIG_SYS_FLASH_BASE CONFIG_SYS_FLASH0_BASE #define CONFIG_SYS_FLASH_SIZE CONFIG_SYS_FLASH0_SIZE #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE #define CONFIG_SYS_MONITOR_LEN (192 * 1024) /* Reserve 196 kB for Monitor */ #define CONFIG_SYS_MALLOC_LEN (128 * 1024) /* Reserve 128 kB for malloc() */ #if CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH0_BASE #define CONFIG_SYS_RAMSTART #endif /* * For booting Linux, the board info and command line data * have to be in the first 8 MB of memory, since this is * the maximum mapped by the Linux kernel during initialization. */ #define CONFIG_SYS_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ /*----------------------------------------------------------------------- * FLASH organization */ #define CONFIG_SYS_MAX_FLASH_BANKS 5 /* max number of memory banks */ #define CONFIG_SYS_MAX_FLASH_SECT 128 /* max number of sectors on one chip */ #define CONFIG_SYS_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */ #define CONFIG_SYS_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */ #ifdef CONFIG_ENV_IS_IN_FLASH #define CONFIG_ENV_OFFSET 0x00060000 /* Offset of Environment Sector */ #define CONFIG_ENV_SIZE 0x00010000 /* Total Size of Environment Sector */ #define CONFIG_ENV_SECT_SIZE 0x00010000 /* see README - env sector total size */ #endif /* On Chip Memory location/size */ #define CONFIG_SYS_OCM_DATA_ADDR 0xF8000000 #define CONFIG_SYS_OCM_DATA_SIZE 0x1000 /* Global info and initial stack */ #define CONFIG_SYS_INIT_RAM_ADDR CONFIG_SYS_OCM_DATA_ADDR /* inside of on-chip SRAM */ #define CONFIG_SYS_INIT_RAM_SIZE CONFIG_SYS_OCM_DATA_SIZE /* Size of used area in RAM */ #define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE) #define CONFIG_SYS_INIT_SP_OFFSET CONFIG_SYS_GBL_DATA_OFFSET #if defined(CONFIG_CMD_KGDB) #define CONFIG_KGDB_BAUDRATE 230400 /* speed to run kgdb serial port */ #define CONFIG_KGDB_SER_INDEX 2 /* which serial port to use */ #endif #endif /* __CONFIG_H */
36.327014
98
0.71272
a2ca77ef118058c20412af518b367d94ac46a120
320
h
C
walker_firmware/types.h
ensaminadin-pe/walker
9b084db2aefa827c0f92466c16a93abfe8f4bff9
[ "Unlicense" ]
null
null
null
walker_firmware/types.h
ensaminadin-pe/walker
9b084db2aefa827c0f92466c16a93abfe8f4bff9
[ "Unlicense" ]
null
null
null
walker_firmware/types.h
ensaminadin-pe/walker
9b084db2aefa827c0f92466c16a93abfe8f4bff9
[ "Unlicense" ]
null
null
null
#ifndef TYPES_H #define TYPES_H typedef signed char int8; typedef unsigned char uint8; typedef signed short int16; typedef unsigned short uint16; #ifdef IS_QT typedef signed long int32; typedef unsigned long uint32; #endif typedef signed long long int64; typedef unsigned long long uint64; #endif // TYPES_H
20
34
0.778125
2e99a67a3e1d2871d772770760b9a12fc3aa73ed
36,787
c
C
src/netpbm/10.27/netpbm-10.27/converter/ppm/ppmtompeg/jrevdct.c
cjd8363/Global-Illum
734987387d3cfb165979862cac862f837b554e2a
[ "TCL", "DOC" ]
2
2016-11-23T18:45:39.000Z
2017-08-28T14:45:50.000Z
vendor/C/netpbm/converter/ppm/ppmtompeg/jrevdct.c
ownclo/jpeg-on-steroids
deef3d015f07c46fedeaf0cceaadd4b702e89838
[ "BSD-3-Clause" ]
null
null
null
vendor/C/netpbm/converter/ppm/ppmtompeg/jrevdct.c
ownclo/jpeg-on-steroids
deef3d015f07c46fedeaf0cceaadd4b702e89838
[ "BSD-3-Clause" ]
1
2021-07-05T02:57:30.000Z
2021-07-05T02:57:30.000Z
/* * jrevdct.c * * Copyright (C) 1991, 1992, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains the basic inverse-DCT transformation subroutine. * * This implementation is based on an algorithm described in * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. * The primary algorithm described there uses 11 multiplies and 29 adds. * We use their alternate method with 12 multiplies and 32 adds. * The advantage of this method is that no data path contains more than one * multiplication; this allows a very simple and accurate implementation in * scaled fixed-point arithmetic, with a minimal number of shifts. * * I've made lots of modifications to attempt to take advantage of the * sparse nature of the DCT matrices we're getting. Although the logic * is cumbersome, it's straightforward and the resulting code is much * faster. * * A better way to do this would be to pass in the DCT block as a sparse * matrix, perhaps with the difference cases encoded. */ #include <memory.h> #include "all.h" #include "ansi.h" #include "dct.h" #define CONST_BITS 13 /* * This routine is specialized to the case DCTSIZE = 8. */ #if DCTSIZE != 8 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ #endif /* * A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT * on each column. Direct algorithms are also available, but they are * much more complex and seem not to be any faster when reduced to code. * * The poop on this scaling stuff is as follows: * * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) * larger than the true IDCT outputs. The final outputs are therefore * a factor of N larger than desired; since N=8 this can be cured by * a simple right shift at the end of the algorithm. The advantage of * this arrangement is that we save two multiplications per 1-D IDCT, * because the y0 and y4 inputs need not be divided by sqrt(N). * * We have to do addition and subtraction of the integer inputs, which * is no problem, and multiplication by fractional constants, which is * a problem to do in integer arithmetic. We multiply all the constants * by CONST_SCALE and convert them to integer constants (thus retaining * CONST_BITS bits of precision in the constants). After doing a * multiplication we have to divide the product by CONST_SCALE, with proper * rounding, to produce the correct output. This division can be done * cheaply as a right shift of CONST_BITS bits. We postpone shifting * as long as possible so that partial sums can be added together with * full fractional precision. * * The outputs of the first pass are scaled up by PASS1_BITS bits so that * they are represented to better-than-integral precision. These outputs * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word * with the recommended scaling. (To scale up 12-bit sample data further, an * intermediate int32 array would be needed.) * * To avoid overflow of the 32-bit intermediate results in pass 2, we must * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis * shows that the values given below are the most effective. */ #ifdef EIGHT_BIT_SAMPLES #define PASS1_BITS 2 #else #define PASS1_BITS 1 /* lose a little precision to avoid overflow */ #endif #define ONE ((int32) 1) #define CONST_SCALE (ONE << CONST_BITS) /* Convert a positive real constant to an integer scaled by CONST_SCALE. * IMPORTANT: if your compiler doesn't do this arithmetic at compile time, * you will pay a significant penalty in run time. In that case, figure * the correct integer constant values and insert them by hand. */ /* Actually FIX is no longer used, we precomputed them all */ #define FIX(x) ((int32) ((x) * CONST_SCALE + 0.5)) /* Descale and correctly round an int32 value that's scaled by N bits. * We assume RIGHT_SHIFT rounds towards minus infinity, so adding * the fudge factor is correct for either sign of X. */ #define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) /* Multiply an int32 variable by an int32 constant to yield an int32 result. * For 8-bit samples with the recommended scaling, all the variable * and constant values involved are no more than 16 bits wide, so a * 16x16->32 bit multiply can be used instead of a full 32x32 multiply; * this provides a useful speedup on many machines. * There is no way to specify a 16x16->32 multiply in portable C, but * some C compilers will do the right thing if you provide the correct * combination of casts. * NB: for 12-bit samples, a full 32-bit multiplication will be needed. */ #ifdef EIGHT_BIT_SAMPLES #ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ #define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const))) #endif #ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ #define MULTIPLY(var,const) (((INT16) (var)) * ((int32) (const))) #endif #endif #ifndef MULTIPLY /* default definition */ #define MULTIPLY(var,const) ((var) * (const)) #endif /* Unlike our decoder where we approximate the FIXes, we need to use exact ones here or successive P-frames will drift too much with Reference frame coding */ #define FIX_0_211164243 1730 #define FIX_0_275899380 2260 #define FIX_0_298631336 2446 #define FIX_0_390180644 3196 #define FIX_0_509795579 4176 #define FIX_0_541196100 4433 #define FIX_0_601344887 4926 #define FIX_0_765366865 6270 #define FIX_0_785694958 6436 #define FIX_0_899976223 7373 #define FIX_1_061594337 8697 #define FIX_1_111140466 9102 #define FIX_1_175875602 9633 #define FIX_1_306562965 10703 #define FIX_1_387039845 11363 #define FIX_1_451774981 11893 #define FIX_1_501321110 12299 #define FIX_1_662939225 13623 #define FIX_1_847759065 15137 #define FIX_1_961570560 16069 #define FIX_2_053119869 16819 #define FIX_2_172734803 17799 #define FIX_2_562915447 20995 #define FIX_3_072711026 25172 /* Switch on reverse_dct choices */ void reference_rev_dct _ANSI_ARGS_((int16 *block)); void mpeg_jrevdct_quick _ANSI_ARGS_((int16 *block)); void init_idctref _ANSI_ARGS_((void)); extern boolean pureDCT; void mpeg_jrevdct(data) DCTBLOCK data; { if (pureDCT) reference_rev_dct(data); else mpeg_jrevdct_quick(data); } /* * Perform the inverse DCT on one block of coefficients. */ void mpeg_jrevdct_quick(data) DCTBLOCK data; { int32 tmp0, tmp1, tmp2, tmp3; int32 tmp10, tmp11, tmp12, tmp13; int32 z1, z2, z3, z4, z5; int32 d0, d1, d2, d3, d4, d5, d6, d7; register DCTELEM *dataptr; int rowctr; SHIFT_TEMPS /* Pass 1: process rows. */ /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ /* furthermore, we scale the results by 2**PASS1_BITS. */ dataptr = data; for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) { /* Due to quantization, we will usually find that many of the input * coefficients are zero, especially the AC terms. We can exploit this * by short-circuiting the IDCT calculation for any row in which all * the AC terms are zero. In that case each output is equal to the * DC coefficient (with scale factor as needed). * With typical images and quantization tables, half or more of the * row DCT calculations can be simplified this way. */ register int *idataptr = (int*)dataptr; d0 = dataptr[0]; d1 = dataptr[1]; if ((d1 == 0) && (idataptr[1] | idataptr[2] | idataptr[3]) == 0) { /* AC terms all zero */ if (d0) { /* Compute a 32 bit value to assign. */ DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS); register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000); idataptr[0] = v; idataptr[1] = v; idataptr[2] = v; idataptr[3] = v; } dataptr += DCTSIZE; /* advance pointer to next row */ continue; } d2 = dataptr[2]; d3 = dataptr[3]; d4 = dataptr[4]; d5 = dataptr[5]; d6 = dataptr[6]; d7 = dataptr[7]; /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)*c(-6). */ { if (d6) { if (d4) { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = d4 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp2 - tmp0; tmp12 = -(tmp0 + tmp2); } } else { if (d0) { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = d4 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp2 - tmp0; tmp12 = -(tmp0 + tmp2); } } } else { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = d0 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp0 + tmp2; tmp12 = tmp0 - tmp2; } else { /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp10 = tmp3; tmp13 = -tmp3; tmp11 = tmp2; tmp12 = -tmp2; } } else { if (d0) { /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = d0 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp0 + tmp2; tmp12 = tmp0 - tmp2; } else { /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp10 = tmp3; tmp13 = -tmp3; tmp11 = tmp2; tmp12 = -tmp2; } } } } else { if (d4) { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = d4 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp2 - tmp0; tmp12 = -(tmp0 + tmp2); } } else { if (d0) { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = (d0 + d4) << CONST_BITS; tmp11 = tmp12 = (d0 - d4) << CONST_BITS; } else { /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = d4 << CONST_BITS; tmp11 = tmp12 = -tmp10; } } } else { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = d0 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp0 + tmp2; tmp12 = tmp0 - tmp2; } else { /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp10 = tmp3; tmp13 = -tmp3; tmp11 = tmp2; tmp12 = -tmp2; } } else { if (d0) { /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */ tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS; } else { /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */ tmp10 = tmp13 = tmp11 = tmp12 = 0; } } } } /* Odd part per figure 8; the matrix is unitary and hence its * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. */ if (d7) { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z2 = d5 + d3; z3 = d7 + d3; z4 = d5 + d1; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */ z2 = d5 + d3; z3 = d7 + d3; z5 = MULTIPLY(z3 + d5, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); z1 = MULTIPLY(-d7, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d5, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 = z1 + z4; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z4 = d5 + d1; z5 = MULTIPLY(d7 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d5, FIX_2_562915447); z3 = MULTIPLY(-d7, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 = z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(-d5, FIX_0_390180644); z5 = MULTIPLY(d5 + d7, FIX_1_175875602); z3 += z5; z4 += z5; tmp0 += z3; tmp1 += z4; tmp2 = z2 + z3; tmp3 = z1 + z4; } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z3 = d7 + d3; z5 = MULTIPLY(z3 + d1, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d3, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d1, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 = z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */ z3 = d7 + d3; tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); tmp2 = MULTIPLY(d3, FIX_0_509795579); z2 = MULTIPLY(-d3, FIX_2_562915447); z5 = MULTIPLY(z3, FIX_1_175875602); z3 = MULTIPLY(-z3, FIX_0_785694958); tmp0 += z3; tmp1 = z2 + z5; tmp2 += z3; tmp3 = z1 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z5 = MULTIPLY(z1, FIX_1_175875602); z1 = MULTIPLY(z1, FIX_0_275899380); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp0 = MULTIPLY(-d7, FIX_1_662939225); z4 = MULTIPLY(-d1, FIX_0_390180644); tmp3 = MULTIPLY(d1, FIX_1_111140466); tmp0 += z1; tmp1 = z4 + z5; tmp2 = z3 + z5; tmp3 += z1; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_1_387039845); tmp1 = MULTIPLY(d7, FIX_1_175875602); tmp2 = MULTIPLY(-d7, FIX_0_785694958); tmp3 = MULTIPLY(d7, FIX_0_275899380); } } } } else { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z4 = d5 + d1; z5 = MULTIPLY(d3 + z4, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-d1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-d3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 = z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z5 = MULTIPLY(z2, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_1_662939225); z4 = MULTIPLY(-d5, FIX_0_390180644); z2 = MULTIPLY(-z2, FIX_1_387039845); tmp2 = MULTIPLY(d3, FIX_1_111140466); z3 = MULTIPLY(-d3, FIX_1_961570560); tmp0 = z3 + z5; tmp1 += z2; tmp2 += z2; tmp3 = z4 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */ z4 = d5 + d1; z5 = MULTIPLY(z4, FIX_1_175875602); z1 = MULTIPLY(-d1, FIX_0_899976223); tmp3 = MULTIPLY(d1, FIX_0_601344887); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(z4, FIX_0_785694958); tmp0 = z1 + z5; tmp1 += z4; tmp2 = z2 + z5; tmp3 += z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */ tmp0 = MULTIPLY(d5, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_0_275899380); tmp2 = MULTIPLY(-d5, FIX_1_387039845); tmp3 = MULTIPLY(d5, FIX_0_785694958); } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */ z5 = d1 + d3; tmp3 = MULTIPLY(d1, FIX_0_211164243); tmp2 = MULTIPLY(-d3, FIX_1_451774981); z1 = MULTIPLY(d1, FIX_1_061594337); z2 = MULTIPLY(-d3, FIX_2_172734803); z4 = MULTIPLY(z5, FIX_0_785694958); z5 = MULTIPLY(z5, FIX_1_175875602); tmp0 = z1 - z4; tmp1 = z2 + z4; tmp2 += z5; tmp3 += z5; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(-d3, FIX_0_785694958); tmp1 = MULTIPLY(-d3, FIX_1_387039845); tmp2 = MULTIPLY(-d3, FIX_0_275899380); tmp3 = MULTIPLY(d3, FIX_1_175875602); } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(d1, FIX_0_275899380); tmp1 = MULTIPLY(d1, FIX_0_785694958); tmp2 = MULTIPLY(d1, FIX_1_175875602); tmp3 = MULTIPLY(d1, FIX_1_387039845); } else { /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = tmp1 = tmp2 = tmp3 = 0; } } } } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr[0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); dataptr[7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); dataptr[6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); dataptr[2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); dataptr[5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); dataptr += DCTSIZE; /* advance pointer to next row */ } /* Pass 2: process columns. */ /* Note that we must descale the results by a factor of 8 == 2**3, */ /* and also undo the PASS1_BITS scaling. */ dataptr = data; for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) { /* Columns of zeroes can be exploited in the same way as we did with rows. * However, the row calculation has created many nonzero AC terms, so the * simplification applies less often (typically 5% to 10% of the time). * On machines with very fast multiplication, it's possible that the * test takes more time than it's worth. In that case this section * may be commented out. */ d0 = dataptr[DCTSIZE*0]; d1 = dataptr[DCTSIZE*1]; d2 = dataptr[DCTSIZE*2]; d3 = dataptr[DCTSIZE*3]; d4 = dataptr[DCTSIZE*4]; d5 = dataptr[DCTSIZE*5]; d6 = dataptr[DCTSIZE*6]; d7 = dataptr[DCTSIZE*7]; /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)*c(-6). */ if (d6) { if (d4) { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = d4 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp2 - tmp0; tmp12 = -(tmp0 + tmp2); } } else { if (d0) { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = d4 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp2 - tmp0; tmp12 = -(tmp0 + tmp2); } } } else { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp0 = d0 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp0 + tmp2; tmp12 = tmp0 - tmp2; } else { /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */ z1 = MULTIPLY(d2 + d6, FIX_0_541196100); tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); tmp10 = tmp3; tmp13 = -tmp3; tmp11 = tmp2; tmp12 = -tmp2; } } else { if (d0) { /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp0 = d0 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp0 + tmp2; tmp12 = tmp0 - tmp2; } else { /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */ tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); tmp10 = tmp3; tmp13 = -tmp3; tmp11 = tmp2; tmp12 = -tmp2; } } } } else { if (d4) { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = (d0 + d4) << CONST_BITS; tmp1 = (d0 - d4) << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; } else { /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = d4 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp2 - tmp0; tmp12 = -(tmp0 + tmp2); } } else { if (d0) { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = (d0 + d4) << CONST_BITS; tmp11 = tmp12 = (d0 - d4) << CONST_BITS; } else { /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = d4 << CONST_BITS; tmp11 = tmp12 = -tmp10; } } } else { if (d2) { if (d0) { /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp0 = d0 << CONST_BITS; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp0 + tmp2; tmp12 = tmp0 - tmp2; } else { /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */ tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); tmp10 = tmp3; tmp13 = -tmp3; tmp11 = tmp2; tmp12 = -tmp2; } } else { if (d0) { /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */ tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS; } else { /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */ tmp10 = tmp13 = tmp11 = tmp12 = 0; } } } } /* Odd part per figure 8; the matrix is unitary and hence its * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. */ if (d7) { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z2 = d5 + d3; z3 = d7 + d3; z4 = d5 + d1; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7; z2 = d5 + d3; z3 = d7 + d3; z5 = MULTIPLY(z3 + d5, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); z1 = MULTIPLY(-d7, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d5, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 = z1 + z4; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */ z1 = d7 + d1; z2 = d5; z3 = d7; z4 = d5 + d1; z5 = MULTIPLY(z3 + z4, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d5, FIX_2_562915447); z3 = MULTIPLY(-d7, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 += z2 + z4; tmp2 = z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(-d5, FIX_0_390180644); z5 = MULTIPLY(d5 + d7, FIX_1_175875602); z3 += z5; z4 += z5; tmp0 += z3; tmp1 += z4; tmp2 = z2 + z3; tmp3 = z1 + z4; } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z3 = d7 + d3; z5 = MULTIPLY(z3 + d1, FIX_1_175875602); tmp0 = MULTIPLY(d7, FIX_0_298631336); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-z1, FIX_0_899976223); z2 = MULTIPLY(-d3, FIX_2_562915447); z3 = MULTIPLY(-z3, FIX_1_961570560); z4 = MULTIPLY(-d1, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 += z1 + z3; tmp1 = z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */ z3 = d7 + d3; tmp0 = MULTIPLY(-d7, FIX_0_601344887); z1 = MULTIPLY(-d7, FIX_0_899976223); tmp2 = MULTIPLY(d3, FIX_0_509795579); z2 = MULTIPLY(-d3, FIX_2_562915447); z5 = MULTIPLY(z3, FIX_1_175875602); z3 = MULTIPLY(-z3, FIX_0_785694958); tmp0 += z3; tmp1 = z2 + z5; tmp2 += z3; tmp3 = z1 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */ z1 = d7 + d1; z5 = MULTIPLY(z1, FIX_1_175875602); z1 = MULTIPLY(z1, FIX_0_275899380); z3 = MULTIPLY(-d7, FIX_1_961570560); tmp0 = MULTIPLY(-d7, FIX_1_662939225); z4 = MULTIPLY(-d1, FIX_0_390180644); tmp3 = MULTIPLY(d1, FIX_1_111140466); tmp0 += z1; tmp1 = z4 + z5; tmp2 = z3 + z5; tmp3 += z1; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */ tmp0 = MULTIPLY(-d7, FIX_1_387039845); tmp1 = MULTIPLY(d7, FIX_1_175875602); tmp2 = MULTIPLY(-d7, FIX_0_785694958); tmp3 = MULTIPLY(d7, FIX_0_275899380); } } } } else { if (d5) { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z4 = d5 + d1; z5 = MULTIPLY(d3 + z4, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_2_053119869); tmp2 = MULTIPLY(d3, FIX_3_072711026); tmp3 = MULTIPLY(d1, FIX_1_501321110); z1 = MULTIPLY(-d1, FIX_0_899976223); z2 = MULTIPLY(-z2, FIX_2_562915447); z3 = MULTIPLY(-d3, FIX_1_961570560); z4 = MULTIPLY(-z4, FIX_0_390180644); z3 += z5; z4 += z5; tmp0 = z1 + z3; tmp1 += z2 + z4; tmp2 += z2 + z3; tmp3 += z1 + z4; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3; z5 = MULTIPLY(z2, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_1_662939225); z4 = MULTIPLY(-d5, FIX_0_390180644); z2 = MULTIPLY(-z2, FIX_1_387039845); tmp2 = MULTIPLY(d3, FIX_1_111140466); z3 = MULTIPLY(-d3, FIX_1_961570560); tmp0 = z3 + z5; tmp1 += z2; tmp2 += z2; tmp3 = z4 + z5; } } else { if (d1) { /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */ z4 = d5 + d1; z5 = MULTIPLY(z4, FIX_1_175875602); z1 = MULTIPLY(-d1, FIX_0_899976223); tmp3 = MULTIPLY(d1, FIX_0_601344887); tmp1 = MULTIPLY(-d5, FIX_0_509795579); z2 = MULTIPLY(-d5, FIX_2_562915447); z4 = MULTIPLY(z4, FIX_0_785694958); tmp0 = z1 + z5; tmp1 += z4; tmp2 = z2 + z5; tmp3 += z4; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */ tmp0 = MULTIPLY(d5, FIX_1_175875602); tmp1 = MULTIPLY(d5, FIX_0_275899380); tmp2 = MULTIPLY(-d5, FIX_1_387039845); tmp3 = MULTIPLY(d5, FIX_0_785694958); } } } else { if (d3) { if (d1) { /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */ z5 = d1 + d3; tmp3 = MULTIPLY(d1, FIX_0_211164243); tmp2 = MULTIPLY(-d3, FIX_1_451774981); z1 = MULTIPLY(d1, FIX_1_061594337); z2 = MULTIPLY(-d3, FIX_2_172734803); z4 = MULTIPLY(z5, FIX_0_785694958); z5 = MULTIPLY(z5, FIX_1_175875602); tmp0 = z1 - z4; tmp1 = z2 + z4; tmp2 += z5; tmp3 += z5; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(-d3, FIX_0_785694958); tmp1 = MULTIPLY(-d3, FIX_1_387039845); tmp2 = MULTIPLY(-d3, FIX_0_275899380); tmp3 = MULTIPLY(d3, FIX_1_175875602); } } else { if (d1) { /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY(d1, FIX_0_275899380); tmp1 = MULTIPLY(d1, FIX_0_785694958); tmp2 = MULTIPLY(d1, FIX_1_175875602); tmp3 = MULTIPLY(d1, FIX_1_387039845); } else { /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = tmp1 = tmp2 = tmp3 = 0; } } } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS+PASS1_BITS+3); dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS+PASS1_BITS+3); dataptr++; /* advance pointer to next column */ } } /* here is the reference one, in case of problems with the normal one */ /* idctref.c, Inverse Discrete Fourier Transform, double precision */ /* Copyright (C) 1994, MPEG Software Simulation Group. All Rights Reserved. */ /* * Disclaimer of Warranty * * These software programs are available to the user without any license fee or * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims * any and all warranties, whether express, implied, or statuary, including any * implied warranties or merchantability or of fitness for a particular * purpose. In no event shall the copyright-holder be liable for any * incidental, punitive, or consequential damages of any kind whatsoever * arising from the use of these programs. * * This disclaimer of warranty extends to the user of these programs and user's * customers, employees, agents, transferees, successors, and assigns. * * The MPEG Software Simulation Group does not represent or warrant that the * programs furnished hereunder are free of infringement of any third-party * patents. * * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, * are subject to royalty fees to patent holders. Many of these patents are * general enough such that they are unavoidable regardless of implementation * design. * */ /* Perform IEEE 1180 reference (64-bit floating point, separable 8x1 * direct matrix multiply) Inverse Discrete Cosine Transform */ /* Here we use math.h to generate constants. Compiler results may vary a little */ #ifndef PI #ifdef M_PI #define PI M_PI #else #define PI 3.14159265358979323846 #endif #endif /* cosine transform matrix for 8x1 IDCT */ static double itrans_coef[8][8]; /* initialize DCT coefficient matrix */ void init_idctref() { int freq, time; double scale; for (freq=0; freq < 8; freq++) { scale = (freq == 0) ? sqrt(0.125) : 0.5; for (time=0; time<8; time++) itrans_coef[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5)); } } /* perform IDCT matrix multiply for 8x8 coefficient block */ void reference_rev_dct(block) int16 *block; { int i, j, k, v; double partial_product; double tmp[64]; for (i=0; i<8; i++) for (j=0; j<8; j++) { partial_product = 0.0; for (k=0; k<8; k++) partial_product+= itrans_coef[k][j]*block[8*i+k]; tmp[8*i+j] = partial_product; } /* Transpose operation is integrated into address mapping by switching loop order of i and j */ for (j=0; j<8; j++) for (i=0; i<8; i++) { partial_product = 0.0; for (k=0; k<8; k++) partial_product+= itrans_coef[k][i]*tmp[8*k+j]; v = floor(partial_product+0.5); block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v); } }
28.762314
81
0.563297
bda20eb133d0cbd36643fe64480f7a08b7d63658
744
c
C
src/add-ons/accelerants/neomagic/GetTimingConstraints.c
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
1,338
2015-01-03T20:06:56.000Z
2022-03-26T13:49:54.000Z
src/add-ons/accelerants/neomagic/GetTimingConstraints.c
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
15
2015-01-17T22:19:32.000Z
2021-12-20T12:35:00.000Z
src/add-ons/accelerants/neomagic/GetTimingConstraints.c
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
350
2015-01-08T14:15:27.000Z
2022-03-21T18:14:35.000Z
/* Author: Rudolf Cornelissen 11/2004 */ #define MODULE_BIT 0x01000000 #include "acc_std.h" /* Used to help generate mode lines */ status_t GET_TIMING_CONSTRAINTS(display_timing_constraints * dtc) { LOG(4, ("GET_TIMING_CONSTRAINTS: returning info\n")); /* specs are identical for all Neomagic cards */ dtc->h_res = 8; dtc->h_sync_min = 8; dtc->h_sync_max = 248; /* Note: * h_blank info is used to determine the max. diff. between h_total and h_display! */ dtc->h_blank_min = 8; dtc->h_blank_max = 504; dtc->v_res = 1; dtc->v_sync_min = 1; dtc->v_sync_max = 15; /* Note: * v_blank info is used to determine the max. diff. between v_total and v_display! */ dtc->v_blank_min = 1; dtc->v_blank_max = 255; return B_OK; }
21.882353
86
0.697581
ec8a32a6e876bd4e6d042294afc42e8f5509e18f
231
c
C
libsrc/cpcmath/ceil.c
dex4er/deb-z88dk
9ee4f23444fa6f6043462332a1bff7ae20a8504b
[ "ClArtistic" ]
1
2018-09-04T23:07:24.000Z
2018-09-04T23:07:24.000Z
libsrc/cpcmath/ceil.c
dex4er/deb-z88dk
9ee4f23444fa6f6043462332a1bff7ae20a8504b
[ "ClArtistic" ]
null
null
null
libsrc/cpcmath/ceil.c
dex4er/deb-z88dk
9ee4f23444fa6f6043462332a1bff7ae20a8504b
[ "ClArtistic" ]
null
null
null
/* * CPC Maths Routines * * August 2003 **_|warp6|_** <kbaccam /at/ free.fr> * * $Id: ceil.c,v 1.1 2003/08/30 16:42:48 dom Exp $ */ #include <float.h> #include <math.h> float ceil(float x) { return (float)((int)x); }
12.833333
53
0.575758
83aff6bcf1e0935999773b4582dbfa75fd2f2982
3,406
h
C
PrivateFrameworks/HomeKitDaemon/HMDSoftwareUpdateDocumentationAsset.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/HomeKitDaemon/HMDSoftwareUpdateDocumentationAsset.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/HomeKitDaemon/HMDSoftwareUpdateDocumentationAsset.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 "HMFObject.h" #import "HMFLogging.h" #import "HMFObject.h" #import "NSSecureCoding.h" #import "NSURLSessionDownloadDelegate.h" #import "SZExtractorDelegate.h" @class HMSoftwareUpdateDocumentation, HMSoftwareUpdateDocumentationMetadata, NSArray, NSInputStream, NSObject<OS_dispatch_queue>, NSString, NSURL, NSURLSession, NSUUID, SZExtractor; @interface HMDSoftwareUpdateDocumentationAsset : HMFObject <HMFLogging, HMFObject, NSURLSessionDownloadDelegate, SZExtractorDelegate, NSSecureCoding> { BOOL _shouldAutomaticallyCache; long long _state; NSUUID *_identifier; HMSoftwareUpdateDocumentationMetadata *_metadata; NSObject<OS_dispatch_queue> *_clientQueue; NSObject<OS_dispatch_queue> *_propertyQueue; NSURLSession *_URLSession; SZExtractor *_extrator; NSInputStream *_archivedFileStream; } + (BOOL)supportsSecureCoding; + (id)logCategory; + (id)assetWithURL:(id)arg1; + (id)assetDirectoryURL; @property(retain, nonatomic) NSInputStream *archivedFileStream; // @synthesize archivedFileStream=_archivedFileStream; @property(retain, nonatomic) SZExtractor *extrator; // @synthesize extrator=_extrator; @property(retain, nonatomic) NSURLSession *URLSession; // @synthesize URLSession=_URLSession; @property(readonly) NSObject<OS_dispatch_queue> *propertyQueue; // @synthesize propertyQueue=_propertyQueue; @property(readonly, nonatomic) NSObject<OS_dispatch_queue> *clientQueue; // @synthesize clientQueue=_clientQueue; @property(readonly) HMSoftwareUpdateDocumentationMetadata *metadata; // @synthesize metadata=_metadata; @property(readonly, copy) NSUUID *identifier; // @synthesize identifier=_identifier; - (void).cxx_destruct; - (void)setExtractionProgress:(double)arg1; - (void)URLSession:(id)arg1 downloadTask:(id)arg2 didFinishDownloadingToURL:(id)arg3; - (void)URLSession:(id)arg1 downloadTask:(id)arg2 didWriteData:(long long)arg3 totalBytesWritten:(long long)arg4 totalBytesExpectedToWrite:(long long)arg5; - (void)URLSession:(id)arg1 task:(id)arg2 didCompleteWithError:(id)arg3; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; - (id)logIdentifier; - (void)finishUnarchive; - (void)cancelUnarchive; - (void)startUnarchive; - (void)finishDownload; - (void)cancelDownload; - (void)startDownload; - (BOOL)purgeWithError:(id *)arg1; - (void)startCaching; - (BOOL)saveWithError:(id *)arg1; @property(readonly, copy) HMSoftwareUpdateDocumentation *documentation; - (id)bundleURL; - (id)archiveURL; - (id)metadataURL; @property(readonly, copy) NSURL *URL; - (void)setState:(long long)arg1; @property(readonly) long long state; // @synthesize state=_state; @property BOOL shouldAutomaticallyCache; // @synthesize shouldAutomaticallyCache=_shouldAutomaticallyCache; - (BOOL)isEqual:(id)arg1; @property(readonly) unsigned long long hash; @property(readonly, copy) NSString *propertyDescription; @property(readonly, copy) NSString *shortDescription; - (id)initWithDocumentationMetadata:(id)arg1; - (id)init; // Remaining properties @property(readonly, copy, nonatomic) NSArray *attributeDescriptions; @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly, copy) NSString *privateDescription; @property(readonly) Class superclass; @end
41.536585
181
0.788021
26353b6bce976f797896c42edbc669d0ffac482c
2,203
c
C
drivers/net/wireless/mediatek/mt76/mmio.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
44
2022-03-16T08:32:31.000Z
2022-03-31T16:02:35.000Z
drivers/net/wireless/mediatek/mt76/mmio.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
13
2021-07-10T04:36:17.000Z
2022-03-03T10:50:05.000Z
drivers/net/wireless/mediatek/mt76/mmio.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
18
2022-03-19T04:41:04.000Z
2022-03-31T03:32:12.000Z
// SPDX-License-Identifier: ISC /* * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> */ #include "mt76.h" #include "trace.h" static u32 mt76_mmio_rr(struct mt76_dev *dev, u32 offset) { u32 val; val = readl(dev->mmio.regs + offset); trace_reg_rr(dev, offset, val); return val; } static void mt76_mmio_wr(struct mt76_dev *dev, u32 offset, u32 val) { trace_reg_wr(dev, offset, val); writel(val, dev->mmio.regs + offset); } static u32 mt76_mmio_rmw(struct mt76_dev *dev, u32 offset, u32 mask, u32 val) { val |= mt76_mmio_rr(dev, offset) & ~mask; mt76_mmio_wr(dev, offset, val); return val; } static void mt76_mmio_write_copy(struct mt76_dev *dev, u32 offset, const void *data, int len) { __iowrite32_copy(dev->mmio.regs + offset, data, DIV_ROUND_UP(len, 4)); } static void mt76_mmio_read_copy(struct mt76_dev *dev, u32 offset, void *data, int len) { __ioread32_copy(data, dev->mmio.regs + offset, DIV_ROUND_UP(len, 4)); } static int mt76_mmio_wr_rp(struct mt76_dev *dev, u32 base, const struct mt76_reg_pair *data, int len) { while (len > 0) { mt76_mmio_wr(dev, data->reg, data->value); data++; len--; } return 0; } static int mt76_mmio_rd_rp(struct mt76_dev *dev, u32 base, struct mt76_reg_pair *data, int len) { while (len > 0) { data->value = mt76_mmio_rr(dev, data->reg); data++; len--; } return 0; } void mt76_set_irq_mask(struct mt76_dev *dev, u32 addr, u32 clear, u32 set) { unsigned long flags; spin_lock_irqsave(&dev->mmio.irq_lock, flags); dev->mmio.irqmask &= ~clear; dev->mmio.irqmask |= set; if (addr) mt76_mmio_wr(dev, addr, dev->mmio.irqmask); spin_unlock_irqrestore(&dev->mmio.irq_lock, flags); } EXPORT_SYMBOL_GPL(mt76_set_irq_mask); void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs) { static const struct mt76_bus_ops mt76_mmio_ops = { .rr = mt76_mmio_rr, .rmw = mt76_mmio_rmw, .wr = mt76_mmio_wr, .write_copy = mt76_mmio_write_copy, .read_copy = mt76_mmio_read_copy, .wr_rp = mt76_mmio_wr_rp, .rd_rp = mt76_mmio_rd_rp, .type = MT76_BUS_MMIO, }; dev->bus = &mt76_mmio_ops; dev->mmio.regs = regs; spin_lock_init(&dev->mmio.irq_lock); } EXPORT_SYMBOL_GPL(mt76_mmio_init);
21.811881
77
0.702224