~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to erts/emulator/hipe/hipe_bif1.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
3
 * 
4
 
 * Copyright Ericsson AB 2001-2009. All Rights Reserved.
 
4
 * Copyright Ericsson AB 2001-2011. All Rights Reserved.
5
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
876
876
 * + The fallback, which is the same as {X,_} = runtime(statistics).
877
877
 */
878
878
 
 
879
static double fallback_get_hrvtime(void)
 
880
{
 
881
    unsigned long ms_user;
 
882
 
 
883
    elapsed_time_both(&ms_user, NULL, NULL, NULL);
 
884
    return (double)ms_user;
 
885
}
 
886
 
879
887
#if USE_PERFCTR
880
888
 
881
889
#include "hipe_perfctr.h"
882
 
static int hrvtime_is_open;
883
 
#define hrvtime_is_started()    hrvtime_is_open
 
890
static int hrvtime_started;     /* 0: closed, +1: perfctr, -1: fallback */
 
891
#define hrvtime_is_started()    (hrvtime_started != 0)
884
892
 
885
893
static void start_hrvtime(void)
886
894
{
887
895
    if (hipe_perfctr_hrvtime_open() >= 0)
888
 
        hrvtime_is_open = 1;
889
 
}
890
 
 
891
 
#define get_hrvtime()           hipe_perfctr_hrvtime_get()
892
 
#define stop_hrvtime()          hipe_perfctr_hrvtime_close()
893
 
 
894
 
#else
 
896
        hrvtime_started = 1;
 
897
    else
 
898
        hrvtime_started = -1;
 
899
}
 
900
 
 
901
static void stop_hrvtime(void)
 
902
{
 
903
    if (hrvtime_started > 0)
 
904
        hipe_perfctr_hrvtime_close();
 
905
    hrvtime_started = 0;
 
906
}
 
907
 
 
908
static double get_hrvtime(void)
 
909
{
 
910
    if (hrvtime_started > 0)
 
911
        return hipe_perfctr_hrvtime_get();
 
912
    else
 
913
        return fallback_get_hrvtime();
 
914
}
 
915
 
 
916
#else   /* !USE_PERFCTR */
895
917
 
896
918
/*
897
919
 * Fallback, if nothing better exists.
902
924
#define hrvtime_is_started()    1
903
925
#define start_hrvtime()         do{}while(0)
904
926
#define stop_hrvtime()          do{}while(0)
905
 
 
906
 
static double get_hrvtime(void)
907
 
{
908
 
    unsigned long ms_user;
909
 
    elapsed_time_both(&ms_user, NULL, NULL, NULL);
910
 
    return (double)ms_user;
911
 
}
912
 
 
913
 
#endif  /* hrvtime support */
 
927
#define get_hrvtime()           fallback_get_hrvtime()
 
928
 
 
929
#endif  /* !USE_PERFCTR */
914
930
 
915
931
BIF_RETTYPE hipe_bifs_get_hrvtime_0(BIF_ALIST_0)
916
932
{
918
934
    Eterm res;
919
935
    FloatDef f;
920
936
 
921
 
    if (!hrvtime_is_started()) {
 
937
    if (!hrvtime_is_started())
922
938
        start_hrvtime();
923
 
        if (!hrvtime_is_started())
924
 
            BIF_RET(NIL); /* arity 0 BIFs may not fail */
925
 
    }
926
939
    f.fd = get_hrvtime();
927
940
    hp = HAlloc(BIF_P, FLOAT_SIZE_OBJECT);
928
941
    res = make_float(hp);