@@ -93,35 +93,34 @@ impl GlobalDescriptorTable {
93
93
& self . table [ ..self . next_free ]
94
94
}
95
95
96
- const_fn ! {
97
- /// Adds the given segment descriptor to the GDT, returning the segment selector.
98
- ///
99
- /// Panics if the GDT has no free entries left.
100
- # [ inline ]
101
- pub fn add_entry( & mut self , entry: Descriptor ) -> SegmentSelector {
102
- let index = match entry {
103
- Descriptor :: UserSegment ( value) => self . push( value) ,
104
- Descriptor :: SystemSegment ( value_low, value_high) => {
105
- let index = self . push( value_low) ;
106
- self . push( value_high) ;
107
- index
108
- }
109
- } ;
96
+ /// Adds the given segment descriptor to the GDT, returning the segment selector.
97
+ ///
98
+ /// Panics if the GDT has no free entries left.
99
+ # [ inline ]
100
+ # [ cfg_attr ( feature = "const_fn" , rustversion :: attr ( all ( ) , const ) ) ]
101
+ pub fn add_entry ( & mut self , entry : Descriptor ) -> SegmentSelector {
102
+ let index = match entry {
103
+ Descriptor :: UserSegment ( value) => self . push ( value) ,
104
+ Descriptor :: SystemSegment ( value_low, value_high) => {
105
+ let index = self . push ( value_low) ;
106
+ self . push ( value_high) ;
107
+ index
108
+ }
109
+ } ;
110
110
111
- let rpl = match entry {
112
- Descriptor :: UserSegment ( value) => {
113
- if DescriptorFlags :: from_bits_truncate( value) . contains( DescriptorFlags :: DPL_RING_3 )
114
- {
115
- PrivilegeLevel :: Ring3
116
- } else {
117
- PrivilegeLevel :: Ring0
118
- }
111
+ let rpl = match entry {
112
+ Descriptor :: UserSegment ( value) => {
113
+ if DescriptorFlags :: from_bits_truncate ( value) . contains ( DescriptorFlags :: DPL_RING_3 )
114
+ {
115
+ PrivilegeLevel :: Ring3
116
+ } else {
117
+ PrivilegeLevel :: Ring0
119
118
}
120
- Descriptor :: SystemSegment ( _, _) => PrivilegeLevel :: Ring0 ,
121
- } ;
119
+ }
120
+ Descriptor :: SystemSegment ( _, _) => PrivilegeLevel :: Ring0 ,
121
+ } ;
122
122
123
- SegmentSelector :: new( index as u16 , rpl)
124
- }
123
+ SegmentSelector :: new ( index as u16 , rpl)
125
124
}
126
125
127
126
/// Loads the GDT in the CPU using the `lgdt` instruction. This does **not** alter any of the
@@ -155,17 +154,16 @@ impl GlobalDescriptorTable {
155
154
}
156
155
}
157
156
158
- const_fn ! {
159
- #[ inline]
160
- fn push( & mut self , value: u64 ) -> usize {
161
- if self . next_free < self . table. len( ) {
162
- let index = self . next_free;
163
- self . table[ index] = value;
164
- self . next_free += 1 ;
165
- index
166
- } else {
167
- panic!( "GDT full" ) ;
168
- }
157
+ #[ inline]
158
+ #[ cfg_attr( feature = "const_fn" , rustversion:: attr( all( ) , const ) ) ]
159
+ fn push ( & mut self , value : u64 ) -> usize {
160
+ if self . next_free < self . table . len ( ) {
161
+ let index = self . next_free ;
162
+ self . table [ index] = value;
163
+ self . next_free += 1 ;
164
+ index
165
+ } else {
166
+ panic ! ( "GDT full" ) ;
169
167
}
170
168
}
171
169
0 commit comments