int zkServer::isLeader() { int ret = 0; int flag = 1; if(NULL == zkhandle) { ERROR_PRINT(" zkhandle is NULL ", ""); return -1; } struct String_vector strings; DEBUG_PRINT("root %s server_name %s count %u", root.c_str(), server_name.c_str(), strings.count); ret = zoo_get_children(zkhandle, (root+server_name).c_str(), 0, &strings); if (ret) { ERROR_PRINT("Error %d for %s", ret, "get_children"); return -1; } int i; for ( i=0; i<strings.count; i++ ) { DEBUG_PRINT("node_name %s string[%d].data %s", node_name.c_str(), i, strings.data[i]); if ( strcmp(node_name.c_str(), strings.data[i])>0 ) { /* 如果我自己不是最小的节点 */ flag = 0; break; } } deallocate_String_vector(&strings); return flag; }
/* 监视league下的节点变化事件 */ int zkServer::watchChildren() { if(NULL == zkhandle) { ERROR_PRINT(" zkhandle is NULL ", ""); return -1; } int ret = 0; memset(¶, 0, sizeof(para)); para.zkhandle = zkhandle; strcpy(para.node, node_name.c_str()); DEBUG_PRINT("node_name %s para.node %s", node_name.c_str(), para.node); para.zks = this; struct String_vector strings; struct Stat stat; ret = zoo_wget_children2(zkhandle, (root+server_name).c_str(), election_watcher, ¶, &strings, &stat); if (ret) { ERROR_PRINT("error %d of %s", ret, "wget children2"); return -2; } deallocate_String_vector(&strings); return ret; }
hid_return hid_os_force_claim(HIDInterface* const hidif, int const interface, HIDInterfaceMatcher const* const matcher, unsigned short retries UNUSED) { if (!hidif) { ERROR_PRINT("cannot open NULL HIDInterface."); return HID_RET_INVALID_PARAMETER; } if (!hid_is_opened(hidif)) { ERROR_PRINT("cannot force claim interface of unopened HIDInterface."); return HID_RET_DEVICE_ALREADY_OPENED; } if (!matcher) { ERROR_PRINT("cannot match against NULL HIDInterfaceMatcher."); return HID_RET_INVALID_PARAMETER; } WARNING_PRINT("code not tested on the Darwin platform!"); TRACE_PRINT("claiming USB device %s...", hidif->id); #if 1 if (usb_claim_interface(hidif->dev_handle, interface) < 0) { WARNING_PRINT("failed to claim USB device %s...", hidif->id); /* return HID_RET_FAIL_CLAIM_IFACE; */ } #endif return HID_RET_SUCCESS; }
int main ( int argc, const char*argv[] ) { bool bret; CSemaphoreMutex sem; int sec = 3; int id; signal(SIGINT,Sighandler); signal(SIGTERM,Sighandler); if ( argc < 3 ) { ERROR_PRINT ( "%s filename key [sec]\n", argv[0] ); exit ( 3 ); } if ( argc >= 4 ) { sec = atoi ( argv[3] ); } id = atoi ( argv[2] ); bret = sem.Create ( argv[1], id ); if ( !bret ) { ERROR_PRINT ( "can not create %s:%d\n", argv[1], id ); return -2; } DEBUG_PRINT("create %s:%d sem\n",argv[1],id); CliSem ( sem, sec ); DEBUG_PRINT("\n"); sem.Destroy(); return 0; }
static int SMT113J_SPI_probe(struct platform_device *pdev) { int ret; struct device *SMT113J_SPI_dev; DEBUG_PRINT("SMT113J_SPI_probe : Start!"); ret = register_chrdev ( NODE_MAJOR, NODE_PATHNAME, &SMT113J_SPI_ctl_fops ); if ( 0 > ret ) { ERROR_PRINT("SMT113J_SPI_probe : register_chrdev failed : ret = %d!", ret ); return ( -EFAULT ); } SMT113J_SPI_class = class_create(THIS_MODULE, NODE_PATHNAME); if (IS_ERR(SMT113J_SPI_class)) { ERROR_PRINT("SMT113J_SPI_probe : class_create failed : ret = %d!", ret ); unregister_chrdev(NODE_MAJOR, NODE_PATHNAME); class_destroy(SMT113J_SPI_class); return ( -EFAULT ); } SMT113J_SPI_dev = device_create ( SMT113J_SPI_class, NULL, MKDEV(NODE_MAJOR, NODE_MINOR), NULL, NODE_PATHNAME); if (IS_ERR(SMT113J_SPI_dev)) { ERROR_PRINT("SMT113J_SPI_probe : device_create failed : ret = %d!", ret ); unregister_chrdev(NODE_MAJOR, NODE_PATHNAME); class_destroy(SMT113J_SPI_class); return ( -EFAULT ); } ret = spi_register_driver ( &smt113j_spi_driver ); if (ret < 0) { ERROR_PRINT( "SMT113J_SPI_probe : spi_register_driver failed : ret = %d!", ret ); return ( -EBUSY ); } smt113j_spi_thread_Init(); DEBUG_PRINT("SMT113J_SPI_probe : End!"); return 0; }
bool Game::init() { if( SDL_Init( SDL_INIT_EVERYTHING ) != 0 ) { ERROR_PRINT( SDL_GetError() ); return false; } SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE ); m_window = SDL_CreateWindow( "Brick Breaker", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, wWindow, hWindow, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL ); if( !m_window ) { ERROR_PRINT( SDL_GetError() ); return false; } if( !SDL_GL_CreateContext( m_window ) ) { ERROR_PRINT( "Failed creating OpenGL context" ); return false; } glewExperimental = GL_TRUE; GLenum glewError = glewInit(); if( glewError != GL_NO_ERROR ) { ERROR_PRINT( "Glew init failed" ); return false; } // glViewport( 0, 0, wWindow, hWindow ); // if( SDL_GL_SetSwapInterval( -1 ) < 0 ) { // if( SDL_GL_SetSwapInterval( 1 ) < 0 ) { // ERROR_PRINT( "Failed to enable VSync" ); // } // } if( !m_renderer.init() ) { ERROR_PRINT( "Renderer failed to init" ); return false; } m_runClock.restart(); m_secondsTimer.setLimit( 1.0 ); m_frameCounter = 0; m_gameState = new LevelState( *this ); m_gameState->init(); return true; }
static int smt113j_spi_cmd_bufstat ( unsigned char *status ) { int ret = 0; unsigned char data = 0; ioctl_spi_bufstatus spi_command = { 0 }; struct spi_message m = {{ 0 }}; struct spi_transfer t[3] = {{ 0 }}; DEBUG_PRINT("smt113j_spi_cmd_bufstat << Start : %x >>", (unsigned int)*status ); /*** argument check ***/ if ( NULL == status ) { ERROR_PRINT ("smt113j_spi_cmd_bufstat : Parameter Error"); return ( -EINVAL ); } /*** SPI message init ***/ spi_message_init ( &m ); /*** SPI command set ***/ spi_command.cmd = 0x03; spi_command.read = 0x10; spi_command.addr = 0x00; spi_command.dum = 0x00; /*** transfer data set ***/ t[0].tx_buf = &spi_command; t[0].rx_buf = NULL; t[0].len = sizeof ( spi_command ); spi_message_add_tail ( &t[0], &m ); /*** transfer data set ***/ t[1].tx_buf = NULL; t[1].rx_buf = &data; t[1].len = sizeof ( unsigned char ); spi_message_add_tail ( &t[1], &m ); /*** SPI transfer request ***/ ret = spi_sync ( smt113j_spi_device, &m ); if ( 0 > ret ) { ERROR_PRINT ("smt113j_spi_cmd_bufstat : Sync Error << ret = %d >>", ret ); } /*** read data set ***/ *status = data; DEBUG_PRINT("smt113j_spi_cmd_bufstat << End : %x >>", *status ); return ( ret ); }
static int access_client_startDaemon(int cpu_id) { /* Check the function of the daemon here */ int res = 0; char* filepath; char *newargv[] = { NULL }; char *newenv[] = { NULL }; char *safeexeprog = TOSTRING(ACCESSDAEMON); char exeprog[1024]; struct sockaddr_un address; size_t address_length; int ret; pid_t pid; int timeout = 1000; int socket_fd = -1; int print_once = 0; if (config.daemonPath != NULL) { strcpy(exeprog, config.daemonPath); } else { strcpy(exeprog, safeexeprog); } if (access(exeprog, X_OK)) { ERROR_PRINT(Failed to find the daemon '%s'\n, exeprog); exit(EXIT_FAILURE); } DEBUG_PRINT(DEBUGLEV_INFO, Starting daemon %s, exeprog); pid = fork(); if (pid == 0) { if (cpu_id >= 0) { cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(cpu_id, &cpuset); sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); } ret = execve (exeprog, newargv, newenv); if (ret < 0) { //ERRNO_PRINT; ERROR_PRINT(Failed to execute the daemon '%s'\n, exeprog); exit(EXIT_FAILURE); } } else if (pid < 0) { ERROR_PRINT(Failed to fork access daemon for CPU %d, cpu_id); return pid; }
static void robot_open_connection(robot_t *self) { int nb; int r; struct sockaddr_in address; memset(&address, 0, sizeof(address)); address.sin_family = AF_INET; address.sin_port = htons(g_config.port); address.sin_addr.s_addr = inet_addr(g_config.ip); self->socketfd = socket(AF_INET, SOCK_STREAM, 0); if(self->socketfd == -1) { ERROR_PRINT("robot [%d] socket errno [%d], %s.", self->id, errno, strerror(errno)); exit(1); } if(setsockopt(self->socketfd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)) == -1) { ERROR_PRINT("robot [%d] setsockopt errno[%d], %s.", self->id, errno, strerror(errno)); exit(1); } if(setsockopt(self->socketfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf)) == -1) { ERROR_PRINT("robot [%d] setsockopt errno[%d], %s.", self->id, errno, strerror(errno)); exit(1); } nb = 1; if(ioctl(self->socketfd, FIONBIO, &nb) == -1) { ERROR_PRINT("robot [%d] ioctl errno[%d], %s.", self->id, errno, strerror(errno)); exit(1); } for(;;) { r = connect(self->socketfd, (struct sockaddr *)&address, sizeof(address)); if(r == 0) { break; } if(errno == EINPROGRESS) { break; } if((errno != EINTR) && (errno != EAGAIN) &&(errno != EWOULDBLOCK)) { ERROR_PRINT("robot [%d] connect errno [%d], %s", self->id, errno, strerror(errno)); exit(1); } usleep(IDLE_TIME_US); } }
static int SMT113J_SPI_open(struct inode *inode, struct file *filp) { int ret = 0; unsigned int majorno = 0, minorno = 0; unsigned char *devarea = NULL; DEBUG_PRINT("SMT113J_SPI_open << Start >>"); majorno = imajor(filp->f_dentry->d_inode); minorno = iminor(filp->f_dentry->d_inode); if (( majorno != NODE_MAJOR ) || ( minorno != NODE_MINOR )) { ERROR_PRINT ("SMT113J_SPI_open Error : << No MAJOR(%d) or No MINOR(%d)", majorno, minorno ); return ( -ENODEV ); } /*** Private Data Area MALLOC Stataus Check ***/ if ( NULL != ( devarea = (unsigned char *)filp->private_data )) { ERROR_PRINT( "SMT113J_SPI_open Error : << Used Private Data Area[0x%08x] >>", (int)devarea ); return ( -ENODEV ); } /*** Private Data Area Alloc ***/ if ( NULL == ( devarea = (unsigned char *)kmalloc ( sizeof(smt113j_ioctl_data), GFP_KERNEL ))) { ERROR_PRINT( "SMT113J_SPI_open Error : << Used Private Data Area Alloc Error"); return ( -ENOMEM ) ; } memset ( devarea, 0, sizeof ( smt113j_ioctl_data )); filp->private_data = (void *)devarea; /*** buffer clear ***/ memset ( rx_pkt_buffer, 0, MAX_BUFFER_PKT * PAKCET_SIZE ); pwrite = 0; pread = 0; spi_open_cnt++; DEBUG_PRINT("SMT113J_SPI_open << End >>"); return ( ret ); }
int prefetcher_init(void) { BUG(); L4_KDB_Enter("Implement me"); #if 0 uint64_t source, target; FILE *pdata; PEntry *entry; dprintk(0,"Initializing prefetch cache "); if( (prefetch_cache = lhmap_create(2097169)) == NULL) return -1; /* load prefetch data from file into cache */ if( (pdata=fopen("prefetch.data", "rb")) == NULL) { ERROR_PRINT("cannot open prefetch.data"); return -1; } while(fscanf(pdata, "%llu -> %llu\n", &source, &target ) != EOF) { if(lhmap_lookup(prefetch_cache, source) != NULL) { ERROR_PRINT("invalid prefetcher data"); return -1; } if( (entry = (PEntry*)qemu_malloc(sizeof(PEntry))) == NULL) { ERROR_PRINT("malloc failed"); return -1; } entry->next = target; if( lhmap_insert(prefetch_cache, source, entry)) { ERROR_PRINT("insert failed"); return -1; } } fclose(pdata); #endif dprintk(0,"done.\n"); return 0; }
void asciiBoxes_addBox(BoxContainer* container, int line, int column, bstring label) { if ( line >= container->numLines ) { ERROR_PRINT(line id %d too large,line); } if ( column >= container->numColumns ) { ERROR_PRINT(column id %d too large,column); } container->boxes[line][column].width = 1; container->boxes[line][column].label = bstrcpy(label); }
void serializeState(State *state, char *fileName, int append) { FILE *fp = NULL; if (append) { fp = fopen(fileName, "a"); fprintf(fp, "------------------------------\n"); } else { fp = fopen(fileName, "w"); } if (fp == NULL) { ERROR_PRINT("Couldn't find file: %s", fileName); exit(1); } for (int i = BOARD_DIM-1; i >= 0; i--) { char line[BOARD_DIM+1]; for (int j = 0; j < BOARD_DIM; j++) { int point = i*BOARD_DIM+j; switch (state->board[point]) { case STATE_WHITE: line[j] = 'W'; break; case STATE_BLACK: line[j] = 'B'; break; case STATE_EMPTY: line[j] = '-'; break; default: ERROR_PRINT("Unknown character in serializing: %d at point %d", state->board[point], point); exit(1); } } line[BOARD_DIM] = '\0'; fprintf(fp, "%s\n", line); } fprintf(fp, "%c\n", state->turn == STATE_WHITE ? 'W' : 'B'); fprintf(fp, "%d\n", state->whitePrisoners); fprintf(fp, "%d\n", state->blackPrisoners); fprintf(fp, "%d\n", state->koPoint); fprintf(fp, "%d\n", state->blackPassed); fclose(fp); }
hid_return hid_prepare_interface(HIDInterface* const hidif) { hid_return ret; if (!hid_is_opened(hidif)) { ERROR_PRINT("cannot prepare unopened HIDinterface."); return HID_RET_DEVICE_NOT_OPENED; } ret = hid_init_parser(hidif); if (ret != HID_RET_SUCCESS) { hid_close(hidif); return ret; } ret = hid_prepare_hid_descriptor(hidif); if (ret != HID_RET_SUCCESS) { hid_close(hidif); return ret; } ret = hid_prepare_report_descriptor(hidif); if (ret != HID_RET_SUCCESS) { hid_close(hidif); return ret; } ret = hid_prepare_parser(hidif); if (ret != HID_RET_SUCCESS) { hid_close(hidif); return ret; } return HID_RET_SUCCESS; }
static void pci_bus_probe (struct pci_info * pci, uint8_t bus) { uint8_t dev; uint8_t dev_found = 0; struct pci_bus * bus_ptr = NULL; for (dev = 0; dev < PCI_MAX_DEV; dev++) { if (pci_get_vendor_id(bus, dev, 0) != 0xffff) { dev_found = 1; break; } } if (dev_found) { bus_ptr = pci_bus_create(bus, pci); if (!bus_ptr) { ERROR_PRINT("Could not create PCI bus\n"); return; } for (dev = 0; dev < PCI_MAX_DEV; dev++) { pci_dev_probe(bus_ptr, dev); } } }
//------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if(idx < max_images) { if(m_specific->m_surf_img[idx]) SDL_FreeSurface(m_specific->m_surf_img[idx]); m_specific->m_surf_img[idx] = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, m_specific->m_surface->format->BitsPerPixel, m_specific->m_rmask, m_specific->m_gmask, m_specific->m_bmask, m_specific->m_amask); if(m_specific->m_surf_img[idx] == 0) { ERROR_PRINT( "Couldn't create image: %s\n", SDL_GetError()); return false; } m_rbuf_img[idx].attach((unsigned char*)m_specific->m_surf_img[idx]->pixels, m_specific->m_surf_img[idx]->w, m_specific->m_surf_img[idx]->h, m_flip_y ? -m_specific->m_surf_img[idx]->pitch : m_specific->m_surf_img[idx]->pitch); return true; } return false; }
int main(int argc, char **argv) { int ret = 0; if(tapp_sigaction() != E_TLIBC_NOERROR) { ret = 1; ERROR_PRINT("tapp_sigaction(), errno %d.", errno); goto done; } tapp_load_config(&g_config, argc, argv, (tapp_xml_reader_t)tlibc_read_tlogd_config); if(init() != E_TLIBC_NOERROR) { ret = 1; goto done; } if(tapp_loop(TAPP_IDLE_USEC, TAPP_IDLE_LIMIT , tbusapi_process, &g_tbusapi , NULL, NULL) != E_TLIBC_NOERROR) { ret = 1; } fini(); done: return ret; }
void partition(p_arr arr, p_arr tmp, lint * bin_idx) { int N = arr->idx; int* histogram = (int*) _mm_malloc(sizeof(int)*NUMENTRIESPERTABLE*num_threads, 64); int* position = (int*) _mm_malloc(sizeof(int)*N, 64); int right_shift = (int)(log2(g_v_num))-8; #pragma omp parallel num_threads(num_threads) { int i, t; int threadid = omp_get_thread_num(); int p_per_thread = N/num_threads; if((p_per_thread * num_threads) != N) p_per_thread++; int start_n = p_per_thread*threadid; int end_n = start_n + p_per_thread; if (end_n > N) end_n = N; memset(histogram + threadid*NUMENTRIESPERTABLE, 0, sizeof(int)*NUMENTRIESPERTABLE); for (i = start_n; i < end_n; i++) { int finalHash = arr->arr[i].int_val1 >> right_shift; position[i] = histogram[threadid*NUMENTRIESPERTABLE + finalHash]; histogram[threadid*NUMENTRIESPERTABLE + finalHash]++; } //__BARRIER__; TREE_BARRIER(&tree_barrier, threadid, num_threads); #pragma omp single { int current_sum = 0; int prev_sum = 0; memset(bin_idx, 0, sizeof(int)*(NUMENTRIESPERTABLE+1)); bin_idx[0] = 0; for (i = 0; i < NUMENTRIESPERTABLE; i++) { for (t = 0; t < num_threads; t++) { //cumsum[i] += histogram[t*NUMENTRIESPERTABLE + i-1]; current_sum = prev_sum + histogram[t*NUMENTRIESPERTABLE + i]; histogram[t*NUMENTRIESPERTABLE + i] = prev_sum; prev_sum = current_sum; } //cumsum[i] += cumsum[i-1]; bin_idx[i+1] = current_sum; } if(current_sum != N) ERROR_PRINT(); } //__BARRIER__; TREE_BARRIER(&tree_barrier, threadid, num_threads); for (i = start_n; i < end_n; i++) { int finalHash = arr->arr[i].int_val1 >> right_shift; int newIndex = histogram[threadid*NUMENTRIESPERTABLE + finalHash] + position[i]; tmp->arr[newIndex] = arr->arr[i]; } } _mm_free(histogram); _mm_free(position); }
static int smt113j_spi_cmd_init ( void ) { int ret = 0; ioctl_spi_internal_reg spi_command = { 0 }; struct spi_message m = {{ 0 }}; struct spi_transfer t[3] = {{ 0 }}; /*** SPI message init ***/ spi_message_init ( &m ); /*** SPI command set ***/ spi_command.cmd = 0x01; spi_command.data = 0xB1; /*** transfer data set ***/ t[0].tx_buf = &spi_command; t[0].rx_buf = NULL; t[0].len = sizeof ( spi_command ); spi_message_add_tail ( &t[0], &m ); /*** SPI transfer request ***/ ret = spi_sync ( smt113j_spi_device, &m ); if ( 0 > ret ) { ERROR_PRINT ("smt113j_spi_cmd_init : Sync Error << ret = %d >>", ret ); } printk("smt113j_spi_cmd_init << End : %d >>\n", ret ); return ( ret ); }
static int smt113j_spi_probe(struct spi_device *spi) { int ret; DEBUG_PRINT("smt113j_spi_probe : Start!"); spi->bits_per_word = 8; spi->mode = SPI_MODE_0; spi->max_speed_hz = (27 * 1000 * 1000); /* 30MHz */ ret = spi_setup ( spi ); if ( ret < 0 ) { ERROR_PRINT("smt113j_spi_probe : spi_setup Failed = %d!", ret ); return ( ret ); } smt113j_spi_device = spi; wake_lock_init ( &smt113j_spi_wake_lock, WAKE_LOCK_SUSPEND, "smt113j_spi_wake_lock" ); DEBUG_PRINT("smt113j_spi_probe : End!"); return ( 0 ); }
int main(int argc, char **argv) { int ret = 0; if(tapp_sigaction() != E_TLIBC_NOERROR) { ERROR_PRINT("tapp_sigaction failed."); goto ERROR_RET; } tapp_load_config(&g_config, argc, argv, (tapp_xml_reader_t)tlibc_read_tconnd_config); if(init() != E_TLIBC_NOERROR) { goto ERROR_RET; } if(tapp_loop(TAPP_IDLE_USEC, TAPP_IDLE_LIMIT , process, NULL , NULL, NULL) == E_TLIBC_NOERROR) { ret = 0; } else { ret = 1; } fini(); return 0; ERROR_RET: return 1; }
int objtable_insert(struct memsection *memsection) { int cmp; struct memsection *closest; if (root == NULL) { root = memsection; } else { closest = find_node(root, objtable_key(memsection), &cmp, NULL); if (cmp == 0) { ERROR_PRINT ( "Failed to insert object into objtable (ms_base: %" PRIxPTR ")\n", objtable_key(memsection) ); return -1; /* Key clash */ } else if (cmp < 0) { closest->left = memsection; } else { closest->right = memsection; } } return 0; }
static int SMT113J_SPI_release(struct inode *inode, struct file *filp) { int ret = 0; DEBUG_PRINT("SMT113J_SPI_release << Start >>"); /*** Device Open Check ***/ if ( 0 == spi_open_cnt ) { ERROR_PRINT ("No Open Devices"); return ( ret ); } spi_open_cnt--; if ( 0 != spi_open_cnt ) { ERROR_PRINT ("Not Relase : Open Device Num[%d]", spi_open_cnt ); return ( ret ); } /*** Private Data Area Check ***/ if ( NULL == (unsigned char *)filp->private_data ) { ERROR_PRINT("No Private Data"); return ( ret ); } /*** thread stop ***/ smt113j_spi_thread_Stop(); memset ( (unsigned char *)filp->private_data, 0, sizeof ( smt113j_ioctl_data )); kfree ( filp->private_data ); filp->private_data = NULL; /*** buffer clear ***/ memset ( rx_pkt_buffer, 0, MAX_BUFFER_PKT * PAKCET_SIZE ); pwrite = 0; pread = 0; DEBUG_PRINT("SMT113J_SPI_release << End >>"); return ret; }
int init_regulator(struct device *dev) { int rc = 1; ant_sw_2p85 = devm_regulator_get(dev, "ANT_SW_2p85"); if (IS_ERR(ant_sw_2p85)) { ERROR_PRINT("%s: unable to get antenna sw 2.85v\n", __func__); return -1; } rc = regulator_set_voltage(ant_sw_2p85, ANT_SW_PHY_2P85_VOL_MIN, ANT_SW_PHY_2P85_VOL_MAX); if (rc) { ERROR_PRINT("%s: unable to get antenna sw 2.85v\n", __func__); return -1; } return rc; }
int parseMoveFromTerminal(void) { char line[MAX_MOVE_LEN]; if(fgets(line, MAX_MOVE_LEN, stdin)) { ERROR_PRINT("Failed to read move from command line"); exit(1); } return parseMove(line); }
bool MCP::turnSw(byte num) { if ((num == -1) || (num == 255)) { ERROR_PRINT("ERROR: MCP.turnSw num = "); ERROR_PRINTLN(num); return false; } return turnSw(num, !actStates.msw[num]); }
int idt_assign_entry (ulong_t entry, ulong_t handler_addr) { if (entry >= NUM_IDT_ENTRIES) { ERROR_PRINT("Assigning invalid IDT entry\n"); return -1; } if (!handler_addr) { ERROR_PRINT("attempt to assign null handler\n"); return -1; } handler_table[entry] = handler_addr; return 0; }
int parseMoveFromFile(char *fileName) { FILE *fp = fopen(fileName, "r"); if (fp == NULL) { ERROR_PRINT("Couldn't find file: %s", fileName); exit(1); } char line[MAX_MOVE_LEN]; if (fgets(line, MAX_MOVE_LEN, fp) == NULL) { ERROR_PRINT("Move is missing"); return MOVE_INVALID; } fclose(fp); return parseMove(line); }
void asciiBoxes_addJoinedBox( BoxContainer* container, int line, int startColumn, int endColumn, bstring label) { if ( line >= container->numLines ) { ERROR_PRINT(line id %d too large,line); } if ( endColumn >= container->numColumns ) { ERROR_PRINT(column id %d too large,endColumn); } container->boxes[line][startColumn].width = (endColumn-startColumn)+1; container->boxes[line][startColumn].label = bstrcpy(label); }
int setup_idt (void) { uint_t i; ulong_t irq_start = (ulong_t)&early_irq_handlers; ulong_t excp_start = (ulong_t)&early_excp_handlers; // clear the IDT out memset(&idt64, 0, sizeof(struct gate_desc64) * NUM_IDT_ENTRIES); for (i = 0; i < NUM_EXCEPTIONS; i++) { set_intr_gate(idt64, i, (void*)(excp_start + i*16)); idt_assign_entry(i, (ulong_t)null_excp_handler); } for (i = 32; i < NUM_IDT_ENTRIES; i++) { set_intr_gate(idt64, i, (void*)(irq_start + (i-32)*16)); idt_assign_entry(i, (ulong_t)null_irq_handler); } if (idt_assign_entry(PF_EXCP, (ulong_t)nk_pf_handler) < 0) { ERROR_PRINT("Couldn't assign page fault handler\n"); return -1; } if (idt_assign_entry(DF_EXCP, (ulong_t)df_handler) < 0) { ERROR_PRINT("Couldn't assign double fault handler\n"); return -1; } if (idt_assign_entry(0xf, (ulong_t)pic_spur_int_handler) < 0) { ERROR_PRINT("Couldn't assign PIC spur int handler\n"); return -1; } lidt(&idt_descriptor); return 0; }