size_t _icv_iconv(void *cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { unsigned int u32; /* UTF-32 */ unsigned char ic1, ic2, ic3; /* 1st, 2nd, and 3rd bytes of a char */ size_t rv = (size_t)0; /* return value of this function */ unsigned char *ip; size_t ileft; char *op; size_t oleft; /* * If inbuf and/or *inbuf are NULL, reset conversion descriptor * and put escape sequence if needed. */ if ((inbuf == NULL) || (*inbuf == NULL)) { _icv_reset_unicode(cd); return ((size_t)0); } ip = (unsigned char *)*inbuf; ileft = *inbytesleft; op = *outbuf; oleft = *outbytesleft; while (ileft != 0) { NGET(ic1, "never fail here"); /* get 1st byte */ if (ISASC(ic1)) { /* ASCII; 1 byte */ u32 = _jfp_tbl_jisx0201roman_to_ucs2[ic1]; PUTU(u32, "ASCII"); } else if (ISCS1(ic1)) { /* JIS X 0208 or UDC; 2 bytes */ NGET(ic2, "CS1-2 not available"); if (ISCS1(ic2)) { /* 2nd byte check passed */ u32 = _jfp_tbl_jisx0208_to_ucs2[ (ic1 - 0xa1) * 94 + (ic2 - 0xa1)]; PUTU(u32, "CS1"); } else { /* 2nd byte check failed */ RETERROR(EILSEQ, "CS1-2") } } else if (ic1 == SS2) { /* JIS X 0201 Kana; 2 bytes */ NGET(ic2, "CS2-2"); if (ISCS2(ic2)) { /* 2nd byte check passed */ u32 = _jfp_tbl_jisx0201kana_to_ucs2[ (ic2 - 0xa1)]; PUTU(u32, "CS2"); } else { /* 2nd byte check failed */ RETERROR(EILSEQ, "CS2-2") } } else if (ic1 == SS3) { /* JIS X 0212 or UDC; 3 bytes */
void fsl_isr2 (void *arg) { volatile int num; *((unsigned int *)(CONFIG_SYS_GPIO_0_ADDR + 0x4)) = ++(*((unsigned int *)(CONFIG_SYS_GPIO_0_ADDR + 0x4))); GET (num, 2); NGET (num, 2); puts("*"); }
int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { unsigned int fslnum; unsigned int num; unsigned int blocking; if (argc < 2) { cmd_usage(cmdtp); return 1; } fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16); blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16); if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) { puts ("Bad number of FSL\n"); cmd_usage(cmdtp); return 1; } switch (fslnum) { #if (XILINX_FSL_NUMBER > 0) case 0: switch (blocking) { case 0: NGET (num, 0); break; case 1: NCGET (num, 0); break; case 2: GET (num, 0); break; case 3: CGET (num, 0); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 1) case 1: switch (blocking) { case 0: NGET (num, 1); break; case 1: NCGET (num, 1); break; case 2: GET (num, 1); break; case 3: CGET (num, 1); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 2) case 2: switch (blocking) { case 0: NGET (num, 2); break; case 1: NCGET (num, 2); break; case 2: GET (num, 2); break; case 3: CGET (num, 2); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 3) case 3: switch (blocking) { case 0: NGET (num, 3); break; case 1: NCGET (num, 3); break; case 2: GET (num, 3); break; case 3: CGET (num, 3); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 4) case 4: switch (blocking) { case 0: NGET (num, 4); break; case 1: NCGET (num, 4); break; case 2: GET (num, 4); break; case 3: CGET (num, 4); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 5) case 5: switch (blocking) { case 0: NGET (num, 5); break; case 1: NCGET (num, 5); break; case 2: GET (num, 5); break; case 3: CGET (num, 5); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 6) case 6: switch (blocking) { case 0: NGET (num, 6); break; case 1: NCGET (num, 6); break; case 2: GET (num, 6); break; case 3: CGET (num, 6); break; default: return 2; } break; #endif #if (XILINX_FSL_NUMBER > 7) case 7: switch (blocking) { case 0: NGET (num, 7); break; case 1: NCGET (num, 7); break; case 2: GET (num, 7); break; case 3: CGET (num, 7); break; default: return 2; } break; #endif default: return 1; } printf ("%01x: 0x%08x - %s %s read\n", fslnum, num, blocking < 2 ? "non blocking" : "blocking", ((blocking == 1) || (blocking == 3)) ? "control" : "data" ); return 0; }
int main(int argc, char **argv) { int i, r, times; unsigned char *key, *val; size_t ksize, vsize, bsize; unsigned long elapsed, misses = 0; nmdb_t *db; if (argc != 4) { printf("Usage: 3-* TIMES KSIZE VSIZE\n"); return 1; } times = atoi(argv[1]); ksize = atoi(argv[2]); vsize = atoi(argv[3]); if (times < 1) { printf("Error: TIMES must be >= 1\n"); return 1; } if (ksize < sizeof(int) || vsize < sizeof(int)) { printf("Error: KSIZE and VSIZE must be >= sizeof(int)\n"); return 1; } key = malloc(ksize); memset(key, 0, ksize); val = malloc(70 * 1024); bsize = 70 * 1024; memset(val, 0, bsize); if (key == NULL || val == NULL) { perror("Error: malloc()"); return 1; } db = nmdb_init(); if (db == NULL) { perror("nmdb_init() failed"); return 1; } NADDSRV(db); timer_start(); for (i = 0; i < times; i++) { * (int *) key = i; * (int *) val = i; r = NSET(db, key, ksize, val, vsize); if (r < 0) { perror("Set"); return 1; } * (int *) key = i; r = NGET(db, key, ksize, val, bsize); if (r <= -2) { perror("Get"); return 1; } else if (r == -1) { misses++; } * (int *) key = i; r = NDEL(db, key, ksize); if (r < 0) { perror("Del"); return 1; } } elapsed = timer_stop(); printf("%lu %lu\n", elapsed, misses); free(key); nmdb_free(db); return 0; }
size_t _icv_iconv(void *cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { unsigned int uni; /* UTF-32 */ unsigned int index; /* index for table lookup */ unsigned char ic1, ic2; /* 1st and 2nd bytes of a char */ size_t rv = (size_t)0; /* return value of this function */ unsigned char *ip; size_t ileft; char *op; size_t oleft; /* * If inbuf and/or *inbuf are NULL, reset conversion descriptor * and put escape sequence if needed. */ if ((inbuf == NULL) || (*inbuf == NULL)) { _icv_reset_unicode(cd); return ((size_t)0); } ip = (unsigned char *)*inbuf; ileft = *inbytesleft; op = *outbuf; oleft = *outbytesleft; while (ileft != 0) { NGET(ic1, "never fail here"); /* get 1st byte */ if (ISASC((int)ic1)) { /* ASCII; 1 byte */ uni = _jfp_tbl_jisx0201roman_to_ucs2[ic1]; PUTU(uni, "ASCII"); } else if (ISSJKANA(ic1)) { /* JIS X 0201 Kana; 1 byte */ uni = _jfp_tbl_jisx0201kana_to_ucs2[(ic1 - 0xa1)]; PUTU(uni, "KANA"); } else if (ISSJKANJI1(ic1)) { /* JIS X 0208 or UDC; 2 bytes */ NGET(ic2, "CS1-2 not available"); if (ISSJKANJI2(ic2)) { ic1 = sjtojis1[(ic1 - 0x80)]; if (ic2 >= 0x9f) { ic1++; } index = ((ic1 - 0x21) * 94) + (sjtojis2[ic2] - 0x21); uni = _jfp_tbl_jisx0208_to_ucs2[index]; PUTU(uni, "KANJI"); } else { /* 2nd byte check failed */ RETERROR(EILSEQ, "EILSEQ at CS1-2") /* NOTREACHED */ } } else if (ISSJSUPKANJI1(ic1)) { /* VDC, 2 bytes */ NGET(ic2, "SUP-2 not available"); if (ISSJKANJI2(ic2)) { ic1 = sjtojis1[(ic1 - 0x80)]; if (ic2 >= 0x9f) { ic1++; } index = ((ic1 - 0x21) * 94) + (sjtojis2[ic2] - 0x21); uni = _jfp_tbl_jisx0212_to_ucs2[index]; PUTU(uni, "SUPKANJI"); } else { /* 2nd byte check failed */ RETERROR(EILSEQ, "EILSEQ at CS1-2") } } else if (ISSJIBM(ic1) || /* Extended IBM char. area */