Skip to content

Commit fc2cb8f

Browse files
committed
Remove #no_copy
1 parent c937d38 commit fc2cb8f

File tree

7 files changed

+34
-42
lines changed

7 files changed

+34
-42
lines changed

base/runtime/wasm_allocator.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4343
THE SOFTWARE.
4444
*/
4545

46-
WASM_Allocator :: struct #no_copy {
46+
WASM_Allocator :: struct {
4747
// The minimum alignment of allocations.
4848
alignment: uint,
4949
// A region that contains as payload a single forward linked list of pointers to

core/odin/doc-format/doc_format.odin

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ Type :: struct {
219219
custom_align: String,
220220

221221
// Used by:
222-
// .Array - 1 count: 0=len
223-
// .Enumerated_Array - 1 count: 0=len
224-
// .SOA_Struct_Fixed - 1 count: 0=len
225-
// .Bit_Set - 2 count: 0=lower, 1=upper
226-
// .Simd_Vector - 1 count: 0=len
227-
// .Matrix - 2 count: 0=row_count, 1=column_count
222+
// .Array - 1 count: 0=len
223+
// .Enumerated_Array - 1 count: 0=len
224+
// .SOA_Struct_Fixed - 1 count: 0=len
225+
// .Bit_Set - 2 count: 0=lower, 1=upper
226+
// .Simd_Vector - 1 count: 0=len
227+
// .Matrix - 2 count: 0=row_count, 1=column_count
228+
// .Struct - <=2 count: 0=min_field_align, 1=max_field_align
228229
elem_count_len: u32le,
229230
elem_counts: [Type_Elems_Cap]i64le,
230231

core/sync/extended.odin

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ is not allowed to become negative.
2626
**Note**: Just like any synchronization primitives, a wait group cannot be
2727
copied after first use. See documentation for `Mutex` or `Cond`.
2828
*/
29-
Wait_Group :: struct #no_copy {
29+
Wait_Group :: struct {
3030
counter: int,
3131
mutex: Mutex,
3232
cond: Cond,
@@ -144,7 +144,7 @@ thread procedure.
144144
thread.destroy(t)
145145
}
146146
*/
147-
Barrier :: struct #no_copy {
147+
Barrier :: struct {
148148
mutex: Mutex,
149149
cond: Cond,
150150
index: int,
@@ -206,7 +206,7 @@ When a thread calls `auto_reset_event_wait`, its execution will be blocked,
206206
until the event is signalled by another thread. The call to
207207
`auto_reset_event_signal` wakes up exactly one thread waiting for the event.
208208
*/
209-
Auto_Reset_Event :: struct #no_copy {
209+
Auto_Reset_Event :: struct {
210210
// status == 0: Event is reset and no threads are waiting
211211
// status == 1: Event is signalled
212212
// status == -N: Event is reset and N threads are waiting
@@ -260,7 +260,7 @@ of entries into the critical section.
260260
This type of synchronization primitive is applicable for short critical sections
261261
in low-contention systems, as it uses a spinlock under the hood.
262262
*/
263-
Ticket_Mutex :: struct #no_copy {
263+
Ticket_Mutex :: struct {
264264
ticket: uint,
265265
serving: uint,
266266
}
@@ -332,7 +332,7 @@ Once a lock on a benaphore is acquired by a thread, no other thread is allowed
332332
into any critical sections, associted with the same benaphore, until the lock
333333
is released.
334334
*/
335-
Benaphore :: struct #no_copy {
335+
Benaphore :: struct {
336336
counter: i32,
337337
sema: Sema,
338338
}
@@ -424,7 +424,7 @@ to acquire another lock on the same benaphore. When a thread has acquired the
424424
lock on a benaphore, the benaphore will stay locked until the thread releases
425425
the lock as many times as it has been locked by the thread.
426426
*/
427-
Recursive_Benaphore :: struct #no_copy {
427+
Recursive_Benaphore :: struct {
428428
counter: int,
429429
owner: int,
430430
recursion: i32,
@@ -536,7 +536,7 @@ Once action.
536536
`Once` a synchronization primitive, that only allows a single entry into a
537537
critical section from a single thread.
538538
*/
539-
Once :: struct #no_copy {
539+
Once :: struct {
540540
m: Mutex,
541541
done: bool,
542542
}
@@ -636,7 +636,7 @@ A Parker is an associated token which is initially not present:
636636
* The `unpark` procedure automatically makes the token available if it
637637
was not already.
638638
*/
639-
Parker :: struct #no_copy {
639+
Parker :: struct {
640640
state: Futex,
641641
}
642642

@@ -713,7 +713,7 @@ A one-shot event is an associated token which is initially not present:
713713
* The `one_shot_event_signal` procedure automatically makes the token
714714
available if its was not already.
715715
*/
716-
One_Shot_Event :: struct #no_copy {
716+
One_Shot_Event :: struct {
717717
state: Futex,
718718
}
719719

core/sync/primitives.odin

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ holding another lock, that will cause a trivial case of deadlock. Do not use
3636
`Mutex` in recursive functions. In case multiple locks by the same thread are
3737
desired, use `Recursive_Mutex`.
3838
*/
39-
Mutex :: struct #no_copy {
39+
Mutex :: struct {
4040
impl: _Mutex,
4141
}
4242

@@ -147,7 +147,7 @@ result in broken and unsafe behavior. For this reason, mutexes are marked as
147147
exclusive lock more than once from the same thread, or an exclusive and shared
148148
lock on the same thread. Taking a shared lock multiple times is acceptable.
149149
*/
150-
RW_Mutex :: struct #no_copy {
150+
RW_Mutex :: struct {
151151
impl: _RW_Mutex,
152152
}
153153

@@ -313,7 +313,7 @@ released. Trying to use a copy of the lock at a different memory address will
313313
result in broken and unsafe behavior. For this reason, mutexes are marked as
314314
`#no_copy`.
315315
*/
316-
Recursive_Mutex :: struct #no_copy {
316+
Recursive_Mutex :: struct {
317317
impl: _Recursive_Mutex,
318318
}
319319

@@ -414,7 +414,7 @@ lock has been released. Trying to use a copy of the lock at a different memory
414414
address will result in broken and unsafe behavior. For this reason, condition
415415
variables are marked as `#no_copy`.
416416
*/
417-
Cond :: struct #no_copy {
417+
Cond :: struct {
418418
impl: _Cond,
419419
}
420420

@@ -494,7 +494,7 @@ must watch the same memory address to know when the lock has been released.
494494
Trying to use a copy of the lock at a different memory address will result in
495495
broken and unsafe behavior. For this reason, semaphores are marked as `#no_copy`.
496496
*/
497-
Sema :: struct #no_copy {
497+
Sema :: struct {
498498
impl: _Sema,
499499
}
500500

core/sync/primitives_atomic.odin

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Atomic_Mutex_State :: enum Futex {
1313
// The zero value for a Atomic_Mutex is an unlocked mutex
1414
//
1515
// An Atomic_Mutex must not be copied after first use
16-
Atomic_Mutex :: struct #no_copy {
16+
Atomic_Mutex :: struct {
1717
state: Atomic_Mutex_State,
1818
}
1919

@@ -105,7 +105,7 @@ Atomic_RW_Mutex_State_Reader_Mask :: ~Atomic_RW_Mutex_State_Is_Writing
105105
// The zero value for an Atomic_RW_Mutex is an unlocked mutex.
106106
//
107107
// An Atomic_RW_Mutex must not be copied after first use.
108-
Atomic_RW_Mutex :: struct #no_copy {
108+
Atomic_RW_Mutex :: struct {
109109
state: Atomic_RW_Mutex_State,
110110
mutex: Atomic_Mutex,
111111
sema: Atomic_Sema,
@@ -246,7 +246,7 @@ atomic_rw_mutex_shared_guard :: proc "contextless" (m: ^Atomic_RW_Mutex) -> bool
246246
// The zero value for a Recursive_Mutex is an unlocked mutex
247247
//
248248
// An Atomic_Recursive_Mutex must not be copied after first use
249-
Atomic_Recursive_Mutex :: struct #no_copy {
249+
Atomic_Recursive_Mutex :: struct {
250250
owner: int,
251251
recursion: int,
252252
mutex: Mutex,
@@ -309,7 +309,7 @@ atomic_recursive_mutex_guard :: proc "contextless" (m: ^Atomic_Recursive_Mutex)
309309
// waiting for signalling the occurence of an event
310310
//
311311
// An Atomic_Cond must not be copied after first use
312-
Atomic_Cond :: struct #no_copy {
312+
Atomic_Cond :: struct {
313313
state: Futex,
314314
}
315315

@@ -344,7 +344,7 @@ atomic_cond_broadcast :: proc "contextless" (c: ^Atomic_Cond) {
344344
// Posting to the semaphore increases the count by one, or the provided amount.
345345
//
346346
// An Atomic_Sema must not be copied after first use
347-
Atomic_Sema :: struct #no_copy {
347+
Atomic_Sema :: struct {
348348
count: Futex,
349349
}
350350

src/parser.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ gb_internal Ast *ast_dynamic_array_type(AstFile *f, Token token, Ast *elem) {
12301230
}
12311231

12321232
gb_internal Ast *ast_struct_type(AstFile *f, Token token, Slice<Ast *> fields, isize field_count,
1233-
Ast *polymorphic_params, bool is_packed, bool is_raw_union, bool is_no_copy, bool is_all_or_none,
1233+
Ast *polymorphic_params, bool is_packed, bool is_raw_union, bool is_all_or_none,
12341234
Ast *align, Ast *min_field_align, Ast *max_field_align,
12351235
Token where_token, Array<Ast *> const &where_clauses) {
12361236
Ast *result = alloc_ast_node(f, Ast_StructType);
@@ -1240,7 +1240,6 @@ gb_internal Ast *ast_struct_type(AstFile *f, Token token, Slice<Ast *> fields, i
12401240
result->StructType.polymorphic_params = polymorphic_params;
12411241
result->StructType.is_packed = is_packed;
12421242
result->StructType.is_raw_union = is_raw_union;
1243-
result->StructType.is_no_copy = is_no_copy;
12441243
result->StructType.is_all_or_none = is_all_or_none;
12451244
result->StructType.align = align;
12461245
result->StructType.min_field_align = min_field_align;
@@ -2776,7 +2775,6 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
27762775
bool is_packed = false;
27772776
bool is_all_or_none = false;
27782777
bool is_raw_union = false;
2779-
bool no_copy = false;
27802778
Ast *align = nullptr;
27812779
Ast *min_field_align = nullptr;
27822780
Ast *max_field_align = nullptr;
@@ -2863,11 +2861,6 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
28632861
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
28642862
}
28652863
is_raw_union = true;
2866-
} else if (tag.string == "no_copy") {
2867-
if (no_copy) {
2868-
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
2869-
}
2870-
no_copy = true;
28712864
} else {
28722865
syntax_error(tag, "Invalid struct tag '#%.*s'", LIT(tag.string));
28732866
}
@@ -2913,7 +2906,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
29132906
parser_check_polymorphic_record_parameters(f, polymorphic_params);
29142907

29152908
return ast_struct_type(f, token, decls, name_count,
2916-
polymorphic_params, is_packed, is_raw_union, no_copy, is_all_or_none,
2909+
polymorphic_params, is_packed, is_raw_union, is_all_or_none,
29172910
align, min_field_align, max_field_align,
29182911
where_token, where_clauses);
29192912
} break;

src/tilde_type_info.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,14 +783,13 @@ gb_internal void cg_setup_type_info_data(cgModule *m) {
783783

784784
i64 is_packed_offset = type_offset_of(tag_type, 5);
785785
i64 is_raw_union_offset = type_offset_of(tag_type, 6);
786-
i64 is_no_copy_offset = type_offset_of(tag_type, 7);
787-
i64 custom_align_offset = type_offset_of(tag_type, 8);
786+
i64 custom_align_offset = type_offset_of(tag_type, 7);
788787

789-
i64 equal_offset = type_offset_of(tag_type, 9);
788+
i64 equal_offset = type_offset_of(tag_type, 8);
790789

791-
i64 soa_kind_offset = type_offset_of(tag_type, 10);
792-
i64 soa_base_type_offset = type_offset_of(tag_type, 11);
793-
i64 soa_len_offset = type_offset_of(tag_type, 12);
790+
i64 soa_kind_offset = type_offset_of(tag_type, 9);
791+
i64 soa_base_type_offset = type_offset_of(tag_type, 10);
792+
i64 soa_len_offset = type_offset_of(tag_type, 11);
794793

795794
// TODO(bill): equal proc stuff
796795
gb_unused(equal_offset);
@@ -825,7 +824,6 @@ gb_internal void cg_setup_type_info_data(cgModule *m) {
825824

826825
set_bool(m, global, offset+is_packed_offset, t->Struct.is_packed);
827826
set_bool(m, global, offset+is_raw_union_offset, t->Struct.is_raw_union);
828-
set_bool(m, global, offset+is_no_copy_offset, t->Struct.is_no_copy);
829827
set_bool(m, global, offset+custom_align_offset, t->Struct.custom_align != 0);
830828

831829
if (t->Struct.soa_kind != StructSoa_None) {

0 commit comments

Comments
 (0)