Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

Location:
EcnlProtoTool/trunk/tcc-0.9.27
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/tcc-0.9.27/tests/boundtest.c

    r321 r331  
    11#include <stdlib.h>
    22#include <stdio.h>
     3#include <string.h>
    34
    45#define NB_ITS 1000000
     
    5051    int *tab4;
    5152
     53    fprintf(stderr, "%s start\n", __FUNCTION__);
     54
    5255    tab4 = malloc(20 * sizeof(int));
    5356    for(i=0;i<20;i++) {
     
    5659    free(tab4);
    5760
     61    fprintf(stderr, "%s end\n", __FUNCTION__);
    5862    return sum;
    5963}
     
    6468    int i, sum = 0;
    6569    int *tab4;
     70
     71    fprintf(stderr, "%s start\n", __FUNCTION__);
    6672
    6773    tab4 = malloc(20 * sizeof(int));
     
    7177    free(tab4);
    7278
     79    fprintf(stderr, "%s end\n", __FUNCTION__);
    7380    return sum;
    7481}
     
    187194}
    188195
     196/* ok */
     197int test16()
     198{
     199    char *demo = "This is only a test.";
     200    char *p;
     201
     202    fprintf(stderr, "%s start\n", __FUNCTION__);
     203
     204    p = alloca(16);
     205    strcpy(p,"12345678901234");
     206    printf("alloca: p is %s\n", p);
     207
     208    /* Test alloca embedded in a larger expression */
     209    printf("alloca: %s\n", strcpy(alloca(strlen(demo)+1),demo) );
     210
     211    fprintf(stderr, "%s end\n", __FUNCTION__);
     212}
     213
     214/* error */
     215int test17()
     216{
     217    char *demo = "This is only a test.";
     218    char *p;
     219
     220    fprintf(stderr, "%s start\n", __FUNCTION__);
     221
     222    p = alloca(16);
     223    strcpy(p,"12345678901234");
     224    printf("alloca: p is %s\n", p);
     225
     226    /* Test alloca embedded in a larger expression */
     227    printf("alloca: %s\n", strcpy(alloca(strlen(demo)),demo) );
     228
     229    fprintf(stderr, "%s end\n", __FUNCTION__);
     230}
     231
    189232int (*table_test[])(void) = {
    190     test1,
    191233    test1,
    192234    test2,
     
    204246    test14,
    205247    test15,
     248    test16,
     249    test17,
    206250};
    207251
     
    210254    int index;
    211255    int (*ftest)(void);
     256    int index_max = sizeof(table_test)/sizeof(table_test[0]);
    212257
    213258    if (argc < 2) {
    214         printf("usage: boundtest n\n"
    215                "test TCC bound checking system\n"
    216                );
     259        printf(
     260            "test TCC bound checking system\n"
     261            "usage: boundtest N\n"
     262            "  1 <= N <= %d\n", index_max);
    217263        exit(1);
    218264    }
     
    220266    index = 0;
    221267    if (argc >= 2)
    222         index = atoi(argv[1]);
     268        index = atoi(argv[1]) - 1;
     269
     270    if ((index < 0) || (index >= index_max)) {
     271        printf("N is outside of the valid range (%d)\n", index);
     272        exit(2);
     273    }
     274
    223275    /* well, we also use bounds on this ! */
    224276    ftest = table_test[index];
Note: See TracChangeset for help on using the changeset viewer.