type
stringclasses
5 values
content
stringlengths
9
163k
includes
#include <stdatomic.h>
includes
#include <pthread.h>
main
int main(int argc, char *argv[]){ pthread_t thr0; pthread_t thr1; atomic_init(&vars[1], 0); atomic_init(&vars[3], 0); atomic_init(&vars[0], 0); atomic_init(&vars[2], 0); atomic_init(&atom_1_r1_1, 0); pthread_create(&thr0, NULL, t0, NULL); pthread_create(&thr1, NULL, t1, NULL); pthread_join(thr0...
includes
#include<stdio.h>
includes
#include<stdlib.h>
functions
void display(float **mat,int n){ int i,j; for (i=0;i<n;i++){ for (j=0;j<n;j++) printf("%f ",mat[i][j]); printf("\n"); }
includes
#include <stdio.h>
includes
#include <unistd.h>
includes
#include <stdlib.h>
includes
#include <string.h>
includes
#include <errno.h>
includes
#include <time.h>
includes
#include <fcntl.h>
functions
int write_2_led(const char* value) { int ret; fled = open(GLED01_DEV, O_RDWR); if (fled < 0) return -1; ret = write(fled, value, 1); close(fled); if (ret < 0) return errno; return 0; }
functions
void remove_log_file() { if (!unlink(LOG_PATH)) logger ("Success!"); else logger (msg_err("Error", errno) ); }
functions
void set_silent(bool s) { silent = s; }
functions
void logger(const char* msg) { char buffer[200]; strcpy(buffer, "["); time_t current_time; char *c_time_string; current_time = time(NULL); c_time_string = ctime(&current_time); c_time_string[strlen(c_time_string)-1] = 0; strcat(buffer, c_time_string); strcat(buffer, "] "); strcat(buffer, msg); strcat(buffer,...
functions
int read_from_file(const char* name, char* buffer) { char io_state[1]; buffer = malloc(2); fd = fopen(name, "r"); if (fd == NULL) return -1; if (fgets (io_state, 1, fd) != NULL) { strcpy(buffer,io_state); buffer[1] = 0; //null terminated fclose(fd); return 0; }
includes
#include <linux/kernel.h>
includes
#include <linux/init.h>
includes
#include <linux/err.h>
includes
#include <linux/platform_device.h>
functions
int omap_hdq1w_reset(struct omap_hwmod *oh) { u32 v; int c = 0; /* Write to the SOFTRESET bit */ omap_hwmod_softreset(oh); /* Enable the module's internal clocks */ v = omap_hwmod_read(oh, HDQ_CTRL_STATUS_OFFSET); v |= 1 << HDQ_CTRL_STATUS_CLOCKENABLE_SHIFT; omap_hwmod_write(v, oh, HDQ_CTRL_STATUS_OFFSET); ...
functions
__init omap_init_hdq(void) { int id = -1; struct platform_device *pdev; struct omap_hwmod *oh; char *oh_name = "hdq1w"; char *devname = "omap_hdq"; oh = omap_hwmod_lookup(oh_name); if (!oh) { return 0; }
includes
#include <linux/kernel.h>
includes
#include <linux/init.h>
includes
#include <linux/io.h>
includes
#include <linux/slab.h>
includes
#include <linux/leds.h>
includes
#include <asm/mach-types.h>
functions
void ebsa110_led_set(struct led_classdev *cdev, enum led_brightness b) { u8 reg = __raw_readb(SOFT_BASE); if (b != LED_OFF) { reg |= 0x80; }
functions
led_brightness ebsa110_led_get(struct led_classdev *cdev) { u8 reg = __raw_readb(SOFT_BASE); return (reg & 0x80) ? LED_FULL : LED_OFF; }
functions
__init ebsa110_leds_init(void) { struct led_classdev *cdev; int ret; if (!machine_is_ebsa110()) { return -ENODEV; }
includes
#include <time.h>
defines
#define WAIT(t) TITLE_SCRIPT_WAIT, t
defines
#define LOADMM() TITLE_SCRIPT_LOADMM
defines
#define LOCATION(x, y) TITLE_SCRIPT_LOCATION, x, y
defines
#define ROTATE(n) TITLE_SCRIPT_ROTATE, n
defines
#define ZOOM(d) TITLE_SCRIPT_ZOOM, d
defines
#define RESTART() TITLE_SCRIPT_RESTART
defines
#define LOAD(i) TITLE_SCRIPT_LOAD, i
functions
void title_load() { log_verbose("loading title"); if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) & 1) pause_toggle(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; reset_park_entrances(); user_string_clear_all(); reset_sprite_list(); ride_init_all(); window_guest_list_init_vars...
functions
void title_create_windows() { window_main_open(); window_title_menu_open(); window_title_exit_open(); window_title_options_open(); window_title_logo_open(); window_resize_gui(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16)); }
functions
void title_init_showcase() { _scriptNoLoadsSinceRestart = 1; SafeFree(_loadedScript); _currentScript = _magicMountainScript; switch (gConfigGeneral.title_sequence) { case TITLE_SEQUENCE_OPENRCT2: _loadedScript = title_script_load(); if (_loadedScript != NULL) _currentScript = _loadedScript; break; case...
functions
int title_load_park(const char *path) { rct_window* w; int successfulLoad; successfulLoad = _strcmpi(path_get_extension(path), ".sv6") == 0 ? game_load_sv6(path) : scenario_load(path); if (!successfulLoad) return 0; w = window_get_main(); w->viewport_target_sprite = -1; w->saved_view_x = RCT2_GLOBAL(RCT...
functions
void title_skip_opcode() { uint8 script_opcode; script_opcode = *_currentScript++; switch (script_opcode) { case TITLE_SCRIPT_WAIT: _currentScript++; break; case TITLE_SCRIPT_LOADMM: _currentScript++; break; case TITLE_SCRIPT_LOCATION: _currentScript++; _currentScript++; break; case TITLE_SCRIPT_R...
functions
void title_do_next_script_opcode() { int i; short x, y, z; uint8 script_opcode, script_operand; rct_window* w; script_opcode = *_currentScript++; switch (script_opcode) { case TITLE_SCRIPT_WAIT: _scriptWaitCounter = (*_currentScript++) * 32; break; case TITLE_SCRIPT_LOADMM: if (!title_load_park(get_file...
functions
void title_update_showcase() { if (_scriptWaitCounter <= 0) { do { title_do_next_script_opcode(); }
functions
void DrawOpenRCT2(int x, int y) { char buffer[256]; rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo); // Draw background gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8); // Format text (name and version) sprintf(buffer, "%c%c%c%s, v%s", FORMAT_MEDIUMFONT, FORMAT...
functions
void title_update() { screenshot_check(); title_handle_keyboard_input(); if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0) { title_update_showcase(); game_logic_update(); start_title_music(); }
functions
void title_script_get_line(FILE *file, char *parts) { int i, c, part, cindex, whitespace, comment; for (i = 0; i < 3; i++) parts[i * 32] = 0; part = 0; cindex = 0; whitespace = 1; comment = 0; for (;;) { c = fgetc(file); if (c == '\n' || c == '\r' || c == EOF) { parts[part * 32 + cindex] = 0; retur...
functions
else if (c == '#') { parts[part * 32 + cindex] = 0; comment = 1; }
functions
else if (c == ' ' && !comment) { if (!whitespace) { parts[part * 32 + cindex] = 0; part++; cindex = 0; }
functions
else if (!comment) { whitespace = 0; if (cindex < 31) { parts[part * 32 + cindex] = c; cindex++; }
includes
#include <stdlib.h>
includes
#include <stdio.h>
includes
#include <stdint.h>
includes
#include <fcntl.h>
includes
#include <types.h>
includes
#include <accessClient.h>
includes
#include <bstrlib.h>
includes
#include <affinity.h>
includes
#include <topology.h>
includes
#include <error.h>
functions
int getBusFromSocket(const uint32_t socket) { int cur_bus = 0; uint32_t cur_socket = 0; char pci_filepath[1024]; int fp; int ret = 0; while(cur_socket <= socket) { sprintf(pci_filepath, "/proc/bus/pci/%02x/05.0", cur_bus); fp = open(pci_filepath, O_RDONLY); if (fp < 0...
functions
int proc_pci_init(uint16_t testDevice, char** socket_bus, int* nrSockets) { FILE *fptr; char buf[1024]; int cntr = 0; uint16_t testVendor = 0x8086; uint32_t sbus, sdevfn, svend, sdev; int busID; if ( (fptr = fopen( "/proc/bus/pci/devices", "r")) == NULL ) { fprintf(stderr, ...
functions
Vram v_lock(SDL_Texture* const texture) { void* raw; int pitch; SDL_LockTexture(texture, NULL, &raw, &pitch); const Vram vram = { (uint32_t*) raw, (int) (pitch / sizeof(uint32_t)) }
functions
void v_unlock(SDL_Texture* const texture) { SDL_UnlockTexture(texture); }
functions
void v_draw_rooms(const Vram vram, const Map map, const uint32_t in, const uint32_t out) { for(int y = 1; y < map.rows - 1; y++) for(int x = 1; x < map.cols - 1; x++) { if(map.walling[y][x] != ' ' && map.walling[y][x + 1] == ' ') vram.pixels[x + y * vram.width] = out; if(map.walling[y][x] !=...
functions
void v_draw_dot(const Vram vram, const Point where, const int size, const uint32_t in, const uint32_t out) { for(int y = -size; y <= size; y++) for(int x = -size; x <= size; x++) { const int xx = x + where.x; const int yy = y + where.y; vram.pixels[xx + yy * vram.width] = in; ...
defines
#define NETF(x) (size_t)&((entityState_t*)0)->x, 1
defines
#define NETA(x) (size_t)&((entityState_t*)0)->x, ARRAY_LEN( ((entityState_t*)0)->x )
defines
#define PSF(x) (size_t)&((playerState_t*)0)->x, 1
defines
#define PSA(x) (size_t)&((playerState_t*)0)->x, ARRAY_LEN( ((playerState_t*)0)->x )
functions
qboolean BG_CheckSpawnEntity( const bgEntitySpawnInfo_t *info ) { int i, gametype; char *s, *value, *gametypeName; static char *gametypeNames[GT_MAX_GAME_TYPE] = {"ffa", "tournament", "single", "team", "ctf" #ifdef MISSIONPACK , "oneflag", "obelisk", "harvester" #endif }
functions
flag if ( gametype == GT_SINGLE_PLAYER ) { info->spawnInt( "notsingle", "0", &i ); if ( i ) { return qfalse; }
functions
qboolean BG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime ) { vec3_t origin; BG_EvaluateTrajectory( &item->pos, atTime, origin ); // we are ignoring ducked differences here if ( ps->origin[0] - origin[0] > 36 || ps->origin[0] - origin[0] < -36 || ps->origin[1] - origin[1] > 36 || ps...
functions
qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ) { gitem_t *item; int upperBound; if ( ent->modelindex < 1 || ent->modelindex >= BG_NumItems() ) { Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" ); }
functions
handicapping if ( ps->stats[STAT_ARMOR] >= upperBound ) { return qfalse; }
functions
endif if ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] ) { return qfalse; }
functions
time if ( ps->stats[STAT_PERSISTANT_POWERUP] ) { return qfalse; }
functions
MISSIONPACK if( gametype == GT_1FCTF ) { // neutral flag can always be picked up if( item->giTag == PW_NEUTRALFLAG ) { return qtrue; }
functions
else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) { if (item->giTag == PW_REDFLAG && ps->powerups[PW_NEUTRALFLAG] ) { return qtrue; }
functions
endif if( gametype == GT_CTF ) { // ent->modelindex2 is non-zero on items if they are dropped // we need to know this because we can pick up our dropped flag (and return it) // but we can't pick up our flag at base if (ps->persistant[PERS_TEAM] == TEAM_RED) { if (item->giTag == PW_BLUEFLAG || (it...
functions
else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) { if (item->giTag == PW_REDFLAG || (item->giTag == PW_BLUEFLAG && ent->modelindex2) || (item->giTag == PW_BLUEFLAG && ps->powerups[PW_REDFLAG]) ) return qtrue; }
functions
MISSIONPACK if( gametype == GT_HARVESTER ) { return qtrue; }
functions
time if ( ps->stats[STAT_HOLDABLE_ITEM] ) { return qfalse; }
functions
void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) { float deltaTime; float phase; switch( tr->trType ) { case TR_STATIONARY: case TR_INTERPOLATE: VectorCopy( tr->trBase, result ); break; case TR_LINEAR: deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds ...
functions
seconds if ( deltaTime < 0 ) { deltaTime = 0; }
functions
void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) { float deltaTime; float phase; switch( tr->trType ) { case TR_STATIONARY: case TR_INTERPOLATE: VectorClear( result ); break; case TR_LINEAR: VectorCopy( tr->trDelta, result ); break; case TR_SINE: deltaTime = ( atTim...
functions
void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps ) { #ifdef _DEBUG { char buf[256]; trap_Cvar_VariableStringBuffer("showevents", buf, sizeof(buf)); if ( atof(buf) != 0 ) { #ifdef GAME Com_Printf(" game event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*...
functions
void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ) { vec3_t angles; float p; int effectNum; // spectators don't use jump pads if ( ps->pm_type != PM_NORMAL ) { return; }
functions
pads if ( ps->powerups[PW_FLIGHT] ) { return; }
functions
trigger if ( ps->jumppad_ent != jumppad->number ) { vectoangles( jumppad->origin2, angles); p = fabs( AngleNormalize180( angles[PITCH] ) ); if( p < 45 ) { effectNum = 0; }
functions
void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ) { int i; if ( !ps->linked ) { s->eType = ET_INVISIBLE; }
functions
else if ( ps->entityEventSequence < ps->eventSequence ) { int seq; if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) { ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS; }
functions
void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ) { int i; if ( !ps->linked ) { s->eType = ET_INVISIBLE; }
functions
else if ( ps->entityEventSequence < ps->eventSequence ) { int seq; if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) { ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS; }
functions
void BG_ComposeBits( int *msg, int *bitsUsed, int value, int bits ) { *msg |= ( value & ( ( 1 << bits ) - 1 ) ) << *bitsUsed; *bitsUsed += bits; if ( *bitsUsed > 32 ) { Com_Error( ERR_DROP, "BG_ComposeBits exceeded 32 bits" ); }
functions
void BG_DecomposeBits( int msg, int *bitsUsed, int *value, int bits ) { if ( value ) { *value = ( msg >> *bitsUsed ) & ( ( 1 << bits ) - 1 ); }