WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.4% of users enabled 2FA.

mod.rs 3.94 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
// Copyright 2017 The Australian National University
qinsoon's avatar
qinsoon committed
2
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
3 4 5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
qinsoon's avatar
qinsoon committed
6
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
//     http://www.apache.org/licenses/LICENSE-2.0
qinsoon's avatar
qinsoon committed
8
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
9 10 11 12 13 14
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

15
use std::sync::atomic;
16
use utils::ByteSize;
17

qinsoon's avatar
qinsoon committed
18
#[cfg(feature = "use-sidemap")]
qinsoon's avatar
qinsoon committed
19
pub mod sidemap;
qinsoon's avatar
qinsoon committed
20
#[cfg(not(feature = "use-sidemap"))]
21 22 23
mod header;

// mark state
24

qinsoon's avatar
qinsoon committed
25 26
pub static INIT_MARK_STATE: usize = 1;
static MARK_STATE: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT;
27

28 29 30 31 32 33 34 35 36 37 38
#[cfg(feature = "use-sidemap")]
pub fn init() {
    use objectmodel::sidemap::*;
    GlobalTypeTable::init();
}

#[cfg(feature = "use-sidemap")]
pub fn cleanup() {
    use objectmodel::sidemap::*;
    GlobalTypeTable::cleanup();
}
39 40 41

pub fn flip_mark_state() {
    let mark_state = MARK_STATE.load(atomic::Ordering::SeqCst);
42 43 44 45 46 47 48
    MARK_STATE.store(mark_state ^ 1, atomic::Ordering::SeqCst);
}

pub fn load_mark_state() -> u8 {
    MARK_STATE.load(atomic::Ordering::SeqCst) as u8
}

49 50 51 52 53 54 55 56 57
#[inline(always)]
pub fn check_alignment(align: ByteSize) -> ByteSize {
    if align < MINIMAL_ALIGNMENT {
        MINIMAL_ALIGNMENT
    } else {
        align
    }
}

58
// --- sidemap object model ---
59

60 61
#[cfg(feature = "use-sidemap")]
pub use self::sidemap::gen_gctype_encode;
qinsoon's avatar
qinsoon committed
62 63
#[cfg(feature = "use-sidemap")]
pub use self::sidemap::gen_hybrid_gctype_encode;
64

65 66
#[cfg(feature = "use-sidemap")]
pub use self::sidemap::MINIMAL_ALIGNMENT;
67 68 69
#[cfg(feature = "use-sidemap")]
pub use self::sidemap::OBJECT_HEADER_SIZE;
#[cfg(feature = "use-sidemap")]
70
pub use self::sidemap::OBJECT_HEADER_OFFSET;
71 72 73 74

#[cfg(feature = "use-sidemap")]
pub use self::sidemap::print_object;

75
// --- header ----
76

77 78
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::gen_gctype_encode;
qinsoon's avatar
qinsoon committed
79 80
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::gen_hybrid_gctype_encode;
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
// flag bit
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::BIT_HAS_REF_MAP;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::BIT_IS_TRACED;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::BIT_IS_FIX_SIZE;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::BIT_IS_OBJ_START;

// field mask
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::MASK_GCTYPE_ID;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::MASK_HYBRID_LENGTH;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::MASK_REF_MAP;
#[cfg(not(feature = "use-sidemap"))]
100 101
pub use self::header::REF_MAP_LENGTH;
#[cfg(not(feature = "use-sidemap"))]
102 103 104 105
pub use self::header::SHR_HYBRID_LENGTH;

// header location/size
#[cfg(not(feature = "use-sidemap"))]
106 107
pub use self::header::MINIMAL_ALIGNMENT;
#[cfg(not(feature = "use-sidemap"))]
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
pub use self::header::OBJECT_HEADER_SIZE;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::OBJECT_HEADER_OFFSET;

#[cfg(not(feature = "use-sidemap"))]
pub use self::header::print_object;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::mark_as_traced;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::mark_as_untraced;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::is_traced;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::header_is_fix_size;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::header_has_ref_map;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::header_is_object_start;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::header_get_gctype_id;
#[cfg(not(feature = "use-sidemap"))]
pub use self::header::header_get_ref_map;
130
#[cfg(not(feature = "use-sidemap"))]
qinsoon's avatar
qinsoon committed
131 132
pub use self::header::header_get_object_size;
#[cfg(not(feature = "use-sidemap"))]
qinsoon's avatar
qinsoon committed
133
pub use self::header::header_get_hybrid_length;