aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/code_ix.h
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-01-31 14:24:40 +0100
committerSverker Eriksson <[email protected]>2012-02-21 12:23:05 +0100
commit7cb4725bcf18f3158e60750ea658e51ab4586e31 (patch)
treecf54f04beb607f84ce5353d48ac9000d337e6820 /erts/emulator/beam/code_ix.h
parent6b97a90f2314b66f4f41b14a986a9c1f1ebebf13 (diff)
downloadotp-7cb4725bcf18f3158e60750ea658e51ab4586e31.tar.gz
otp-7cb4725bcf18f3158e60750ea658e51ab4586e31.tar.bz2
otp-7cb4725bcf18f3158e60750ea658e51ab4586e31.zip
erts: Refactor code_ix
Move implementation from beam_load into new file code_ix.c and module.c and make some function inline.
Diffstat (limited to 'erts/emulator/beam/code_ix.h')
-rw-r--r--erts/emulator/beam/code_ix.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/erts/emulator/beam/code_ix.h b/erts/emulator/beam/code_ix.h
index f6926acab5..99fd4ec348 100644
--- a/erts/emulator/beam/code_ix.h
+++ b/erts/emulator/beam/code_ix.h
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2012-2012. All Rights Reserved.
+ * Copyright Ericsson AB 2012. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -49,6 +49,12 @@
#ifndef __CODE_IX_H__
#define __CODE_IX_H__
+#ifndef __SYS_H__
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+# include "sys.h"
+#endif
#define ERTS_NUM_CODE_IX 3
typedef unsigned ErtsCodeIndex;
@@ -59,15 +65,17 @@ void erts_code_ix_init(void);
/* Return active code index.
* Is guaranteed to be valid until the calling BIF returns.
- * To get a consistent view of the code only one call to erts_active_code_ix()
- * should be made within the same BIF call.
+ * To get a consistent view of the code, only one call to erts_active_code_ix()
+ * should be made and the returned ix reused within the same BIF call.
*/
+ERTS_GLB_INLINE
ErtsCodeIndex erts_active_code_ix(void);
/* Return staging code ix.
* Only used by a process performing code loading/upgrading/deleting/purging.
* code_ix must be locked.
*/
+ERTS_GLB_INLINE
ErtsCodeIndex erts_staging_code_ix(void);
/* Lock code_ix.
@@ -100,14 +108,27 @@ void erts_commit_staging_code_ix(void);
*/
void erts_abort_staging_code_ix(void);
-void erts_rwlock_old_code(ErtsCodeIndex);
-void erts_rwunlock_old_code(ErtsCodeIndex);
-void erts_rlock_old_code(ErtsCodeIndex);
-void erts_runlock_old_code(ErtsCodeIndex);
-
#ifdef ERTS_ENABLE_LOCK_CHECK
-int erts_is_old_code_rlocked(ErtsCodeIndex);
int erts_is_code_ix_locked(void);
#endif
+
+
+#if ERTS_GLB_INLINE_INCL_FUNC_DEF
+
+extern erts_smp_atomic32_t the_active_code_index;
+extern erts_smp_atomic32_t the_staging_code_index;
+
+ERTS_GLB_INLINE ErtsCodeIndex erts_active_code_ix(void)
+{
+ return erts_smp_atomic32_read_nob(&the_active_code_index);
+}
+ERTS_GLB_INLINE ErtsCodeIndex erts_staging_code_ix(void)
+{
+ return erts_smp_atomic32_read_nob(&the_staging_code_index);
+}
+
+#endif /* ERTS_GLB_INLINE_INCL_FUNC_DEF */
+
#endif /* !__CODE_IX_H__ */
+