~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_bif_info.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2010-03-09 17:34:57 UTC
  • mfrom: (10.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100309173457-4yd6hlcb2osfhx31
Tags: 1:13.b.4-dfsg-3
Manpages in section 1 are needed even if only arch-dependent packages are
built. So, re-enabled them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
 
 * 
4
 
 * Copyright Ericsson AB 1999-2009. All Rights Reserved.
5
 
 * 
 
3
 *
 
4
 * Copyright Ericsson AB 1999-2010. All Rights Reserved.
 
5
 *
6
6
 * The contents of this file are subject to the Erlang Public License,
7
7
 * Version 1.1, (the "License"); you may not use this file except in
8
8
 * compliance with the License. You should have received a copy of the
9
9
 * Erlang Public License along with this software. If not, it can be
10
10
 * retrieved online at http://www.erlang.org/.
11
 
 * 
 
11
 *
12
12
 * Software distributed under the License is distributed on an "AS IS"
13
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
 * the License for the specific language governing rights and limitations
15
15
 * under the License.
16
 
 * 
 
16
 *
17
17
 * %CopyrightEnd%
18
18
 */
19
19
 
543
543
    am_last_calls,
544
544
    am_total_heap_size,
545
545
    am_suspending,
 
546
    am_min_heap_size,
 
547
    am_min_bin_vheap_size,
546
548
#ifdef HYBRID
547
549
    am_message_binary
548
550
#endif
589
591
    case am_last_calls:                         return 24;
590
592
    case am_total_heap_size:                    return 25;
591
593
    case am_suspending:                         return 26;
 
594
    case am_min_heap_size:                      return 27;
 
595
    case am_min_bin_vheap_size:                 return 28;
592
596
#ifdef HYBRID
593
 
    case am_message_binary:                     return 27;
 
597
    case am_message_binary:                     return 29;
594
598
#endif
595
599
    default:                                    return -1;
596
600
    }
1355
1359
        break;
1356
1360
    }
1357
1361
 
 
1362
    case am_fullsweep_after: {
 
1363
        Uint hsz = 3;
 
1364
        (void) erts_bld_uint(NULL, &hsz, MAX_GEN_GCS(rp));
 
1365
        hp = HAlloc(BIF_P, hsz);
 
1366
        res = erts_bld_uint(&hp, NULL, MAX_GEN_GCS(rp));
 
1367
        break;
 
1368
    }
 
1369
 
 
1370
    case am_min_heap_size: {
 
1371
        Uint hsz = 3;
 
1372
        (void) erts_bld_uint(NULL, &hsz, MIN_HEAP_SIZE(rp));
 
1373
        hp = HAlloc(BIF_P, hsz);
 
1374
        res = erts_bld_uint(&hp, NULL, MIN_HEAP_SIZE(rp));
 
1375
        break;
 
1376
    }
 
1377
 
 
1378
    case am_min_bin_vheap_size: {
 
1379
        Uint hsz = 3;
 
1380
        (void) erts_bld_uint(NULL, &hsz, MIN_VHEAP_SIZE(rp));
 
1381
        hp = HAlloc(BIF_P, hsz);
 
1382
        res = erts_bld_uint(&hp, NULL, MIN_VHEAP_SIZE(rp));
 
1383
        break;
 
1384
    }
 
1385
 
1358
1386
    case am_total_heap_size: {
1359
1387
        ErlMessage *mp;
1360
1388
        Uint total_heap_size;
1433
1461
        DECL_AM(minor_gcs);
1434
1462
        Eterm t;
1435
1463
 
1436
 
        hp = HAlloc(BIF_P, 3+2+3+2+3);
1437
 
        t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp)));
1438
 
        hp += 3;
1439
 
        res = CONS(hp, t, NIL);
1440
 
        hp += 2;
1441
 
        t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp)));
1442
 
        hp += 3;
1443
 
        res = CONS(hp, t, res);
1444
 
        hp += 2;
 
1464
        hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2 + 3+2 + 3); /* last "3" is for outside tuple */
 
1465
 
 
1466
        t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp))); hp += 3;
 
1467
        res = CONS(hp, t, NIL); hp += 2;
 
1468
        t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp))); hp += 3;
 
1469
        res = CONS(hp, t, res); hp += 2;
 
1470
 
 
1471
        t = TUPLE2(hp, am_min_heap_size, make_small(MIN_HEAP_SIZE(rp))); hp += 3;
 
1472
        res = CONS(hp, t, res); hp += 2;
 
1473
        t = TUPLE2(hp, am_min_bin_vheap_size, make_small(MIN_VHEAP_SIZE(rp))); hp += 3;
 
1474
        res = CONS(hp, t, res); hp += 2;
1445
1475
        break;
1446
1476
    }
1447
1477
 
1897
1927
        BIF_RET(res);
1898
1928
    } else if (BIF_ARG_1 == am_garbage_collection){
1899
1929
        Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs);
1900
 
        hp = HAlloc(BIF_P, 3+2);
1901
 
        res = TUPLE2(hp, am_fullsweep_after, make_small(val));
1902
 
        hp += 3;
1903
 
        res = CONS(hp, res, NIL);
 
1930
        Eterm tup;
 
1931
        hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2);
 
1932
 
 
1933
        tup = TUPLE2(hp, am_fullsweep_after, make_small(val)); hp += 3;
 
1934
        res = CONS(hp, tup, NIL); hp += 2;
 
1935
 
 
1936
        tup = TUPLE2(hp, am_min_heap_size, make_small(H_MIN_SIZE)); hp += 3;
 
1937
        res = CONS(hp, tup, res); hp += 2;
 
1938
 
 
1939
        tup = TUPLE2(hp, am_min_bin_vheap_size, make_small(BIN_VH_MIN_SIZE)); hp += 3;
 
1940
        res = CONS(hp, tup, res); hp += 2;
 
1941
 
1904
1942
        BIF_RET(res);
1905
1943
    } else if (BIF_ARG_1 == am_fullsweep_after){
1906
1944
        Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs);
1907
1945
        hp = HAlloc(BIF_P, 3);
1908
1946
        res = TUPLE2(hp, am_fullsweep_after, make_small(val));
1909
1947
        BIF_RET(res);
 
1948
    } else if (BIF_ARG_1 == am_min_heap_size) {
 
1949
        hp = HAlloc(BIF_P, 3);
 
1950
        res = TUPLE2(hp, am_min_heap_size,make_small(H_MIN_SIZE));
 
1951
        BIF_RET(res);
 
1952
    } else if (BIF_ARG_1 == am_min_bin_vheap_size) {
 
1953
        hp = HAlloc(BIF_P, 3);
 
1954
        res = TUPLE2(hp, am_min_bin_vheap_size,make_small(BIN_VH_MIN_SIZE));
 
1955
        BIF_RET(res);
1910
1956
    } else if (BIF_ARG_1 == am_process_count) {
1911
1957
        BIF_RET(make_small(erts_process_count()));
1912
1958
    } else if (BIF_ARG_1 == am_process_limit) {
3131
3177
        else if (ERTS_IS_ATOM_STR("available_internal_state", BIF_ARG_1)) {
3132
3178
            BIF_RET(am_true);
3133
3179
        }
 
3180
        else if (ERTS_IS_ATOM_STR("force_heap_frags", BIF_ARG_1)) {
 
3181
#ifdef FORCE_HEAP_FRAGS
 
3182
            BIF_RET(am_true);
 
3183
#else
 
3184
            BIF_RET(am_false);
 
3185
#endif
 
3186
        }
3134
3187
    }
3135
3188
    else if (is_tuple(BIF_ARG_1)) {
3136
3189
        Eterm* tp = tuple_val(BIF_ARG_1);
3651
3704
    ASSERT(ltype);
3652
3705
    
3653
3706
    type  = am_atom_put(ltype, strlen(ltype));           
3654
 
 
3655
3707
    name  = am_atom_put(lock->name, strlen(lock->name)); 
3656
3708
 
3657
3709
    if (lock->flag & ERTS_LCNT_LT_ALLOC) {
3658
3710
        /* use allocator types names as id's for allocator locks */
3659
 
        ltype = ERTS_ALC_A2AD(signed_val(lock->id));
 
3711
        ltype = (char *) ERTS_ALC_A2AD(signed_val(lock->id));
3660
3712
        id    = am_atom_put(ltype, strlen(ltype));
3661
3713
    } else if (lock->flag & ERTS_LCNT_LT_PROCLOCK) {
3662
3714
        /* use registered names as id's for process locks if available */
3725
3777
{
3726
3778
#ifdef ERTS_ENABLE_LOCK_COUNT
3727
3779
    Eterm res = NIL;
3728
 
    erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3729
 
    erts_smp_block_system(0);
3730
 
 
3731
 
    if (BIF_ARG_1 == am_info) {
 
3780
#endif
 
3781
 
 
3782
 
 
3783
    if (BIF_ARG_1 == am_enabled) {
 
3784
#ifdef ERTS_ENABLE_LOCK_COUNT
 
3785
        BIF_RET(am_true);
 
3786
#else
 
3787
        BIF_RET(am_false);
 
3788
#endif
 
3789
    }
 
3790
#ifdef ERTS_ENABLE_LOCK_COUNT
 
3791
 
 
3792
    else if (BIF_ARG_1 == am_info) {
3732
3793
        erts_lcnt_data_t *data; 
3733
3794
        Uint hsize = 0;
3734
3795
        Uint *szp;
3735
3796
        Eterm* hp;
3736
3797
 
 
3798
        erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3799
        erts_smp_block_system(0);
 
3800
 
3737
3801
        erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_SUSPEND);
3738
 
 
3739
3802
        data = erts_lcnt_get_data();
3740
3803
 
3741
3804
        /* calculate size */
3750
3813
        res = lcnt_build_result_term(&hp, NULL, data, res);
3751
3814
        
3752
3815
        erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_SUSPEND);
 
3816
 
 
3817
        erts_smp_release_system();
 
3818
        erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3753
3819
        
3754
 
        goto done;
 
3820
        BIF_RET(res);
3755
3821
    } else if (BIF_ARG_1 == am_clear) {
 
3822
        erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3823
        erts_smp_block_system(0);
 
3824
 
3756
3825
        erts_lcnt_clear_counters();
3757
 
        res = am_ok;
3758
 
        goto done;
 
3826
 
 
3827
        erts_smp_release_system();
 
3828
        erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3829
 
 
3830
        BIF_RET(am_ok);
3759
3831
    } else if (is_tuple(BIF_ARG_1)) {
3760
 
        Uint prev = 0;
3761
3832
        Eterm* tp = tuple_val(BIF_ARG_1);
 
3833
 
3762
3834
        switch (arityval(tp[0])) {
3763
3835
            case 2:
3764
 
                if (ERTS_IS_ATOM_STR("process_locks", tp[1])) {
3765
 
                    if (tp[2] == am_true) {
3766
 
                        prev = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK);
3767
 
                        if (prev) res = am_true;
3768
 
                        else res = am_false;
3769
 
                        goto done;
3770
 
                    } else if (tp[2] == am_false) {
3771
 
                        prev = erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_PROCLOCK);
3772
 
                        if (prev) res = am_true;
3773
 
                        else res = am_false;
3774
 
                        goto done;
3775
 
                    }
 
3836
                if (ERTS_IS_ATOM_STR("copy_save", tp[1])) {
 
3837
                    erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3838
                    erts_smp_block_system(0);
 
3839
                    if (tp[2] == am_true) {
 
3840
 
 
3841
                        res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_COPYSAVE) ? am_true : am_false;
 
3842
 
 
3843
                    } else if (tp[2] == am_false) {
 
3844
 
 
3845
                        res = erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_COPYSAVE) ? am_true : am_false;
 
3846
 
 
3847
                    } else {
 
3848
                        erts_smp_release_system();
 
3849
                        erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3850
                        BIF_ERROR(BIF_P, BADARG);
 
3851
                    }
 
3852
                    erts_smp_release_system();
 
3853
                    erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3854
                    BIF_RET(res);
 
3855
 
 
3856
                } else if (ERTS_IS_ATOM_STR("process_locks", tp[1])) {
 
3857
                    erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3858
                    erts_smp_block_system(0);
 
3859
                    if (tp[2] == am_true) {
 
3860
 
 
3861
                        res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK) ? am_true : am_false;
 
3862
 
 
3863
                    } else if (tp[2] == am_false) {
 
3864
 
 
3865
                        res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK) ? am_true : am_false;
 
3866
 
 
3867
                    } else {
 
3868
                        erts_smp_release_system();
 
3869
                        erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3870
                        BIF_ERROR(BIF_P, BADARG);
 
3871
                    }
 
3872
                    erts_smp_release_system();
 
3873
                    erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
 
3874
                    BIF_RET(res);
3776
3875
                 }
3777
3876
            break;
3778
3877
     
3781
3880
        }
3782
3881
    } 
3783
3882
 
3784
 
    erts_smp_release_system();
3785
 
    erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3786
3883
#endif 
3787
3884
    BIF_ERROR(BIF_P, BADARG);
3788
 
#ifdef ERTS_ENABLE_LOCK_COUNT
3789
 
done:    
3790
 
    erts_smp_release_system();
3791
 
    erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3792
 
    BIF_RET(res);
3793
 
#endif 
3794
3885
}
3795
3886
 
3796
3887
void