~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_time.h

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
3
 * 
4
 
 * Copyright Ericsson AB 2006-2009. All Rights Reserved.
 
4
 * Copyright Ericsson AB 2006-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
20
20
#ifndef ERL_TIME_H__
21
21
#define ERL_TIME_H__
22
22
 
 
23
#define ERTS_SHORT_TIME_T_MAX ERTS_AINT32_T_MAX
 
24
#define ERTS_SHORT_TIME_T_MIN ERTS_AINT32_T_MIN
 
25
typedef erts_aint32_t erts_short_time_t;
 
26
 
 
27
extern erts_smp_atomic32_t do_time;     /* set at clock interrupt */
 
28
extern SysTimeval erts_first_emu_time;
 
29
 
23
30
/*
24
31
** Timer entry:
25
32
*/
26
33
typedef struct erl_timer {
27
34
    struct erl_timer* next;     /* next entry tiw slot or chain */
 
35
    struct erl_timer* prev;     /* prev entry tiw slot or chain */
28
36
    Uint slot;                  /* slot in timer wheel */
29
37
    Uint count;                 /* number of loops remaining */
30
38
    int    active;              /* 1=activated, 0=deactivated */
39
47
typedef void (*ErlCancelProc)(void*);
40
48
 
41
49
#ifdef ERTS_SMP
42
 
 
43
50
/*
44
51
 * Process and port timer
45
52
 */
61
68
                            ErlTimeoutProc timeout_func,
62
69
                            Uint timeout);
63
70
void erts_cancel_smp_ptimer(ErtsSmpPTimer *ptimer);
64
 
 
65
 
#endif
66
 
 
67
 
#endif
 
71
#endif
 
72
 
 
73
/* timer-wheel api */
 
74
 
 
75
void erts_init_time(void);
 
76
void erts_set_timer(ErlTimer*, ErlTimeoutProc, ErlCancelProc, void*, Uint);
 
77
void erts_cancel_timer(ErlTimer*);
 
78
void erts_bump_timer(erts_short_time_t);
 
79
Uint erts_timer_wheel_memory_size(void);
 
80
Uint erts_time_left(ErlTimer *);
 
81
erts_short_time_t erts_next_time(void);
 
82
 
 
83
#ifdef DEBUG
 
84
void erts_p_slpq(void);
 
85
#endif
 
86
 
 
87
ERTS_GLB_INLINE erts_short_time_t erts_do_time_read_and_reset(void);
 
88
ERTS_GLB_INLINE void erts_do_time_add(erts_short_time_t);
 
89
 
 
90
#if ERTS_GLB_INLINE_INCL_FUNC_DEF
 
91
 
 
92
ERTS_GLB_INLINE erts_short_time_t erts_do_time_read_and_reset(void)
 
93
{
 
94
    erts_short_time_t time = erts_smp_atomic32_xchg_acqb(&do_time, 0);
 
95
    if (time < 0)
 
96
        erl_exit(ERTS_ABORT_EXIT, "Internal time management error\n");
 
97
    return time;
 
98
}
 
99
 
 
100
ERTS_GLB_INLINE void erts_do_time_add(erts_short_time_t elapsed)
 
101
{
 
102
    erts_smp_atomic32_add_relb(&do_time, elapsed);
 
103
}
 
104
 
 
105
#endif /* #if ERTS_GLB_INLINE_INCL_FUNC_DEF */
 
106
 
 
107
 
 
108
/* time_sup */
 
109
 
 
110
#if (defined(HAVE_GETHRVTIME) || defined(HAVE_CLOCK_GETTIME))
 
111
#  ifndef HAVE_ERTS_NOW_CPU
 
112
#    define HAVE_ERTS_NOW_CPU
 
113
#    ifdef HAVE_GETHRVTIME
 
114
#      define erts_start_now_cpu() sys_start_hrvtime()
 
115
#      define erts_stop_now_cpu()  sys_stop_hrvtime()
 
116
#    endif
 
117
#  endif
 
118
void erts_get_now_cpu(Uint* megasec, Uint* sec, Uint* microsec);
 
119
#endif
 
120
 
 
121
void erts_get_timeval(SysTimeval *tv);
 
122
erts_time_t erts_get_time(void);
 
123
void erts_get_emu_time(SysTimeval *);
 
124
 
 
125
ERTS_GLB_INLINE int erts_cmp_timeval(SysTimeval *t1p, SysTimeval *t2p);
 
126
 
 
127
#if ERTS_GLB_INLINE_INCL_FUNC_DEF
 
128
 
 
129
ERTS_GLB_INLINE int
 
130
erts_cmp_timeval(SysTimeval *t1p, SysTimeval *t2p)
 
131
{
 
132
    if (t1p->tv_sec == t2p->tv_sec) {
 
133
        if (t1p->tv_usec < t2p->tv_usec)
 
134
            return -1;
 
135
        else if (t1p->tv_usec > t2p->tv_usec)
 
136
            return 1;
 
137
        return 0;
 
138
    }
 
139
    return t1p->tv_sec < t2p->tv_sec ? -1 : 1;
 
140
}
 
141
 
 
142
#endif /* #if ERTS_GLB_INLINE_INCL_FUNC_DEF */
 
143
#endif /* ERL_TIME_H__ */